continue v1
This commit is contained in:
parent
85f7f1cb8e
commit
be693864ab
25 changed files with 139 additions and 244 deletions
|
|
@ -64,9 +64,6 @@ class Menu extends Widget {
|
|||
this.parseValues()
|
||||
|
||||
|
||||
this.parentScroll = [0,0]
|
||||
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
doubletab(this.widget, (e)=>{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class Widget extends EventEmitter {
|
|||
'Insert icons using the prefix ^ followed by the icon\'s name : ^play, ^pause, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)'
|
||||
]},
|
||||
visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'},
|
||||
// interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'},
|
||||
|
||||
_geometry:'geometry',
|
||||
|
||||
|
|
@ -174,7 +175,6 @@ class Widget extends EventEmitter {
|
|||
this.errors.id = 'There can only be one root'
|
||||
}
|
||||
|
||||
this.disabledProps = []
|
||||
// this.mathjsDeprecationWarned = false
|
||||
|
||||
// cache precision
|
||||
|
|
@ -281,8 +281,6 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
getSplit() {}
|
||||
|
||||
checkLinkedProps(propNames) {
|
||||
|
||||
// Dynamic props cache check
|
||||
|
|
@ -440,7 +438,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
var variables = {},
|
||||
defaultScope = this.constructor.parsersContexts[propName] || {},
|
||||
mathscope = context || {},
|
||||
jsScope = context || {},
|
||||
varnumber = 999
|
||||
|
||||
if (typeof propValue == 'string') {
|
||||
|
|
@ -548,7 +546,7 @@ class Widget extends EventEmitter {
|
|||
varnumber--
|
||||
|
||||
variables[varname] = r
|
||||
mathscope[varname] = r
|
||||
jsScope[varname] = r
|
||||
|
||||
return varname
|
||||
|
||||
|
|
@ -588,7 +586,7 @@ class Widget extends EventEmitter {
|
|||
varnumber--
|
||||
|
||||
variables[varname] = r
|
||||
mathscope[varname] = r
|
||||
jsScope[varname] = r
|
||||
|
||||
return varname
|
||||
})
|
||||
|
|
@ -597,12 +595,21 @@ class Widget extends EventEmitter {
|
|||
propValue = propValue.replace(/#\{(?:[^{}]|\{[^{}]*\})*\}/g, (m)=>{
|
||||
// one bracket nesting allowed, if we need two: #\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}
|
||||
|
||||
//TODO: js one-liner
|
||||
var code = m.substr(2, m.length - 3).trim()
|
||||
|
||||
if (!this.parsers[code]) this.parsers[code] = evaljs('return ' + code, defaultScope)
|
||||
|
||||
let r = this.parsers[code](jsScope)
|
||||
|
||||
if (r === undefined) r = ''
|
||||
|
||||
return typeof r !== 'string' ? JSON.stringify(r) : r
|
||||
|
||||
return ''
|
||||
})
|
||||
} catch (err) {
|
||||
console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err)
|
||||
var stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err + line)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -610,7 +617,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (!this.parsers[code]) this.parsers[code] = evaljs(code, defaultScope)
|
||||
|
||||
let r = this.parsers[code](mathscope)
|
||||
let r = this.parsers[code](jsScope)
|
||||
|
||||
if (r === undefined) r = ''
|
||||
|
||||
|
|
@ -794,9 +801,6 @@ class Widget extends EventEmitter {
|
|||
address: propName == 'address' ? oldPropValue : this.getProp('address')
|
||||
}
|
||||
data[propName] = this.getProp(propName)
|
||||
if (propName === 'address' && this.getSplit()) {
|
||||
data['split'] = this.getSplit()
|
||||
}
|
||||
widgetManager.registerWidget(this, data, oldData)
|
||||
return
|
||||
|
||||
|
|
@ -931,13 +935,20 @@ class Widget extends EventEmitter {
|
|||
if (styles.includes('color')) {
|
||||
|
||||
// color
|
||||
this.container.style.setProperty('--color-widget', this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '')
|
||||
this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '')
|
||||
this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '')
|
||||
this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '')
|
||||
this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '')
|
||||
this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '')
|
||||
this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
|
||||
for (var cssvar of ['color-widget', 'color-fill', 'color-stroke', 'alpha-stroke', 'alpha-fill-on', 'alpha-fill-off']) {
|
||||
var val = this.getProp(cssvar.replace(/\-([a-z])/g, (a,s)=>s.toUpperCase()))
|
||||
this.container.style.setProperty('--' + cssvar, val !== undefined && val != 'auto' ? val : '')
|
||||
}
|
||||
this.container.style.setProperty('--widget-padding', this.getProp('padding') !== undefined && this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
|
||||
|
||||
|
||||
// this.container.style.setProperty('--color-widget', this.getProp('colorWidget') && this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '')
|
||||
// this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '')
|
||||
// this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '')
|
||||
// this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '')
|
||||
// this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '')
|
||||
// this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '')
|
||||
// this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var Container = require('../common/container'),
|
|||
{diff, diffToWidget} = require('../../editor/diff'),
|
||||
html = require('nanohtml')
|
||||
|
||||
var excludedCloneClasses = ['widget', 'absolute-position', 'ui-resizable', 'ui-draggable', 'not-editable', 'editing']
|
||||
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing']
|
||||
|
||||
class Clone extends Container() {
|
||||
|
||||
|
|
@ -28,7 +28,12 @@ class Clone extends Container() {
|
|||
|
||||
props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'},
|
||||
|
||||
}, ['label', 'color', 'linkId', '_value', 'default', 'value', '_osc', 'precision', 'address', 'preArgs', 'target', 'bypass'])
|
||||
}, [
|
||||
'_style', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn', 'padding',
|
||||
'label', 'color', 'linkId',
|
||||
'_value', 'default', 'value',
|
||||
'_osc', 'precision', 'address', 'preArgs', 'target', 'bypass'
|
||||
])
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ class Modal extends Panel {
|
|||
|
||||
super(options)
|
||||
|
||||
this.disabledProps = []
|
||||
|
||||
this.popup = html`
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
|
|
@ -104,7 +102,6 @@ class Modal extends Panel {
|
|||
if (e.keyCode==27) this.setValue(0, {sync:true, send:true})
|
||||
}).bind(this)
|
||||
|
||||
this.parentScroll = [0,0]
|
||||
this.value = 0
|
||||
this.init = false
|
||||
this.labelChange = true
|
||||
|
|
@ -134,12 +131,10 @@ class Modal extends Panel {
|
|||
|
||||
this.popup.classList.toggle('show', this.value)
|
||||
this.container.classList.toggle('on', this.value)
|
||||
this.light.classList.toggle('on', this.value)
|
||||
|
||||
|
||||
this.bindEscKey(this.value)
|
||||
|
||||
if (this.init) this.fixParents()
|
||||
|
||||
if (this.value) {
|
||||
resize.check(this.widget, true)
|
||||
}
|
||||
|
|
@ -167,36 +162,6 @@ class Modal extends Panel {
|
|||
super.onRemove()
|
||||
}
|
||||
|
||||
fixParents() {
|
||||
|
||||
var parent = this.parent,
|
||||
scrollFixed = false
|
||||
|
||||
while (parent && parent.props && parent.getProp('type') !== 'modal') {
|
||||
|
||||
// scroll
|
||||
if (!scrollFixed && parent.getProp('type') == 'tab') {
|
||||
if (this.value) {
|
||||
this.parentScroll = [parent.widget.scrollLeft, parent.widget.scrollTop]
|
||||
}
|
||||
parent.widget.scrollLeft = this.value ? 0 : this.parentScroll[0]
|
||||
parent.widget.scrollTop = this.value ? 0 : this.parentScroll[1]
|
||||
parent.widget.style.overflow = this.value ? 'hidden' : ''
|
||||
scrollFixed = true
|
||||
}
|
||||
|
||||
// stacking
|
||||
parent.container.style.zIndex = this.value ? 'initial' : ''
|
||||
parent.container.style.contain = this.value ? 'style size' : ''
|
||||
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
this.container.style.contain = this.value ? 'style size' : ''
|
||||
|
||||
|
||||
}
|
||||
|
||||
updatePopupLabel() {
|
||||
|
||||
if (!this.popup) return
|
||||
|
|
|
|||
|
|
@ -128,19 +128,6 @@ class Panel extends Container() {
|
|||
|
||||
}
|
||||
|
||||
if (this.getProp('tabs') && !this.getProp('tabs').length) {
|
||||
this.disabledProps.push(
|
||||
'precision', 'address', 'preArgs', 'target', 'bypass',
|
||||
'value', 'default'
|
||||
)
|
||||
}
|
||||
if (this.getProp('widgets') && !this.getProp('widgets').length) {
|
||||
this.disabledProps.push(
|
||||
'scroll'
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if (this.getProp('traversing')) this.setTraversing()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,14 @@ module.exports = class _matrix_base extends Container() {
|
|||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
case 'colorWidget':
|
||||
case 'colorFill':
|
||||
case 'colorStroke':
|
||||
case 'alphaStroke':
|
||||
case 'alphaFillOff':
|
||||
case 'alphaFillOn':
|
||||
for (var w of this.children) {
|
||||
if (w) w.onPropChanged('color')
|
||||
if (w) w.onPropChanged(propName)
|
||||
}
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,6 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
|
||||
}, ['_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 (`\\$`))'
|
||||
]},
|
||||
css: {type: 'string', value: '', help: [
|
||||
'Available CSS variables:',
|
||||
'- `--color-white:color;` (white keys color)',
|
||||
|
|
@ -86,20 +81,12 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
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}'
|
||||
}
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `#{
|
||||
a = @{parent.preArgs};
|
||||
b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
|
||||
concat(b, [${i}])
|
||||
}`
|
||||
|
||||
var key = parser.parse({
|
||||
data: data,
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ class PatchBayNode extends Widget {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: html`
|
||||
<div class="node">
|
||||
</div>
|
||||
`})
|
||||
super({...options, html: null})
|
||||
|
||||
this.value = []
|
||||
|
||||
|
|
@ -108,11 +105,11 @@ class PatchBay extends Container(Canvas) {
|
|||
constructor(options) {
|
||||
|
||||
super({...options, html: html`
|
||||
<div class="patchbay">
|
||||
<inner>
|
||||
<div class="nodes inputs"></div>
|
||||
<canvas></canvas>
|
||||
<div class="nodes outputs"></div>
|
||||
</div>
|
||||
</inner>
|
||||
`})
|
||||
|
||||
this.inputs = PatchBay.normalizeArrayObject(this.getProp('inputs'))
|
||||
|
|
@ -148,8 +145,8 @@ class PatchBay extends Container(Canvas) {
|
|||
var outputs = DOM.get(this.widget, '.outputs')[0]
|
||||
for (let k in this.outputs) {
|
||||
var node = html`
|
||||
<div class="widget">
|
||||
<div class="label">${k}</div>
|
||||
<div class="widget patchbaynode-container">
|
||||
<label>${k}</label>
|
||||
</div>
|
||||
`
|
||||
outputs.appendChild(node)
|
||||
|
|
@ -265,7 +262,8 @@ class PatchBay extends Container(Canvas) {
|
|||
if (this.connecting.length) {
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.custom
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
|
||||
var side = this.connecting[0] !== undefined ? 0 : 1,
|
||||
cx = side === 0 ? 0 : this.width,
|
||||
|
|
@ -289,10 +287,10 @@ class PatchBay extends Container(Canvas) {
|
|||
}
|
||||
|
||||
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.globalAlpha = strongLines.length ? this.cssVars.alphaFillOff : this.cssVars.alphaFillOn
|
||||
|
||||
this.ctx.globalAlpha = strongLines.length ? 0.3 : 0.7
|
||||
this.ctx.beginPath()
|
||||
for (i in lines) {
|
||||
this.ctx.moveTo(...lines[i][0])
|
||||
|
|
@ -302,7 +300,7 @@ class PatchBay extends Container(Canvas) {
|
|||
|
||||
if (strongLines.length) {
|
||||
|
||||
this.ctx.globalAlpha = 0.7
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
this.ctx.beginPath()
|
||||
for (i in strongLines) {
|
||||
if (strongLines[i] === null) continue
|
||||
|
|
|
|||
|
|
@ -45,11 +45,6 @@ module.exports = class MultiXy extends Pad {
|
|||
}, [], {
|
||||
|
||||
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'},
|
||||
split: {type: 'boolean|object', value: false, help: [
|
||||
'Set to `true` to send separate osc messages for each point\'s x and y axis. The address will be the same as the widget\'s with `/N/x` or `/N/y` appended to it, where N is the point\'s id (or the point\'s label if points is an array)',
|
||||
'Can be set as an `object` to specify a different address : `[\'/0/x\', \'/0/y\', \'/1/x\', \'/2/y\']`',
|
||||
'Note: the widget will only respond to its original osc address, not to the splitted version'
|
||||
]},
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -247,25 +242,6 @@ module.exports = class MultiXy extends Pad {
|
|||
|
||||
}
|
||||
|
||||
getSplit() {
|
||||
|
||||
return this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 * this.npoints ?
|
||||
this.getProp('split')
|
||||
: (()=>{
|
||||
var s={},
|
||||
t
|
||||
for (var i=0; i<this.npoints * 2;i=i+2) {
|
||||
t = this.labels ? this.getProp('points')[i/2] : i/2
|
||||
s[i]=this.getProp('address') + '/' + t + '/x'
|
||||
s[i+1]=this.getProp('address') + '/' + t + '/y'
|
||||
}
|
||||
return s
|
||||
})()
|
||||
: false
|
||||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options, oldPropValue) {
|
||||
|
||||
if (super.onPropChanged(...arguments)) return true
|
||||
|
|
|
|||
|
|
@ -33,11 +33,6 @@ module.exports = class Rgb extends Pad {
|
|||
|
||||
}, ['color'], {
|
||||
|
||||
split: {type: 'boolean|object', value: false, help: [
|
||||
'Set to `true` to send separate osc messages for for r and g & b. The address will be the same as the widget\'s with `/r`, `/g` or `/b` appended to it',
|
||||
'Can be set as an `object` to specify a different address : `[\'/r\', \'/g\', \'b\']`',
|
||||
'Note: the widget will only respond to its original osc address, not to the splitted version'
|
||||
]}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@ module.exports = class Xy extends Pad {
|
|||
}, [], {
|
||||
|
||||
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`)'},
|
||||
split: {type: 'boolean|object', value: false, help: [
|
||||
'Set to `true` to send separate osc messages for each point\'s x and y axis. The address will be the same as the widget\'s with `/x` or `/y` appended to it',
|
||||
'Can be set as an `object` to specify a different address : [\'/osc_address_x\', \'/osc_address_y\']',
|
||||
'Note: the widget will only respond to its original osc address, not to the splitted version'
|
||||
]},
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -282,16 +277,6 @@ module.exports = class Xy extends Pad {
|
|||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getSplit() {
|
||||
|
||||
return this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/x', this.getProp('address') + '/y']
|
||||
: false
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
|
|
|||
|
|
@ -117,8 +117,6 @@ module.exports = class Fader extends Slider {
|
|||
(e.offsetX - this.gaugePadding) / (this.width - this.gaugePadding * 2) * 100:
|
||||
(this.height - e.offsetY - this.gaugePadding) / (this.height - this.gaugePadding * 2) * 100
|
||||
|
||||
// this.percent = clip(this.percent,[0,100])
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {send: true, sync: true, dragged: true})
|
||||
|
||||
}
|
||||
|
|
@ -149,10 +147,6 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
var ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
// if (this.getProp('compact') && this.getProp('horizontal')) {
|
||||
// event.height = 1 / ratio
|
||||
// }
|
||||
|
||||
super.resizeHandle(event)
|
||||
|
||||
if (this.getProp('horizontal')){
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
_knob:'knob',
|
||||
|
||||
mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], help: [
|
||||
mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [
|
||||
'- `circular`: relative move in circular motion',
|
||||
'- `snap`: snap to touch position and move in vertical motion',
|
||||
'- `vertical`: relative move in vertical motion',
|
||||
|
|
|
|||
|
|
@ -190,16 +190,6 @@ class Range extends Fader {
|
|||
|
||||
}
|
||||
|
||||
getSplit() {
|
||||
|
||||
return this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/low', this.getProp('address') + '/high']
|
||||
: false
|
||||
|
||||
}
|
||||
|
||||
draw() {
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue