widgets: add default property for setting initial/doubleTap/spring value (issue #174)
This commit is contained in:
parent
9eac3e991a
commit
a185103701
33 changed files with 138 additions and 57 deletions
|
|
@ -9,6 +9,7 @@
|
|||
- add `--fullscreen` switch (default gui only, bypasses the sidepanel fullscreen button)
|
||||
- widgets
|
||||
- knob: big knobs design tweaks
|
||||
- **new** `default` property that sets a widgets initial/doubleTap/spring value. The `value` property does no longer serve this purpose.
|
||||
- property inheritance: `@{widget_id.value}`, `@{widget_id}` and `@{widget_id._value}` now all refer to the widget's current value (the latter being kept for backward compatibility)
|
||||
- editor
|
||||
- allow selecting multiple widgets (`ctrl + click`) if they share the same parent. Context-menu and sidepanel editing actions apply to all selected widgets
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ Pads are multidimensional widgets that output multiple values.
|
|||
### `spring`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: when set to `true`, the widget will go back to its initial value when released.
|
||||
- usage: when set to `true`, the widget will go back to its `default` value when released.
|
||||
|
||||
### `doubleTap`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: set to `true` to make the xy reset to its initial value when receiving a double tap
|
||||
- usage: set to `true` to make the xy reset to its `default` value when receiving a double tap
|
||||
|
||||
### `split`
|
||||
- type: `boolean|object`
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ range: {
|
|||
### `spring`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: when set to `true`, the widget will go back to its initial value when released.
|
||||
- usage: when set to `true`, the widget will go back to its `default` value when released.
|
||||
|
||||
|
||||
### `doubleTap`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: set to `true` to make the fader reset to its initial value when receiving a double tap
|
||||
- usage: set to `true` to make the fader reset to its `default` value when receiving a double tap
|
||||
|
||||
### `meter`
|
||||
- type: `boolean`
|
||||
|
|
@ -181,12 +181,12 @@ range: {
|
|||
### `spring`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: when set to `true`, the widget will go back to its initial value when released.
|
||||
- usage: when set to `true`, the widget will go back to its `default` value when released.
|
||||
|
||||
### `doubleTap`
|
||||
- type: `boolean`
|
||||
- default: `false`
|
||||
- usage: set to `true` to make the knob reset to its initial value when receiving a double tap
|
||||
- usage: set to `true` to make the knob reset to its `default` value when receiving a double tap
|
||||
|
||||
### `css`
|
||||
```
|
||||
|
|
|
|||
|
|
@ -55,16 +55,24 @@ All widgets share a set of generic properties described below.
|
|||
- `border-radius:5rem; > .label {font-size: 20rem}` will round the widget's corners and increase its label's font-size (the `>` selector targets only the direct children of the widget element)
|
||||
|
||||
|
||||
## OSC
|
||||
## Value
|
||||
|
||||
### `default`
|
||||
- type: `*`
|
||||
- default: `empty`
|
||||
- usage: if set, the widget will be initialized with this `value` when the session is loaded. Some widgets use recall this property under specific conditions (see fader's `doubleTap` for example).
|
||||
- note: its `type` must match the widget's value type (ie a `number` for sliders, an `array` for pads, etc).
|
||||
|
||||
|
||||
### `value`<i class="md-icon" title="dynamic">flash_on</i>
|
||||
- type: `*`
|
||||
- default: `empty`
|
||||
- usage: if set, the widget will be initialized with this `value`. This won't send any osc message unless it is changed because of a property inheritance update initiated by an action that should send osc (e.g. dragging a slider).
|
||||
- usage: set `value` to define a widget's value depending on other widget's values / properties using [property inheritance](../extras/property-inheritance.md) and [property maths](../extras/property-maths.md). When updated by an osc-sending event (e.g. dragging a slider), the widget will send its own osc message as well.
|
||||
- note: its `type` must match the widget's value type (ie a `number` for sliders, an `array` for pads, etc).
|
||||
|
||||
|
||||
## OSC
|
||||
|
||||
### `precision`<i class="md-icon" title="dynamic">flash_on</i>
|
||||
- type: `integer|string`
|
||||
- default: `2`
|
||||
|
|
|
|||
|
|
@ -66,8 +66,17 @@ var Parser = class Parser {
|
|||
widget.created()
|
||||
|
||||
// set widget's initial state
|
||||
if (widget.getProp('value') !== '') {
|
||||
stateManager.pushValueNewProp(widget.getProp('id'), widget.getProp('value'))
|
||||
var defaultValue = widget.getProp('default'),
|
||||
currentValue = widget.getProp('value')
|
||||
|
||||
if (currentValue !== '' && currentValue !== undefined) {
|
||||
|
||||
stateManager.pushValueNewProp(widget.getProp('id'), currentValue)
|
||||
|
||||
} else if (defaultValue !== '' && defaultValue !== undefined) {
|
||||
|
||||
widget.setValue(defaultValue)
|
||||
|
||||
}
|
||||
|
||||
// Append the widget to its parent
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ class Dropdown extends Widget {
|
|||
_dropdown:'dropdown',
|
||||
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default:'',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,10 @@ module.exports = class Switch extends Widget {
|
|||
horizontal:false,
|
||||
showValues:false,
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default:'',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ module.exports = class Switch extends Widget {
|
|||
}
|
||||
|
||||
var isArray = Array.isArray(values)
|
||||
|
||||
|
||||
for (var k in values) {
|
||||
|
||||
this.values.push(values[k])
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@ class Toggle extends Widget {
|
|||
led: false,
|
||||
on:1,
|
||||
off:0,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ var Panel = require('./panel'),
|
|||
resize = require('../../events/resize'),
|
||||
doubletab = require('../mixins/double_tap')
|
||||
|
||||
|
||||
module.exports = class Modal extends Panel {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -34,7 +33,10 @@ module.exports = class Modal extends Panel {
|
|||
popupHeight:'80%',
|
||||
layout:'',
|
||||
spacing:0,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -90,7 +92,7 @@ module.exports = class Modal extends Panel {
|
|||
})
|
||||
} else {
|
||||
this.light.addEventListener('fast-click',(e)=>{
|
||||
if (e.capturedByEditor === true) return
|
||||
if (e.capturedByEditor === true) return
|
||||
this.setValue(1, {sync:true, send:true})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ class Panel extends Widget {
|
|||
border:true,
|
||||
layout:'',
|
||||
spacing:0,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -99,7 +102,6 @@ class Panel extends Widget {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
createNavigation() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ var Panel = require('./panel'),
|
|||
Tab = require('./tab'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
|
||||
|
||||
module.exports = class Root extends Panel {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -19,9 +17,9 @@ module.exports = class Root extends Panel {
|
|||
color:'auto',
|
||||
css:'',
|
||||
|
||||
_panel: 'panel',
|
||||
|
||||
value:'',
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ module.exports = class Tab extends Panel {
|
|||
|
||||
layout:'',
|
||||
spacing:0,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ module.exports = class Input extends Canvas {
|
|||
vertical:false,
|
||||
unit: '',
|
||||
editable:true,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@ module.exports = class Multifader extends Matrix {
|
|||
strips:2,
|
||||
start:0,
|
||||
traversing:true,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_fader: 'fader',
|
||||
|
||||
range:{min:0,max:1},
|
||||
|
|
|
|||
|
|
@ -31,8 +31,11 @@ module.exports = class Multipush extends Matrix {
|
|||
on:1,
|
||||
off:0,
|
||||
norelease:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
precision:2,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ module.exports = class Multitoggle extends Matrix {
|
|||
led: false,
|
||||
on:1,
|
||||
off:0,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc: 'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ module.exports = class MultiXy extends Pad {
|
|||
rangeY:{min:0,max:1},
|
||||
logScaleX:false,
|
||||
logScaleY:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -85,7 +88,7 @@ module.exports = class MultiXy extends Pad {
|
|||
...xyDefaults,
|
||||
snap:this.getProp('snap'),
|
||||
spring:this.getProp('spring'),
|
||||
value:this.getProp('value').length == this.getProp('points') * 2 ? [this.getProp('value')[i*2], this.getProp('value')[i*2 + 1]] : '',
|
||||
default:this.getProp('default').length === this.getProp('points') * 2 ? [this.getProp('default')[i*2], this.getProp('default')[i*2 + 1]] : '',
|
||||
rangeX:this.getProp('rangeX'),
|
||||
rangeY:this.getProp('rangeY'),
|
||||
precision:this.precision,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ module.exports = class Rgb extends Pad {
|
|||
input: true,
|
||||
snap:false,
|
||||
spring:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ module.exports = class Xy extends Pad {
|
|||
rangeY:{min:0,max:1},
|
||||
logScaleX:false,
|
||||
logScaleY:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -74,7 +77,7 @@ module.exports = class Xy extends Pad {
|
|||
horizontal:true,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getProp('value').length==2?this.getProp('value')[0]:'',
|
||||
default:this.getProp('default').length === 2 ? this.getProp('default')[0] : '',
|
||||
snap:this.getProp('snap'),
|
||||
range:this.getProp('rangeX'),
|
||||
origin:'auto',
|
||||
|
|
@ -90,7 +93,7 @@ module.exports = class Xy extends Pad {
|
|||
horizontal:false,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getProp('value').length==2?this.getProp('value')[1]:'',
|
||||
default:this.getProp('default').length === 2 ? this.getProp('default')[1] : '',
|
||||
snap:this.getProp('snap'),
|
||||
range:this.getProp('rangeY'),
|
||||
origin:'auto',
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ module.exports = class Eq extends _plots_base {
|
|||
origin: 'auto',
|
||||
logScaleX: false,
|
||||
smooth: false,
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ module.exports = class Led extends Widget {
|
|||
repeat: 'no-repeat',
|
||||
border: true,
|
||||
cache: true,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ module.exports = class Led extends Widget {
|
|||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var Fader = require('../sliders/fader'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
|
||||
|
||||
module.exports = class Meter extends Fader {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -35,7 +34,10 @@ module.exports = class Meter extends Fader {
|
|||
horizontal:false,
|
||||
pips:false,
|
||||
dashed:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ module.exports = class Plot extends _plots_base {
|
|||
logScaleY: false,
|
||||
smooth: false,
|
||||
pips:true,
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ module.exports = class Rbgled extends Widget {
|
|||
label:'auto',
|
||||
css:'',
|
||||
|
||||
_rgbled:'rgbled',
|
||||
|
||||
value:'',
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ module.exports = class Text extends Widget {
|
|||
_text: 'text',
|
||||
|
||||
vertical:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ module.exports = class Visualizer extends _plots_base {
|
|||
logScale: false,
|
||||
smooth: false,
|
||||
pips:true,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -49,7 +52,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
options.props.value = '@{' + options.props.widgetId + '}'
|
||||
delete options.props.widgetId
|
||||
}
|
||||
|
||||
|
||||
super(options)
|
||||
|
||||
this.fps = 30
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ var {clip, mapToScale} = require('../utils'),
|
|||
Slider = require('./slider'),
|
||||
parser = require('../../parser')
|
||||
|
||||
|
||||
module.exports = class Fader extends Slider {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -41,7 +40,10 @@ module.exports = class Fader extends Slider {
|
|||
logScale:false,
|
||||
unit:'',
|
||||
origin: 'auto',
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ module.exports = class Knob extends Slider {
|
|||
logScale:false,
|
||||
unit:'',
|
||||
origin: 'auto',
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,10 @@ module.exports = class Range extends Widget {
|
|||
spring:false,
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
@ -245,7 +248,7 @@ module.exports = class Range extends Widget {
|
|||
horizontal:this.getProp('horizontal'),
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getProp('value').length==2?this.getProp('value')[0]:this.getProp('range').min,
|
||||
default:this.getProp('default').length === 2 ? this.getProp('default')[0] : this.getProp('range').min,
|
||||
snap:this.getProp('snap'),
|
||||
spring:this.getProp('spring'),
|
||||
range:this.getProp('range'),
|
||||
|
|
@ -262,7 +265,7 @@ module.exports = class Range extends Widget {
|
|||
horizontal:this.getProp('horizontal'),
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getProp('value').length==2?this.getProp('value')[1]:this.getProp('range').max,
|
||||
default:this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max,
|
||||
snap:this.getProp('snap'),
|
||||
spring:this.getProp('spring'),
|
||||
range:this.getProp('range'),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ var {clip, mapToScale} = require('../utils'),
|
|||
doubletab = require('../mixins/double_tap'),
|
||||
Input = require('../inputs/input')
|
||||
|
||||
|
||||
class Slider extends Canvas {
|
||||
|
||||
constructor(options) {
|
||||
|
|
@ -51,7 +50,7 @@ class Slider extends Canvas {
|
|||
this.rangeValsMin:
|
||||
clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
this.springValue = this.getProp('value') !== '' ? this.getProp('value') : this.originValue
|
||||
this.springValue = this.getProp('default') !== '' ? this.getProp('default') : this.originValue
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
|
|
@ -100,7 +99,7 @@ class Slider extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
this.setValue(this.originValue)
|
||||
this.setValue(this.springValue)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ var Widget = require('../common/widget'),
|
|||
widgetManager = require('../../managers/widgets'),
|
||||
osc = require('../../osc')
|
||||
|
||||
|
||||
module.exports = class _switchers_base extends Widget {
|
||||
|
||||
constructor(options) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ module.exports = class Switcher extends _switchers_base {
|
|||
horizontal:false,
|
||||
linkedWidgets:'',
|
||||
values:['A', 'B'],
|
||||
value:'',
|
||||
|
||||
_value: 'value',
|
||||
default: '',
|
||||
value: '',
|
||||
|
||||
_osc:'osc',
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue