class Fidgit::VerticalScrollBar
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
Fidgit::ScrollBar::new
# File lib/fidgit/elements/scroll_bar.rb, line 96 def initialize(options = {}) super options @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
Public Instance Methods
clicked_to_move(x, y)
click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 123 def clicked_to_move(x, y) new_y = y < @handle.y ? @handle.y - @handle.height : @handle.y + @handle.height handle_dragged_to @handle.x, new_y end
draw_foreground()
click to toggle source
Calls superclass method
# File lib/fidgit/elements/scroll_bar.rb, line 114 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)
click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 119 def handle_dragged_to(x, y) @owner.offset_y = @owner.content_height * ((y - self.y) / height.to_f) end
update()
click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 107 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