Class: Nuklear::UI::Slider

Inherits:
Base
  • Object
show all
Defined in:
lib/nuklear/ui/slider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

descendants, #dsl, inherited

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

#currentObject

Returns the value of attribute current.



4
5
6
# File 'lib/nuklear/ui/slider.rb', line 4

def current
  @current
end

#maxObject

Returns the value of attribute max.



4
5
6
# File 'lib/nuklear/ui/slider.rb', line 4

def max
  @max
end

#minObject

Returns the value of attribute min.



4
5
6
# File 'lib/nuklear/ui/slider.rb', line 4

def min
  @min
end

#stepObject

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_commandObject



15
16
17
# File 'lib/nuklear/ui/slider.rb', line 15

def to_command
  [:ui_slider, current, min, max, step]
end