Class: Fidgit::ColorPicker
- Defined in:
- lib/fidgit/elements/color_picker.rb
Constant Summary collapse
- CHANNELS =
[:red, :green, :blue]
- DEFAULT_CHANNEL_NAMES =
CHANNELS.map {|c| c.to_s.capitalize }
- INDICATOR_HEIGHT =
25
Constants inherited from Composite
Fidgit::Composite::DEBUG_BORDER_COLOR
Constants inherited from Element
Element::DEFAULT_SCHEMA_FILE, Element::VALID_ALIGN_H, Element::VALID_ALIGN_V
Instance Attribute Summary
Attributes inherited from Packer
Attributes inherited from Element
#align_h, #align_v, #background_color, #border_thickness, #font, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #tip, #z
Instance Method Summary collapse
- #color ⇒ Object
- #color=(value) ⇒ Object
-
#initialize(options = {}, &block) ⇒ ColorPicker
constructor
A new instance of ColorPicker.
Methods inherited from Container
#add, #button, #clear, #color_picker, #color_well, #combo_box, #file_browser, #grid, #group, #hit_element, #horizontal, #image_frame, #insert, #label, #list, #radio_button, #remove, #scroll_area, #scroll_window, #slider, #text_area, #to_s, #toggle_button, #update, #vertical, #write_tree, #x=, #y=
Methods inherited from Element
#default, #drag?, #draw, #draw_frame, #draw_rect, #enabled=, #enabled?, #height, #height=, #hit?, #max_height, #max_width, #min_height, #min_width, new, original_new, #outer_height, #outer_width, #recalc, schema, #to_s, #update, #width, #width=, #with, #x, #x=, #y, #y=
Methods included from Event
#events, included, new_event_handlers, #publish, #subscribe, #unsubscribe
Constructor Details
#initialize(options = {}, &block) ⇒ ColorPicker
Returns a new instance of ColorPicker.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fidgit/elements/color_picker.rb', line 27 def initialize( = {}, &block) = { padding: 0, spacing: 0, channel_names: DEFAULT_CHANNEL_NAMES, color: default(:color), indicator_height: default(:indicator_height), }.merge! @color = [:color].dup @indicator_height = [:indicator_height] super() = width vertical do @sliders = {} CHANNELS.each_with_index do |channel, i| @sliders[channel] = (value: @color.send(channel), range: 0..255, width: , tip: [:channel_names][i]) do |sender, value| @color.send "#{channel}=", value @indicator.background_color = @color publish :changed, @color.dup end end @indicator = label '', background_color: @color, width: , height: @indicator_height end end |
Instance Method Details
#color ⇒ Object
12 |
# File 'lib/fidgit/elements/color_picker.rb', line 12 def color; @color.dup; end |