Sha256: 0103825e90bb288de9e1cf637d4fbb0b387317194c3cba18532f70f1da5d5d8f

Contents?: true

Size: 971 Bytes

Versions: 4

Compression:

Stored size: 971 Bytes

Contents

module Nuklear
  module UI
    class Menu < Nuklear::UI::Base
      include Nuklear::UI::Container
      include Nuklear::UI::TextAlign

      attr_accessor :title, :image, :symbol, :align, :width, :height

      def initialize(enabled: true, title: nil, image: nil, symbol: nil,
                     align: :left, width:, height:)
        super enabled: enabled
        @title = title
        @image = image
        @symbol = symbol
        @align = align
        @width = width
        @height = height
      end

      def to_command
        [:ui_menu, {
            id: object_id,
            title: title,
            image: image,
            symbol: symbol,
            align: align_as_flags(align),
            width: width,
            height: height
          }
        ]
      end

      def visible?
        @visible
      end

      def result(visible, context)
        @visible = visible
        run_commands(context) if visible
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nuklear-0.1.3 lib/nuklear/ui/menu.rb
nuklear-0.1.2 lib/nuklear/ui/menu.rb
nuklear-0.1.1 lib/nuklear/ui/menu.rb
nuklear-0.1.0 lib/nuklear/ui/menu.rb