Class: GlimR::ScrollableContainer

Inherits:
Widget show all
Defined in:
lib/glimr/widgets/scrollable_container.rb

Direct Known Subclasses

ScrollableList

Constant Summary

Constants included from Layoutable

Layoutable::DIMENSIONS

Instance Attribute Summary collapse

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 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) ⇒ ScrollableContainer

Returns a new instance of ScrollableContainer.



23
24
25
26
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
56
57
58
59
60
61
# File 'lib/glimr/widgets/scrollable_container.rb', line 23

def initialize(*a, &b)
  super
  @resizer = Resizer.new(:target => self)
  vsplit = VLayout.new(
    :item_spacing => 0,
    :expand_width => true, :expand_height => true
  )
  hsplit = HLayout.new(
    :item_spacing => 0,
    :expand_width => true, :expand_height => true
  )
  @container = Container.new(
    :content => @content,
    :expand_width => true, :expand_height => true
  )
  @vertical_scrollbar = VScrollBar.new(:container => @container)
  @horizontal_scrollbar = HScrollBar.new(:container => @container)
  @vertical_scrollbar.on_scroll{|o,e|
    @container.scroll_y = e.y
  }
  @horizontal_scrollbar.on_scroll{|o,e|
    @container.scroll_x = e.x
  }
  bottom_scroller = HLayout.new(:expand_width => true, :item_spacing => 0)
  bottom_scroller << @horizontal_scrollbar << @resizer
  hsplit << @container << @vertical_scrollbar
  vsplit << hsplit << bottom_scroller
  attach vsplit
  @container.on_mouse_down{|o,e|
    case e.button
    when :wheel_up
      @vertical_scrollbar.scroll_up
    when :wheel_down
      @vertical_scrollbar.scroll_down
    end
  }
  self.min_width = @horizontal_scrollbar.min_width + @resizer.width
  self.min_height = @vertical_scrollbar.min_height + @resizer.height
end

Dynamic Method Handling

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

Instance Attribute Details

#containerObject

Returns the value of attribute container.



13
14
15
# File 'lib/glimr/widgets/scrollable_container.rb', line 13

def container
  @container
end

#horizontal_scrollbarObject

Returns the value of attribute horizontal_scrollbar.



13
14
15
# File 'lib/glimr/widgets/scrollable_container.rb', line 13

def horizontal_scrollbar
  @horizontal_scrollbar
end

#resizerObject

Returns the value of attribute resizer.



13
14
15
# File 'lib/glimr/widgets/scrollable_container.rb', line 13

def resizer
  @resizer
end

#vertical_scrollbarObject

Returns the value of attribute vertical_scrollbar.



13
14
15
# File 'lib/glimr/widgets/scrollable_container.rb', line 13

def vertical_scrollbar
  @vertical_scrollbar
end

Instance Method Details

#default_configObject



15
16
17
18
19
20
21
# File 'lib/glimr/widgets/scrollable_container.rb', line 15

def default_config
  super.merge(
    :width => 200,
    :height => 200,
    :content => nil
  )
end