From d673cb1e3aa3d7ae1e5e92c10df11e269def7878 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 21 Jan 2022 17:33:34 +0100 Subject: [PATCH 01/13] context-menu: double click issue in submenus on small touch screens --- CHANGELOG.md | 5 +++++ src/client/ui/context-menu.js | 1 + 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb59be1..c7368dc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.14.2 + +- bug fixes + - context-menu: double click issue in submenus on small touch screens + ## 1.14.0, 1.14.1 - bug fixes diff --git a/src/client/ui/context-menu.js b/src/client/ui/context-menu.js index 13b4dd78..fc96bd56 100644 --- a/src/client/ui/context-menu.js +++ b/src/client/ui/context-menu.js @@ -50,6 +50,7 @@ class ContextMenu extends UiWidget { }) this.container.addEventListener('touchstart', (e)=>{ + if (e.target.classList.contains('has-sub')) e.preventDefault() if (!e.target.classList.contains('focus')) { DOM.each(e.target.parentNode, '.focus', (el)=>{ el.classList.remove('focus') From feab5194d81556869d2de0523439e9c5d64a5d5b Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 21 Jan 2022 20:08:54 +0100 Subject: [PATCH 02/13] clone/fragment: broken onDraw / onTouch scripts if cloned widget is a canvas --- CHANGELOG.md | 1 + src/client/managers/session/session.js | 4 ++-- src/client/widgets/containers/clone.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7368dc8..7240772d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - context-menu: double click issue in submenus on small touch screens + - clone/fragment: broken onDraw / onTouch scripts if cloned widget is a canvas ## 1.14.0, 1.14.1 diff --git a/src/client/managers/session/session.js b/src/client/managers/session/session.js index 1e324d88..ff5bbef5 100644 --- a/src/client/managers/session/session.js +++ b/src/client/managers/session/session.js @@ -306,8 +306,8 @@ var converters = [ } } if (data.type === 'canvas') { - data.onDraw = data.draw - data.onTouch = data.touch + if (data.draw !== undefined) data.onDraw = data.draw + if (data.touch !== undefined) data.onTouch = data.touch } } diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 95bb19b7..0ac758e8 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -31,6 +31,8 @@ class Clone extends Container() { defaults.style = {css: defaults.style.css} + delete defaults.scripting + return defaults } From 6abedd948badd7ef68cec89e9716093d645b2bed Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 21 Jan 2022 20:09:20 +0100 Subject: [PATCH 03/13] package: v1.14.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 18218bcf..f0a533bd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.14.1", + "version": "1.14.2", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From 26207f0e70e38bdc1c9d3ba8bade471926ab6ada Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 22 Jan 2022 11:40:58 +0100 Subject: [PATCH 04/13] clone/fragment: remove scripting properties as theyr are supposed to bo overriden in `props` --- CHANGELOG.md | 5 +++++ src/client/widgets/containers/clone.js | 5 ++--- src/client/widgets/containers/fragment.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7240772d..868c9b75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.14.3 + +- widgets + - clone/fragment: remove scripting properties as theyr are supposed to bo overriden in `props` + ## 1.14.2 - bug fixes diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 0ac758e8..428a9f53 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -26,13 +26,12 @@ class Clone extends Container() { props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Cloned widget\'s properties to override'}, }, value: null, - osc: null + osc: null, + scripting: null }) defaults.style = {css: defaults.style.css} - delete defaults.scripting - return defaults } diff --git a/src/client/widgets/containers/fragment.js b/src/client/widgets/containers/fragment.js index 679c3ee1..94883996 100644 --- a/src/client/widgets/containers/fragment.js +++ b/src/client/widgets/containers/fragment.js @@ -28,7 +28,8 @@ class Fragment extends Container() { props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Fragment widget\'s properties to override'}, }, value: null, - osc: null + osc: null, + scripting: null }) defaults.style = {css: defaults.style.css} From 52147ba0a6c7610c21222e54276c8bb1fe2e3cf2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 22 Jan 2022 13:09:45 +0100 Subject: [PATCH 05/13] osc receivers: apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets) --- CHANGELOG.md | 3 ++ .../docs/docs/widgets/advanced-syntaxes.md | 3 ++ src/client/osc.js | 45 +++++++++++-------- src/client/widgets/common/osc-receiver.js | 5 ++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 868c9b75..d8c848d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.14.3 +- bug fixes + - osc receivers (`OSC{}` syntax) now apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets) + - widgets - clone/fragment: remove scripting properties as theyr are supposed to bo overriden in `props` diff --git a/resources/docs/docs/widgets/advanced-syntaxes.md b/resources/docs/docs/widgets/advanced-syntaxes.md index 288e86fa..ea1a28b7 100644 --- a/resources/docs/docs/widgets/advanced-syntaxes.md +++ b/resources/docs/docs/widgets/advanced-syntaxes.md @@ -46,6 +46,9 @@ The OSC listener syntax returns the value received on specified address (or the Options can contain `@{}` blocks. +!!! note "Receiving MIDI" + Midi messages will be processed only if the receiver's widget includes the emitting MIDI device in its targets. + ??? example "Array/Object default value" ```js JS{ diff --git a/src/client/osc.js b/src/client/osc.js index 947f6b0e..f2519f3d 100644 --- a/src/client/osc.js +++ b/src/client/osc.js @@ -39,6 +39,30 @@ var Osc = class Osc extends EventEmitter { } + match(widget, data) { + + let widgetTarget = widget.getProp('target'), + match = true + + if (data._rawTarget) { + // if the message target is provided (when message comes from another client connected to the same server) + // then we only update the widgets that have the exact same target + match = deepEqual(widgetTarget, data._rawTarget) + + } else if (data.host === 'midi') { + // if the message comes from a midi port, only update widgets that send to that port + let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget], + strTarget = data.host + ':' + data.port + + match = widgetArrayTarget.includes(strTarget) || + (!widgetArrayTarget.includes(null) && this.serverTargets.includes(strTarget)) + + } + + return match + + } + receive(data){ if (typeof this.remoteControl.exists === 'function' && this.remoteControl.exists(data.address)) this.remoteControl.exec(data.address, data.args) @@ -47,30 +71,13 @@ var Osc = class Osc extends EventEmitter { for (let i in widgets) { - let widgetTarget = widgets[i].getProp('target'), - match = true - - if (data._rawTarget) { - // if the message target is provided (when message comes from another client connected to the same server) - // then we only update the widgets that have the exact same target - match = deepEqual(widgetTarget, data._rawTarget) - } else if (data.host === 'midi') { - // if the message comes from a midi port, only update widgets that send to that port - let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget], - strTarget = data.host + ':' + data.port - - match = widgetArrayTarget.includes(strTarget) || - (!widgetArrayTarget.includes(null) && this.serverTargets.includes(strTarget)) - - } - - if (match) { + if (this.match(widgets[i], data)) { widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target}) } } - this.trigger(data.address, data.args) + this.trigger(data.address, data) } diff --git a/src/client/widgets/common/osc-receiver.js b/src/client/widgets/common/osc-receiver.js index bb234503..09121fbf 100644 --- a/src/client/widgets/common/osc-receiver.js +++ b/src/client/widgets/common/osc-receiver.js @@ -56,7 +56,9 @@ module.exports = class OscReceiver { } - callback(args) { + callback(data) { + + var {args} = data if (!Array.isArray(args)) args = [args] var preArgs = this.usePreArgs ? (this.parent.getProp('preArgs') || []) : [] @@ -65,6 +67,7 @@ module.exports = class OscReceiver { for (var i in preArgs) { if (preArgs[i] !== args[i]) return } + if (!osc.match(this.parent, data)) return var value = args.slice(preArgs.length) if (value.length < 2) value = value[0] if (typeof value === 'string' && isJSONObject(value)) { From 6eeeffee992c37dea1dbcb0bab5d3157db033477 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 23 Jan 2022 14:53:39 +0100 Subject: [PATCH 06/13] modal: rendering issue on iOS (#770) --- CHANGELOG.md | 1 + src/scss/widgets/containers.scss | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c848d9..9a9327e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - osc receivers (`OSC{}` syntax) now apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets) + - modal: rendering issue on iOS - widgets - clone/fragment: remove scripting properties as theyr are supposed to bo overriden in `props` diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss index 4c4a3a8f..136d325e 100644 --- a/src/scss/widgets/containers.scss +++ b/src/scss/widgets/containers.scss @@ -456,9 +456,11 @@ > .toggle { --alpha-fill:var(--alpha-fill-on); + z-index: 1; } > label { color: var(--color-text-on); + z-index: 2; } z-index: 9999999999999!important; From 09812748d374882b20493a648fe347caa41a93c4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 24 Jan 2022 11:24:59 +0100 Subject: [PATCH 07/13] button: `locals.touchCoords` not updated since v1.14.0 --- CHANGELOG.md | 3 ++- src/client/widgets/basics/button.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9327e8..d3cd53f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,10 @@ - bug fixes - osc receivers (`OSC{}` syntax) now apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets) - modal: rendering issue on iOS + - button: `locals.touchCoords` not updated since v1.14.0 - widgets - - clone/fragment: remove scripting properties as theyr are supposed to bo overriden in `props` + - clone/fragment: remove scripting properties as they are supposed to bo overriden in `props` ## 1.14.2 diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 8f543f4f..63c65cb5 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -64,7 +64,7 @@ class Button extends Widget { this.pulse = null this.buttonSize = [100, 100] - this.exposeTouchCoords = String(this.getProp('script')).includes('touchCoords') + this.exposeTouchCoords = String(this.getProp('onValue')).includes('touchCoords') this.parsersLocalScope.touchCoords = [0.5, 0.5] if (this.exposeTouchCoords) { this.on('resize', (e)=>{ From 41237d5bc85fbc0617d78d8613d3519c8aeb50ac Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 24 Jan 2022 11:25:52 +0100 Subject: [PATCH 08/13] package: v1.14.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0a533bd..4dbdee5e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.14.2", + "version": "1.14.3", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From 05aa6bf9987faf2c7ba9adf24264add664390469 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 24 Jan 2022 12:05:05 +0100 Subject: [PATCH 09/13] script-vm: setInterval callback error handling --- src/client/widgets/scripts/script-vm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/widgets/scripts/script-vm.js b/src/client/widgets/scripts/script-vm.js index 78cd77e3..ae986074 100644 --- a/src/client/widgets/scripts/script-vm.js +++ b/src/client/widgets/scripts/script-vm.js @@ -402,7 +402,7 @@ class ScriptVm extends Vm { try { callback() } catch(e) { - this.errorProp('script', 'setInterval', e) + widget.errorProp('script', 'setInterval', e) } this.setWidget() this.setValueOptions() From e4846688c89031b1b1dce93949241d6ff1212507 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 26 Jan 2022 11:57:33 +0100 Subject: [PATCH 10/13] inspector: color picker overhaul (#771) --- CHANGELOG.md | 5 ++ src/client/editor/index.js | 5 +- src/client/locales/en.js | 2 +- src/client/locales/fr.js | 2 +- src/client/ui/ui-colorpicker.js | 90 ++++++++++++++++++++------------- src/client/ui/ui-inspector.js | 24 ++++++--- src/scss/ui/inspector.scss | 52 +++++++++++++++---- 7 files changed, 123 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3cd53f1..a291ae73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.14.4 + +- inspector + - the color picker is no longer in a modal and now shows changes on the fly (the new color is not saved unless "confirm" is clicked) + ## 1.14.3 - bug fixes diff --git a/src/client/editor/index.js b/src/client/editor/index.js index 39cdd77a..9928d60f 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -29,7 +29,7 @@ class Editor { this.inspector = new UiInspector({selector: '#osc-inspector'}) this.inspector.on('update', (event)=>{ - var {propName, value} = event, + var {propName, value, preventHistory} = event, newWidgets = [], error = false @@ -70,7 +70,7 @@ class Editor { if (error) return - this.pushHistory() + if (!preventHistory) this.pushHistory() if (newWidgets.length > 1) this.select(newWidgets) @@ -484,6 +484,7 @@ class Editor { disable() { + if (this.inspector.colorPicker.opened) this.inspector.colorPicker.cancel() this.unselect() this.selectedWidgets = [] diff --git a/src/client/locales/en.js b/src/client/locales/en.js index f7baa57b..576e6ece 100644 --- a/src/client/locales/en.js +++ b/src/client/locales/en.js @@ -65,7 +65,7 @@ module.exports = { // inspector inspector_color_confirm: 'Confirm', - inspector_color_apply: 'Apply', + inspector_color_cancel: 'Cancel', inspector_error: 'An error just occured, open the console to read more.', // nosleep diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js index 4734a9ae..067b1dc7 100644 --- a/src/client/locales/fr.js +++ b/src/client/locales/fr.js @@ -64,7 +64,7 @@ module.exports = { // inspector inspector_color_confirm: 'Confirmer', - inspector_color_apply: 'Appliquer', + inspector_color_cancel: 'Annuler', inspector_error: 'Une erreur vient de survenir, ouvrez la console pour en savoir plus.', // nosleep diff --git a/src/client/ui/ui-colorpicker.js b/src/client/ui/ui-colorpicker.js index 8d962438..677fe3d2 100644 --- a/src/client/ui/ui-colorpicker.js +++ b/src/client/ui/ui-colorpicker.js @@ -27,63 +27,58 @@ class ColorPicker extends UiWidget { }, parent: this}) this.rgb.container.classList.add('not-editable') - this.modal = new UiModal({ - width: 280, - height: 320, - closable: true, - title: '', - hide: true, - html: true, - content: html` -
- ${this.rgb.container} -
-
${locales('inspector_color_apply')}
-
${locales('inspector_color_confirm')}
-
-
- `, - enterKey: this.confirm.bind(this) - }) + this.container = html` +
+ ${this.rgb.container} +
+
${locales('inspector_color_confirm')}
+
${locales('inspector_color_cancel')}
+
+
+ ` - DOM.get(this.modal.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this)) - DOM.get(this.modal.container, '.color-apply')[0].addEventListener('click', this.apply.bind(this)) + DOM.get(this.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this)) + DOM.get(this.container, '.color-cancel')[0].addEventListener('click', this.cancel.bind(this)) this.rgb.on('change', (e)=>{ e.stopPropagation = true + this.value = chroma(this.rgb.value).hex() + this.trigger('change', {preventHistory: true}) }) - // this.rgb.on('dragend', (e)=>{ - // this.value = chroma(this.rgb.value).hex() - // this.trigger('change') - // }) - this.opened = 0 - this.label = DOM.get(this.modal.container, '.title')[0] + + this.cancelValue = '#00000000' + + this.escKeyHandler = ((e)=>{ + if (e.keyCode==27) this.cancel() + }).bind(this) + + this.enterKeyHandler = ((e)=>{ + if (e.keyCode == 13) this.confirm() + }).bind(this) } open() { - this.label.innerHTML = this.name - this.modal.open() + this.parentNode.appendChild(this.container) resize.check(this.rgb.container) this.opened = 1 + document.addEventListener('keydown', this.escKeyHandler) + document.addEventListener('keydown', this.enterKeyHandler) } close() { - this.modal.close() + if (this.parentNode.contains(this.container)) { + this.parentNode.removeChild(this.container) + } this.setName() this.opened = 0 - } - - apply() { - - this.value = chroma(this.rgb.getValue(true)).css('rgba') - this.trigger('change') - + document.removeEventListener('keydown', this.escKeyHandler) + document.removeEventListener('keydown', this.enterKeyHandler) } confirm() { @@ -94,6 +89,16 @@ class ColorPicker extends UiWidget { } + cancel() { + + if (this.value !== this.cancelValue) { + this.value = this.cancelValue + this.trigger('change', {preventHistory: true}) + } + this.close() + + } + isVisible() { return true @@ -114,6 +119,19 @@ class ColorPicker extends UiWidget { } + setCancelValue(v) { + + this.cancelValue = v + + } + + setParent(node) { + + if (this.opened && node !== this.parentNode) this.close() + this.parentNode = node + + } + } module.exports = ColorPicker diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index d5f21aa2..98bbf1e7 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -40,11 +40,11 @@ class UiInspector extends UiWidget { this.parentContainer = DOM.get('osc-panel-container.right osc-panel-inner')[0] this.colorPicker = new UiColorPicker() - this.colorPicker.on('change', ()=>{ + this.colorPicker.on('change', (event)=>{ var textarea = DOM.get(this.container, `textarea[name="${this.colorPicker.name}"]`) if (textarea) { textarea[0].value = this.colorPicker.value - DOM.dispatchEvent(textarea[0], 'change') + DOM.dispatchEvent(textarea[0], 'change', event) } }) @@ -64,9 +64,19 @@ class UiInspector extends UiWidget { } else if (node.tagName === 'OSC-INSPECTOR-COLOR') { - this.colorPicker.setName(node.getAttribute('name')) - this.colorPicker.setValue(node.getAttribute('value')) - this.colorPicker.open() + var name = node.getAttribute('name'), + textarea = DOM.get(this.container, `textarea[name="${name}"]`) + + if (this.colorPicker.name === name) { + this.colorPicker.cancel() + } else { + if (this.colorPicker.opened) this.colorPicker.cancel() + this.colorPicker.setParent(node.parentNode) + this.colorPicker.setName(name) + this.colorPicker.setValue(node.getAttribute('value')) + this.colorPicker.setCancelValue(textarea[0].value) + this.colorPicker.open() + } } else if (node.tagName === 'LABEL') { @@ -192,6 +202,7 @@ class UiInspector extends UiWidget { var picker = DOM.get(this.container, `osc-inspector-color[name="${this.colorPicker.name}"]`) if (picker && picker[0]) { this.colorPicker.setValue(picker[0].getAttribute('value')) + this.colorPicker.open() } else { this.colorPicker.close() } @@ -227,7 +238,8 @@ class UiInspector extends UiWidget { this.trigger('update', { propName: input.name, - value: v + value: v, + preventHistory: event.detail && event.detail.preventHistory }) // this may not be reached if an error is thrown diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss index d4d7ca81..9a544857 100644 --- a/src/scss/ui/inspector.scss +++ b/src/scss/ui/inspector.scss @@ -1,5 +1,6 @@ $header-height: 28rem; $field-height: 24rem; +$label-width: 94rem; $padding: 8rem; $radius: 3rem; @@ -24,7 +25,7 @@ osc-inspector-field { &:after { content:""; position: absolute; - left:94rem; + left:$label-width; top:0; right: 1rem; border-top:1rem solid var(--color-ui-background); @@ -35,7 +36,7 @@ osc-inspector-field { --widget-padding: -1rem; > label { - width: 94rem; + width: $label-width; text-transform: none; padding-left: 4rem; padding-right: 4rem; @@ -457,6 +458,9 @@ osc-inspector-category { } border-top-left-radius: $radius; border-top-right-radius: $radius; + .color-picker { + margin-top: 2rem; + } } osc-inspector-field.last-child, osc-inspector-field:last-child { @@ -595,17 +599,43 @@ osc-inspector-color { } } -.color-picker-modal { - - flex: 1; +.color-picker { + position: absolute; + z-index: 99; + height: 180rem; + top: 0; + right: 22rem; + left: $label-width; + margin: 3rem 2rem; display: flex; flex-direction: column; + $padding: 2rem; + border: 1rem solid var(--color-ui-button); + overflow: hidden; .widget { - background: var(--color-background); + background: var(--color-ui-background); flex: 1; width: auto; - --widget-padding: #{$padding}; + --widget-padding: 0rem; + inner { + padding: 1rem; + } + .hue { + margin-left: 1rem; + width: 16rem; + --knob-size: 1rem; + } + .alpha { + margin-top: 0.5rem; + left:0; + margin-left: 0; + border:0; + } + .hue:after { + left:0; + right:0; + } } .actions { @@ -613,17 +643,17 @@ osc-inspector-color { flex-direction: row; align-items: flex-end; justify-content: stretch; - height: 42rem + $padding * 2; - line-height: 38rem; + // height: 24rem + $padding * 2; + line-height: $field-height; flex-shrink: 0; background: var(--color-ui-foreground); - padding: $padding; + // padding: $padding; .btn { flex: 1; text-overflow: clip; min-width: 0; background: var(--color-ui-button); - margin-right: $padding; + margin-right: 1rem; &:last-child { margin: 0; } From 795142adfe914aa50266ef82b50b2d5443992708 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 26 Jan 2022 12:05:53 +0100 Subject: [PATCH 11/13] inspector: commit color picker changes on dragend and remove action buttons (#771) --- CHANGELOG.md | 2 +- src/client/ui/ui-colorpicker.js | 34 ++++++++------------------------- src/client/ui/ui-inspector.js | 4 +--- src/scss/ui/inspector.scss | 22 --------------------- 4 files changed, 10 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a291ae73..e0192c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.14.4 - inspector - - the color picker is no longer in a modal and now shows changes on the fly (the new color is not saved unless "confirm" is clicked) + - color picker: inline picker widget (no longer in a modal); show color changes on the fly ## 1.14.3 diff --git a/src/client/ui/ui-colorpicker.js b/src/client/ui/ui-colorpicker.js index 677fe3d2..26d80242 100644 --- a/src/client/ui/ui-colorpicker.js +++ b/src/client/ui/ui-colorpicker.js @@ -30,27 +30,25 @@ class ColorPicker extends UiWidget { this.container = html`
${this.rgb.container} -
-
${locales('inspector_color_confirm')}
-
${locales('inspector_color_cancel')}
-
` - DOM.get(this.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this)) - DOM.get(this.container, '.color-cancel')[0].addEventListener('click', this.cancel.bind(this)) - this.rgb.on('change', (e)=>{ e.stopPropagation = true this.value = chroma(this.rgb.value).hex() this.trigger('change', {preventHistory: true}) }) + + this.rgb.on('dragend', (e)=>{ + this.value = chroma(this.rgb.value).hex() + this.trigger('change') + }) + + this.opened = 0 - this.cancelValue = '#00000000' - this.escKeyHandler = ((e)=>{ - if (e.keyCode==27) this.cancel() + if (e.keyCode==27) this.close() }).bind(this) this.enterKeyHandler = ((e)=>{ @@ -89,16 +87,6 @@ class ColorPicker extends UiWidget { } - cancel() { - - if (this.value !== this.cancelValue) { - this.value = this.cancelValue - this.trigger('change', {preventHistory: true}) - } - this.close() - - } - isVisible() { return true @@ -119,12 +107,6 @@ class ColorPicker extends UiWidget { } - setCancelValue(v) { - - this.cancelValue = v - - } - setParent(node) { if (this.opened && node !== this.parentNode) this.close() diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index 98bbf1e7..062e8439 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -68,13 +68,11 @@ class UiInspector extends UiWidget { textarea = DOM.get(this.container, `textarea[name="${name}"]`) if (this.colorPicker.name === name) { - this.colorPicker.cancel() + this.colorPicker.close() } else { - if (this.colorPicker.opened) this.colorPicker.cancel() this.colorPicker.setParent(node.parentNode) this.colorPicker.setName(name) this.colorPicker.setValue(node.getAttribute('value')) - this.colorPicker.setCancelValue(textarea[0].value) this.colorPicker.open() } diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss index 9a544857..34489d98 100644 --- a/src/scss/ui/inspector.scss +++ b/src/scss/ui/inspector.scss @@ -638,28 +638,6 @@ osc-inspector-color { } } - .actions { - display: flex; - flex-direction: row; - align-items: flex-end; - justify-content: stretch; - // height: 24rem + $padding * 2; - line-height: $field-height; - flex-shrink: 0; - background: var(--color-ui-foreground); - // padding: $padding; - .btn { - flex: 1; - text-overflow: clip; - min-width: 0; - background: var(--color-ui-button); - margin-right: 1rem; - &:last-child { - margin: 0; - } - } - } - } .inspector-help { From 5e90b86bfa26d3184cac994656c6224405731c61 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 26 Jan 2022 12:11:22 +0100 Subject: [PATCH 12/13] inspector: lint/clean --- src/client/locales/en.js | 2 -- src/client/locales/fr.js | 2 -- src/client/ui/ui-colorpicker.js | 8 +++----- src/client/ui/ui-inspector.js | 7 +++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/client/locales/en.js b/src/client/locales/en.js index 576e6ece..eb263bf0 100644 --- a/src/client/locales/en.js +++ b/src/client/locales/en.js @@ -64,8 +64,6 @@ module.exports = { fullscreen_addtohome: 'You must add this page to your home screen to launch it in fullscreen', // inspector - inspector_color_confirm: 'Confirm', - inspector_color_cancel: 'Cancel', inspector_error: 'An error just occured, open the console to read more.', // nosleep diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js index 067b1dc7..d7ad04d1 100644 --- a/src/client/locales/fr.js +++ b/src/client/locales/fr.js @@ -63,8 +63,6 @@ module.exports = { fragment_mode_explanation: 'La session sera enregistrée sous forme de fragment : seul le premier descendant de l\'élément root sera sauvegardé.', // inspector - inspector_color_confirm: 'Confirmer', - inspector_color_cancel: 'Annuler', inspector_error: 'Une erreur vient de survenir, ouvrez la console pour en savoir plus.', // nosleep diff --git a/src/client/ui/ui-colorpicker.js b/src/client/ui/ui-colorpicker.js index 26d80242..d4ec3d5b 100644 --- a/src/client/ui/ui-colorpicker.js +++ b/src/client/ui/ui-colorpicker.js @@ -1,10 +1,8 @@ var UiWidget = require('./ui-widget'), Rgb = require('../widgets/pads/rgb'), - UiModal = require('./ui-modal'), html = require('nanohtml'), chroma = require('chroma-js'), - resize = require('../events/resize'), - locales = require('../locales') + resize = require('../events/resize') class ColorPicker extends UiWidget { @@ -35,8 +33,8 @@ class ColorPicker extends UiWidget { this.rgb.on('change', (e)=>{ e.stopPropagation = true - this.value = chroma(this.rgb.value).hex() - this.trigger('change', {preventHistory: true}) + this.value = chroma(this.rgb.value).hex() + this.trigger('change', {preventHistory: true}) }) this.rgb.on('dragend', (e)=>{ diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index 062e8439..f4f7b9ee 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -54,9 +54,9 @@ class UiInspector extends UiWidget { if (node.tagName === 'OSC-INSPECTOR-CHECKBOX') { - var name = node.getAttribute('name') + let name = node.getAttribute('name'), + textarea = DOM.get(this.container, `textarea[name="${name}"]`) - var textarea = DOM.get(this.container, `textarea[name="${name}"]`) if (textarea) { textarea[0].value = !node.classList.contains('on') DOM.dispatchEvent(textarea[0], 'change') @@ -64,8 +64,7 @@ class UiInspector extends UiWidget { } else if (node.tagName === 'OSC-INSPECTOR-COLOR') { - var name = node.getAttribute('name'), - textarea = DOM.get(this.container, `textarea[name="${name}"]`) + let name = node.getAttribute('name') if (this.colorPicker.name === name) { this.colorPicker.close() From 5e51760c9e46330d2aaaf2813d4cb25b6b29d045 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 26 Jan 2022 12:13:48 +0100 Subject: [PATCH 13/13] editor: rm undefined function call --- src/client/editor/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/editor/index.js b/src/client/editor/index.js index 9928d60f..5ba4f758 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -484,8 +484,6 @@ class Editor { disable() { - if (this.inspector.colorPicker.opened) this.inspector.colorPicker.cancel() - this.unselect() this.selectedWidgets = []