Class: Fidgit::List

Inherits:
Composite show all
Defined in:
lib/fidgit/elements/list.rb

Defined Under Namespace

Classes: Item

Constant Summary

Constants inherited from Composite

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

#spacing_h, #spacing_v

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

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(options = {})
  options = {
    background_color: default(:background_color),
    border_color: default(:border_color),
  }.merge! options

  super options

  group do
    subscribe :changed do |sender, value|
      publish :changed, value
    end

    @items = vertical spacing: 0
  end
end

Instance Method Details

#clearObject



11
# File 'lib/fidgit/elements/list.rb', line 11

def clear; @items.clear; end

#item(text, value, options = {}, &block) ⇒ Object

Parameters:

  • text (String)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :icon (Gosu::Image)


32
33
34
# File 'lib/fidgit/elements/list.rb', line 32

def item(text, value, options = {}, &block)
  Item.new(text, value, { parent: @items }.merge!(options), &block)
end

#sizeObject



10
# File 'lib/fidgit/elements/list.rb', line 10

def size; @items.size; end