Class: GlimR::VScroller
- Defined in:
- lib/glimr/widgets/scrollbar.rb
Constant Summary
Constants included from Layoutable
Instance Attribute Summary
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
- #click(o, e) ⇒ Object
- #default_config ⇒ Object
-
#initialize(*a, &b) ⇒ VScroller
constructor
A new instance of VScroller.
- #layout ⇒ Object
- #update_knob ⇒ Object
Methods inherited from Widget
#activate, #blur, #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) ⇒ VScroller
Returns a new instance of VScroller.
236 237 238 239 240 241 |
# File 'lib/glimr/widgets/scrollbar.rb', line 236 def initialize(*a,&b) super @knob.z = 5 attach @background,@knob self.min_height = @knob.height end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GlimR::EventListener
Instance Method Details
#click(o, e) ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/glimr/widgets/scrollbar.rb', line 243 def click(o,e) if e.target == @background.geometry distance_from_knob_bottom = (@knob.y + @knob.height - e.ry) distance_from_knob_top = (@knob.y - e.ry) if distance_from_knob_bottom.abs > distance_from_knob_top.abs @knob.new_y = e.ry else @knob.new_y = e.ry - @knob.height end end end |
#default_config ⇒ Object
228 229 230 231 232 233 234 |
# File 'lib/glimr/widgets/scrollbar.rb', line 228 def default_config super.merge( :expand_height => true, :knob => VScrollKnob.new, :background => GlimR::StretchableImage.load_theme('vscroller_bg.png') ) end |
#layout ⇒ Object
259 260 261 262 263 264 265 266 |
# File 'lib/glimr/widgets/scrollbar.rb', line 259 def layout return if @layouting @layouting = true super @background.set_dimensions(@width, @height) if @background.width != @width or @background.height != @height update_knob @layouting = false end |
#update_knob ⇒ Object
255 256 257 |
# File 'lib/glimr/widgets/scrollbar.rb', line 255 def update_knob @knob.layout end |