Class: Cura::Component::Scrollbar
- Includes:
- Attributes::HasOrientation
- Defined in:
- lib/cura/component/scrollbar.rb
Overview
A component for scrolling. TODO: Option to have buttons or not
Instance Attribute Summary collapse
-
#buttons ⇒ Object
readonly
Get the buttons for this scrollbar.
-
#max ⇒ Object
Get the maximum value of this scrollbar.
-
#min ⇒ Object
Get the minimum value of this scrollbar.
-
#percent ⇒ Object
readonly
Get the percentage of this scrollbar.
-
#value ⇒ Object
Get the value of this scrollbar.
Attributes included from Attributes::HasOrientation
Attributes included from Attributes::HasAncestry
Attributes included from Attributes::HasOffsets
Attributes included from Attributes::HasEvents
Instance Method Summary collapse
-
#decrement(value = 1) ⇒ Object
Decrement the value of this scrollbar by the given number.
-
#height=(value) ⇒ Object
Set the height of this scrollbar.
-
#increment(value = 1) ⇒ Object
Increment the value of this scrollbar by the given number.
-
#initialize(attributes = {}) ⇒ Scrollbar
constructor
A new instance of Scrollbar.
-
#orientation=(value) ⇒ Object
Set the orientation of this scrollbar.
-
#width=(value) ⇒ Object
Set the width of this scrollbar.
Methods included from Attributes::HasOrientation
Methods included from Attributes::HasAttributes
Methods inherited from Group
#add_child, #delete_child_at, #draw, #height, #update, #width
Methods included from Attributes::HasChildren
#add_child, #add_children, #children, #children?, #delete_child, #delete_child_at, #delete_children, #each
Methods inherited from Base
#application, #background, #contains_coordinates?, #cursor, #draw, #focus, #focused?, #foreground, #inspect, #pencil, #update
Methods included from Attributes::HasRelativeCoordinates
Methods included from Attributes::HasCoordinates
Methods included from Attributes::HasAncestry
Methods included from Attributes::HasOffsets
#border, #border=, #margin, #margin=, #padding, #padding=
Methods included from Attributes::HasColors
#background, #background=, #foreground, #foreground=
Methods included from Attributes::HasFocusability
Methods included from Attributes::HasEvents
Methods included from Attributes::HasDimensions
Constructor Details
#initialize(attributes = {}) ⇒ Scrollbar
Returns a new instance of Scrollbar.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cura/component/scrollbar.rb', line 16 def initialize(attributes={}) @value = 0 @min = 0 @max = 100 @orientation = :vertical @buttons = {} @buttons[:decrement] = Button.new(width: 1, height: 1) { parent.decrement } @buttons[:increment] = Button.new(width: 1, height: 1) { parent.increment } @handle = Component.new(width: 1, height: 1) super setup_value setup_handle set_percentage set_handle_position end |
Instance Attribute Details
#buttons ⇒ Object (readonly)
Get the buttons for this scrollbar.
40 41 42 |
# File 'lib/cura/component/scrollbar.rb', line 40 def @buttons end |
#max ⇒ Object
Get the maximum value of this scrollbar.
90 91 92 |
# File 'lib/cura/component/scrollbar.rb', line 90 def max @max end |
#min ⇒ Object
Get the minimum value of this scrollbar.
80 81 82 |
# File 'lib/cura/component/scrollbar.rb', line 80 def min @min end |
#percent ⇒ Object (readonly)
Get the percentage of this scrollbar.
59 60 61 |
# File 'lib/cura/component/scrollbar.rb', line 59 def percent @percent end |
#value ⇒ Object
Get the value of this scrollbar.
43 44 45 |
# File 'lib/cura/component/scrollbar.rb', line 43 def value @value end |
Instance Method Details
#decrement(value = 1) ⇒ Object
Decrement the value of this scrollbar by the given number.
114 115 116 117 118 |
# File 'lib/cura/component/scrollbar.rb', line 114 def decrement(value=1) raise ArgumentError, "value must respond to :to_i" unless value.respond_to?(:to_i) self.value -= value.to_i end |
#height=(value) ⇒ Object
Set the height of this scrollbar.
71 72 73 74 75 76 77 |
# File 'lib/cura/component/scrollbar.rb', line 71 def height=(value) super # @height = 2 if @height == 0 # TODO: Depends on if buttons are shown or not AND orientation end |
#increment(value = 1) ⇒ Object
Increment the value of this scrollbar by the given number.
107 108 109 110 111 |
# File 'lib/cura/component/scrollbar.rb', line 107 def increment(value=1) raise ArgumentError, "value must respond to :to_i" unless value.respond_to?(:to_i) self.value += value.to_i end |
#orientation=(value) ⇒ Object
Set the orientation of this scrollbar.
100 101 102 103 104 |
# File 'lib/cura/component/scrollbar.rb', line 100 def orientation=(value) super end |
#width=(value) ⇒ Object
Set the width of this scrollbar.
62 63 64 65 66 67 68 |
# File 'lib/cura/component/scrollbar.rb', line 62 def width=(value) super # @width = 2 if @width == 0 # TODO: Depends on if buttons are shown or not AND orientation end |