From 2414722ea10d6b687fdd99ad9ae5bee5239fa9f6 Mon Sep 17 00:00:00 2001 From: bordun Date: Fri, 19 Jul 2019 11:57:26 +0200 Subject: [PATCH] push: force release when widget is removed/recreated, prevent setting active state after editing --- CHANGELOG.md | 5 +++-- src/client/app/managers/state.js | 4 ++-- src/client/app/widgets/buttons/push.js | 15 +++++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48f40cda..99918cd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ - midi: `path` option not applied to launcher's `list` contextual action - midi: pitchbend messages not received correctly - style: layout issues in recent chromium - - encoder: `0` value in `back` property not working + - encoder: `0` value in `back` property not working + - editor: state not completely restored under some conditions + - push: force release when the widget is removed/recreated while pressed ## 0.47.1 @@ -34,7 +36,6 @@ - script: `get(id)` function added in `script`execution context - script: `getProp(id, property)` function added in `script`execution context - script: `id` variable added in `script`execution context (id of the widget that triggered the script) - - editor: state not completely restored under some conditions ## 0.46.1 diff --git a/src/client/app/managers/state.js b/src/client/app/managers/state.js index d0519c0d..6762fb22 100644 --- a/src/client/app/managers/state.js +++ b/src/client/app/managers/state.js @@ -63,7 +63,7 @@ var StateManager = class StateManager { if (widgets[j].setValue) { - widgets[j].setValue(value, {send:send,sync:true}) + widgets[j].setValue(value, {send:send, sync:true, fromState:true}) } @@ -216,7 +216,7 @@ var StateManager = class StateManager { preset[id] = w.getProp('value') } } - + this.set(preset) this.valueStateQueue = {} diff --git a/src/client/app/widgets/buttons/push.js b/src/client/app/widgets/buttons/push.js index 58ababdc..8e6c6924 100644 --- a/src/client/app/widgets/buttons/push.js +++ b/src/client/app/widgets/buttons/push.js @@ -32,7 +32,7 @@ class Push extends Widget { super({...options, html: html`
`}) this.state = 0 - this.active = 0 + this.active = null this.lastChanged = 'state' if (this.getProp('doubleTap')) { @@ -76,7 +76,7 @@ class Push extends Widget { if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) { this.widget.classList.add('active') this.container.classList.add('active') - this.active = 1 + this.active = options this.lastChanged = 'active' this.updateValue() if (options.send) this.sendValue() @@ -84,7 +84,7 @@ class Push extends Widget { } else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) { this.widget.classList.remove('active') this.container.classList.remove('active') - this.active = 0 + this.active = null this.lastChanged = 'active' this.updateValue() if (options.send) this.sendValue(null, {syncOnly: this.getProp('norelease')}) @@ -96,9 +96,10 @@ class Push extends Widget { setValue(v,options={}) { if (!options.fromExternal) { - this.setValuePrivate(v,options) + if (!options.fromState) this.setValuePrivate(v,options) return } + if (typeof v == 'object' && v !== null) v = v.value if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) { this.widget.classList.add('on') @@ -135,6 +136,12 @@ class Push extends Widget { } + onRemove() { + + if (this.active) this.setValuePrivate(this.getProp('off'), this.active) + super.onRemove() + + } } Push.dynamicProps = Push.prototype.constructor.dynamicProps.concat(