Class: Nuklear::UI::Slider
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#step ⇒ Object
Returns the value of attribute step.
Instance Method Summary collapse
-
#initialize(enabled: true, min: 0.0, max: 1.0, current: 0.0, step: 0.001) ⇒ Slider
constructor
A new instance of Slider.
- #result(x, context) ⇒ Object
- #to_command ⇒ Object
Methods inherited from Base
Methods included from Enableable
#disable, #disabled=, #disabled?, #enable, #enabled=, #enabled?
Methods included from Events
#event_listeners_for, #on, #trigger
Constructor Details
#initialize(enabled: true, min: 0.0, max: 1.0, current: 0.0, step: 0.001) ⇒ Slider
Returns a new instance of Slider.
6 7 8 9 10 11 12 13 |
# File 'lib/nuklear/ui/slider.rb', line 6 def initialize(enabled: true, min: 0.0, max: 1.0, current: 0.0, step: 0.001) super enabled: enabled @min = min @max = max @current = current @step = step on(:changed) { yield @current } if block_given? end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
4 5 6 |
# File 'lib/nuklear/ui/slider.rb', line 4 def current @current end |
#max ⇒ Object
Returns the value of attribute max.
4 5 6 |
# File 'lib/nuklear/ui/slider.rb', line 4 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
4 5 6 |
# File 'lib/nuklear/ui/slider.rb', line 4 def min @min end |
#step ⇒ Object
Returns the value of attribute step.
4 5 6 |
# File 'lib/nuklear/ui/slider.rb', line 4 def step @step end |
Instance Method Details
#result(x, context) ⇒ Object
19 20 21 22 23 |
# File 'lib/nuklear/ui/slider.rb', line 19 def result(x, context) @current = x trigger :changed @last_event = nil end |
#to_command ⇒ Object
15 16 17 |
# File 'lib/nuklear/ui/slider.rb', line 15 def to_command [:ui_slider, current, min, max, step] end |