Sha256: d2ad8cbfcfdbaa8fcc7576c399b348dacd871ee36170036d7749a47f04790659

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

module Nuklear
  module UI
    class Row < Base
      include Nuklear::UI::Container
      attr_accessor :height, :type, :width

      def initialize(height:, width: nil, type: nil, **options)
        super(**options)
        self.type = type
        self.height = height
        self.width = width
        raise ArgumentError, ":width is required if type is :static" if type == :static && width.nil?
      end

      def to_command
        case type
        when :dynamic then [:ui_layout_row_dynamic, height, commands.size]
        when :static  then [:ui_layout_row_static, height, width, commands.size]
        else [:ui_layout_row_begin, type || :static, height, commands.size]
        end
      end

      def result(_, context)
        run_commands(context)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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