class Fidgit::HorizontalScrollBar

Attributes

owner[R]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Fidgit::ScrollBar::new
# File lib/fidgit/elements/scroll_bar.rb, line 60
def initialize(options = {})
  super options

  @handle.height = height

  @handle_container.subscribe :left_mouse_button do |sender, x, y|
    distance = @owner.view_width
    @owner.offset_x += (x > @handle.x)? +distance : -distance
  end
end

Public Instance Methods

clicked_to_move(x, y) click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 89
def clicked_to_move(x, y)
  new_x = x < @handle.x ? @handle.x - @handle.width : @handle.x + @handle.width
  handle_dragged_to new_x, @handle.y
end
draw_foreground() click to toggle source
Calls superclass method
# File lib/fidgit/elements/scroll_bar.rb, line 80
def draw_foreground
  draw_rect x + padding_left, y + (height - @rail_thickness) / 2, width, @rail_thickness, z, @rail_color
  super
end
handle_dragged_to(x, y) click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 85
def handle_dragged_to(x, y)
  @owner.offset_x = @owner.content_width * ((x - self.x) / width.to_f)
end
update() click to toggle source
# File lib/fidgit/elements/scroll_bar.rb, line 71
def update
  window = parent.parent

  # Resize and re-locate the handles based on changes to the scroll-window.
  content_width = window.content_width.to_f
  @handle.width = (window.view_width * width) / content_width
  @handle.x = x + (window.offset_x * width) / content_width
end