widgets: remove deprecated widgets
This commit is contained in:
parent
258fc7c750
commit
f94fb7728f
6 changed files with 1 additions and 522 deletions
|
|
@ -3,6 +3,7 @@
|
|||
## next
|
||||
|
||||
- widgets
|
||||
- **removed** deprecated widgets `multifader`, `multitoggle`, `multipush` and `formula`
|
||||
- new `JS{{}}` property syntax for javascript lovers
|
||||
- errors encountered in `#{}` blocks are now printed to the client console (F12)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ module.exports.widgets = {
|
|||
patchbay: require('./matrices/patchbay').PatchBay,
|
||||
patchbaynode: require('./matrices/patchbay').PatchBayNode,
|
||||
|
||||
// deprecated / hidden
|
||||
multitoggle: require('./matrices/multitoggle'),
|
||||
multipush: require('./matrices/multipush'),
|
||||
multifader: require('./matrices/multifader'),
|
||||
|
||||
// plots
|
||||
led: require('./plots/led'),
|
||||
rgbled: require('./plots/rgbled'),
|
||||
|
|
@ -60,10 +55,6 @@ module.exports.widgets = {
|
|||
gyroscope: require('./inputs/gyroscope'),
|
||||
file: require('./inputs/file'),
|
||||
|
||||
// maths
|
||||
// deprecated / hidden
|
||||
formula: require('./maths/formula')
|
||||
|
||||
}
|
||||
|
||||
module.exports.categories = {
|
||||
|
|
|
|||
|
|
@ -1,197 +0,0 @@
|
|||
var Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
{math} = require('../utils'),
|
||||
Input = require('../inputs/input'),
|
||||
html = require('nanohtml')
|
||||
|
||||
|
||||
module.exports = class Formula extends Widget {
|
||||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
|
||||
_formula: 'formula',
|
||||
|
||||
formula: {type: 'string', value: '', help: ''},
|
||||
condition: {type: 'string', value: '', help: ''},
|
||||
unit: {type: 'string', value: '', help: ''},
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: html`
|
||||
<div class="formula">
|
||||
</div>
|
||||
`})
|
||||
|
||||
|
||||
this.formulaString = String(this.getProp('formula'))
|
||||
this.conditionString = String(this.getProp('condition'))
|
||||
|
||||
this.input = new Input({
|
||||
props:{
|
||||
...Input.defaults()._props(),
|
||||
editable:false,
|
||||
precision:this.getProp('precision'),
|
||||
unit: this.getProp('unit')
|
||||
},
|
||||
parent:this, parentNode:this.widget
|
||||
})
|
||||
|
||||
this.widget.appendChild(this.input.widget)
|
||||
|
||||
this.linkedWidgets = []
|
||||
|
||||
if (this.formulaString.length) {
|
||||
|
||||
if (this.formulaString.match(/\$\{([^}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.formulaString.match(/\$\{([^}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
|
||||
}
|
||||
|
||||
if (this.conditionString.length) {
|
||||
|
||||
if (this.conditionString.match(/\$\{([^}]*)\}/g) != null) this.linkedWidgets = this.linkedWidgets.concat(this.conditionString.match(/\$\{([^}]*)\}/g).map((a)=>{return a.substr(2, a.length - 3)}))
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
this.condition = math.compile(this.conditionString.replace(/\$\{([^}]*)\}/g, '_$1'))
|
||||
delete this.errors.condition
|
||||
|
||||
} catch(err) {
|
||||
|
||||
this.errors.condition = 'Error parsing formula "' + this.conditionString + '" (' + err + ')'
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
this.formula = math.compile(this.formulaString.replace(/\$\{([^}]*)\}/g, '_$1'))
|
||||
delete this.errors.formula
|
||||
|
||||
} catch(err) {
|
||||
|
||||
this.errors.formula = 'Error parsing formula "' + this.conditionString + '" (' + err + ')'
|
||||
|
||||
}
|
||||
|
||||
this.conditionState = true
|
||||
|
||||
|
||||
widgetManager.on('change', this.syncHandle.bind(this), {context: this})
|
||||
|
||||
if (this.formulaString.length) this.updateValue({options:{}})
|
||||
|
||||
}
|
||||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.linkedWidgets.indexOf(e.id)==-1 || !widgetManager.getWidgetById(e.id).length) return
|
||||
this.updateValue(e)
|
||||
|
||||
}
|
||||
|
||||
updateValue(e){
|
||||
|
||||
var variables = {}
|
||||
|
||||
for (let id of this.linkedWidgets) {
|
||||
if (id !== undefined) {
|
||||
variables['_'+id] = 0
|
||||
let widgets = widgetManager.getWidgetById(id)
|
||||
for (let w of widgets) {
|
||||
if (w.getValue) {
|
||||
variables['_'+id] = w.getValue()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (this.conditionString.length) {
|
||||
|
||||
try {
|
||||
|
||||
var s = this.condition.eval(variables).valueOf()
|
||||
|
||||
if (Array.isArray(s) && s.length == 1) s = s[0]
|
||||
|
||||
this.conditionState = s.data !== undefined ? s.data : s
|
||||
|
||||
delete this.errors.condition
|
||||
|
||||
} catch(err) {
|
||||
|
||||
this.errors.condition = 'Error parsing formula "' + this.conditionString + '" (' + err + ')'
|
||||
this.conditionState = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
var v = this.formula.eval(variables).valueOf()
|
||||
|
||||
if (Array.isArray(v) && v.length == 1) v = v[0]
|
||||
|
||||
this.value = v.data ? v.data : v
|
||||
|
||||
this.showValue()
|
||||
|
||||
if (e.options.sync && this.conditionState) this.changed(e.options)
|
||||
if (e.options.send && this.conditionState) this.sendValue()
|
||||
|
||||
delete this.errors.formula
|
||||
|
||||
} catch(err) {
|
||||
|
||||
this.errors.formula = 'Error parsing formula "' + this.formulaString + '" (' + err + ')'
|
||||
this.value = undefined
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
showValue() {
|
||||
|
||||
this.input.setValue(this.value)
|
||||
|
||||
if (this.getProp('condition').length && !this.conditionState) {
|
||||
this.input.stringValue = '* ' + this.input.stringValue
|
||||
this.input.batchDraw()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getSplit() {
|
||||
|
||||
return typeof this.getProp('split') == 'object' && this.getProp('split').length ? this.getProp('split') : false
|
||||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options, oldPropValue) {
|
||||
|
||||
if (super.onPropChanged(...arguments)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
if (this.input) this.input.onPropChanged('color')
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.input.onRemove()
|
||||
super.onRemove()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
ipc = require('../../ipc'),
|
||||
parser = require('../../parser')
|
||||
|
||||
module.exports = class Multifader extends _matrix_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
||||
return super.defaults({
|
||||
|
||||
_matrix:'matrix',
|
||||
|
||||
strips: {type: 'integer', value: 2, help: [
|
||||
'Number of faders in the row, each fader will inherit its parent\'s properties and the following ones (where i is the fader\'s index in the row)',
|
||||
'- `id`: same as the widget\'s with /i appended to it',
|
||||
'- `label`: i',
|
||||
'- `address`: see split',
|
||||
]},
|
||||
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
|
||||
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
|
||||
|
||||
_fader: 'fader',
|
||||
|
||||
range: {type: 'object', value: {min:0,max:1}, help: 'See fader\'s `range`'},
|
||||
logScale: {type: 'boolean', value: false, help: 'See fader\'s `logScale`'},
|
||||
origin: {type: 'number', value: 'auto', help: 'See fader\'s `origin`'},
|
||||
unit: {type: 'string', value: '', help: 'See fader\'s `unit`'},
|
||||
alignRight: {type: 'boolean', value: false, help: 'See fader\'s `alignRight`'},
|
||||
horizontal: {type: 'boolean', value: false, help: 'See fader\'s `horizontal`'},
|
||||
pips: {type: 'boolean', value: false, help: 'See fader\'s `pips`'},
|
||||
dashed: {type: 'boolean', value: false, help: 'See fader\'s `dashed`'},
|
||||
snap: {type: 'boolean', value: true, help: 'See fader\'s `snap`'},
|
||||
meter: {type: 'boolean', value: false, help: 'See fader\'s `meter`'},
|
||||
input: {type: 'boolean', value: true, help: 'See fader\'s `input`'},
|
||||
compact: {type: 'boolean', value: false, help: 'See fader\'s `compact`'},
|
||||
|
||||
}, [], {
|
||||
|
||||
split: {type: 'boolean|string', value: false, help: [
|
||||
'- `true`: the widget\'s index will be appended to the matrice\'s osc address',
|
||||
'- `false`: it will be prepended to the widget\'s preArgs',
|
||||
'- `string`: will be used to define the widgets\' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\\$`))'
|
||||
]}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
ipc.send('errorLog', `[Warning]\n"${this.getProp('type')}" is deprecated and will be removed in the future, please use "matrix" instead.`)
|
||||
|
||||
this.strips = parseInt(this.getProp('strips'))
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.classList.add('horizontal')
|
||||
}
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.classList.add('compact')
|
||||
}
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
var start = parseInt(this.getProp('start'))
|
||||
|
||||
for (var i = start; i < this.strips + start; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'fader'
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.css = ''
|
||||
|
||||
data.target = '@{parent.target}'
|
||||
data.precision = '@{parent.precision}'
|
||||
|
||||
if (!this.getProp('split')) {
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `#{
|
||||
a = @{parent.preArgs};
|
||||
b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
|
||||
concat(b, [${i}])
|
||||
}`
|
||||
} else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) {
|
||||
data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$')
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
} else if (this.getProp('split')) {
|
||||
data.address = '@{parent.address}/' + i
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
}
|
||||
|
||||
var fader = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this
|
||||
})
|
||||
fader._index = i - start
|
||||
fader.container.classList.add('not-editable')
|
||||
|
||||
this.value[i-start] = this.getProp('range').min
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
ipc = require('../../ipc'),
|
||||
parser = require('../../parser')
|
||||
|
||||
module.exports = class Multipush extends _matrix_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
|
||||
_matrix: 'matrix',
|
||||
|
||||
matrix: {type: 'array', value: [2,2], help: [
|
||||
'Defines the number of columns and and rows in the matrix. Each cell will contain a push button that will inherit its parent\'s properties and the following ones (where i is the push\'s index)',
|
||||
'- `id`: same as the widget\'s with /i appended to it',
|
||||
'- `label`: i',
|
||||
'- `address`: see split'
|
||||
]},
|
||||
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
|
||||
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
|
||||
spacing: {type: 'integer', value: 0, help: 'Adds space between widgets'},
|
||||
|
||||
_push: 'push',
|
||||
|
||||
on: {type: '*', value: 1, help: [
|
||||
'Set to `null` to send send no argument in the osc message',
|
||||
'Can be an `object` if the type needs to be specified (see preArgs)'
|
||||
]},
|
||||
off: {type: '*', value: 0, help: [
|
||||
'Set to `null` to send send no argument in the osc message',
|
||||
'Can be an `object` if the type needs to be specified (see preArgs)'
|
||||
]},
|
||||
norelease: {type: 'boolean', value: false, help: 'Set to `true` to prevent sending any osc message when releasing the button'},
|
||||
|
||||
}, ['_value', 'default', 'value'], {
|
||||
|
||||
split: {type: 'boolean|string', value: false, help: [
|
||||
'`true`: the widget\'s index will be appended to the matrice\'s osc address',
|
||||
'`false`: it will be prepended to the widget\'s preArgs',
|
||||
'`string`: will be used to define the widgets\' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\\$`))'
|
||||
]}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
ipc.send('errorLog', `[Warning]\n"${this.getProp('type')}" is deprecated and will be removed in the future, please use "matrix" instead.`)
|
||||
|
||||
this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
var start = parseInt(this.getProp('start'))
|
||||
|
||||
for (var i = start; i < this.getProp('matrix')[0] * this.getProp('matrix')[1] + start; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'push'
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.css = ''
|
||||
|
||||
data.target = '@{parent.target}'
|
||||
data.precision = '@{parent.precision}'
|
||||
|
||||
if (!this.getProp('split')) {
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `#{
|
||||
a = @{parent.preArgs};
|
||||
b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
|
||||
concat(b, [${i}])
|
||||
}`
|
||||
} else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) {
|
||||
data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$')
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
} else if (this.getProp('split')) {
|
||||
data.address = '@{parent.address}/' + i
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
}
|
||||
|
||||
var push = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this
|
||||
})
|
||||
|
||||
push._index = i - start
|
||||
push.container.classList.add('not-editable')
|
||||
|
||||
this.value[i - start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
ipc = require('../../ipc'),
|
||||
parser = require('../../parser')
|
||||
|
||||
module.exports = class Multitoggle extends _matrix_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
|
||||
_matrix:'matrix',
|
||||
|
||||
matrix: {type: 'array', value: [2,2], help: [
|
||||
'Defines the number of columns and and rows in the matrix. Each cell will contain a toggle button that will inherit its parent\'s properties and the following ones (where i is the toggle\'s index)',
|
||||
'- `id`: same as the widget\'s with /i appended to it',
|
||||
'- `label`: i',
|
||||
'- `address`: see split'
|
||||
]},
|
||||
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
|
||||
spacing: {type: 'integer', value: 0, help: 'Adds space between widgets'},
|
||||
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
|
||||
|
||||
_toggle: 'toggle',
|
||||
|
||||
led: {type: 'boolean', value: false, help: 'Set to `true` to display the toggle\'s state with a led'},
|
||||
on: {type: '*', value: 1, help: [
|
||||
'Set to `null` to send send no argument in the osc message',
|
||||
'Can be an `object` if the type needs to be specified (see preArgs)'
|
||||
]},
|
||||
off: {type: '*', value: 0, help: [
|
||||
'Set to `null` to send send no argument in the osc message',
|
||||
'Can be an `object` if the type needs to be specified (see `preArgs`)'
|
||||
]},
|
||||
|
||||
}, [], {
|
||||
|
||||
split: {type: 'boolean|string', value: false, help: [
|
||||
'`true`: the widget\'s index will be appended to the matrice\'s osc address',
|
||||
'`false`: it will be prepended to the widget\'s `preArgs`',
|
||||
'`string`: will be used to define the widgets\' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\\$`))'
|
||||
]}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
ipc.send('errorLog', `[Warning]\n"${this.getProp('type')}" is deprecated and will be removed in the future, please use "matrix" instead.`)
|
||||
|
||||
this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
var start = parseInt(this.getProp('start'))
|
||||
|
||||
for (var i = start; i < this.getProp('matrix')[0] * this.getProp('matrix')[1] + start; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'toggle'
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.css = ''
|
||||
|
||||
data.target = '@{parent.target}'
|
||||
data.precision = '@{parent.precision}'
|
||||
|
||||
if (!this.getProp('split')) {
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `#{
|
||||
a = @{parent.preArgs};
|
||||
b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
|
||||
concat(b, [${i}])
|
||||
}`
|
||||
} else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) {
|
||||
data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$')
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
} else if (this.getProp('split')) {
|
||||
data.address = '@{parent.address}/' + i
|
||||
data.preArgs = '@{parent.preArgs}'
|
||||
}
|
||||
|
||||
var toggle = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this
|
||||
})
|
||||
toggle._index = i - start
|
||||
toggle.container.classList.add('not-editable')
|
||||
|
||||
this.value[i-start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue