Class: Fidgit::ScrollBar Abstract

Inherits:
Composite show all
Defined in:
lib/fidgit/elements/scroll_bar.rb

Overview

This class is abstract.

Direct Known Subclasses

HorizontalScrollBar, VerticalScrollBar

Defined Under Namespace

Classes: Handle

Constant Summary

Constants inherited from Composite

Composite::DEBUG_BORDER_COLOR

Constants inherited from Element

Element::DEFAULT_SCHEMA_FILE, Element::VALID_ALIGN_H, Element::VALID_ALIGN_V

Instance Attribute Summary

Attributes inherited from Packer

#spacing_h, #spacing_v

Attributes inherited from Element

#align_h, #align_v, #background_color, #border_thickness, #font, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #tip, #z

Instance Method Summary collapse

Methods inherited from Container

#add, #button, #clear, #color_picker, #color_well, #combo_box, #file_browser, #grid, #group, #hit_element, #horizontal, #image_frame, #insert, #label, #list, #radio_button, #remove, #scroll_area, #scroll_window, #slider, #text_area, #to_s, #toggle_button, #update, #vertical, #write_tree, #x=, #y=

Methods inherited from Element

#default, #drag?, #draw, #draw_frame, #draw_rect, #enabled=, #enabled?, #height, #height=, #hit?, #max_height, #max_width, #min_height, #min_width, new, original_new, #outer_height, #outer_width, #recalc, schema, #to_s, #update, #width, #width=, #with, #x, #x=, #y, #y=

Methods included from Event

#events, included, new_event_handlers, #publish, #subscribe, #unsubscribe

Constructor Details

#initialize(options = {}) ⇒ 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