diff --git a/CHANGELOG.md b/CHANGELOG.md index 971809bc..23e4b032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,7 +91,7 @@ - always hidden except in project tree - `script` property must not be wrapped in a JS{{}} block anymore - added `stateGet` and `stateSet` functions - - added `storage` object, proxy to the document's sessionStorage object (allows storing data that persist after page refresh, but not closing) + - added `storage` object, proxy to the document's localStorage object (allows storing data that persist after refresh/close (cleared with the browser's cache) - added `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` function proxies with an extra `id` argument (they clear automatically when called multiple times and upon widget removal. `id` is scoped to the widget) diff --git a/package.json b/package.json index 98a5ba91..25186367 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "sanitize-html": "1.22.1", "scope-css": "1.2.1", "screenfull": "5.0.2", + "semver": "^7.1.3", "send": "0.17.1", "sortablejs": "1.10.2", "source-map-support": "0.5.16", @@ -93,7 +94,7 @@ "watch-browser": "npm run build-client-js -- --watch", "watch-css": "nodemon --watch src/scss -e scss -x \"npm run build-css -- --reload\"", "watch-server": "nodemon --watch src/server/ -e js -x \"npm run build-server-js\"", - "watch-launcher": "nodemon --watch src/ -e js -x \"npm run build-launcher-js\"", + "watch-launcher": "nodemon --watch src/launcher/ -e js -x \"npm run build-launcher-js\"", "build-docs": "node scripts/build-widgets-reference.js > resources/docs/docs/widgets-reference.md && cd resources && npm run build", "test": "eslint src && npm run build && node tests/test.js" }, diff --git a/resources/docs/support.md b/resources/docs/support.md new file mode 100644 index 00000000..5ec86fd5 --- /dev/null +++ b/resources/docs/support.md @@ -0,0 +1,39 @@ +## Support Open Stage Control + +If you would like to show your appreciation, drop a line on the forums, it's always appreciated ! + +Donations are not possible per see, but you may buy some music made by [AMMD](http://ammd.bandcamp.com), a french nonprofit organization and independent music label that promotes free arts and free softwares. + +If you wish to sponsor the project or hire me to build something with Open Stage Control, feel free to [contact me](mailto:jean-emmanuel@ammd.net) but please note that: + +- Sponsoring is only possible in an "altruistic" way, that is with no guarantee whatsoever of prioritizing anyone's interests +- I'm not interested in developing dedicated features for proprietary softwares +- I'm not interested in developing closed-source contents + +## Infrastructure Sponsors + +---- + + + +AMMD hosts this website and made this project possible by funding its first 2 years of development. + +---- + + + +Discourse provides the community forum. + +---- + + + +BrowserStack provides a complete suite of browser emulators for Android, iOS and Windows. + +---- diff --git a/resources/src/scss/highlight.min.scss b/resources/src/scss/highlight.min.scss new file mode 100644 index 00000000..2b8ac2cf --- /dev/null +++ b/resources/src/scss/highlight.min.scss @@ -0,0 +1 @@ +.hljs{display:block;overflow-x:auto;padding:.5em;background:#F0F0F0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-built_in,.hljs-bullet,.hljs-code,.hljs-addition{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} \ No newline at end of file diff --git a/resources/src/scss/styles.scss b/resources/src/scss/styles.scss index c5d7e5dc..3bbf2bb0 100644 --- a/resources/src/scss/styles.scss +++ b/resources/src/scss/styles.scss @@ -8,6 +8,7 @@ $font-size: 0.6rem; @import "admonition"; @import "codehilite"; @import "discourse"; +@import "highlight.min.scss"; body { diff --git a/resources/theme/base.html b/resources/theme/base.html index 01234378..af307122 100644 --- a/resources/theme/base.html +++ b/resources/theme/base.html @@ -11,7 +11,6 @@ - {% block extrahead %} {% endblock %} diff --git a/src/client/backup.js b/src/client/backup.js new file mode 100644 index 00000000..27b1fee7 --- /dev/null +++ b/src/client/backup.js @@ -0,0 +1,58 @@ +var localBackup = sessionStorage.getItem('osc.backup') + + +module.exports = { + + exists: localBackup !== null, + + save: ()=>{ + + var session = require('./managers/session/'), + state = require('./managers/state'), + editor = require('./editor/') + + if (session.session) { + sessionStorage.setItem('osc.backup', JSON.stringify({ + session: session.session.data, + sessionPath: session.sessionPath, + state: state.get(), + history: editor.history, + historyState: editor.historyState, + editorEnabled: editor.enabled + })) + } + + }, + + load: ()=>{ + + var session = require('./managers/session/'), + state = require('./managers/state'), + editor = require('./editor/'), + ipc = require('./ipc/') + + if (localBackup) { + + var data = JSON.parse(localBackup) + + sessionStorage.removeItem('osc.backup') + session.load(data.session, ()=>{ + + state.set(data.state, false) + + editor.clearHistory() + editor.history = data.history + editor.historyState = data.historyState + + if (data.editorEnabled) editor.enable() + + + ipc.send('sessionSetPath', {path: data.sessionPath}) + session.setSessionPath(data.sessionPath) + + }) + + } + + } +} diff --git a/src/client/editor/index.js b/src/client/editor/index.js index 4d9e2fe0..a44db6df 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -704,7 +704,7 @@ class Editor { this.historyState = -1 } - var d = diff.diff(this.historySession, sessionManager.session) + var d = diff.diff(this.historySession, sessionManager.session.getRoot()) if (d) { diff.patch(this.historySession, deepCopy(d)) @@ -718,7 +718,7 @@ class Editor { this.history = [] this.historyState = -1 - this.historySession = deepCopy(sessionManager.session) + this.historySession = deepCopy(sessionManager.session.getRoot()) } @@ -733,7 +733,7 @@ class Editor { d2 = deepCopy(patch) diff.unpatch(this.historySession, d1) - diff.unpatch(sessionManager.session, d2) + diff.unpatch(sessionManager.session.getRoot(), d2) this.updateWidgetFromPatch(patch, indexes ? { addedIndexes: deepCopy(indexes.removedIndexes), @@ -751,7 +751,7 @@ class Editor { d2 = deepCopy(patch) diff.patch(this.historySession, d1) - diff.patch(sessionManager.session, d2) + diff.patch(sessionManager.session.getRoot(), d2) this.updateWidgetFromPatch(patch, indexes ? { addedIndexes: deepCopy(indexes.addedIndexes), @@ -796,4 +796,4 @@ var editor = new Editor() module.exports = editor require('./context-menu') -sessionManager = require('../managers/session') +sessionManager = require('../managers/session/') diff --git a/src/client/index.js b/src/client/index.js index 5e5c52c8..e995bb93 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -16,7 +16,9 @@ document.addEventListener('DOMContentLoaded', function(event) { setTimeout(()=>{ - var ipc = require('./ipc/') + var ipc = require('./ipc/'), + backup = require('./backup') + ipc.init() @@ -24,7 +26,9 @@ document.addEventListener('DOMContentLoaded', function(event) { document.title = TITLE - ipc.send('ready', {backupId: ENV.backupId}) + ipc.send('ready', {hotReload: backup.exists}) + + backup.load() }, 100) diff --git a/src/client/ipc/callbacks.js b/src/client/ipc/callbacks.js index bdea1748..58670ed3 100644 --- a/src/client/ipc/callbacks.js +++ b/src/client/ipc/callbacks.js @@ -1,17 +1,15 @@ var utils = require('../ui/utils'), osc = require('../osc'), - session = require('../managers/session'), + session = require('../managers/session/'), widgetManager = require('../managers/widgets'), state = require('../managers/state'), editor = require('../editor/'), locales = require('../locales'), - {deepCopy} = require('../utils'), UiModal = require('../ui/ui-modal'), uiLoading = require('../ui/ui-loading'), notifications = require('../ui/notifications'), - {TRAVERSING_SAMEWIDGET} = require('../events/utils'), raw = require('nanohtml/raw'), - ipc = require('./') + backup = require('../backup') module.exports = { @@ -96,75 +94,9 @@ module.exports = { reload: function(){ - var id = Math.random(), - search = location.search, - query = 'backupId=' + id - - // disable editor's warning + backup.save() window.onbeforeunload = null - - if (!session.session) { - window.location.href = window.location.href - return - } - - try { - - // store session & state backup - ipc.send('storeBackup', { - backupId: id, - session: session.session || {}, - sessionPath: session.sessionPath, - state: state.get(), - history: editor.history, - historyState: editor.historyState, - editorEnabled: editor.enabled, - }) - - // reload page and hold backup id - - if (search) { - if (search.includes('backupId=')) { - search = search.replace(/backupId=[^&]*/, query) - } else { - search += '&' + query - } - } else { - search += '?' + query - } - - window.location.search = search - - } catch(e) { - - window.location.href = window.location.href - - } - - }, - - loadBackup: function(data) { - - session.load(data.session, ()=>{ - - state.set(data.state, false) - - editor.historySession = deepCopy(data.session) - editor.history = data.history - editor.historyState = data.historyState - if (data.editorEnabled) editor.enable() - - if (data.traversing === TRAVERSING_SAMEWIDGET) { - DOM.get('.traversingSmart')[0].click() - } else if (data.traversing) { - DOM.get('.traversingEnable')[0].click() - } - - ipc.send('sessionSetPath', {path: data.sessionPath}) - session.setSessionPath(data.sessionPath) - ipc.send('deleteBackup', data.backupId) - - }) + window.location.href = window.location.href }, diff --git a/src/client/locales/en.js b/src/client/locales/en.js index 178f9014..59173b52 100644 --- a/src/client/locales/en.js +++ b/src/client/locales/en.js @@ -63,6 +63,8 @@ module.exports = { session_parsingerror: 'Parsing error.', session_uploaderror: 'Failed to upload session file.', session_unsaved: 'Your changes will be lost if you close this session without saving, continue ?', + session_oldversion_title: 'Warning', + session_oldversion: 'This session was created with an older version, an automatic conversion has been done.', // state state: 'State', diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js index 7aada79a..a3385c08 100644 --- a/src/client/locales/fr.js +++ b/src/client/locales/fr.js @@ -63,6 +63,8 @@ module.exports = { session_parsingerror: 'Erreur à l\'ouverture de la session.', session_uploaderror: 'Échec à l\'envoi du fichier de session.', session_unsaved: 'Vos modifications seront perdues si vous fermez la session actuelle sans sauvegarder, continuer ?', + session_oldversion_title: 'Attention', + session_oldversion: 'Cette session a été créée avec une ancienne version, une conversion automatique a été appliquée.', // state state: 'État', diff --git a/src/client/managers/session.js b/src/client/managers/session/index.js similarity index 82% rename from src/client/managers/session.js rename to src/client/managers/session/index.js index c6ec0e58..b6a35857 100644 --- a/src/client/managers/session.js +++ b/src/client/managers/session/index.js @@ -1,13 +1,14 @@ -var ipc = require('../ipc/'), - parser = require('../parser'), - editor = require('../editor/'), - uiFilebrowser = require('../ui/ui-filebrowser'), - uiFileupload = require('../ui/ui-fileupload'), - UiModal = require('../ui/ui-modal'), - uiLoading = require('../ui/ui-loading'), +var ipc = require('../../ipc/'), + parser = require('../../parser'), + editor = require('../../editor/'), + uiFilebrowser = require('../../ui/ui-filebrowser'), + uiFileupload = require('../../ui/ui-fileupload'), + UiModal = require('../../ui/ui-modal'), + uiLoading = require('../../ui/ui-loading'), {saveAs} = require('file-saver'), - widgetManager = require('./widgets'), - locales = require('../locales') + widgetManager = require('../widgets'), + locales = require('../../locales'), + Session = require('./session') var SessionManager = class SessionManager { @@ -38,18 +39,12 @@ var SessionManager = class SessionManager { setTimeout(()=>{ try { - // backward compat - if (Array.isArray(session)) session = session[0] - - // session object must be a root widget - if (session.type !== 'root') throw new Error(locales('session_malformed')) - - // ok - this.session = session + this.session = new Session(session) + console.log(this.session) container.innerHTML = '' parser.reset() parser.parse({ - data: this.session, + data: this.session.getRoot(), parentNode: DOM.get('#osc-container')[0] }) editor.clearHistory() @@ -99,7 +94,7 @@ var SessionManager = class SessionManager { if (!this.sessionPath) return this.saveAs() ipc.send('sessionSave', { - session: JSON.stringify(this.session, null, ' '), + session: this.session.toJSON(), path: this.sessionPath }) @@ -118,7 +113,7 @@ var SessionManager = class SessionManager { export() { - var sessionfile = JSON.stringify(this.session,null,' '), + var sessionfile = this.session.toJSON(), blob = new Blob([sessionfile],{type : 'application/json'}) saveAs(blob, new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16) + '.json') @@ -164,7 +159,7 @@ var SessionManager = class SessionManager { try { session = JSON.parse(result) } catch (err) { - new UiModal({title: locales('session_parsingerror'), content: err, icon: 'exclamation-triangle', closable:true}) + new UiModal({title: locales('session_parsingerror'), content: err.message, icon: 'exclamation-triangle', closable:true}) } if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return if (session) sessionManager.load(session, ()=>{ @@ -181,7 +176,7 @@ var SessionManager = class SessionManager { if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return - this.load({type: 'root'},function(){ + this.load(null, function(){ editor.enable() editor.select(widgetManager.getWidgetById('root')) }) diff --git a/src/client/managers/session/session.js b/src/client/managers/session/session.js new file mode 100644 index 00000000..e26c0d78 --- /dev/null +++ b/src/client/managers/session/session.js @@ -0,0 +1,196 @@ +var semver = require('semver'), + UiModal = require('../../ui/ui-modal'), + locales = require('../../locales') + +module.exports = class Session { + + constructor(data) { + + if (data === null) { + + data = { + session: {type: 'root'} + } + + + } else { + + var version = data.version || '0.0.0', + warning = false + + for (var converter of converters) { + + if (semver.lte(version, converter.version)) { + + if (converter.global) data = converter.global(data) + if (converter.widget) this.applyConvert(data.session, converter.widget) + + if (converter.warning) warning = true + + } + + } + + + if (warning) { + + new UiModal({title: locales('session_oldversion_title'), content: locales('session_oldversion'), icon: 'exclamation-triangle', closable:true}) + + + } + + } + + data.version = PACKAGE.version + data.type = PACKAGE.productName + ' ' + 'session' + + this.data = data + + } + + applyConvert(data, convert) { + + convert(data) + + if (data.widgets) { + for (let c of data.widgets) { + this.applyConvert(c, convert) + } + } + + if (data.tabs) { + for (let c of data.tabs) { + this.applyConvert(c, convert) + } + } + + } + + getRoot() { + + return this.data.session + + } + + toJSON() { + + return JSON.stringify(this.data, null, ' ') + + } + +} + +var converters = [ + { + version: '0.49.12', + warning: true, + global: (data)=>{ + return { + session: data + } + }, + widget: (data)=>{ + + data.decimals = data.precision + + if (data.precision === 0) { + data.typeTags = 'i' + data.decimals = 0 + } + if (data.color !== 'auto') data.colorWidget = data.color + + switch (data.type) { + + case 'toggle': + data.type = 'button' + data.mode = 'toggle' + break + + case 'push': + data.type = 'button' + data.mode = data.norelease ? 'tap' : 'push' + break + + case 'fader': + data.design = data.compact ? 'compact' : 'default' + break + + case 'meter': + data.type = 'fader' + data.design = 'compact' + data.interaction = false + break + + + case 'strip': + data.type = 'panel' + data.layout = data.horizontal ? 'horizontal' : 'vertical' + break + + case 'matrix': + + + data.layout = 'grid' + if (Array.isArray(data.matrix) && data.matrix.every(x=>typeof x === 'number')) { + data.quantity = data.matrix[0] * data.matrix[1] + data.gridTemplate = data.matrix[0] + } + + + var oprops = typeof data.props === 'object' && data.props !== null + + switch (data.widgetType) { + case 'toggle': + data.widgetType = 'button' + if (oprops) data.props.mode = 'toggle' + break + + case 'push': + data.widgetType = 'button' + if (oprops) data.props.mode = data.props.norelease ? 'tap' : 'push' + break + + case 'fader': + if (oprops) data.props.design = data.props.compact ? 'compact' : 'default' + break + + case 'meter': + data.widgetType = 'fader' + if (oprops) { + data.props.design = 'compact' + data.props.interaction = false + } + break + + case 'strip': + data.widgetType = 'panel' + if (oprops) data.props.layout = data.props.horizontal ? 'horizontal' : 'vertical' + break + } + break + case 'eq': + data.filter = data.value + data.value = '' + break + + case 'keys': + data.type = 'script' + data.event = 'keyboard' + data.keyRepeat = data.repeat + data.keyBinding = data.binding + data.keyType = data.keyDown && data.keyUp ? 'both' : data.keyUp ? 'keyup' : 'keydown' + data.script = ` + // converted from keys widget data + if (type === 'keyup') { + ${String(data.keyUp).replace(/^JS{{(.*)}}$/, '$1')} + } else if (type === 'keydown') { + ${String(data.keyDown).replace(/^JS{{(.*)}}$/, '$1')} + } + ` + break + + } + + } + } +] diff --git a/src/client/ui/ui-filebrowser.js b/src/client/ui/ui-filebrowser.js index 723af335..41208821 100644 --- a/src/client/ui/ui-filebrowser.js +++ b/src/client/ui/ui-filebrowser.js @@ -17,6 +17,7 @@ module.exports = function UiFilebrowser(options, callback) { var popup = new UiModal({ height: 360, closable: true, + html: true, title: locales(save ? 'remotesave_save' : 'remotesave_open'), hide: true }) diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index 9fb982c7..aab71b28 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -264,15 +264,20 @@ class UiInspector extends UiWidget { computedValue = JSON.stringify(computedValue, null, ' ') } - new UiModal({closable: true, title: html`${name}`, content: html` + new UiModal({closable: true, title: html`${name}`, html: true, content: html`
-

Type: ${defaultValue.type}

-

Default: ${JSON.stringify(defaultValue.value)}

-

Dynamic: ${dynamic ? 'true' : 'false'}

-

Computed: ${computedValue}

- - ${htmlHelp} +
+

Type: ${defaultValue.type}

+

Default: ${JSON.stringify(defaultValue.value)}

+

Dynamic: ${dynamic ? 'true' : 'false'}

+
+
+ ${htmlHelp} +
+
+

Computed value: ${computedValue || 'empty'}

+
`}) diff --git a/src/client/ui/ui-modal.js b/src/client/ui/ui-modal.js index 67a2f62f..45a44e56 100644 --- a/src/client/ui/ui-modal.js +++ b/src/client/ui/ui-modal.js @@ -34,7 +34,7 @@ class UiModal extends UiWidget { ${options.closable? html`${raw(icon('times'))}` : ''} - diff --git a/src/client/ui/ui-toolbar.js b/src/client/ui/ui-toolbar.js index 40ad7325..86aeaebe 100644 --- a/src/client/ui/ui-toolbar.js +++ b/src/client/ui/ui-toolbar.js @@ -5,7 +5,7 @@ var UiWidget = require('./ui-widget'), notifications = require('./notifications'), fullscreen = require('./fullscreen'), editor = require('../editor'), - sessionManager = require('../managers/session'), + sessionManager = require('../managers/session/'), stateManager = require('../managers/state'), {leftUiSidePanel, rightUiSidePanel} = require('../ui/') diff --git a/src/client/ui/ui-tree.js b/src/client/ui/ui-tree.js index b5436d86..52b7b543 100644 --- a/src/client/ui/ui-tree.js +++ b/src/client/ui/ui-tree.js @@ -174,6 +174,7 @@ class UiTree extends UiWidget { if (this.expanded[widget.hash]) node.classList.add('expanded') if (!init && widget instanceof Root) { node.classList.add('expanded') + this.expanded[widget.hash] = true init = true } var sublist = node.appendChild(html`
    `) diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 71401d27..e5ab02ce 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -31,7 +31,7 @@ class Button extends Widget { '- `tap` (no release)' ]}, doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'}, - colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, + colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, }) diff --git a/src/client/widgets/basics/switch.js b/src/client/widgets/basics/switch.js index c182aadb..c624ce8d 100644 --- a/src/client/widgets/basics/switch.js +++ b/src/client/widgets/basics/switch.js @@ -29,7 +29,7 @@ class Switch extends MenuBase { '- `slide`: same as `tap` but allows sliding between values', '- `click`: activates upon click only and allows further scrolling', ]}, - colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, + colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, }) diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 8a8f33af..525ed01b 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -76,15 +76,15 @@ class Widget extends EventEmitter { _style:'style', - colorText: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - colorWidget: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - colorStroke: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - colorFill: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - alphaStroke: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - alphaFillOff: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, - alphaFillOn: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, + colorText: {type: 'string', value: 'auto', help: 'Text color. Set to "auto" to inherit from parent widget.'}, + colorWidget: {type: 'string', value: 'auto', help: 'Widget\'s default accent color. Set to "auto" to inherit from parent widget.'}, + colorStroke: {type: 'string', value: 'auto', help: 'Stroke color. Set to "auto" to use `colorWidget`.'}, + colorFill: {type: 'string', value: 'auto', help: 'Fill color. Set to "auto" to use `colorWidget`.'}, + alphaStroke: {type: 'number', value: 'auto', help: 'Stroke color opacity.'}, + alphaFillOff: {type: 'number', value: 'auto', help: 'Fill color opacity (off).'}, + alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'}, - padding: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'}, + padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, @@ -99,14 +99,13 @@ class Widget extends EventEmitter { 'When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)', 'When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending)' ]}, - script: {type: 'script', value: '', help: ''}, + script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s value is set.'}, _osc: 'osc', address: {type: 'string', value: 'auto', help: 'OSC address for sending messages, it must start with a /'}, preArgs: {type: '*|array', value: '', help: [ 'A value or array of values that will be prepended to the OSC messages.', - 'Values can be defined as objects if the osc type tag needs to be specified: `{type: "i", value: 1}`' ]}, typeTags: {type: 'string', value: '', help: [ 'Defines the osc argument types, one letter per argument (including preArgs)', diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index db226624..7c1ee6a2 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -6,7 +6,7 @@ var Container = require('../common/container'), {diff, diffToWidget} = require('../../editor/diff'), html = require('nanohtml') -var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand'] +var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand', 'no-interaction'] class Clone extends Container() { diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index 6149ec18..68fabd81 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -20,7 +20,8 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) { _matrix: 'matrix', widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'}, - layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help:''}, + colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, start: {type: 'integer', value: 0, help: 'First widget\'s index'}, diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js index ec62988a..aff54a5a 100644 --- a/src/client/widgets/containers/modal.js +++ b/src/client/widgets/containers/modal.js @@ -26,8 +26,8 @@ class Modal extends Panel { popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'}, popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, - colorPanel: {type: 'string', value: 'auto', help:''}, - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''}, + colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help: 'Defines how children are laid out.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'}, scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, diff --git a/src/client/widgets/containers/panel.js b/src/client/widgets/containers/panel.js index 6b5d3593..e094eff2 100644 --- a/src/client/widgets/containers/panel.js +++ b/src/client/widgets/containers/panel.js @@ -19,8 +19,8 @@ class Panel extends Container() { _panel:'panel', - colorPanel: {type: 'string', value: 'auto', help:''}, - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''}, + colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, diff --git a/src/client/widgets/containers/root.js b/src/client/widgets/containers/root.js index 2734e4fe..23d0b47e 100644 --- a/src/client/widgets/containers/root.js +++ b/src/client/widgets/containers/root.js @@ -17,8 +17,8 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro _panel:'panel', - colorPanel: {type: 'string', value: 'auto', help:''}, - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''}, + colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, @@ -47,6 +47,7 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro constructor(options) { options.root = true + options.props.id = 'root' super(options) diff --git a/src/client/widgets/containers/tab.js b/src/client/widgets/containers/tab.js index d735acfe..ea2b8f2d 100644 --- a/src/client/widgets/containers/tab.js +++ b/src/client/widgets/containers/tab.js @@ -17,7 +17,8 @@ module.exports = class Tab extends Panel { _tab:'tab', // detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'}, - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''}, + colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, diff --git a/src/client/widgets/graphs/eq.js b/src/client/widgets/graphs/eq.js index bee346f9..9499af4c 100644 --- a/src/client/widgets/graphs/eq.js +++ b/src/client/widgets/graphs/eq.js @@ -19,11 +19,11 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo filters: {type: 'array', value: '', help: [ 'Each item must be an object with the following properties', - '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch")', - '- `freq`: number (filter\'s resonant frequency)', - '- `q`: number (Q factor)', - '- `gain`: number', - '- `on`: boolean', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")', + '- `freq`: number (filter\'s resonant frequency, default: 1000)', + '- `q`: number (Q factor, default: 1)', + '- `gain`: number (default: 0)', + '- `on`: boolean (default: true)', 'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode' ]}, @@ -40,9 +40,7 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo super(options) - setTimeout(()=>{ - this.calcResponse() - }) + this.calcResponse() } @@ -58,23 +56,33 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo for (let filter of this.getProp('filters')) { - if (filter.on === false) continue + if (filter.on !== undefined && !filter.on) continue biquadResponse({ - type: filter.type, - gain: filter.gain, - frequency: filter.freq, - q: filter.q + type: filter.type || 'peak', + gain: filter.gain || 0, + frequency: filter.freq || 1000, + q: filter.q || 1 }, frequencyHz, filterResponse) } - this.value = filterResponse - this.batchDraw() + this.setValue(filterResponse, {sync: true}) + + } - setValue() {} + setValue(v, options={}) { + + if (!(v instanceof Float32Array) && !(Array.isArray(v)) || v.length !== this.width) return + + this.value = v + this.batchDraw() + + if (options.sync) this.changed(options) + + } resizeHandle(event){ diff --git a/src/client/widgets/indicators/led.js b/src/client/widgets/indicators/led.js index e22fca21..8dd325e7 100644 --- a/src/client/widgets/indicators/led.js +++ b/src/client/widgets/indicators/led.js @@ -1,4 +1,4 @@ -var {mapToScale, clip} = require('../utils'), +var {mapToScale} = require('../utils'), Widget = require('../common/widget'), html = require('nanohtml'), StaticProperties = require('../mixins/static_properties') @@ -17,19 +17,20 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter _led:'led', - mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: [ - '' - ]}, - range: {type: 'object', value: {min:0,max:1}, help: 'Value to led intensity mapping range'}, - logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'}, + mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: 'Defines how value is interpreted (see `value`)'}, + range: {type: 'object', value: {min:0, max:1}, help: 'Value range'}, + alphaRange: {type: 'object', value: {min:0, max:1}, help: 'Alpha range (if `mode` is `color`)'}, + logScale: {type: 'boolean', value: false, help: 'If `mode` is `intensity`, set to `true` to use logarithmic scale.'}, borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'}, }, ['interaction', 'decimals', 'bypass'], { value: {type: 'number|array|string', value: '', help: [ - '- `Number`: if `mode` is set to `intensity`', - '- `Array`: `[r, g, b]` (`r`, `g` and `b` between `0` and `255`)', - '- `Array`: `[r, g, b, alpha]` (`alpha` between `0` and `255`)', + 'If `mode` is `intensity`:', + '- `Number`: `intensity` between `range.min` and `range.max`', + 'If `mode` is `color`:', + '- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)', + '- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)', '- `String`: CSS color', ]} @@ -75,11 +76,11 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter if (Array.isArray(v) && v.length >= 3) { - for (let i in [0,1,2]) { - v[i] = parseInt(clip(v[i],[0,255])) + for (let i in [0, 1, 2]) { + v[i] = parseInt(mapToScale(v[i], [this.getProp('range').min, this.getProp('range').max], [0, 255])) } - v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1]) + v[3] = v[3] === undefined ? 1 : mapToScale(v[3], [this.getProp('alphaRange').min, this.getProp('alphaRange').max], [0, 1], -1) c = `rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})` diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 7a275e68..bf236db7 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -189,6 +189,16 @@ module.exports = class MultiXy extends Pad { } + cacheCanvasStyle(style) { + + super.cacheCanvasStyle(style) + for (var k in this.pads) { + this.pads[k].cacheCanvasStyle() + this.pads[k].batchDraw() + } + + } + updateHandlesPosition() { for (var i=0;i:([0-9]+):[0-9]+/) || '') : '', + line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' + console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line) + this.script = ()=>{} + } } else if (this.getProp('event') === 'keyboard' && this.getProp('keyBinding')) { @@ -91,7 +98,7 @@ class Script extends Widget { meta: false, }) } catch(err) { - var stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', + let 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) + '.script error:\n' + err + line) this.script = ()=>{} diff --git a/src/client/widgets/sliders/encoder.js b/src/client/widgets/sliders/encoder.js index f04b11b3..582c5d7f 100644 --- a/src/client/widgets/sliders/encoder.js +++ b/src/client/widgets/sliders/encoder.js @@ -219,6 +219,12 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range this.clear() + if (this.minDimension < 40) { + minRadius /= 2 + gaugeWidth = maxRadius - minRadius + gaugeRadius = maxRadius - gaugeWidth / 2 + } + // fill this.ctx.globalAlpha = this.cssVars.alphaFill this.ctx.strokeStyle = this.cssVars.colorFill @@ -244,10 +250,12 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range this.ctx.strokeStyle = this.cssVars.colorStroke this.ctx.lineWidth = PXSCALE - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI) - this.ctx.stroke() - + if (this.minDimension > 40) { + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI) + this.ctx.stroke() + } + this.ctx.beginPath() this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI) this.ctx.stroke() diff --git a/src/client/widgets/sliders/knob.js b/src/client/widgets/sliders/knob.js index f38bd2b3..2d6888e0 100644 --- a/src/client/widgets/sliders/knob.js +++ b/src/client/widgets/sliders/knob.js @@ -15,7 +15,6 @@ module.exports = class Knob extends Slider { _knob:'knob', - design: {type: 'string', value: 'default', choices: ['default', 'classic'], help: 'Design style'}, 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', @@ -182,117 +181,126 @@ module.exports = class Knob extends Slider { this.clear() - if (this.getProp('design') === 'default') { + // if (this.getProp('design') === 'default') { - // fill - this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2 + if (this.minDimension < 40) { + minRadius /= 2 + gaugeWidth = maxRadius - minRadius + gaugeRadius = maxRadius - gaugeWidth / 2 + } - if (this.cssVars.alphaFillOff) { - this.ctx.globalAlpha = this.cssVars.alphaFillOff - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max) - this.ctx.stroke() - } + // fill + this.ctx.strokeStyle = this.cssVars.colorFill + this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2 - if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE]) + if (this.cssVars.alphaFillOff) { + this.ctx.globalAlpha = this.cssVars.alphaFillOff + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max) + this.ctx.stroke() + } - if (this.cssVars.alphaFillOn) { - this.ctx.globalAlpha = this.cssVars.alphaFillOn - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d) - this.ctx.stroke() - } + if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE]) - if (dashed) this.ctx.setLineDash([]) + if (this.cssVars.alphaFillOn) { + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d) + this.ctx.stroke() + } + + if (dashed) this.ctx.setLineDash([]) - // stroke + // stroke - this.ctx.globalAlpha = this.cssVars.alphaStroke - this.ctx.strokeStyle = this.cssVars.colorStroke - this.ctx.lineWidth = PXSCALE + this.ctx.globalAlpha = this.cssVars.alphaStroke + this.ctx.strokeStyle = this.cssVars.colorStroke + this.ctx.lineWidth = PXSCALE + if (this.minDimension > 40) { this.ctx.beginPath() this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI) this.ctx.stroke() - - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI) - this.ctx.stroke() - - - // knob - - this.ctx.globalAlpha = 1 - this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 1.5 * PXSCALE - - let r1 = minRadius + this.gaugePadding, - r2 = maxRadius - this.gaugePadding, - a = 2 * Math.PI - d - - this.ctx.beginPath() - this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a)) - this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a)) - this.ctx.stroke() - - } else { - - // fill - this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 2 * PXSCALE - - if (this.cssVars.alphaFillOff) { - this.ctx.globalAlpha = this.cssVars.alphaFillOff - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max) - this.ctx.stroke() - } - - if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE]) - - if (this.cssVars.alphaFillOn) { - this.ctx.globalAlpha = this.cssVars.alphaFillOn - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d) - this.ctx.stroke() - } - - if (dashed) this.ctx.setLineDash([]) - - - - // center - this.ctx.fillStyle = this.cssVars.colorPanel - this.ctx.strokeStyle = this.cssVars.colorStroke - this.ctx.lineWidth = 1 * PXSCALE - - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI) - this.ctx.globalAlpha = this.cssVars.alphaStroke - this.ctx.stroke() - this.ctx.globalAlpha = 1 - // this.ctx.fill() - - - - // knob - this.ctx.globalAlpha = 1 - this.ctx.fillStyle = this.cssVars.colorFill - this.ctx.lineWidth = 1.5 * PXSCALE - - let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE, - a = 2 * Math.PI - d - - this.ctx.beginPath() - this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI) - this.ctx.fill() - - } + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI) + this.ctx.stroke() + + + // knob + + this.ctx.globalAlpha = 1 + this.ctx.strokeStyle = this.cssVars.colorFill + this.ctx.lineWidth = 1.5 * PXSCALE + + let r1 = minRadius + this.gaugePadding, + r2 = maxRadius - this.gaugePadding, + a = 2 * Math.PI - d + + this.ctx.beginPath() + this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a)) + this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a)) + this.ctx.stroke() + + // } else { + // + // // fill + // this.ctx.strokeStyle = this.cssVars.colorFill + // this.ctx.lineWidth = 2 * PXSCALE + // + // if (this.cssVars.alphaFillOff) { + // this.ctx.globalAlpha = this.cssVars.alphaFillOff + // this.ctx.beginPath() + // this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max) + // this.ctx.stroke() + // } + // + // if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE]) + // + // if (this.cssVars.alphaFillOn) { + // this.ctx.globalAlpha = this.cssVars.alphaFillOn + // this.ctx.beginPath() + // this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d) + // this.ctx.stroke() + // } + // + // if (dashed) this.ctx.setLineDash([]) + // + // + // + // // center + // this.ctx.fillStyle = this.cssVars.colorPanel + // this.ctx.strokeStyle = this.cssVars.colorStroke + // this.ctx.lineWidth = 1 * PXSCALE + // + // this.ctx.beginPath() + // this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI) + // this.ctx.globalAlpha = this.cssVars.alphaStroke + // this.ctx.stroke() + // this.ctx.globalAlpha = 1 + // // this.ctx.fill() + // + // + // + // // knob + // this.ctx.globalAlpha = 1 + // this.ctx.fillStyle = this.cssVars.colorFill + // this.ctx.lineWidth = 1.5 * PXSCALE + // + // let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE, + // a = 2 * Math.PI - d + // + // this.ctx.beginPath() + // this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI) + // this.ctx.fill() + // + // + // } + + // pips diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss index 1e434905..ba95fd52 100644 --- a/src/scss/ui/inspector.scss +++ b/src/scss/ui/inspector.scss @@ -269,6 +269,8 @@ osc-inspector-color { padding: 8rem; background: var(--color-background); + p { + } .error { color: red; margin-top: 10rem; @@ -278,7 +280,7 @@ osc-inspector-color { } code { color: var(--color-accent); - padding: 1rem 3rem; + padding: 4rem; background: rgba(black, 0.2); display: inline-block; user-select: auto; @@ -292,9 +294,30 @@ osc-inspector-color { .pre { white-space: pre; vertical-align: text-top; + margin-top: -4rem; + position: relative; + padding: 5rem; + user-select: text; } - .help { + + .header p { + margin-bottom: 2rem; + user-select: text; + } + .description { + border-top: 2rem solid var(--color-ui-background); margin-top: 10rem; + padding-top: 10rem; white-space: normal; + * { + user-select: text; + } + } + + .computed { + border-top: 2rem solid var(--color-ui-background); + margin-top: 10rem; + padding-top: 10rem; + } } diff --git a/src/scss/ui/modal.scss b/src/scss/ui/modal.scss index de98f8a6..7b89392d 100644 --- a/src/scss/ui/modal.scss +++ b/src/scss/ui/modal.scss @@ -96,5 +96,13 @@ $padding: 8rem; min-height: 0; display: flex; } + + .message { + white-space: normal; + line-height: 150%; + background: var(--color-background); + padding-top:8rem; + overflow-x: auto; + } } } diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index 4213e113..4f8086c8 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -1,4 +1,4 @@ -.buttons-container, +.button-container, .menu-container, .dropdown-container, .input-container, diff --git a/src/scss/widgets/frames.scss b/src/scss/widgets/frames.scss index c9471e4c..2ebf2857 100644 --- a/src/scss/widgets/frames.scss +++ b/src/scss/widgets/frames.scss @@ -23,3 +23,9 @@ } } + +.frame-container { + iframe[src=""] { + pointer-events: none; + } +} diff --git a/src/scss/widgets/indicators.scss b/src/scss/widgets/indicators.scss index e5445b04..57710ede 100644 --- a/src/scss/widgets/indicators.scss +++ b/src/scss/widgets/indicators.scss @@ -43,7 +43,7 @@ padding: var(--widget-padding); display: flex; - + width: 100%; } @@ -51,7 +51,7 @@ color: var(--color-fill); opacity: var(--alpha-fill-on); flex: 1; - height: 100%; + height: auto; display: flex; justify-content: center; align-items: center; diff --git a/src/server/callbacks.js b/src/server/callbacks.js index ac24305a..07a8527e 100644 --- a/src/server/callbacks.js +++ b/src/server/callbacks.js @@ -7,12 +7,11 @@ var path = require('path'), theme = require('./theme') var widgetHashTable = {}, - sessionBackups = {}, clipboard = {clipboard: null, idClipboard: null} module.exports = { - ready: function(data,clientId) { + ready(data,clientId) { ipc.send('connected') @@ -20,26 +19,13 @@ module.exports = { ipc.send('sessionList', recentSessions, clientId) ipc.send('clipboard', clipboard, clientId) - - if (data.backupId && sessionBackups[data.backupId]) { - ipc.send('loadBackup', sessionBackups[data.backupId]) - return - } - - if (settings.read('load')) return this.sessionOpen({path:settings.read('load')},clientId) - - - if (settings.read('examples')) { - var dir = path.resolve(__dirname + '/../examples') - recentSessions = fs.readdirSync(dir) - recentSessions = recentSessions.map(function(file){return dir + '/' + file}) - } - ipc.send('serverTargets', settings.read('send'), clientId) + if (settings.read('load') && !data.hotReload) return this.sessionOpen({path: settings.read('load')}, clientId) + }, - sessionAddToHistory: function(data) { + sessionAddToHistory(data) { var recentSessions = settings.read('recentSessions') @@ -65,7 +51,7 @@ module.exports = { }) }, - sessionRemoveFromHistory: function(data) { + sessionRemoveFromHistory(data) { var recentSessions = settings.read('recentSessions') if (recentSessions.indexOf(data) > -1) { @@ -76,7 +62,7 @@ module.exports = { }, - sessionSetPath: function(data, clientId) { + sessionSetPath(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -90,7 +76,7 @@ module.exports = { }, - sessionOpen: function(data, clientId) { + sessionOpen(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -103,7 +89,7 @@ module.exports = { }, - sessionOpened: function(data, clientId) { + sessionOpened(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -128,7 +114,7 @@ module.exports = { }, - fileRead: function(data, clientId, ok, callback) { + fileRead(data, clientId, ok, callback) { if (!ok) return @@ -155,7 +141,7 @@ module.exports = { }, - fileSave: function(data, clientId, ok, callback) { + fileSave(data, clientId, ok, callback) { if (!ok) return @@ -212,7 +198,7 @@ module.exports = { }, - stateOpen: function(data, clientId) { + stateOpen(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -224,7 +210,7 @@ module.exports = { }, - sessionSave: function(data, clientId) { + sessionSave(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -249,7 +235,7 @@ module.exports = { }, - stateSave: function(data, clientId) { + stateSave(data, clientId) { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) @@ -263,7 +249,7 @@ module.exports = { }, - syncOsc: function(shortdata, clientId) { + syncOsc(shortdata, clientId) { if (!(widgetHashTable[clientId] && widgetHashTable[clientId][shortdata.h])) return @@ -285,7 +271,7 @@ module.exports = { }, - sendOsc: function(shortdata, clientId) { + sendOsc(shortdata, clientId) { if (!(widgetHashTable[clientId] && widgetHashTable[clientId][shortdata.h])) return @@ -376,50 +362,38 @@ module.exports = { }, - fullscreen: function(data) { + fullscreen(data) { window.setFullScreen(!window.isFullScreen()) }, - reload: function(data) { + reload(data) { ipc.send('reload') }, - storeBackup: function(data, clientId) { - - sessionBackups[data.backupId] = data - - }, - - deleteBackup: function(data) { - - delete sessionBackups[data] - - }, - - reloadCss:function(){ + reloadCss() { theme.load() ipc.send('reloadCss') }, - log: function(data) { + log(data) { console.log(data) }, - error: function(data) { + error(data) { console.error(data) }, - errorLog: function(data) { + errorLog(data) { console.error(data) }, - errorPopup: function(data) { + errorPopup(data) { ipc.send('error', data) }, - listDir: function(data, clientId) { + listDir(data, clientId) { var p = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'] @@ -455,7 +429,7 @@ module.exports = { }, - clipboard: function(data, clientId) { + clipboard(data, clientId) { clipboard = data ipc.send('clipboard', data, null, clientId) diff --git a/src/server/electron-window.js b/src/server/electron-window.js index 821878e4..beb0782c 100644 --- a/src/server/electron-window.js +++ b/src/server/electron-window.js @@ -79,7 +79,7 @@ module.exports = function(options={}) { window.webContents.on('before-input-event', (e, input)=>{ // using before-input-event because electron-localshortcut // gets azerty keyboards wrong (ctrl + z would also be catched) - if ((input.key === 'w' || input.key === 'W') && input.control) { + if ((input.key === 'w' || input.key === 'W') && input.control && input.type === 'keyDown') { window.close() } }) diff --git a/src/server/options.js b/src/server/options.js index a0d58a66..acf018d5 100644 --- a/src/server/options.js +++ b/src/server/options.js @@ -25,7 +25,7 @@ module.exports = { }, 'c': {alias: 'custom-module', type: 'array', file: {name: 'OSC Custom module (.js)', extensions: ['js']}, describe: 'custom module file to load (custom options can be passed after the filename)', check: (arg)=>{ - return fs.lstatSync(arg) ? true : 'Custom module file not found: ' + arg + return fs.lstatSync(arg[0]) ? true : 'Custom module file not found: ' + arg }, }, 'p': {alias: 'port', type: 'number', describe: 'http port of the server (default to 8080)',