Method: Fidgit::ScrollBar#initialize

Defined in:
lib/fidgit/elements/scroll_bar.rb

#initialize(options = {}) ⇒ ScrollBar

Returns a new instance of ScrollBar.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fidgit/elements/scroll_bar.rb', line 31

def initialize(options = {})
  options = {
    background_color: default(:background_color),
    border_color: default(:border_color),
    rail_width: default(:rail_width),
    rail_color: default(:rail_color),
    handle_color: default(:handle_color),
    owner: nil,
  }.merge! options

  @owner = options[:owner]
  @rail_thickness = options[:rail_width]
  @rail_color = options[:rail_color]

  super options

  @handle_container = Container.new(parent: self, width: options[:width], height: options[:height]) do
    @handle = Handle.new(parent: self, x: x, y: y, background_color: options[:handle_color])
  end

  subscribe :left_mouse_button do |sender, x, y|
    clicked_to_move x, y
  end
end