diff --git a/src/client/app/editor/data-workers.js b/src/client/app/editor/data-workers.js index 45b6d9c9..53133afd 100644 --- a/src/client/app/editor/data-workers.js +++ b/src/client/app/editor/data-workers.js @@ -16,30 +16,14 @@ function updateWidget(widget, options={}) { if (options.changedProps) { // alternate routine for small edits - var propNames = options.changedProps, - propValues = propNames.map(x => widget.props[x]), - linkedProps = [] - - Object.values(widget.nestedLinkedProps).forEach(l => linkedProps = linkedProps.concat(l)) - Object.values(widget.linkedProps).forEach(l => linkedProps = linkedProps.concat(l)) - Object.values(widget.linkedPropsValue).forEach(l => linkedProps = linkedProps.concat(l)) - Object.values(widget.oscReceivers).forEach(r => linkedProps = linkedProps.concat(r.propNames)) + var propNames = options.changedProps if ( // if non dynamic props have changed, skip this and use rebuild routine !propNames.some(n => !widget.isDynamicProp(n)) ) { - var edited = widget.updateProps(options.changedProps, null) || widget - - if ( - // if prop/osc listeners have changed (@{} / OSC{}) - // refresh the widget's props cache and update linked props bindings - propValues.some(x => typeof x === 'string' && x.match(/OSC\{|@\{/)) - || propNames.some(n => linkedProps.includes(n)) - ) { - widget.createPropsCache() - } + var edited = widget.updateProps(options.changedProps, null, {fromEditor: true}) || widget if (editor.selectedWidgets.includes(widget) && !options.preventSelect) { editor.select(edited) diff --git a/src/client/app/widgets/common/widget.js b/src/client/app/widgets/common/widget.js index 37f71961..6ec4bf42 100644 --- a/src/client/app/widgets/common/widget.js +++ b/src/client/app/widgets/common/widget.js @@ -268,6 +268,27 @@ class Widget extends EventEmitter { getSplit() {} + checkLinkedProps(propNames) { + + // Dynamic props cache check + var linkedProps = [] + + Object.values(this.nestedLinkedProps).forEach(l => linkedProps = linkedProps.concat(l)) + Object.values(this.linkedProps).forEach(l => linkedProps = linkedProps.concat(l)) + Object.values(this.linkedPropsValue).forEach(l => linkedProps = linkedProps.concat(l)) + Object.values(this.oscReceivers).forEach(r => linkedProps = linkedProps.concat(r.propNames)) + + if ( + // if prop/osc listeners have changed (@{} / OSC{}) + // refresh the widget's props cache and update linked props bindings + propNames.map(x => this.props[x]).some(x => typeof x === 'string' && x.match(/OSC\{|@\{/)) + || propNames.some(n => linkedProps.includes(n)) + ) { + this.createPropsCache() + } + + } + createPropsCache() { // @{props} links lists @@ -656,6 +677,10 @@ class Widget extends EventEmitter { } else if (changedProps.length) { + if (options && options.fromEditor) { + this.checkLinkedProps(propNames) + } + for (var i in changedProps) { this.onPropChanged(changedProps[i].propName, options, changedProps[i].oldPropValue) diff --git a/src/client/app/widgets/containers/clone.js b/src/client/app/widgets/containers/clone.js index e869e7cf..cc3f3f92 100644 --- a/src/client/app/widgets/containers/clone.js +++ b/src/client/app/widgets/containers/clone.js @@ -78,7 +78,7 @@ class Clone extends Container { if (e.widget === this.cloneTarget || this.cloneTarget.contains(e.widget)) { - this.updateClone() + this.updateClone(e.options) } @@ -189,7 +189,7 @@ class Clone extends Container { } - updateClone() { + updateClone(options) { if (this.cloneLock) return @@ -214,7 +214,7 @@ class Clone extends Container { } else { - widget.updateProps(changedProps, this) + widget.updateProps(changedProps, this, options) this.updateContainer(true) } diff --git a/src/client/app/widgets/matrices/matrix.js b/src/client/app/widgets/matrices/matrix.js index ab1a15f3..693c9818 100644 --- a/src/client/app/widgets/matrices/matrix.js +++ b/src/client/app/widgets/matrices/matrix.js @@ -90,7 +90,7 @@ class Matrix extends _matrix_base { if (typeof data === 'object' && data !== null) { Object.assign(this.children[i].props, data) } - this.children[i].updateProps(Object.keys(data), this) + this.children[i].updateProps(Object.keys(data), this, options) // this.children[i] might have been recreated this.children[i].container.classList.add('not-editable')