Class: GlimR::HScrollBar

Inherits:
HLayout show all
Includes:
Scrollable
Defined in:
lib/glimr/widgets/scrollbar.rb

Constant Summary

Constants included from Layoutable

Layoutable::DIMENSIONS

Instance Attribute Summary

Attributes included from Scrollable

#default_scroll_horiz, #default_scroll_vert, #scroll_x, #scroll_y

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 included from Scrollable

#scroll, #scroll_down, #scroll_left, #scroll_right, #scroll_to, #scroll_up

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, #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) ⇒ HScrollBar

Returns a new instance of HScrollBar.



105
106
107
108
109
110
111
112
# File 'lib/glimr/widgets/scrollbar.rb', line 105

def initialize(*a, &b)
  super
  attach @left_button, @scroller, @right_button
  @updater = lambda{|o,e| @scroller.update_knob }
  self.container = @container
  on_scroll{ @scroller.knob.scroll_handler if @scroller }
  self.min_width = @left_button.width + @right_button.width + @scroller.min_width
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



114
115
116
117
118
119
120
121
# File 'lib/glimr/widgets/scrollbar.rb', line 114

def click(o,e)
  case e.button
  when :wheel_down
    scroll_right
  when :wheel_up
    scroll_left
  end
end

#container=(c) ⇒ Object



123
124
125
126
127
128
129
# File 'lib/glimr/widgets/scrollbar.rb', line 123

def container=(c)
  @container.remove_event_listener(:layout, @updater) if @container
  @container = c
  @container.add_event_listener(:layout, @updater) if @container
  @scroller.update_knob if @scroller
  touch!
end

#default_configObject



95
96
97
98
99
100
101
102
103
# File 'lib/glimr/widgets/scrollbar.rb', line 95

def default_config
  super.merge(
    :item_spacing => 0,
    :expand_width => true, :container => nil,
    :left_button => ScrollLeftButton.new,
    :right_button => ScrollRightButton.new,
    :scroller => HScroller.new
  )
end