Class: GlimR::VScrollKnob
- Inherits:
-
EmptyButton
- Object
- SceneObject
- Model
- Widget
- EmptyButton
- GlimR::VScrollKnob
- Defined in:
- lib/glimr/widgets/scrollbar.rb
Constant Summary
Constants included from Layoutable
Instance Attribute Summary
Attributes inherited from EmptyButton
#background, #cover, #down, #down_background, #down_cover, #hover_indicator, #label, #up_background, #up_cover
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
- #container ⇒ Object
- #default_config ⇒ Object
-
#initialize(*a, &b) ⇒ VScrollKnob
constructor
A new instance of VScrollKnob.
- #layout ⇒ Object
- #mouse_down(o, e) ⇒ Object
- #mouse_move(o, e) ⇒ Object
- #new_y ⇒ Object
- #new_y=(ny) ⇒ Object
- #scroll_handler(*a) ⇒ Object
-
#scroll_max ⇒ Object
The highest value the scroll knob can have.
- #update_scroll(o, e) ⇒ Object
Methods inherited from EmptyButton
#button_down, #button_up, #focus_indicator=, #focused=, #key_down, #key_up, #label_model=, #load_image, load_image, #mouse_out, #mouse_over, #mouse_up
Methods inherited from Widget
#activate, #blur, #click, #focus, for, #key_down, #key_up, #lock, #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) ⇒ VScrollKnob
Returns a new instance of VScrollKnob.
361 362 363 364 |
# File 'lib/glimr/widgets/scrollbar.rb', line 361 def initialize(*a,&b) super on_scroll(:scroll_handler) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GlimR::EventListener
Instance Method Details
#container ⇒ Object
366 367 368 369 370 |
# File 'lib/glimr/widgets/scrollbar.rb', line 366 def container parent.parent.container rescue NoMethodError nil end |
#default_config ⇒ Object
352 353 354 355 356 357 358 359 |
# File 'lib/glimr/widgets/scrollbar.rb', line 352 def default_config super.merge( :up_background => "scroll_vknob_up.png", :down_background => "scroll_vknob_down.png", :up_cover => nil, :down_cover => nil, :focus_indicator => nil, :label => nil, :padding => 0, :rel_y => 0 ) end |
#layout ⇒ Object
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/glimr/widgets/scrollbar.rb', line 372 def layout return if @layouting @layouting = true if container self.height = [parent.inner_height, [ self.min_height || 0.0, (container.content.height > 0 ? (container.height / container.content.height.to_f)*parent.inner_height : 0).to_i ].max ].min.to_i @background_model.height = @height if @background_model parent.parent.scroll_y = parent.parent.scroll_y end @layouting = false end |
#mouse_down(o, e) ⇒ Object
388 389 390 391 |
# File 'lib/glimr/widgets/scrollbar.rb', line 388 def mouse_down(o,e) super @rel_y = e.ry end |
#mouse_move(o, e) ⇒ Object
393 394 395 396 397 398 |
# File 'lib/glimr/widgets/scrollbar.rb', line 393 def mouse_move(o,e) if @down and e.[:left] self.new_y += e.dy @rel_y += e.dy end end |
#new_y ⇒ Object
400 401 402 |
# File 'lib/glimr/widgets/scrollbar.rb', line 400 def new_y @new_y || self.y end |
#new_y=(ny) ⇒ Object
404 405 406 407 |
# File 'lib/glimr/widgets/scrollbar.rb', line 404 def new_y=(ny) on_frame(:update_scroll) unless @new_y @new_y = [scroll_max, [0, ny].max].min end |
#scroll_handler(*a) ⇒ Object
414 415 416 |
# File 'lib/glimr/widgets/scrollbar.rb', line 414 def scroll_handler(*a) self.y = parent.parent.scroll_y * scroll_max end |
#scroll_max ⇒ Object
The highest value the scroll knob can have. (Lowest is 0.)
410 411 412 |
# File 'lib/glimr/widgets/scrollbar.rb', line 410 def scroll_max parent.inner_height - self.full_height end |
#update_scroll(o, e) ⇒ Object
418 419 420 421 422 423 |
# File 'lib/glimr/widgets/scrollbar.rb', line 418 def update_scroll(o,e) new_scroll = (scroll_max > 0 ? (@new_y.to_f / scroll_max) : (@rel_y.to_f / parent.inner_height)) parent.parent.scroll_y = new_scroll @new_y = nil remove_event_listener(:frame, :update_scroll) end |