Class: Nuklear::UI::Property

Inherits:
Base
  • Object
show all
Defined in:
lib/nuklear/ui/property.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, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1) ⇒ Property

Returns a new instance of Property.



6
7
8
9
10
11
12
13
14
15
# File 'lib/nuklear/ui/property.rb', line 6

def initialize(enabled: true, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1)
  super enabled: enabled
  @text = text
  @min = min
  @max = max
  @current = current
  @step = step
  @inc_per_pixel = inc_per_pixel
  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/property.rb', line 4

def current
  @current
end

#inc_per_pixelObject

Returns the value of attribute inc_per_pixel.



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

def inc_per_pixel
  @inc_per_pixel
end

#maxObject

Returns the value of attribute max.



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

def max
  @max
end

#minObject

Returns the value of attribute min.



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

def min
  @min
end

#stepObject

Returns the value of attribute step.



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

def step
  @step
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#result(x, context) ⇒ Object



21
22
23
24
25
# File 'lib/nuklear/ui/property.rb', line 21

def result(x, context)
  @current = x
  trigger :changed
  @last_event = nil
end

#to_commandObject



17
18
19
# File 'lib/nuklear/ui/property.rb', line 17

def to_command
  [:ui_property, text, min, current, max, step, inc_per_pixel]
end