widgets: add default property for setting initial/doubleTap/spring value (issue #174)
This commit is contained in:
parent
72e724aa85
commit
99a7e4d2ac
33 changed files with 138 additions and 57 deletions
|
|
@ -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