buttons:
- remove special `false` value case for push/toggles (which used to disable osc sending) - add `norelease` option to `push` for disabling osc messages when releasing the button
This commit is contained in:
parent
eee1e67aa2
commit
f776645ce0
4 changed files with 24 additions and 18 deletions
|
|
@ -10,6 +10,8 @@
|
|||
- explicit loadings
|
||||
- widgets
|
||||
- make push's backlight only respond to external osc messages (not to synchronization messages from other widgets or clients)
|
||||
- remove special `false` value case for push/toggles (which used to disable osc sending)
|
||||
- add `norelease` option to `push` for disabling osc messages when releasing the button
|
||||
- misc
|
||||
- rewritten matrices with prototypes inheritance
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ module.exports.options = {
|
|||
|
||||
on:1,
|
||||
off:0,
|
||||
norelease:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
|
|
@ -57,20 +58,23 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget[widget.lastChanged]?widgetData.on:widgetData.off
|
||||
return widget[widget.lastChanged] ?
|
||||
widgetData.on.value !== undefined ? widgetData.on.value : widgetData.on
|
||||
:
|
||||
widgetData.off.value !== undefined ? widgetData.off.value : widgetData.off
|
||||
}
|
||||
|
||||
widget.setValuePrivate = function(v,options={}) {
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('active')
|
||||
widget.active = 1
|
||||
if (options.send) widget.sendValue(v)
|
||||
widget.lastChanged = 'active'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options:options})
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('active')
|
||||
widget.active = 0
|
||||
if (options.send) widget.sendValue(v)
|
||||
if (options.send && !widgetData.norelease) widget.sendValue(v)
|
||||
widget.lastChanged = 'active'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId, options:options})
|
||||
}
|
||||
|
|
@ -81,13 +85,13 @@ module.exports.create = function(widgetData,container) {
|
|||
if (options.send || options.sync) widget.setValuePrivate(v,options)
|
||||
return
|
||||
}
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (options.send) widget.sendValue(v)
|
||||
widget.lastChanged = 'state'
|
||||
if (options.sync) widget.trigger({type:'sync',id:widgetData.id,widget:widget, linkId:widgetData.linkId,options:options})
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (options.send) widget.sendValue(v)
|
||||
|
|
@ -97,8 +101,8 @@ module.exports.create = function(widgetData,container) {
|
|||
}
|
||||
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
|
|
@ -106,6 +110,5 @@ module.exports.create = function(widgetData,container) {
|
|||
args:args
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,14 +55,17 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.state?widgetData.on:widgetData.off
|
||||
return widget.state ?
|
||||
widgetData.on.value !== undefined ? widgetData.on.value : widgetData.on
|
||||
:
|
||||
widgetData.off.value !== undefined ? widgetData.off.value : widgetData.off
|
||||
}
|
||||
widget.setValue = function(v,options={}) {
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
if (v===widgetData.on || (v.value === widgetData.on.value && v.value !== undefined)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (options.send) widget.sendValue(widgetData.on)
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
} else if (v===widgetData.off || (v.value === widgetData.off.value && v.value !== undefined)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (options.send) widget.sendValue(widgetData.off)
|
||||
|
|
@ -72,7 +75,6 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
|
|
@ -82,6 +84,5 @@ module.exports.create = function(widgetData,container) {
|
|||
args:args
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ Buttons are exactly what you think they are.
|
|||
- default: `1`
|
||||
- usage: defines which value is sent on `on` position
|
||||
- set to `null` to send send no argument in the osc message
|
||||
- set to `false` to prevent sending any osc message
|
||||
- can be an `object` if the type needs to be specified (see [preArgs](../widgets-generics.md#preargs))
|
||||
|
||||
#### `off`
|
||||
|
|
@ -25,7 +24,6 @@ Buttons are exactly what you think they are.
|
|||
- default: `0`
|
||||
- usage: defines which value is sent on `off` position
|
||||
- set to `null` to send send no argument in the osc message
|
||||
- set to `false` to prevent sending any osc message
|
||||
- can be an `object` if the type needs to be specified (see [preArgs](../widgets-generics.md#preargs))
|
||||
|
||||
|
||||
|
|
@ -44,7 +42,6 @@ Buttons are exactly what you think they are.
|
|||
- default: `1`
|
||||
- usage: defines which value is sent when pushing the button
|
||||
- set to `null` to send send no argument in the osc message
|
||||
- set to `false` to prevent sending any osc message
|
||||
- can be an `object` if the type needs to be specified (see [preArgs](../widgets-generics.md#preargs))
|
||||
|
||||
#### `off`
|
||||
|
|
@ -52,11 +49,14 @@ Buttons are exactly what you think they are.
|
|||
- default: `0`
|
||||
- usage: defines which value is sent when releasing the button
|
||||
- set to `null` to send send no argument in the osc message
|
||||
- set to `false` to prevent sending any osc message
|
||||
- can be an `object` if the type needs to be specified (see [preArgs](../widgets-generics.md#preargs))
|
||||
|
||||
### `norelease`
|
||||
- type: `bool`
|
||||
- default: `false`
|
||||
- usage: set to true to prevent sending any osc message when releasing the button
|
||||
|
||||
Setting the `push`'s value externally (via osc or widget linking/cloning) will toggle it's inner light.
|
||||
Setting the `push`'s value externally (via osc) will toggle it's inner light.
|
||||
|
||||
|
||||
----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue