Class: GlimR::Container
- Defined in:
- lib/glimr/widgets/container.rb
Constant Summary
Constants included from Layoutable
Instance Attribute Summary collapse
-
#content_view ⇒ Object
readonly
Returns the value of attribute content_view.
Attributes inherited from Widget
Attributes included from Layoutable
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
- #content=(c) ⇒ Object
- #default_config ⇒ Object
-
#initialize(*a, &b) ⇒ Container
constructor
A new instance of Container.
- #layout ⇒ Object
- #mirror_event(o, e) ⇒ Object
- #scroll ⇒ Object
- #scroll=(s) ⇒ Object
- #scroll_x=(x) ⇒ Object
- #scroll_y=(y) ⇒ Object
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, #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) ⇒ Container
Returns a new instance of Container.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/glimr/widgets/container.rb', line 21 def initialize(*a, &b) @content_view = Viewport.new( :x => 0, :y => 0, :width => 1, :height => 1 ) @mirror_event = method(:mirror_event).to_proc super self.content = @content if @content @content_view.on_layout(@mirror_event) attach @content_view end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GlimR::EventListener
Instance Attribute Details
#content_view ⇒ Object (readonly)
Returns the value of attribute content_view.
9 10 11 |
# File 'lib/glimr/widgets/container.rb', line 9 def content_view @content_view end |
Instance Method Details
#content=(c) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/glimr/widgets/container.rb', line 36 def content= c @content_view.detach @content if @content @content.remove_event_listener(:layout, @mirror_event) if @content @content = c @content_view.attach @content if @content @content.add_event_listener(:layout, @mirror_event) if @content end |
#default_config ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/glimr/widgets/container.rb', line 11 def default_config super.merge( :scroll_x => 0, :scroll_y => 0, :width => 200, :height => 100, :fit_to_children => false ) end |
#layout ⇒ Object
76 77 78 79 80 |
# File 'lib/glimr/widgets/container.rb', line 76 def layout super @content_view.width = @width @content_view.height = @height end |
#mirror_event(o, e) ⇒ Object
32 33 34 |
# File 'lib/glimr/widgets/container.rb', line 32 def mirror_event(o,e) process_event e end |
#scroll ⇒ Object
68 69 70 |
# File 'lib/glimr/widgets/container.rb', line 68 def scroll [@scroll_x, @scroll_y] end |
#scroll=(s) ⇒ Object
72 73 74 |
# File 'lib/glimr/widgets/container.rb', line 72 def scroll= s self.scroll_x, self.scroll_y = *s end |
#scroll_x=(x) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/glimr/widgets/container.rb', line 44 def scroll_x=(x) @scroll_x = x if @content case x when Float @content.x = -x*(@content.width-@width).to_i else @content.x = -x end end end |
#scroll_y=(y) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/glimr/widgets/container.rb', line 56 def scroll_y=(y) @scroll_y = y if @content case y when Float @content.y = -y*(@content.height-@height).to_i else @content.y = -y end end end |