Class: GlimR::RadioGroup

Inherits:
VLayout show all
Defined in:
lib/glimr/widgets/radiogroup.rb

Constant Summary

Constants included from Layoutable

Layoutable::DIMENSIONS

Instance Attribute Summary collapse

Attributes inherited from Layout

#direction, #item_spacing

Attributes inherited from Widget

#focused, #hover

Attributes included from Layoutable

#align, #valign

Attributes inherited from Model

#geometry, #material, #shader, #texture, #transform

Attributes inherited from SceneObject

#children, #drawables, #mtime, #parent, #viewport

Attributes included from EventListener

#event_listeners, #listener_count

Instance Method Summary collapse

Methods inherited from Layout

#calculate_free_height, #calculate_free_width, #children_change, #fit_height!, #fit_width!, #free_height, #free_width, #horiz_tile, #layout, #vert_tile

Methods inherited from Widget

#activate, #blur, #click, #focus, for, #key_down, #key_up, #lock, #mouse_down, #mouse_move, #mouse_out, #mouse_over, #mouse_up, #unlock

Methods included from Layoutable

#attach, #children_change, #constant_size?, #detach, #expand!, #expand?, #expand_height, #expand_to_max_height!, #expand_to_max_width!, #expand_width, #fit_height!, #fit_to_children!, #fit_width!, #free_height, #free_width, #full_depth, #full_height, #full_width, #inner_depth, #inner_height, #inner_width, #inspect, #layout, #layoutable_children, #margin, #margin=, #max_height=, #max_width=, #min_height=, #min_width=, #padding, #padding=, #parent=, #size_changing, size_changing_accessor, #tell_children_of_size_change, #x=, #y=

Methods inherited from Model

#absolute_transform, #apply, #inspect, #pop_state, #push_state

Methods inherited from SceneObject

#<<, #absolute_geometry, #absolute_material, #absolute_shader, #absolute_texture, #absolute_transform, #absolute_transform_for_drawing, #add_drawables, #apply, #attach, #clone, #detach, #detach_self, #inspect, #pop_state, #push_state, #remove_drawables, #render, #replace_node, #root, #touch!, #visible

Methods included from EventListener

#add_event_listener, #decrement_listener_count, #dispatch_event, #event_root, #increment_listener_count, #method_missing, #multicast_event, #process_event, #remove_event_listener

Constructor Details

#initialize(*a, &b) ⇒ RadioGroup

Returns a new instance of RadioGroup.



17
18
19
20
21
22
23
# File 'lib/glimr/widgets/radiogroup.rb', line 17

def initialize(*a, &b)
  super
  self.label = @label if @label
  @option_models = []
  self.options = @options
  self.selected_index = @selected_index
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GlimR::EventListener

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/glimr/widgets/radiogroup.rb', line 8

def options
  @options
end

#selected_indexObject

Returns the value of attribute selected_index.



8
9
10
# File 'lib/glimr/widgets/radiogroup.rb', line 8

def selected_index
  @selected_index
end

Instance Method Details

#default_configObject



10
11
12
13
14
15
# File 'lib/glimr/widgets/radiogroup.rb', line 10

def default_config
  super.merge(
    :selected_index => 0,
    :options => ["Default", "Options"]
  )
end

#label=(l) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/glimr/widgets/radiogroup.rb', line 25

def label= l
  if @label_model
    @label_model.text = l
  else
    @label_model = Label.new(:text => @label)
    attach @label_model
  end
end

#selected_modelObject



64
65
66
# File 'lib/glimr/widgets/radiogroup.rb', line 64

def selected_model
  @option_models[@selected_index]
end

#selected_model=(s) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/glimr/widgets/radiogroup.rb', line 68

def selected_model= s
  @option_models.each_with_index{|e,i|
    if e == s
      self.selected_index = i
      break
    end
  }
end

#selectionObject



77
78
79
# File 'lib/glimr/widgets/radiogroup.rb', line 77

def selection
  @option_models[@selected_index].label
end

#selection=(s) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/glimr/widgets/radiogroup.rb', line 81

def selection= s
  @option_models.each_with_index{|e,i|
    if e.label == s
      self.selected_index = i
      break
    end
  }
end