Sha256: 1aa6b35f3d9443bbce1da6e9a483f4b67dd8d97a649f3534e43fd902a5ad107f

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

module Nuklear
  module UI
    class ColorPicker < Base
      attr_accessor :color
      attr_reader :type

      def initialize(color, type: :rgba, **options)
        super(**options)
        self.color = color
        self.type = type
      end

      def type=(t)
        case t
        when :rgb, :rgba then @type = t
        else raise ArgumentError, "invalid color picker type, must be :rgb or :rgba"
        end
      end

      def to_command
        [:ui_color_picker, color, type]
      end

      def result(color, context)
        @color = color
        trigger :color_changed
        @last_event = nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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