Class: Fidgit::List
- Defined in:
- lib/fidgit/elements/list.rb
Defined Under Namespace
Classes: Item
Constant Summary
Constants inherited from Composite
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
- #clear ⇒ Object
-
#initialize(options = {}) ⇒ List
constructor
A new instance of List.
- #item(text, value, options = {}, &block) ⇒ Object
- #size ⇒ Object
Methods inherited from Container
#add, #button, #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 = {}) ⇒ List
Returns a new instance of List.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fidgit/elements/list.rb', line 13 def initialize( = {}) = { background_color: default(:background_color), border_color: default(:border_color), }.merge! super group do subscribe :changed do |sender, value| publish :changed, value end @items = vertical spacing: 0 end end |
Instance Method Details
#clear ⇒ Object
11 |
# File 'lib/fidgit/elements/list.rb', line 11 def clear; @items.clear; end |
#item(text, value, options = {}, &block) ⇒ Object
32 33 34 |
# File 'lib/fidgit/elements/list.rb', line 32 def item(text, value, = {}, &block) Item.new(text, value, { parent: @items }.merge!(), &block) end |
#size ⇒ Object
10 |
# File 'lib/fidgit/elements/list.rb', line 10 def size; @items.size; end |