Class: SparkleMotion::LaunchPad::Widgets::RadioGroup
- Inherits:
-
SparkleMotion::LaunchPad::Widget
- Object
- SparkleMotion::LaunchPad::Widget
- SparkleMotion::LaunchPad::Widgets::RadioGroup
- Defined in:
- lib/sparkle_motion/launch_pad/widgets/radio_group.rb
Overview
Class to represent a radio-button group control on a Novation Launchpad.
Instance Attribute Summary collapse
-
#on_deselect ⇒ Object
Returns the value of attribute on_deselect.
-
#on_select ⇒ Object
Returns the value of attribute on_select.
Attributes inherited from SparkleMotion::LaunchPad::Widget
#down, #height, #off, #on, #value, #width, #x, #y
Instance Method Summary collapse
-
#initialize(launchpad:, x:, y:, size:, on:, off:, down:, on_select: nil, on_deselect:, value: nil) ⇒ RadioGroup
constructor
A new instance of RadioGroup.
- #render ⇒ Object
- #update(*args) ⇒ Object
Methods inherited from SparkleMotion::LaunchPad::Widget
Constructor Details
#initialize(launchpad:, x:, y:, size:, on:, off:, down:, on_select: nil, on_deselect:, value: nil) ⇒ RadioGroup
Returns a new instance of RadioGroup.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sparkle_motion/launch_pad/widgets/radio_group.rb', line 8 def initialize(launchpad:, x:, y:, size:, on:, off:, down:, on_select: nil, on_deselect:, value: nil) super(launchpad: launchpad, x: x, y: y, width: size[0], height: size[1], on: on, off: off, down: down, value: value) @on_select = on_select @on_deselect = on_deselect end |
Instance Attribute Details
#on_deselect ⇒ Object
Returns the value of attribute on_deselect.
6 7 8 |
# File 'lib/sparkle_motion/launch_pad/widgets/radio_group.rb', line 6 def on_deselect @on_deselect end |
#on_select ⇒ Object
Returns the value of attribute on_select.
6 7 8 |
# File 'lib/sparkle_motion/launch_pad/widgets/radio_group.rb', line 6 def on_select @on_select end |
Instance Method Details
#render ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/sparkle_motion/launch_pad/widgets/radio_group.rb', line 23 def render (0..max_x).each do |xx| (0..max_y).each do |yy| col = (value == index_for(x: xx, y: yy)) ? on : off change_grid(x: xx, y: yy, color: col) end end end |
#update(*args) ⇒ Object
33 34 35 36 37 |
# File 'lib/sparkle_motion/launch_pad/widgets/radio_group.rb', line 33 def update(*args) super(*args) on_select.call(value) if on_select && value on_deselect.call(value) if on_deselect && !value end |