Class: Fidgit::VerticalScrollBar
Constant Summary
Constants inherited from Composite
Constants inherited from Element
Element::DEFAULT_SCHEMA_FILE, Element::VALID_ALIGN_H, Element::VALID_ALIGN_V
Instance Attribute Summary
Attributes inherited from Packer
Attributes inherited from Element
#align_h, #align_v, #background_color, #border_thickness, #font_size, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #tip, #z
Instance Method Summary collapse
- #draw_foreground ⇒ Object
- #handle_dragged_to(x, y) ⇒ Object
-
#initialize(options = {}) ⇒ VerticalScrollBar
constructor
A new instance of VerticalScrollBar.
- #update ⇒ Object
Methods inherited from Container
#add, #button, #clear, #color_picker, #color_well, #combo_box, #file_browser, #grid, #group, #hit_element, #horizontal, #insert, #label, #list, #radio_button, #remove, #scroll_area, #scroll_window, #slider, #text_area, #toggle_button, #vertical, #x=, #y=
Methods inherited from Element
#default, #drag?, #draw, #draw_frame, #draw_rect, #enabled=, #enabled?, #font, #height, #height=, #hit?, #max_height, #max_width, #min_height, #min_width, new, original_new, #outer_height, #outer_width, #recalc, schema, #width, #width=, #with, #x, #x=, #y, #y=
Methods included from Event
#events, included, #publish, #subscribe
Constructor Details
#initialize(options = {}) ⇒ VerticalScrollBar
Returns a new instance of VerticalScrollBar.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/fidgit/elements/scroll_bar.rb', line 87 def initialize( = {}) super @handle.width = width @handle_container.subscribe :left_mouse_button do |sender, x, y| distance = @owner.view_height @owner.offset_y += (y > @handle.y)? +distance : -distance end end |
Instance Method Details
#draw_foreground ⇒ Object
105 106 107 108 |
# File 'lib/fidgit/elements/scroll_bar.rb', line 105 def draw_foreground draw_rect x + (width - @rail_thickness) / 2, y + padding_top, @rail_thickness, height, z, @rail_color super end |
#handle_dragged_to(x, y) ⇒ Object
110 111 112 |
# File 'lib/fidgit/elements/scroll_bar.rb', line 110 def handle_dragged_to(x, y) @owner.offset_y = @owner.content_height * ((y - self.y) / height.to_f) end |
#update ⇒ Object
98 99 100 101 102 103 |
# File 'lib/fidgit/elements/scroll_bar.rb', line 98 def update window = parent.parent content_height = window.content_height.to_f @handle.height = (window.view_height * height) / content_height @handle.y = y + (window.offset_y * height) / content_height end |