From 9c2a624aa0e4d6fb93fb02bce55db881de224aee Mon Sep 17 00:00:00 2001 From: bordun Date: Sun, 23 Feb 2020 12:34:22 +0100 Subject: [PATCH] v1 refactor wip --- app/client/index.html | 25 +- package.json | 2 + src/client/app/editor/context-menu.js | 12 +- src/client/app/editor/data-workers.js | 15 +- src/client/app/editor/edit-field.js | 13 +- src/client/app/editor/index.js | 334 +++++------ src/client/app/events/double-click.js | 43 ++ src/client/app/globals.js | 5 - src/client/app/ipc/callbacks.js | 8 +- src/client/app/locales/en.js | 1 - src/client/app/locales/fr.js | 5 +- src/client/app/locales/ru.js | 1 - src/client/app/managers/session.js | 4 +- src/client/app/ui/context-menu.js | 6 +- src/client/app/ui/init.js | 12 +- src/client/app/ui/scrollbar-color.js | 19 + src/client/app/ui/sidepanel.js | 13 +- src/client/app/ui/ui-dragresize.js | 190 +++++++ src/client/app/ui/ui-inspector-field.js | 120 ++++ src/client/app/ui/ui-inspector.js | 188 +++++++ src/client/app/ui/ui-modal.js | 97 ++++ .../select-area.js => ui/ui-selectarea.js} | 7 +- src/client/app/ui/ui-sidepanel.js | 112 ++++ src/client/app/ui/ui-tree.js | 159 ++++++ src/client/app/ui/ui-widget.js | 16 + src/client/app/ui/ui-workspace.js | 16 + src/client/app/widgets/buttons/menu.js | 104 ++-- src/client/app/widgets/buttons/push.js | 160 ------ src/client/app/widgets/buttons/switch.js | 29 +- src/client/app/widgets/buttons/toggle.js | 103 +++- src/client/app/widgets/common/canvas.js | 43 +- src/client/app/widgets/common/widget.js | 140 +++-- src/client/app/widgets/containers/modal.js | 28 +- src/client/app/widgets/containers/panel.js | 99 +++- src/client/app/widgets/containers/root.js | 62 +-- src/client/app/widgets/containers/strip.js | 66 --- src/client/app/widgets/containers/tab.js | 28 +- .../app/widgets/{plots => frames}/frame.js | 8 +- .../app/widgets/{plots => frames}/html.js | 7 +- .../app/widgets/{plots => frames}/image.js | 5 +- .../app/widgets/{plots => frames}/svg.js | 6 +- .../_biquad_response.js => graphs/eq.js} | 111 +++- src/client/app/widgets/graphs/plot.js | 246 ++++++++ .../widgets/{plots => graphs}/visualizer.js | 25 +- src/client/app/widgets/index.js | 53 +- src/client/app/widgets/indicators/led.js | 102 ++++ .../app/widgets/{plots => indicators}/text.js | 24 +- src/client/app/widgets/inputs/file.js | 2 +- src/client/app/widgets/inputs/input.js | 33 +- src/client/app/widgets/inputs/keys.js | 27 +- src/client/app/widgets/pads/canvas.js | 172 ++++++ src/client/app/widgets/pads/multixy.js | 46 +- src/client/app/widgets/pads/pad.js | 18 +- src/client/app/widgets/pads/xy.js | 212 ++++--- src/client/app/widgets/plots/_plots_base.js | 209 ------- src/client/app/widgets/plots/eq.js | 109 ---- src/client/app/widgets/plots/led.js | 52 -- src/client/app/widgets/plots/meter.js | 65 --- src/client/app/widgets/plots/plot.js | 53 -- src/client/app/widgets/plots/rgbled.js | 79 --- src/client/app/widgets/scripts/script.js | 20 + src/client/app/widgets/sliders/encoder.js | 358 ++++++------ src/client/app/widgets/sliders/fader.js | 219 +++----- src/client/app/widgets/sliders/knob.js | 185 ++----- src/client/app/widgets/sliders/range.js | 524 ++++++------------ src/client/app/widgets/sliders/slider.js | 74 +-- src/client/app/widgets/switchers/state.js | 8 +- src/client/app/widgets/utils.js | 39 +- src/client/libs/jquery.touch.js | 183 ------ src/client/libs/jquery.ui.js | 8 - src/scss/editor.scss | 488 +--------------- src/scss/index.scss | 102 +--- src/scss/layout.scss | 139 ----- src/scss/mixins.scss | 32 ++ src/scss/scrollbars.scss | 88 --- src/scss/sidepanel.scss | 128 ++--- src/scss/themes/default.scss | 24 +- src/scss/ui.scss | 9 + src/scss/ui/contextmenu.scss | 60 ++ src/scss/ui/dragresize.scss | 80 +++ src/scss/ui/inspector.scss | 226 ++++++++ src/scss/ui/modal.scss | 78 +++ src/scss/{ => ui}/notifications.scss | 0 src/scss/ui/scrollbars.scss | 44 ++ src/scss/ui/selectarea.scss | 19 + src/scss/ui/tree.scss | 115 ++++ src/scss/ui/workspaces.scss | 221 ++++++++ src/scss/widgets.old.scss | 107 ++++ src/scss/{widgets => widgets.old}/fader.scss | 0 src/scss/widgets.old/inputs.scss | 238 ++++++++ src/scss/{widgets => widgets.old}/knob.scss | 0 src/scss/{widgets => widgets.old}/maths.scss | 0 .../{widgets => widgets.old}/matrices.scss | 0 src/scss/{widgets => widgets.old}/menu.scss | 0 src/scss/widgets.old/pads.scss | 206 +++++++ src/scss/{widgets => widgets.old}/panel.scss | 0 .../{widgets => widgets.old}/patchbay.scss | 0 src/scss/widgets.old/plots.scss | 265 +++++++++ src/scss/{widgets => widgets.old}/push.scss | 0 src/scss/{widgets => widgets.old}/switch.scss | 0 src/scss/{widgets => widgets.old}/toggle.scss | 0 src/scss/widgets.scss | 105 ++-- src/scss/widgets/buttons.scss | 299 ++++++++++ src/scss/widgets/containers.scss | 418 ++++++++++++++ src/scss/widgets/indicators.scss | 74 +++ src/scss/widgets/inputs.scss | 274 ++------- src/scss/widgets/pads.scss | 203 +------ src/scss/widgets/plots.scss | 271 +-------- src/scss/widgets/sliders.scss | 31 ++ 109 files changed, 5639 insertions(+), 4272 deletions(-) create mode 100644 src/client/app/events/double-click.js create mode 100644 src/client/app/ui/scrollbar-color.js create mode 100644 src/client/app/ui/ui-dragresize.js create mode 100644 src/client/app/ui/ui-inspector-field.js create mode 100644 src/client/app/ui/ui-inspector.js create mode 100644 src/client/app/ui/ui-modal.js rename src/client/app/{editor/select-area.js => ui/ui-selectarea.js} (95%) create mode 100644 src/client/app/ui/ui-sidepanel.js create mode 100644 src/client/app/ui/ui-tree.js create mode 100644 src/client/app/ui/ui-widget.js create mode 100644 src/client/app/ui/ui-workspace.js delete mode 100644 src/client/app/widgets/buttons/push.js delete mode 100644 src/client/app/widgets/containers/strip.js rename src/client/app/widgets/{plots => frames}/frame.js (91%) rename src/client/app/widgets/{plots => frames}/html.js (91%) rename src/client/app/widgets/{plots => frames}/image.js (93%) rename src/client/app/widgets/{plots => frames}/svg.js (95%) rename src/client/app/widgets/{plots/_biquad_response.js => graphs/eq.js} (56%) create mode 100644 src/client/app/widgets/graphs/plot.js rename src/client/app/widgets/{plots => graphs}/visualizer.js (66%) create mode 100644 src/client/app/widgets/indicators/led.js rename src/client/app/widgets/{plots => indicators}/text.js (63%) create mode 100644 src/client/app/widgets/pads/canvas.js delete mode 100644 src/client/app/widgets/plots/_plots_base.js delete mode 100644 src/client/app/widgets/plots/eq.js delete mode 100644 src/client/app/widgets/plots/led.js delete mode 100644 src/client/app/widgets/plots/meter.js delete mode 100644 src/client/app/widgets/plots/plot.js delete mode 100644 src/client/app/widgets/plots/rgbled.js create mode 100644 src/client/app/widgets/scripts/script.js delete mode 100644 src/client/libs/jquery.touch.js delete mode 100644 src/client/libs/jquery.ui.js delete mode 100644 src/scss/layout.scss create mode 100644 src/scss/mixins.scss delete mode 100644 src/scss/scrollbars.scss create mode 100644 src/scss/ui.scss create mode 100644 src/scss/ui/contextmenu.scss create mode 100644 src/scss/ui/dragresize.scss create mode 100644 src/scss/ui/inspector.scss create mode 100644 src/scss/ui/modal.scss rename src/scss/{ => ui}/notifications.scss (100%) create mode 100644 src/scss/ui/scrollbars.scss create mode 100644 src/scss/ui/selectarea.scss create mode 100644 src/scss/ui/tree.scss create mode 100644 src/scss/ui/workspaces.scss create mode 100644 src/scss/widgets.old.scss rename src/scss/{widgets => widgets.old}/fader.scss (100%) create mode 100644 src/scss/widgets.old/inputs.scss rename src/scss/{widgets => widgets.old}/knob.scss (100%) rename src/scss/{widgets => widgets.old}/maths.scss (100%) rename src/scss/{widgets => widgets.old}/matrices.scss (100%) rename src/scss/{widgets => widgets.old}/menu.scss (100%) create mode 100644 src/scss/widgets.old/pads.scss rename src/scss/{widgets => widgets.old}/panel.scss (100%) rename src/scss/{widgets => widgets.old}/patchbay.scss (100%) create mode 100644 src/scss/widgets.old/plots.scss rename src/scss/{widgets => widgets.old}/push.scss (100%) rename src/scss/{widgets => widgets.old}/switch.scss (100%) rename src/scss/{widgets => widgets.old}/toggle.scss (100%) create mode 100644 src/scss/widgets/buttons.scss create mode 100644 src/scss/widgets/containers.scss create mode 100644 src/scss/widgets/indicators.scss create mode 100644 src/scss/widgets/sliders.scss diff --git a/app/client/index.html b/app/client/index.html index 4799c8ba..18b4ddff 100644 --- a/app/client/index.html +++ b/app/client/index.html @@ -19,8 +19,29 @@ -
-
+ + +
+
+ + Project + + +
+ + + + +
+
+ + Inspector + + +
+ +
+ diff --git a/package.json b/package.json index 08cc146b..1df135f1 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "bonjour": "github:jean-emmanuel/bonjour", "browserify": "16.5.0", "cardinal-spline-js": "2.3.10", + "chroma-js": "2.1.0", "core-js": "3.6.4", "cpr": "3.0.1", "deep-extend": "0.6.0", @@ -60,6 +61,7 @@ "scope-css": "1.2.1", "screenfull": "5.0.1", "send": "0.17.1", + "sortablejs": "1.10.2", "source-map-support": "0.5.16", "stacktrace-js": "2.0.2", "through": "2.3.8", diff --git a/src/client/app/editor/context-menu.js b/src/client/app/editor/context-menu.js index 48d23c66..f5fd3705 100644 --- a/src/client/app/editor/context-menu.js +++ b/src/client/app/editor/context-menu.js @@ -14,8 +14,7 @@ var handleClick = function(event) { if (!EDITING) return if (!event.detail[multiSelectKey] && event.type !== 'fast-right-click' && ( - event.target.classList.contains('ui-resizable-handle') || - event.target.classList.contains('ui-draggable-handle') || + event.target.classList.contains('no-widget-select') || event.target.id === 'open-toggle' )) { return } @@ -74,13 +73,6 @@ var handleClick = function(event) { var clickX = Math.round((eventData.offsetX + eventData.target.scrollLeft) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH, clickY = Math.round((eventData.offsetY + eventData.target.scrollTop) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH - actions.push({ - label: icon('expand') + ' ' + locales('editor_editparent'), - action: ()=>{ - editor.select(parent) - } - }) - if (type === 'widget') { actions.push({ @@ -129,7 +121,7 @@ var handleClick = function(event) { } actions.push({ - label: icon('box') + ' ' + locales('editor_wrap'), + label: icon('layer-group') + ' ' + locales('editor_wrap'), action: wrapActions }) diff --git a/src/client/app/editor/data-workers.js b/src/client/app/editor/data-workers.js index 6b4cfee9..f2a19991 100644 --- a/src/client/app/editor/data-workers.js +++ b/src/client/app/editor/data-workers.js @@ -3,14 +3,8 @@ var widgetManager = require('../managers/widgets'), stateManager = require('../managers/state'), parser = require('../parser'), Panel, - sidepanel, editor, - scrollState = {}, - sidepanelScroll - -DOM.ready(()=>{ - sidepanel = DOM.get('#sidepanel')[0] -}) + scrollState = {} function updateWidget(widget, options={}) { @@ -25,6 +19,8 @@ function updateWidget(widget, options={}) { var edited = widget.updateProps(options.changedProps, null, {fromEditor: true}) || widget + editor.widgetTree.updateTree(editor.selectedWidgets) + if (editor.selectedWidgets.includes(widget) && !options.preventSelect) { editor.select(edited) } @@ -67,13 +63,13 @@ function updateWidget(widget, options={}) { var index = widget.parent.children.indexOf(widget) // list widgets to remove + removedChildren = removedChildren.filter(x => x !== undefined) var removedWidgets = reuseChildren ? removedChildren.map(x => x.getAllChildren().concat(x)).concat(widget).reduce((a,b)=>a.concat(b), []) : widget.getAllChildren().concat(widget) // save state if (stateManager.queueCounter === 0) { - sidepanelScroll = sidepanel.scrollTop scrollState = {} } stateManager.incrementQueue() @@ -135,7 +131,6 @@ function updateWidget(widget, options={}) { // restore state stateManager.decrementQueue() if (stateManager.queueCounter === 0) { - sidepanel.scrollTop = sidepanelScroll for (let id in scrollState) { for (let w of widgetManager.getWidgetById(id)) { if (w.scroll) w.scroll(scrollState[id]) @@ -143,6 +138,8 @@ function updateWidget(widget, options={}) { } } + editor.widgetTree.updateTree(editor.selectedWidgets) + if (editor.selectedWidgets.includes(widget) && !options.preventSelect) { editor.select(newWidget) } diff --git a/src/client/app/editor/edit-field.js b/src/client/app/editor/edit-field.js index e40d8811..7deb5ce8 100644 --- a/src/client/app/editor/edit-field.js +++ b/src/client/app/editor/edit-field.js @@ -14,9 +14,9 @@ module.exports = function editField(editor, widget, propName, defaultValue){ error = widget.errors[propName] let field = html` -
- -
+ + + ` let input @@ -69,12 +69,14 @@ module.exports = function editField(editor, widget, propName, defaultValue){ } }) + field.appendChild(input) + if (defaultValue.type.includes('boolean')) { let toggle = html` - + ${raw(icon('check'))} - + ` toggle.addEventListener('click', ()=>{ @@ -91,7 +93,6 @@ module.exports = function editField(editor, widget, propName, defaultValue){ } - field.appendChild(input) } var lock, diff --git a/src/client/app/editor/index.js b/src/client/app/editor/index.js index 69a7a252..838c7aff 100644 --- a/src/client/app/editor/index.js +++ b/src/client/app/editor/index.js @@ -1,49 +1,87 @@ -var {widgets} = require('../widgets/'), - editField = require('./edit-field'), +var editField = require('./edit-field'), {updateWidget, incrementWidget} = require('./data-workers'), keyboardJS = require('keyboardjs'), {diff, diffToWidget} = require('./diff'), widgetManager = require('../managers/widgets'), {deepCopy} = require('../utils'), + {defaults} = require('../widgets/'), macOs = (navigator.platform || '').match('Mac'), - SelectArea = require('./select-area'), + UiSelectArea = require('../ui/ui-selectarea'), + UiInspector = require('../ui/ui-inspector'), + UiTree = require('../ui/ui-tree'), + UiDragResize = require('../ui/ui-dragresize'), + sidepanel = require('../ui/ui-sidepanel'), html = require('nanohtml'), sessionManager - const HISTORY_SIZE = 50 var Editor = class Editor { constructor() { - this.wrapper = html` -
-
-
-
- ` + this.inspector = new UiInspector({selector: '#osc-inspector'}) + this.inspector.on('update', (event)=>{ - this.form = DOM.get(this.wrapper, '.form')[0] - this.form.addEventListener('fast-click', (e)=>{ - if (e.target.classList.contains('separator')) { - var name = e.target.getAttribute('data-name'), - foldedIndex = this.foldedCategories.indexOf(name) - e.target.parentNode.classList.toggle('folded', foldedIndex < 0) - if (foldedIndex > -1) { - this.foldedCategories.splice(foldedIndex, 1) + var {propName, value} = event, + newWidgets = [] + + for (var w of this.selectedWidgets) { + if (propName === 'address' && value === '') { + // special case + w.props[propName] = '/' + w.props.id } else { - this.foldedCategories.push(name) + w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type][propName].value) } - + newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})) } + + this.pushHistory() + + if (newWidgets.length > 1) this.select(newWidgets) + }) - this.defaults = {} - for (var k in widgets) { - this.defaults[k] = widgets[k].defaults() - } + this.widgetTree = new UiTree({selector: '#osc-tree'}) + this.widgetTree.on('sorted', (event)=>{ + + var {widget, oldIndex, newIndex} = event, + propName = widget.props.tabs.length ? 'tabs' : 'widgets' + + if (widget.props[propName].length < 2) return + + widget.props[propName].splice(newIndex, 0, widget.props[propName].splice(oldIndex, 1)[0]) + + var indices = [newIndex, oldIndex] + if (Math.abs(oldIndex - newIndex) > 1) { + for (var i = Math.min(newIndex, oldIndex) + 1; i < Math.max(newIndex, oldIndex); i++) { + indices.push(i) + } + } + + var container = updateWidget(widget, {removedIndexes: indices, addedIndexes: indices, preventSelect: true}) + + this.pushHistory({removedIndexes: indices, addedIndexes: indices}) + this.select(container.children[newIndex]) + + }) + + this.oscContainer = DOM.get('#osc-container')[0] + + + + this.widgetDragResize = new UiDragResize({}) + this.widgetDragResize.on('move', (e)=>{ + var dX = Math.round((e.left - e.initLeft) / GRIDWIDTH) * GRIDWIDTH, + dY = Math.round((e.top - e.initTop) / GRIDWIDTH) * GRIDWIDTH + this.moveWidget(dX, dY) + }) + this.widgetDragResize.on('resize', (e)=>{ + var dX = Math.round((e.width - e.initWidth) / GRIDWIDTH) * GRIDWIDTH, + dY = Math.round((e.height - e.initHeight) / GRIDWIDTH) * GRIDWIDTH + this.resizeWidget(dX, dY) + }) this.selectedWidgets = [] @@ -62,8 +100,6 @@ var Editor = class Editor { this.historyState = -1 this.historySession = null - this.foldedCategories = [] - this.mousePosition = {x:0, y:0} this.mouveMoveHandler = this.mouseMove.bind(this) @@ -128,7 +164,7 @@ var Editor = class Editor { }) - this.selectarea = new SelectArea('.widget:not(.not-editable), .tablink', (elements)=>{ + this.selectarea = new UiSelectArea('[data-widget]:not(.not-editable)', (elements)=>{ elements = elements.map(e => widgetManager.getWidgetByElement(e, ':not(.not-editable)')).filter(e => e) @@ -225,6 +261,7 @@ var Editor = class Editor { if (!this.selectedWidgets.length) return this.unselect() this.selectedWidgets = [] + this.inspector.clear() break case 'mod + a': @@ -285,15 +322,15 @@ var Editor = class Editor { break - case 'f2': - var input = DOM.get(this.form, 'textarea[name="label"]')[0] - if (input) { - var folded = input.closest('.category.folded') - if (folded) DOM.dispatchEvent(DOM.get(folded, '.separator'), 'fast-click') - input.focus() - input.setSelectionRange(0, input.value.length) - } - break + // case 'f2': + // var input = DOM.get(this.form, 'textarea[name="label"]')[0] + // if (input) { + // var folded = input.closest('.category.folded') + // if (folded) DOM.dispatchEvent(DOM.get(folded, '.separator'), 'fast-click') + // input.focus() + // input.setSelectionRange(0, input.value.length) + // } + // break } @@ -307,40 +344,44 @@ var Editor = class Editor { EDITING = true this.enabled = true - DOM.get('.editor-root')[0].setAttribute('data-widget', DOM.get('.root-container')[0].getAttribute('data-widget')) - DOM.get('.editor-root')[0].classList.remove('disabled') - DOM.get('.disable-editor')[0].classList.remove('on') - DOM.get('.enable-editor')[0].classList.add('on') + // DOM.get('.disable-editor')[0].classList.remove('on') + // DOM.get('.enable-editor')[0].classList.add('on') + // document.body.classList.add('editor-enabled') - document.body.classList.toggle('no-grid', GRIDWIDTH == 1) + // document.body.classList.toggle('no-grid', GRIDWIDTH == 1) + // + // + // GRIDWIDTH = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) + // + // var gridForm = html` + //
+ //
Grid
+ //
+ // + // + //
+ //
+ // ` + // + // DOM.each(gridForm, '#grid-width-input', (input)=>{ + // DOM.addEventListener(input, 'keyup mouseup change mousewheel', (e)=>{ + // setTimeout(()=>{ + // var v = Math.max(Math.min(parseInt(input.value), 100), 1) + // if (isNaN(v)) return + // input.value = v + // GRIDWIDTH = v + // document.body.classList.toggle('no-grid', GRIDWIDTH == 1) + // document.documentElement.style.setProperty('--grid-width', GRIDWIDTH) + // }) + // }) + // }) + // + // DOM.get(document, '.editor-menu')[0].appendChild(gridForm) + this.widgetTree.updateTree(this.selectedWidgets) - GRIDWIDTH = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) - - var gridForm = html` -
-
Grid
-
- - -
-
- ` - - DOM.each(gridForm, '#grid-width-input', (input)=>{ - DOM.addEventListener(input, 'keyup mouseup change mousewheel', (e)=>{ - setTimeout(()=>{ - var v = Math.max(Math.min(parseInt(input.value), 100), 1) - if (isNaN(v)) return - input.value = v - GRIDWIDTH = v - document.body.classList.toggle('no-grid', GRIDWIDTH == 1) - document.documentElement.style.setProperty('--grid-width', GRIDWIDTH) - }) - }) - }) - - DOM.get(document, '.editor-menu')[0].appendChild(gridForm) + sidepanel.left.enable() + sidepanel.right.enable() keyboardJS.setContext('editing') @@ -357,7 +398,6 @@ var Editor = class Editor { this.unselect() this.selectedWidgets = [] - DOM.get('.editor-root')[0].classList.add('disabled') DOM.get('.disable-editor')[0].classList.add('on') DOM.get('.enable-editor')[0].classList.remove('on') document.body.classList.remove('editor-enabled') @@ -369,6 +409,11 @@ var Editor = class Editor { document.body.removeEventListener('mousemove', this.mouveMoveHandler) + sidepanel.left.disable() + sidepanel.right.disable() + this.widgetTree.clear() + this.inspector.clear() + this.selectarea.disable() } @@ -376,16 +421,14 @@ var Editor = class Editor { unselect() { - DOM.get('#editor')[0].innerHTML = '' - - this.form.innerHTML = '' + this.widgetDragResize.clear() + this.inspector.clear() DOM.each(document, '.editing', (element)=>{ element.classList.remove('editing') }) - $('.widget.ui-resizable').resizable('destroy') - $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove() + this.widgetTree.select([]) } @@ -428,81 +471,18 @@ var Editor = class Editor { if (this.selectedWidgets.length > 0 && !options.fromLasso) { - this.createEditForm() + this.inspector.inspect(this.selectedWidgets) this.createSelectionBlock() + } else { + + this.inspector.clear() + } } - createEditForm(){ - - var widget = this.selectedWidgets[0], - props = this.defaults[widget.props.type], - multi = this.selectedWidgets.length > 1 - - this.form.appendChild(html` -
- - Widget${multi ? 's' : ''}: ${multi ? this.selectedWidgets.length + ' selected': widget.getProp('id')} - -
- `) - - let category - - for (let propName in props) { - - let field, - shared = true - - for (var w of this.selectedWidgets) { - if (this.defaults[w.props.type][propName] === undefined) { - shared = false - } - } - - if (!shared) continue - - if (propName.indexOf('_') === 0 && propName !== '_props') { - - if (category) this.form.appendChild(category) - category = html`
` - - field = html`
${props[propName]}
` - - } else if (widget.props[propName] === undefined) { - - continue - - } else { - - if (widget.parent !== widgetManager && widget.parent.getProp('type') === 'strip') { - // special case for widgets in strips - if (propName === 'top' || propName === 'left' || propName === (widget.parent.getProp('horizontal') ? 'height' : 'width')) continue - } - - field = editField(this, widget, propName, props[propName]) - if (!field) continue - - } - - if (category) { - category.appendChild(field) - } else { - this.form.appendChild(field) - } - - } - - if (category) this.form.appendChild(category) - - this.wrapper.appendChild(this.form) - DOM.get('#editor')[0].appendChild(this.wrapper) - - } - createSelectionBlock(){ for (let widget of this.selectedWidgets) { @@ -510,59 +490,8 @@ var Editor = class Editor { item.classList.add('editing') }) } - - var widget = this.selectedWidgets[0] - - if (widget.props.height !== undefined || widget.props.width !== undefined) { - - let $container = $(widget.container) - $container.resizable({ - handles: 's, e, se', - helper: 'ui-helper', - resize: (event, ui)=>{ - ui.size.height = Math.round(ui.size.height / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH * PXSCALE - ui.size.width = Math.round(ui.size.width / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH * PXSCALE - }, - stop: (event, ui)=>{ - - var deltaH = ui.size.height - ui.originalSize.height, - deltaW = ui.size.width - ui.originalSize.width - - this.resizeWidget(deltaW, deltaH, ui) - - }, - grid: [GRIDWIDTH * PXSCALE, GRIDWIDTH * PXSCALE] - }) - - } - - if (widget.props.top !== undefined && widget.parent.getProp('type') !== 'strip') { - let $container = $(widget.container) - $container.draggable({ - cursor:'-webkit-grabbing', - drag: (event, ui)=>{ - ui.position.top = Math.round(ui.position.top / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH * PXSCALE - ui.position.left = Math.round(ui.position.left / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH * PXSCALE - }, - stop: (event, ui)=>{ - event.preventDefault() - - var deltaX = (ui.helper.position().left + $container.parent().scrollLeft()) / PXSCALE - widget.container.offsetLeft / PXSCALE, - deltaY = (ui.helper.position().top + $container.parent().scrollTop()) / PXSCALE - widget.container.offsetTop / PXSCALE - - this.moveWidget(deltaX, deltaY) - - ui.helper.remove() - }, - handle:'.ui-draggable-handle, > .label', - grid: [GRIDWIDTH * PXSCALE, GRIDWIDTH * PXSCALE], - helper:()=>{ - return $('
').css({height:$container.outerHeight(),width:$container.outerWidth()}) - } - }).append('
') - - } - + this.widgetTree.select(this.selectedWidgets) + this.widgetDragResize.create(this.selectedWidgets) } @@ -717,10 +646,12 @@ var Editor = class Editor { } } - this.select(updateWidget(parent, { - preventSelect: true, - removedIndexes - })) + var container = updateWidget(parent, {preventSelect: true, removedIndexes}) + if (container.children.length) { + this.select(container.children[Math.min(index.pop(), container.children.length - 1)]) + } else { + this.select(container) + } this.pushHistory({removedIndexes}) } @@ -781,13 +712,13 @@ var Editor = class Editor { for (var w of this.selectedWidgets) { - var newTop = parseInt(w.container.offsetTop) / PXSCALE + deltaY + var newTop = Math.max(parseInt(w.container.offsetTop) / PXSCALE + deltaY, 0) if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) { w.props.top = (100 * PXSCALE * newTop / w.container.parentNode.offsetHeight).toFixed(2) + '%' } else { w.props.top = newTop } - var newLeft = parseInt(w.container.offsetLeft) / PXSCALE + deltaX + var newLeft = Math.max(parseInt(w.container.offsetLeft) / PXSCALE + deltaX, 0) if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) { w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2) + '%' } else { @@ -890,6 +821,9 @@ var Editor = class Editor { if (this.selectedWidgets[0] && !widgetManager.widgets[this.selectedWidgets[0].hash]) { this.unselect() this.selectedWidgets = [] + this.inspector.clear() + } else if (this.selectedWidgets[0]) { + this.widgetDragResize.create(this.selectedWidgets) } } diff --git a/src/client/app/events/double-click.js b/src/client/app/events/double-click.js new file mode 100644 index 00000000..cba97f49 --- /dev/null +++ b/src/client/app/events/double-click.js @@ -0,0 +1,43 @@ +module.exports = (element, callback, options={})=>{ + + var lastTapTime = 0, + lastTapX, + lastTapY + + element.addEventListener(options.click ? 'click' : 'fast-click', (event)=>{ + + if (event.capturedByEditor && !options.ignoreEditorCapture) return + + var tapTime = Date.now(), + tapLength = tapTime - lastTapTime, + eventData = options.click ? event : event.detail + + if ( + + tapLength < DOUBLE_TAP_TIME && + Math.abs(lastTapX - eventData.pageX) < 20 && + Math.abs(lastTapY - eventData.pageY) < 20 && + (!options.click || event.pageX !== 0) // prevent fake click emitted with keyboard focus events + + ) { + + // execute callback at next cycle to ensure draginit events are resolved first + setTimeout(()=>{ + callback(event.detail) + }, 0) + lastTapTime = 0 + + // prevent touchend + if (!options.click) event.detail.preventOriginalEvent = true + + } else { + + lastTapTime = tapTime + lastTapX = eventData.pageX + lastTapY = eventData.pageY + + } + + }) + +} diff --git a/src/client/app/globals.js b/src/client/app/globals.js index 9c675325..5ad08c3e 100644 --- a/src/client/app/globals.js +++ b/src/client/app/globals.js @@ -33,9 +33,4 @@ window.JSON.parseFlex = require('json5').parse window.DOM = require('./dom') -window.$ = require('jquery/dist/jquery.slim.min.js') - -require('../libs/jquery.ui') -require('../libs/jquery.touch') - require('cardinal-spline-js/curve.min.js') diff --git a/src/client/app/ipc/callbacks.js b/src/client/app/ipc/callbacks.js index 36914248..2d823246 100644 --- a/src/client/app/ipc/callbacks.js +++ b/src/client/app/ipc/callbacks.js @@ -93,11 +93,11 @@ module.exports = { setTimeout(()=>{ var root = widgetManager.getWidgetById('root')[0] - if (root) root.reCreateWidget() - },100) + if (root) root.onPropChanged('color') + },200) - GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue('--grid-width') + GRIDWIDTH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) }, readOnly: function(){ @@ -132,8 +132,6 @@ module.exports = { history: editor.history, historyState: editor.historyState, editorEnabled: editor.enabled, - sidepanelOpened: document.getElementById('sidepanel').classList.contains('sidepanel-open'), - traversing: document.getElementById('container')._traversing }) // reload page and hold backup id diff --git a/src/client/app/locales/en.js b/src/client/app/locales/en.js index b0e68112..3ef064de 100644 --- a/src/client/app/locales/en.js +++ b/src/client/app/locales/en.js @@ -12,7 +12,6 @@ module.exports = { // editor context-menu - editor_editparent: 'Edit parent', editor_copy: 'Copy', editor_cut: 'Cut', editor_wrap: 'Wrap in', diff --git a/src/client/app/locales/fr.js b/src/client/app/locales/fr.js index 438f15ea..70d3924e 100644 --- a/src/client/app/locales/fr.js +++ b/src/client/app/locales/fr.js @@ -11,15 +11,14 @@ module.exports = { editor_export: 'Exporter', // editor context-menu - editor_editparent: 'Éditer parent', editor_copy: 'Copier', editor_cut: 'Couper', editor_wrap: 'Grouper dans', editor_paste: 'Coller', editor_pasteindent: 'ID + 1', editor_clone: 'Clone', - editor_addwidget: 'Nouveau widget', - editor_addtab: 'Nouvel onglet', + editor_addwidget: 'Ajouter widget', + editor_addtab: 'Ajouter onglet', editor_delete: 'Supprimer', editor_click_for_help: 'Cliquer sur le nom de la propriété pour afficher l\'aide', diff --git a/src/client/app/locales/ru.js b/src/client/app/locales/ru.js index 13152b9e..11bfa9b6 100644 --- a/src/client/app/locales/ru.js +++ b/src/client/app/locales/ru.js @@ -11,7 +11,6 @@ module.exports = { // @https://github.com/suhr editor_export: 'Export', // editor context-menu - editor_editparent: 'К родителю', editor_copy: 'Копировать', editor_cut: 'Вырезать', editor_wrap: 'Обернуть в', diff --git a/src/client/app/managers/session.js b/src/client/app/managers/session.js index 084c2255..36d2f58d 100644 --- a/src/client/app/managers/session.js +++ b/src/client/app/managers/session.js @@ -31,7 +31,7 @@ var SessionManager = class SessionManager { this.lock = true - var container = DOM.get('#container')[0], + var container = DOM.get('#osc-container')[0], loader = loading(locales('loading_session')) setTimeout(()=>{ @@ -49,7 +49,7 @@ var SessionManager = class SessionManager { parser.reset() parser.parse({ data: this.session, - parentNode: DOM.get('#container')[0] + parentNode: DOM.get('#osc-container')[0] }) editor.clearHistory() diff --git a/src/client/app/ui/context-menu.js b/src/client/app/ui/context-menu.js index a155fe3f..48c9310a 100644 --- a/src/client/app/ui/context-menu.js +++ b/src/client/app/ui/context-menu.js @@ -6,7 +6,7 @@ class ContextMenu { constructor(){ this.menu = null - this.root = document.body + this.root = DOM.get('osc-workspace')[0] this.clickHandler = (e)=>{ if (this.menu && !this.menu.contains(e.target)) this.close() } @@ -116,12 +116,12 @@ class ContextMenu { if (width + position.left > totalWidth) { menu.style.right = parent ? '100%' : '0' menu.style.left = 'auto' - menu.style.marginRight = '2rem' + menu.style.marginRight = '1rem' } if (height + position.top > totalHeight) { menu.style.top = 'auto' - menu.style.bottom = '2rem' + menu.style.bottom = '0rem' } } diff --git a/src/client/app/ui/init.js b/src/client/app/ui/init.js index 55970d82..690e4402 100644 --- a/src/client/app/ui/init.js +++ b/src/client/app/ui/init.js @@ -1,6 +1,16 @@ require('./zoom') require('./lobby').create() -require('./sidepanel') +// require('./sidepanel') require('../events/click') require('./ios') require('./notifications') +require('./ui-workspace') +// require('./ui-sidepanel') + +var UiModal = require('./ui-modal') + +module.exports = { + + uiModal: new UiModal({selector: 'osc-modal-container'}) + +} diff --git a/src/client/app/ui/scrollbar-color.js b/src/client/app/ui/scrollbar-color.js new file mode 100644 index 00000000..1ffa0da2 --- /dev/null +++ b/src/client/app/ui/scrollbar-color.js @@ -0,0 +1,19 @@ +var chroma = require('chroma-js') + +module.exports = (container)=>{ + + setTimeout(()=>{ + + var computedStyle = window.getComputedStyle(container), + color = computedStyle.getPropertyValue('--color-fill').trim(), + alpha = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar')), + alphaOn = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar-on')) + + if (color) { + container.style.setProperty('--color-scrollbar', chroma(color).alpha(alpha).css()) + container.style.setProperty('--color-scrollbar-on', chroma(color).alpha(alphaOn).css()) + } + + }) + +} diff --git a/src/client/app/ui/sidepanel.js b/src/client/app/ui/sidepanel.js index 79dd07a1..6f0f36df 100644 --- a/src/client/app/ui/sidepanel.js +++ b/src/client/app/ui/sidepanel.js @@ -277,7 +277,7 @@ if (fullscreen.isEnabled) { } // open / close / toggle - +/* var sidepaneLock = false function sidepanelOpen() { @@ -350,9 +350,11 @@ document.addEventListener('keydown', function(e){ // Sidepanel resize + + var sidepanelWidth -$('#sidepanel-handle').draggable({ +$('osc-panel-container sidepanel-handle').draggable({ cursor:'col-resize', start: ()=>{ sidepanelWidth = parseInt(sidepanelContainer.offsetWidth) / PXSCALE @@ -377,3 +379,10 @@ module.exports = { close: sidepanelClose, toggle: sidepanelToggle } +*/ + +module.exports = { + open: ()=>{}, + close: ()=>{}, + toggle: ()=>{} +} diff --git a/src/client/app/ui/ui-dragresize.js b/src/client/app/ui/ui-dragresize.js new file mode 100644 index 00000000..b4680f25 --- /dev/null +++ b/src/client/app/ui/ui-dragresize.js @@ -0,0 +1,190 @@ +var UiWidget = require('./ui-widget'), + html = require('nanohtml'), + Tab, Root, Modal + +class UiDragResize extends UiWidget { + + constructor(options) { + + Tab = require('../widgets/containers/tab') + Root = require('../widgets/containers/root') + Modal = require('../widgets/containers/modal') + + super(options) + + this.container = html` +
+
+
+
+
+
+
+
+ ` + + + this.initLeft = 0 + this.initTop = 0 + this.initWidth = 0 + this.initHeight = 0 + + this.left = 0 + this.top = 0 + this.width = 0 + this.height = 0 + + this.mounted = false + + this.handles = DOM.get(this.container, '.handle') + this.dragging = null + + this.on('draginit', (event)=>{ + + var node = event.target + if (!this.handles.includes(node)) return + + this.initLeft = this.left + this.initTop = this.top + this.initWidth = this.width + this.initHeight = this.height + + this.container.classList.add('dragging') + this.dragging = node.getAttribute('data-action').split(',') + event.traversing = false // stop traversing here + + }, {element: this.container}) + + this.on('drag', (event)=>{ + + if (!this.dragging) return + + for (var k of this.dragging) { + + switch (k) { + case 'left': + case 'width': + this[k] += event.movementX / PXSCALE + break + case 'top': + case 'height': + this[k] += event.movementY / PXSCALE + break + + } + + } + + this.updateCss(true) + + + }, {element: this.container}) + + + this.on('dragend', (event)=>{ + + this.container.classList.remove('dragging') + this.left = Math.max(0, this.left) + this.top = Math.max(0, this.top) + this.trigger(this.dragging.indexOf('left') > -1 ? 'move' : 'resize', this) + this.dragging = null + + }, {element: this.container}) + + + // handles appear on top of modal widgets + // very special case fix here... + this.watchedModalWidget = null + this.checkModalState = (e)=>{ + if (e.widget !== this.watchedModalWidget) return + console.log(e.widget.value) + this.container.style.display = e.widget.value ? 'none' : '' + } + + } + + clear() { + + if (!this.mounted) return + + if (this.watchedModalWidget) { + // reset modal widget fix + this.watchedModalWidget.off('change', this.checkModalState) + this.watchedModalWidget = null + this.container.style.display = '' + } + + this.container.parentNode.removeChild(this.container) + this.mounted = false + + + } + + create(widgets) { + + this.clear() + + var widget = widgets[0] + + if (widget instanceof Modal) { + // modal widget fix + this.watchedModalWidget = widget + widget.on('change', this.checkModalState) + if (widget.getValue()) this.container.style.display = 'none' + } + + if ( + widget instanceof Tab || + widget instanceof Root || + !widget.getProp('visible') + ) return + + var handlesVisibility = [ + !(widget instanceof Tab) && widget.parent.getProp('layout') === 'default', // nw + widget.parent.getProp('layout') !== 'vertical', // e + widget.parent.getProp('layout') !== 'horizontal', // s + ] + handlesVisibility.push(handlesVisibility[1] && handlesVisibility[2]) // se + + for (var i in handlesVisibility) { + this.handles[i].style.display = handlesVisibility[i] ? '' : 'none' + } + + + + var parent = widget.parentNode, + lefts = widgets.map(w => w.container.offsetLeft), + tops = widgets.map(w => w.container.offsetTop), + rights = widgets.map(w => w.container.offsetLeft + w.container.offsetWidth), + bottoms = widgets.map(w => w.container.offsetTop + w.container.offsetHeight) + + this.left = Math.min(...lefts) / PXSCALE + this.top = Math.min(...tops) / PXSCALE + this.width = (Math.max(...rights) - Math.min(...lefts)) / PXSCALE + this.height = (Math.max(...bottoms) - Math.min(...tops)) / PXSCALE + + this.updateCss() + + parent.appendChild(this.container) + this.mounted = true + + } + + updateCss(grid) { + + for (var k of ['top', 'left', 'width', 'height']) { + + var val = this[k] + + if (k === 'width' || k === 'height') val = Math.max(10 * PXSCALE, val) + if (grid) val = Math.round(val / GRIDWIDTH) * GRIDWIDTH + + this.container.style.setProperty('--' + k, val + 'rem') + + } + + } + +} + +module.exports = UiDragResize diff --git a/src/client/app/ui/ui-inspector-field.js b/src/client/app/ui/ui-inspector-field.js new file mode 100644 index 00000000..53f72559 --- /dev/null +++ b/src/client/app/ui/ui-inspector-field.js @@ -0,0 +1,120 @@ +var UiWidget = require('./ui-widget'), + {categories} = require('../widgets/'), + html = require('nanohtml'), + raw = require('nanohtml/raw'), + {icon, Popup} = require('../ui/utils') + + +class UiInspectorField extends UiWidget { + + constructor(options) { + + super(options) + + this.name = options.name + this.widget = options.widget + this.value = options.value + this.default = options.default + + this.container = html`` + this.label = this.container.appendChild(html``) + + if (this.name === 'type') this.createTypeSelect() + else this.createInput() + + } + + createTypeSelect() { + + + if (this.widget.props.type == 'tab' || this.widget.props.type == 'root') { + this.container.appendChild(html` + + `) + return + } + + this.createInput() + + var select = html`` + + + this.container.appendChild(input) + + + if (this.default.choices) { + + let wrapper = html``, + select = wrapper.appendChild(html`` + + this.container.appendChild(picker) + + } + + if (this.default.type.includes('boolean')) { + + let toggle = html` + + ${raw(icon('check'))} + + ` + + toggle.addEventListener('click', ()=>{ + if (this.name === 'label' && !this.widget.getProp(this.name) === true) { + // special case + input.value = 'auto' + } else { + input.value = !this.widget.getProp(this.name) + } + DOM.dispatchEvent(input, 'change') + }) + + + this.container.appendChild(toggle) + + } + + + } + +} + +module.exports = UiInspectorField diff --git a/src/client/app/ui/ui-inspector.js b/src/client/app/ui/ui-inspector.js new file mode 100644 index 00000000..22262e6e --- /dev/null +++ b/src/client/app/ui/ui-inspector.js @@ -0,0 +1,188 @@ +var UiWidget = require('./ui-widget'), + UiInspectorField = require('./ui-inspector-field'), + morph = require('nanomorph'), + {widgets, defaults} = require('../widgets/'), + {deepCopy} = require('../utils'), + html = require('nanohtml') + +class UiInspector extends UiWidget { + + constructor(options) { + + super(options) + + this.mounted = false + + this.foldedCategories = [] + + this.container.addEventListener('fast-click', (e)=>{ + + if (e.target.classList.contains('category-header')) { + var name = e.target.getAttribute('data-name'), + foldedIndex = this.foldedCategories.indexOf(name) + e.target.parentNode.classList.toggle('folded', foldedIndex < 0) + if (foldedIndex > -1) { + this.foldedCategories.splice(foldedIndex, 1) + } else { + this.foldedCategories.push(name) + } + + } + + }) + + this.container.addEventListener('change', this.onChange.bind(this)) + this.container.addEventListener('keydown', this.onKeydown.bind(this)) + this.container.addEventListener('input', this.textAutoHeight.bind(this)) + this.container.addEventListener('focus', this.textAutoHeight.bind(this)) + + + this.lock = false + + } + + clear() { + + this.container.innerHTML = '' + this.mounted = false + + } + + inspect(widgets) { + + var content = html`
` + + var widget = widgets[0], + props = defaults[widget.props.type], + multi = widgets.length > 1 + + // this.form.appendChild(html` + //
+ // + // Widget${multi ? 's' : ''}: ${multi ? this.selectedWidgets.length + ' selected': widget.getProp('id')} + // + //
+ // `) + + let category + + for (let propName in props) { + + if (propName === 'tabs' || propName === 'widgets') continue + + let field, + shared = true + + for (var w of widgets) { + if (defaults[w.props.type][propName] === undefined) { + shared = false + } + } + + if (!shared) continue + + if (propName.indexOf('_') === 0 && propName !== '_props') { + + if (category) content.appendChild(category) + + category = html`` + + field = html`
${props[propName]}
` + + } else if (widget.props[propName] === undefined) { + + continue + + } else { + + // if (widget.parent !== widgetManager && widget.parent.getProp('type') === 'strip') { + // // special case for widgets in strips + // if (propName === 'top' || propName === 'left' || propName === (widget.parent.getProp('horizontal') ? 'height' : 'width')) continue + // } + + field = new UiInspectorField({ + parent: this, + widget: widget, + name: propName, + value: widget.props[propName], + default: defaults[w.props.type][propName] + }).container + if (!field) continue + + } + if (category) { + category.appendChild(field) + } else { + content.appendChild(field) + } + + } + + if (category) content.appendChild(category) + + + if (this.mounted) { + morph(this.container.firstChild, content) + } else { + this.container.appendChild(content) + } + + this.mounted = true + + } + + onChange(event) { + + if (this.lock) return + + this.lock = true + + var input = event.target + + input.blur() + + var v + var str = input.value.replace(/[‟”]/g, '"').replace(/[‘’]/g, '\'') // convert invalid quote characters + + try { + v = JSON.parseFlex(str) + if (typeof v === 'string') { + // escape backslashes in simple strings only + v = JSON.parseFlex(str.replace(/\\/g, '__BACKSLASH__')) + v = v.replace(/__BACKSLASH__/g, '\\') + } + } catch(err) { + v = str + } + + this.trigger('update', { + propName: input.name, + value: v + }) + + this.lock = false + } + + onKeydown(event) { + + var input = event.target + + if (event.keyCode === 13 && !event.shiftKey) { + event.preventDefault() + DOM.dispatchEvent(input, 'change') + } + + } + + textAutoHeight(event) { + + var input = event.target + + input.setAttribute('rows',0) + input.setAttribute('rows', input.value.split('\n').length) + + } + +} + +module.exports = UiInspector diff --git a/src/client/app/ui/ui-modal.js b/src/client/app/ui/ui-modal.js new file mode 100644 index 00000000..9af18fe0 --- /dev/null +++ b/src/client/app/ui/ui-modal.js @@ -0,0 +1,97 @@ +var UiWidget = require('./ui-widget'), + html = require('nanohtml'), + raw = require('nanohtml/raw'), + {iconify} = require('../ui/utils') + + +class UiModalWindow { + + constructor(options) { + + this.container = html` + + + ${options.content} + + + ` + + if (options.label) { + this.container.appendChild(html``) + } + + this.opened = false + } + + open(z) { + + this.opened = true + this.container.classList.add('on') + this.container.style.zIndex = z + + } + + close() { + + this.opened = false + this.container.classList.remove('on') + + } + +} + +class UiModal extends UiWidget { + + constructor(options) { + + super(options) + + this.modals = {} + this.openedModals = [] + + } + + create(id, options) { + + if (this.modals[id]) this.destroy(id) + + this.modals[id] = new UiModalWindow(options) + this.container.appendChild(this.modals[id].container) + + + } + + destroy(id) { + + if (!this.modals[id]) return + + this.close(id) + this.container.removeChild(this.modals[id].container) + delete this.modals[id] + } + + open(id) { + + if (!this.modals[id]) return + if (this.openedModals.includes(id)) this.close(id) + + this.openedModals.push(id) + + this.modals[id].open(this.openedModals.length) + + } + + close(id) { + + if (!this.modals[id] || !this.openedModals.includes(id)) return + + this.openedModals.splice(this.openedModals.indexOf(id), 1) + this.modals[id].close() + + } + + + +} + +module.exports = UiModal diff --git a/src/client/app/editor/select-area.js b/src/client/app/ui/ui-selectarea.js similarity index 95% rename from src/client/app/editor/select-area.js rename to src/client/app/ui/ui-selectarea.js index cfa023f2..a96bdf18 100644 --- a/src/client/app/editor/select-area.js +++ b/src/client/app/ui/ui-selectarea.js @@ -1,6 +1,6 @@ var html = require('nanohtml') -class SelectArea { +class UiSelectArea { constructor(selector, callback){ @@ -13,8 +13,7 @@ class SelectArea { this.rectSize = [0, 0] this.elements = [] - this.rect = html`` - document.body.appendChild(this.rect) + this.rect = document.body.appendChild(html``) this.selector = selector this.callback = callback @@ -126,4 +125,4 @@ class SelectArea { } -module.exports = SelectArea +module.exports = UiSelectArea diff --git a/src/client/app/ui/ui-sidepanel.js b/src/client/app/ui/ui-sidepanel.js new file mode 100644 index 00000000..f0ef4db1 --- /dev/null +++ b/src/client/app/ui/ui-sidepanel.js @@ -0,0 +1,112 @@ +var UiWidget = require('./ui-widget') + +class UiSidePanel extends UiWidget { + + constructor(options) { + + super(options) + + this.resizeDirection = this.container.classList.contains('left') ? 1 : -1 + this.resizeHandle = DOM.get(this.container, '.resize-handle')[0] + this.toggleButton = DOM.get(this.container, '.toggle-button')[0] + this.content = DOM.get(this.container, 'osc-panel-inner')[0] + + this.minWidth = 250 + this.width = 250 + + this.disabled = true + this.minimized = false + this.init = false + + this.on('drag', (event)=>{ + + this.width += this.resizeDirection * event.movementX / PXSCALE + this.container.style.width = this.width + 'rem' + + }, {element: this.resizeHandle}) + + this.on('dragend', (event)=>{ + + this.width = parseInt(this.container.offsetWidth) / PXSCALE + DOM.dispatchEvent(window, 'resize') + + }, {element: this.resizeHandle}) + + this.toggleButton.addEventListener('click', ()=>{ + + if (this.disabled) return + + if (this.minimized) this.restore() + else this.minimize() + + }) + + } + + enable() { + + this.container.classList.remove('disabled') + this.disabled = false + + if (!this.minimized) this.open() + + } + + disable() { + + this.container.classList.add('disabled') + this.disabled = false + + this.close() + + } + + minimize() { + + if (this.minimized) return + + this.minimized = true + this.close() + + + } + + restore() { + + if (!this.minimized) return + + this.minimized = false + this.open() + + + } + + open() { + + this.container.style.width = this.width + 'rem' + this.container.style.minWidth = this.minWidth + 'rem' + this.container.classList.remove('minimized') + + DOM.dispatchEvent(window, 'resize') + + } + + close() { + + this.container.style.width = 0 + this.container.style.minWidth = 0 + this.container.classList.add('minimized') + + DOM.dispatchEvent(window, 'resize') + + } + +} + +var leftUiSidePanel = new UiSidePanel({selector: 'osc-panel-container.right'}), + rightUiSidePanel = new UiSidePanel({selector: 'osc-panel-container.left'}) + +module.exports = { + left: leftUiSidePanel, + right: rightUiSidePanel +} diff --git a/src/client/app/ui/ui-tree.js b/src/client/app/ui/ui-tree.js new file mode 100644 index 00000000..57c3d4e9 --- /dev/null +++ b/src/client/app/ui/ui-tree.js @@ -0,0 +1,159 @@ +var UiWidget = require('./ui-widget'), + html = require('nanohtml'), + doubleClick = require('../events/double-click'), + Sortable = require('sortablejs'), + morph = require('nanomorph'), + Panel, widgetManager + +class UiTree extends UiWidget { + + constructor(options) { + + Panel = require('../widgets/containers/panel') + widgetManager = require('../managers/widgets') + + super(options) + + this.mounted = false + this.list = this.container.appendChild(html`
    ` + + + this.expanded = {root: true} + this.container.addEventListener('fast-click', (event)=>{ + + var node = event.target + if (node.classList.contains('toggle')) { + var exp = node.parentNode.classList.toggle('expanded') + if (exp) { + this.expanded[node.parentNode.getAttribute('data-id')] = true + } else { + delete this.expanded[node.parentNode.getAttribute('data-id')] + } + } + + + }) + + doubleClick(this.container, (event)=>{ + + var node = event.target + if (node.classList.contains('container')) { + var exp = node.classList.toggle('expanded') + if (exp) { + this.expanded[node.getAttribute('data-id')] = true + } else { + delete this.expanded[node.getAttribute('data-id')] + } + } + + }, {ignoreEditorCapture: true}) + + + this.sortables = [] + this.sortCallback = (event)=>{ + var widget = widgetManager.widgets[event.to.parentNode.getAttribute('data-widget')] + if (!widget) return + this.trigger('sorted', { + widget: widget, + oldIndex: event.oldIndex, + newIndex: event.newIndex + }) + } + + } + + clear() { + + this.list.innerHTML = '' + this.mounted = false + for (var s of this.sortables) { + s.destroy() + } + this.sortables = [] + + } + + updateTree(selectedWidgets) { + + for (var s of this.sortables) { + s.destroy() + } + this.sortables = [] + + var content = this.parseWidgets(widgetManager.getWidgetById('root')[0], selectedWidgets) + + // morph DOM + if (this.mounted) { + morph(this.list.firstChild, content) + } else { + this.list.appendChild(content) + } + + + // sortable lists + DOM.each(this.list, 'ol', (el)=>{ + + this.sortables.push(new Sortable(el, { + group: { + name: 'group-' + el.parentNode.getAttribute('data-widget'), + pull: false, + put: false + }, + onEnd: this.sortCallback, + setData: (dataTransfer)=>{ + dataTransfer.setDragImage(this.dragDummy, 0, 0) + }, + })) + }) + + this.mounted = true + + + } + + select() { + + // hint selection in folded containers + DOM.each(this.list, '.contains-editing', (element)=>{ + element.classList.remove('contains-editing') + }) + var selected = DOM.get(this.list, '.editing')[0] + if (selected) { + var node = selected.parentNode + while (node && node !== this.list) { + if (node.classList.contains('container')) { + node.classList.add('contains-editing') + } + node = node.parentNode + } + } + } + + parseWidgets(widget, selectedWidgets, depth = 1) { + + var selected = selectedWidgets.includes(widget), + id = widget.getProp('id'), + node = html`
  1. + ${id}
  2. ` + + if (widget instanceof Panel) { + node.insertBefore(html``, node.childNodes[0]) + node.classList.add('container') + if (this.expanded[id]) node.classList.add('expanded') + var sublist = node.appendChild(html`
      `) + for (let child of widget.children) { + sublist.appendChild(this.parseWidgets(child, selectedWidgets, depth)) + } + + } + + return node + + } + +} + +module.exports = UiTree diff --git a/src/client/app/ui/ui-widget.js b/src/client/app/ui/ui-widget.js new file mode 100644 index 00000000..5192fd27 --- /dev/null +++ b/src/client/app/ui/ui-widget.js @@ -0,0 +1,16 @@ +var EventEmitter = require('../events/event-emitter') + +class UiWidget extends EventEmitter { + + constructor(options) { + + super() + + this.container = options.selector ? DOM.get(options.selector)[0] : options.element + this.parent = options.parent + + } + +} + +module.exports = UiWidget diff --git a/src/client/app/ui/ui-workspace.js b/src/client/app/ui/ui-workspace.js new file mode 100644 index 00000000..9e4cee53 --- /dev/null +++ b/src/client/app/ui/ui-workspace.js @@ -0,0 +1,16 @@ +var UiWidget = require('./ui-widget'), + setScrollbarColor = require('./scrollbar-color') + +class UiWorksapce extends UiWidget { + + constructor(options) { + + super(options) + + setScrollbarColor(this.container) + + } + +} + +module.exports = new UiWorksapce({selector: 'osc-workspace'}) diff --git a/src/client/app/widgets/buttons/menu.js b/src/client/app/widgets/buttons/menu.js index a7e52e31..5aab958b 100644 --- a/src/client/app/widgets/buttons/menu.js +++ b/src/client/app/widgets/buttons/menu.js @@ -19,23 +19,18 @@ class Menu extends Widget { _menu:'menu', size: {type: 'number|array', value: 200, help: [ - '- If `circular` is `true`: diameter (in px)', - '- If `circular` is `false`: square size or `[width, height]` array', + '- If `layout` is `circular`: diameter (in px)', + '- Else: square size or `[width, height]` array', ]}, - circular: {type: 'boolean', value: true, help: [ - 'Defines whether the menu should be rendered in a circle or in a box' + layout: {type: 'string', value: 'circular', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [ + 'Defines whether the menu\'s layout should be rendered in a circle or in a box' ]}, - vertical: {type: 'boolean|number', value: false, help: [ - 'If `circular` is `false`, set this to `true` for vertical layout', - 'Ignored when `grid` is `true`' - ]}, - grid: {type: 'boolean|number', value: false, help: [ - '- If `circular` is `false`, set this to `true` for grid layout', - '- Can be a `number` to define the number of columns' + columns: {type: 'number', value: '', help: [ + 'If `layout` is `grid`, defines the number of columns' ]}, toggle: {type: 'boolean', value: false, help: 'Set to `true` to make the menu stay opened after mouse/touch release'}, doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the menu require a double tap to be opened instead of a single tap'}, - values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ + values: {type: 'array|object', value: [1, 2, 3], help: [ '`Array` of possible values to switch between : `[1,2,3]`', '`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept', ]}, @@ -50,12 +45,19 @@ class Menu extends Widget { constructor(options) { - super({...options, html: html`
      `}) + super({...options, html: html` + + - this.menu = this.widget.appendChild(html``) + `}) + + this.menu = html`` this.opened = false + this.values = [] + this.stringValues = [] + this.selected = -1 this.value = undefined @@ -63,7 +65,6 @@ class Menu extends Widget { this.parentScroll = [0,0] - this.opened = false if (this.getProp('doubleTap')) { @@ -121,7 +122,6 @@ class Menu extends Widget { } else { - this.menu.classList.add('norelease') this.toggleCloseHandler = (e)=>{ if (!this.opened || this.menu.contains(e.target)) return this.close() @@ -137,23 +137,22 @@ class Menu extends Widget { open(e) { + if (this.opened) return + this.opened = true - var off = this.scrollOffset() - this.menu.style.setProperty('--x', (e.offsetX - off[0]) / PXSCALE + 'rem') - this.menu.style.setProperty('--y', (e.offsetY - off[1]) / PXSCALE + 'rem') - this.menu.classList.add('show') - this.widget.classList.add('on') this.container.classList.add('on') + this.widget.appendChild(this.menu) } close() { + if (!this.opened) return + this.opened = false - this.menu.classList.remove('show') DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')}) this.container.classList.remove('on') - this.widget.classList.remove('on') + this.widget.removeChild(this.menu) } @@ -187,7 +186,7 @@ class Menu extends Widget { var nval = 0, i = 0, - circular = this.getProp('circular'), + circular = this.getProp('layout') === 'circular', values = this.getProp('values'), weights = this.getProp('weights'), totalWeight @@ -197,7 +196,7 @@ class Menu extends Widget { } this.values = [] - this.widget.removeChild(this.menu) + if (this.opened) this.widget.removeChild(this.menu) this.menu.innerHTML = '' @@ -211,6 +210,11 @@ class Menu extends Widget { let angle = Math.min(360 * weights[i] / totalWeight, 120), skew = 90 - angle this.values.push(values[k]) + if (typeof values[k] == 'object') { + this.stringValues.push(JSON.stringify(values[k])) + } else { + this.stringValues.push(0) + } this.menu.appendChild(html`
      ${raw(iconify(parseFloat(k) != k ? k : values[k]))}
      @@ -224,20 +228,18 @@ class Menu extends Widget { this.setValue(this.value) - this.widget.appendChild(this.menu) - - if (!this.getProp('circular') && this.getProp('grid')) { - this.container.style.setProperty('--grid-columns', this.getProp('grid') === true ? parseInt(nval / 2) : parseInt(this.getProp('grid'))) - } + if (this.opened) this.widget.appendChild(this.menu) } setMode() { - this.container.classList.toggle('box', !this.getProp('circular')) - this.container.classList.toggle('circular', this.getProp('circular')) - this.container.classList.toggle('grid', this.getProp('grid') && !this.getProp('circular')) - this.container.classList.toggle('vertical', this.getProp('vertical') && !this.getProp('circular')) + var layout = this.getProp('layout') + this.container.classList.toggle('box', layout !== 'circular') + this.container.classList.toggle('circular', layout === 'circular') + this.container.classList.toggle('grid', layout === 'grid') + this.container.classList.toggle('vertical', layout === 'vertical') + this.container.style.setProperty('--grid-columns', this.getProp('columns') === '' ? parseInt(this.values.length / 2) : parseInt(this.getProp('columns'))) } @@ -257,22 +259,6 @@ class Menu extends Widget { } - scrollOffset() { - - var parent = this.parent, - scrollOffset = [0,0] - - while (parent && parent.props && parent.getProp('type') !== 'tab') { - scrollOffset[0] += parent.widget.scrollLeft - scrollOffset[1] += parent.widget.scrollTop - parent = parent.parent - if (parent.getProp('type') === 'modal') break - } - - return scrollOffset - - } - setValue(v,options={}) { var i = this.values.indexOf(v) @@ -284,6 +270,7 @@ class Menu extends Widget { DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')}) if (i > -1) DOM.get(this.menu, '.item')[i].classList.add('on') + this.widget.textContent = this.stringValues[i] || this.value if (options.send) this.sendValue() if (options.sync) this.changed(options) @@ -299,16 +286,12 @@ class Menu extends Widget { case 'size': this.setSize() return - case 'vertical': - this.setMode() - return - case 'circular': - this.setMode() + case 'layout': this.parseValues() - return - case 'grid': this.setMode() - if (this.getProp('grid') === true) this.parseValues() + return + case 'columns': + this.setMode() return case 'values': this.parseValues() @@ -333,9 +316,8 @@ class Menu extends Widget { Menu.dynamicProps = Menu.prototype.constructor.dynamicProps.concat( 'size', - 'circular', - 'vertical', - 'grid', + 'layout', + 'columns', 'values' ) diff --git a/src/client/app/widgets/buttons/push.js b/src/client/app/widgets/buttons/push.js deleted file mode 100644 index 827c489d..00000000 --- a/src/client/app/widgets/buttons/push.js +++ /dev/null @@ -1,160 +0,0 @@ -var Widget = require('../common/widget'), - doubletab = require('../mixins/double_tap'), - osc = require('../../osc'), - html = require('nanohtml') - -class Push extends Widget { - - static description() { - - return 'On / off button that turns off when released.' - - } - - - static defaults() { - - - return super.defaults({ - - _push: 'push', - - 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'}, - on: {type: '*', value: 1, help: [ - 'Set to `null` to send send no argument in the osc message', - 'Can be an `object` if the type needs to be specified (see preArgs)' - ]}, - off: {type: '*', value: 0, help: [ - 'Set to `null` to send send no argument in the osc message', - 'Can be an `object` if the type needs to be specified (see preArgs)' - ]}, - norelease: {type: 'boolean', value: false, help: 'Set to `true` to prevent sending any osc message when releasing the button'}, - - }, ['default']) - - } - - constructor(options) { - - super({...options, html: html`
      `}) - - this.state = 0 - this.active = null - this.lastChanged = 'state' - - if (this.getProp('doubleTap')) { - - doubletab(this.widget, ()=>{ - if (this.active) return - this.setValuePrivate(this.getProp('on'),{send:true,sync:true}) - }) - - } else { - - this.on('draginit',()=>{ - if (this.active) return - this.setValuePrivate(this.getProp('on'),{send:true,sync:true}) - }, {element: this.widget}) - - } - - this.on('dragend',()=>{ - if (!this.active) return - this.setValuePrivate(this.getProp('off'),{send:true,sync:true}) - }, {element: this.widget}) - - this.value = this.getProp('off') - - - } - - updateValue(){ - - this.value = this[this.lastChanged] ? - this.getProp('on') != null && this.getProp('on').value !== undefined ? this.getProp('on').value : this.getProp('on') - : - this.getProp('off') != null && this.getProp('off').value !== undefined ? this.getProp('off').value : this.getProp('off') - - } - - setValuePrivate(v,options={}) { - - 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('active') - this.container.classList.add('active') - this.active = options - this.lastChanged = 'active' - this.updateValue() - if (options.send) this.sendValue() - if (options.sync) this.changed(options) - } 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 = null - this.lastChanged = 'active' - this.updateValue() - if (options.send) this.sendValue(null, {syncOnly: this.getProp('norelease')}) - if (options.sync) this.changed(options) - } - - } - - setValue(v,options={}) { - - if (!options.fromExternal) { - 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') - this.container.classList.add('on') - this.state = 1 - if (options.send) this.sendValue() - this.lastChanged = 'state' - if (options.sync) this.changed(options) - } else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) { - this.widget.classList.remove('on') - this.container.classList.remove('on') - this.state = 0 - if (options.send) this.sendValue() - this.lastChanged = 'state' - if (options.sync) this.changed(options) - } - - } - - sendValue(overrides, options={}) { - - if (!options.syncOnly) { - - super.sendValue(overrides, options) - - } else { - - osc.sync({ - h: this.hash, - v: this.value - }) - - } - - } - - onRemove() { - - if (this.active) this.setValuePrivate(this.getProp('off'), this.active) - super.onRemove() - - } -} - -Push.dynamicProps = Push.prototype.constructor.dynamicProps.concat( - 'on', - 'off', - 'norelease' -) - -module.exports = Push diff --git a/src/client/app/widgets/buttons/switch.js b/src/client/app/widgets/buttons/switch.js index 46001012..ef15392a 100644 --- a/src/client/app/widgets/buttons/switch.js +++ b/src/client/app/widgets/buttons/switch.js @@ -23,7 +23,12 @@ module.exports = class Switch extends Widget { '`Array` of possible values to switch between : `[1,2,3]`', '`Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept', ]}, - traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'}, + mode: {type: 'string', value: 'tap', choices: ['tap', 'slide', 'click'], help: [ + 'Interraction mode:', + '- `tap`: activates when the pointer is down but prevents further scrolling', + '- `slide`: same as `tap` but allows sliding between values', + '- `click`: activates upon click only and allows further scrolling', + ]}, }) @@ -31,10 +36,9 @@ module.exports = class Switch extends Widget { constructor(options) { - super({...options, html: html`
      `}) + super({...options, html: html``}) - - if (this.getProp('horizontal')) this.widget.classList.add('horizontal') + if (this.getProp('horizontal')) this.container.classList.add('horizontal') this.values = [] this.stringValues = [] @@ -61,7 +65,7 @@ module.exports = class Switch extends Widget { if (this.getProp('showValues') && !isArray) label = label + ': ' + (this.stringValues[this.stringValues.length - 1] || values[k]) this.widget.appendChild(html` -
      ${raw(iconify(label))}
      + ${raw(iconify(label))} `) } @@ -92,10 +96,15 @@ module.exports = class Switch extends Widget { } - this.on('draginit', dragCallback , {element: this.widget}) - this.on('drag', (e)=>{ - if (this.getProp('traversing') || e.traversing) dragCallback(e, true) - } , {element: this.widget}) + if (this.getProp('mode') === 'tap' || this.getProp('mode') === 'slide') { + this.on('draginit', dragCallback , {element: this.widget}) + this.on('drag', (e)=>{ + if (this.getProp('mode') === 'slide' || e.traversing) dragCallback(e, true) + } , {element: this.widget}) + } else { + this.widget.addEventListener('click', dragCallback) + + } } @@ -109,7 +118,7 @@ module.exports = class Switch extends Widget { if (i!=-1) { this.value = this.values[i] - DOM.get(this.widget, '.value')[i].classList.add('on') + DOM.get(this.widget, 'value')[i].classList.add('on') if (options.send) this.sendValue(this.value) if (options.sync) this.changed(options) } else { diff --git a/src/client/app/widgets/buttons/toggle.js b/src/client/app/widgets/buttons/toggle.js index 0b1fc7a4..0c1b79b7 100644 --- a/src/client/app/widgets/buttons/toggle.js +++ b/src/client/app/widgets/buttons/toggle.js @@ -16,8 +16,6 @@ class Toggle extends Widget { _toggle: 'toggle', - doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be toggled instead of a single tap'}, - led: {type: 'boolean', value: false, help: 'Set to `true` to display the toggle\'s state with a led'}, on: {type: '*', value: 1, help: [ 'Set to `null` to send send no argument in the osc message', 'Can be an `object` if the type needs to be specified (see preArgs)' @@ -25,7 +23,14 @@ class Toggle extends Widget { off: {type: '*', value: 0, help: [ 'Set to `null` to send send no argument in the osc message', 'Can be an `object` if the type needs to be specified (see preArgs)' - ]} + ]}, + mode: {type: 'string', value: 'toggle', choices: ['toggle', 'push', 'tap'], help: [ + 'Interraction mode:', + '- `toggle` (classic on/off switch)', + '- `push` (press & release)', + '- `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'}, }) @@ -33,65 +38,121 @@ class Toggle extends Widget { constructor(options) { - super({...options, html: html`
      `}) + super({...options, html: html``}) this.state = 0 this.active = false if (this.getProp('led')) this.container.classList.add('led') - if (this.getProp('doubleTap')) { + var tap = this.getProp('mode') === 'tap', + push = this.getProp('mode') === 'push' || tap - doubletab(this.widget, ()=>{ - var newVal = this.state?this.getProp('off'):this.getProp('on') - this.setValue(newVal,{sync:true,send:true}) - }) + if (push) { + + if (this.getProp('doubleTap')) { + + doubletab(this.container, ()=>{ + + this.setValue(this.getProp('on'), {sync: true, send: true}) + + }) + + } else { + + this.on('draginit',()=>{ + + if (this.active) return + + this.active = true + this.setValue(this.getProp('on'), {sync: true, send: true}) + + }, {element: this.container}) + + } + + this.on('dragend',()=>{ + + this.active = false + this.setValue(this.getProp('off'), {sync: true, send: !tap}) + + }, {element: this.container}) } else { - this.on('draginit',()=>{ - if (this.active) return - this.active = true - var newVal = this.state?this.getProp('off'):this.getProp('on') - this.setValue(newVal,{sync:true,send:true}) - }, {element: this.widget}) + if (this.getProp('doubleTap')) { - this.on('dragend',()=>{ - this.active = false - }, {element: this.widget}) + doubletab(this.container, ()=>{ + + this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true}) + + }) + + } else { + + this.on('draginit',()=>{ + + if (this.active) return + + this.active = true + this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true}) + + }, {element: this.container}) + + this.on('dragend',()=>{ + + this.active = false + + }, {element: this.container}) + + } } + this.value = this.getProp('off') } + + setValue(v,options={}) { 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') + this.container.classList.add('on') this.state = 1 this.value = this.getProp('on') if (options.send) this.sendValue() + } else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) { - this.widget.classList.remove('on') + this.container.classList.remove('on') this.state = 0 this.value = this.getProp('off') if (options.send) this.sendValue() + } if (options.sync) this.changed(options) } + onRemove() { + + if (this.active && this.getProp('mode') === 'push') this.setValue(this.getProp('off'), {sync: true, send: true}) + super.onRemove() + + } + } Toggle.dynamicProps = Toggle.prototype.constructor.dynamicProps.concat( 'on', - 'off' + 'off', + 'norelease' ) module.exports = Toggle diff --git a/src/client/app/widgets/common/canvas.js b/src/client/app/widgets/common/canvas.js index fb303d82..16b1ea2a 100644 --- a/src/client/app/widgets/common/canvas.js +++ b/src/client/app/widgets/common/canvas.js @@ -1,4 +1,6 @@ -var Widget = require('./widget') +var Widget = require('./widget'), + resize = require('../../events/resize') + class CanvasQueue { @@ -65,12 +67,13 @@ class Canvas extends Widget { super(options) - this.canvas = DOM.get(this.widget, 'canvas')[0] + this.canvas = DOM.get(this.container, 'canvas')[0] this.ctx = this.canvas.getContext('2d',{ desynchronized: true, lowLatency: true, - alpha: true + alpha: true, + preserveDrawingBuffer: true // avoid flickering }) this.height = undefined @@ -82,6 +85,7 @@ class Canvas extends Widget { this.visible = false this.colors = {} + this.cssVars = {} this.on('resize', this.resizeHandleProxy.bind(this), {element: this.canvas}) @@ -121,7 +125,7 @@ class Canvas extends Widget { if (!this.visible) this.visible = true - requestAnimationFrame(this.draw.bind(this)) + this.batchDraw() } @@ -129,6 +133,20 @@ class Canvas extends Widget { style = style || window.getComputedStyle(this.canvas) + this.cssVars.padding = parseFloat(style.getPropertyValue('--widget-padding')) * PXSCALE // rem unit + + this.cssVars.colorWidget = style.getPropertyValue('--color-widget') + this.cssVars.colorFill = style.getPropertyValue('--color-fill') + this.cssVars.colorStroke = style.getPropertyValue('--color-stroke') + this.cssVars.colorForeground = style.getPropertyValue('--color-foreground') + + this.cssVars.alphaStroke = parseFloat(style.getPropertyValue('--alpha-stroke')) + this.cssVars.alphaFillOff = parseFloat(style.getPropertyValue('--alpha-fill-off')) + this.cssVars.alphaFillOn = parseFloat(style.getPropertyValue('--alpha-fill-on')) + + + + this.colors.custom = style.getPropertyValue('--color-custom') this.colors.track = style.getPropertyValue('--color-track') this.colors.text = style.getPropertyValue('--color-text') @@ -188,11 +206,20 @@ class Canvas extends Widget { switch (propName) { - case 'color': - this.cacheCanvasStyle() - this.batchDraw() + case 'css': + case 'colorWidget': + case 'colorFill': + case 'colorStroke': + case 'alphaStroke': + case 'alphaFillOff': + case 'alphaFillOn': + setTimeout(()=>{ + this.cacheCanvasStyle() + this.batchDraw() + },10) return - + case 'padding': + resize.check(this.widget) } return ret diff --git a/src/client/app/widgets/common/widget.js b/src/client/app/widgets/common/widget.js index 39a288cf..fb6d112d 100644 --- a/src/client/app/widgets/common/widget.js +++ b/src/client/app/widgets/common/widget.js @@ -45,13 +45,15 @@ class Widget extends EventEmitter { var defaults = { + _widget:'widget', + type: {type: 'string', value: 'auto', help: ''}, id: {type: 'string', value: 'auto', help: 'Widgets sharing the same `id` will act as clones and update each other\'s value(s) without sending extra osc messages.' }, - linkId: {type: 'string|array', value: '', help: [ - 'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.', - '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)' + label: {type: 'string|boolean', value: 'auto', help: [ + 'Set to `false` to hide completely', + 'Insert icons using the prefix ^ followed by the icon\'s name : ^play, ^pause, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)' ]}, + visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'}, _geometry:'geometry', @@ -68,17 +70,29 @@ class Widget extends EventEmitter { _style:'style', - label: {type: 'string|boolean', value: 'auto', help: [ - 'Set to `false` to hide completely', - 'Insert icons using the prefix ^ followed by the icon\'s name : ^play, ^pause, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)' - ]}, - color: {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.'}, + + 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.'}, + + + css: {type: 'string', value: '', help: 'CSS rules. See documentation.'}, _value: 'value', default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'}, - value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using property inheritance and property maths'}, + value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using the advanced property syntax'}, + linkId: {type: 'string|array', value: '', help: [ + 'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.', + '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)' + ]}, _osc: 'osc', @@ -118,7 +132,8 @@ class Widget extends EventEmitter { } for (var m in push) { - alterDefaults[m] = push[m] + if (!alterDefaults[m]) alterDefaults[m] = [] + Object.assign(alterDefaults[m], push[m]) } alterDefaults._props = function() { @@ -167,19 +182,15 @@ class Widget extends EventEmitter { this.precision = Math.min(20,Math.max(this.getProp('precision', undefined, false),0)) } - if (options.container) { - this.container = html` -
      - ` - this.label = html`
      ` - this.container.appendChild(this.label) - this.container.appendChild(this.widget) - this.container._widget_instance = this - this.setContainerStyles() - } else { - this.container = dummyDOM - } + this.container = html` +
      + ` + this.label = html`` + if (this.getProp('label') !== false) this.container.appendChild(this.label) + if (this.widget) this.container.appendChild(this.widget) + this.container._widget_instance = this + this.setContainerStyles() } @@ -586,35 +597,9 @@ class Widget extends EventEmitter { propValue = propValue.replace(/#\{(?:[^{}]|\{[^{}]*\})*\}/g, (m)=>{ // one bracket nesting allowed, if we need two: #\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\} - // if (!this.mathjsDeprecationWarned) { - // this.mathjsDeprecationWarned = true - // ipc.send('error', `Warning: Widget#${this.getProp('id')} MathJS syntax (#{}) is deprecated and will be removed in the future. Consider using the Javascript syntax instead.`) - // } + //TODO: js one-liner - // unescape brackets (not needed anymore, just here for backward compatibility) - m = m.replace(/\\(\{|\})/g, '$1') - - // espace multiline strings - m = m.replace(/`([^`]*)`/g, (m)=>{ - return m.replace(/"/g,'\\"').replace(/\n/g,'\\n').replace(/`/g,'"') - }) - - if (!this.parsers[m]) this.parsers[m] = math.compile(m.substr(2, m.length - 3).trim()) - - for (var k in defaultScope) { - if (mathscope[k] === undefined) mathscope[k] = defaultScope[k] - } - - let r = this.parsers[m].eval(mathscope) - - if (r instanceof math.type.ResultSet && !r.entries.length) { - r = '' - } else if (typeof r === 'object' && r !== null && r.valueOf) { - r = r.valueOf() - if (Array.isArray(r) && r.length == 1) r = r[0] - } - - return typeof r != 'string' ? JSON.stringify(r) : r + return '' }) } catch (err) { console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err) @@ -758,6 +743,11 @@ class Widget extends EventEmitter { resize.check(this.container) return + case 'visible': + this.setContainerStyles(['visibility']) + resize.check(this.container) + return + case 'label': this.setContainerStyles(['label']) if (oldPropValue === false || this.getProp('label') === false) { @@ -774,7 +764,13 @@ class Widget extends EventEmitter { } return - case 'color': + case 'colorWidget': + case 'colorFill': + case 'colorStroke': + case 'alphaStroke': + case 'alphaFillOff': + case 'alphaFillOn': + case 'padding': this.setContainerStyles(['color']) return @@ -808,11 +804,16 @@ class Widget extends EventEmitter { } - setContainerStyles(styles = ['geometry', 'label', 'css', 'color']) { + setContainerStyles(styles = ['geometry', 'label', 'css', 'color', 'visibility']) { + + if (styles.includes('visibility')) { + this.container.style.display = this.getProp('visible') ? '' : 'none' + } if (styles.includes('geometry')) { // geometry + var absolutePos = false for (let d of ['width', 'height', 'top', 'left']) { let val = this.getProp(d), geometry @@ -827,9 +828,12 @@ class Widget extends EventEmitter { this.container.style[d] = geometry if (d === 'width') this.container.style.minWidth = geometry if (d === 'height') this.container.style.minHeight = geometry - this.container.classList.toggle('absolute-position', geometry && (d === 'top' || d === 'left')) + absolutePos = absolutePos || geometry && (d === 'top' || d === 'left') + } } + this.container.classList.toggle('absolute-position', absolutePos) + } @@ -838,6 +842,7 @@ class Widget extends EventEmitter { // label if (this.getProp('label') === false) { this.container.classList.add('nolabel') + this.label.innerHTML = '' } else { this.container.classList.remove('nolabel') var label = this.getProp('label') == 'auto'? @@ -845,6 +850,7 @@ class Widget extends EventEmitter { iconify(this.getProp('label')) this.label.innerHTML = label + this.container.appendChild(this.label) } } @@ -925,10 +931,18 @@ class Widget extends EventEmitter { if (styles.includes('color')) { // color - this.container.style.setProperty('--color-custom', this.getProp('color') && this.getProp('color') != 'auto' ? this.getProp('color') : '') + this.container.style.setProperty('--color-widget', this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '') + this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '') + this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '') + this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '') + this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '') + this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '') + this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') } + return style + } @@ -951,14 +965,26 @@ class Widget extends EventEmitter { Widget.parsersContexts = {} Widget.dynamicProps = [ + 'visible', + 'label', + 'top', 'left', 'height', 'width', - 'label', + + + 'colorWidget', + 'colorFill', + 'colorStroke', + 'alphaStroke', + 'alphaFillOff', + 'alphaFillOn', + 'padding', 'css', + 'value', - 'color', + 'precision', 'address', 'preArgs', diff --git a/src/client/app/widgets/containers/modal.js b/src/client/app/widgets/containers/modal.js index 6fd28fde..9aeb24af 100644 --- a/src/client/app/widgets/containers/modal.js +++ b/src/client/app/widgets/containers/modal.js @@ -26,13 +26,14 @@ 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'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''}, scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, + variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, }, [], { _chidlren:'children', - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object'}, value: {type: 'integer', value: '', help: [ 'Defines the modal\'s state:`0` for closed, `1` for opened' @@ -52,12 +53,13 @@ class Modal extends Panel { ` this.container.appendChild(this.popup) + this.popupContent = DOM.get(this.popup, '.popup-content')[0] // convert dimensions / coordinates to rem var geometry = {} @@ -109,6 +111,12 @@ class Modal extends Panel { this.init = false this.labelChange = true + + this.popupContent.classList.add('layout-' + this.getProp('layout')) + this.popupContent.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') + + + } setValue(v, options={}) { @@ -118,7 +126,7 @@ class Modal extends Panel { this.value = v ? 1 : 0 if (!this.init && this.value) { - DOM.get(this.popup, '.popup-content')[0].appendChild(this.widget) + this.popupContent.appendChild(this.widget) this.init = true } @@ -195,7 +203,7 @@ class Modal extends Panel { if (!this.popup) return - var label = this.getProp('popupLabel') ? iconify(this.getProp('popupLabel')) : DOM.get(this.container, '> .label')[0].innerHTML + var label = this.getProp('popupLabel') ? iconify(this.getProp('popupLabel')) : this.label.innerHTML DOM.get(this.popup, '.popup-title .popup-label')[0].innerHTML = label this.labelChange = false @@ -221,6 +229,18 @@ class Modal extends Panel { } + setContainerStyles(styles = ['geometry', 'label', 'css', 'color', 'visibility']) { + + super.setContainerStyles(styles) + + if (styles.includes('color') && this.popupContent) { + + this.popupContent.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') + + } + + } + } Modal.dynamicProps = Modal.prototype.constructor.dynamicProps.concat( diff --git a/src/client/app/widgets/containers/panel.js b/src/client/app/widgets/containers/panel.js index afdf59ba..fba8b413 100644 --- a/src/client/app/widgets/containers/panel.js +++ b/src/client/app/widgets/containers/panel.js @@ -2,7 +2,9 @@ var Container = require('../common/container'), widgetManager = require('../../managers/widgets'), parser = require('../../parser'), html = require('nanohtml'), - raw = require('nanohtml/raw') + raw = require('nanohtml/raw'), + {enableTraversingGestures, disableTraversingGestures} = require('../../events/drag'), + setScrollbarColor = require('../../ui/scrollbar-color') class Panel extends Container() { @@ -19,18 +21,19 @@ class Panel extends Container() { _panel:'panel', scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - border: {type: 'boolean', value: true, help: 'By default, widgets in panels/strip have their border disabled, except for panels and strips. Set to `false` to apply this rule to the panel too'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''}, + 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'}, + variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, }, [], { _children:'children', - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, value: {type: 'integer', value: '', help: [ - 'Defines currently opened tab in the widget', + 'Defines currently widgeted tab in the widget', 'A tab can be opened only by setting its parent\'s value' ]}, @@ -44,31 +47,41 @@ class Panel extends Container() { super({...options, html: html`
      `}) - if (this.getProp('scroll') === false) this.widget.classList.add('noscroll') - if (this.getProp('border') === false) this.container.classList.add('noborder') - if (this.getProp('tabs') && this.getProp('tabs').length) this.widget.classList.add('has-tabs') + if (this.getProp('scroll') === false) this.container.classList.add('noscroll') + this.container.classList.add('layout-' + this.getProp('layout')) + + + if (this.getProp('tabs') && this.getProp('tabs').length) { + + this.container.classList.add('contains-tabs') + + } else { + + this.container.classList.add('contains-widgets') + + } + + + this.value = -1 this.tabs = [] if (this.getProp('tabs') && this.getProp('tabs').length) { - this.widget.appendChild(html``) - this.navigation = DOM.get(this.widget, '.tablist')[0] - - this.wrapper = this.widget.appendChild(html`
      `) + this.navigation = this.widget.appendChild(html``) this.children = options.children || new Array(this.getProp('tabs').length) for (let i = 0; i < this.children.length; i++) { if (this.children[i]) { - this.wrapper.appendChild(this.children[i].container) + this.widget.appendChild(this.children[i].container) this.children[i].mounted = true this.children[i].parent = this - this.children[i].parentNode = this.wrapper + this.children[i].parentNode = this.widget } else { parser.parse({ data: this.getProp('tabs')[i], - parentNode: this.wrapper, + parentNode: this.widget, parent: this, tab: true, index: i @@ -130,6 +143,7 @@ class Panel extends Container() { } + if (this.getProp('traversing')) this.setTraversing() } @@ -138,16 +152,21 @@ class Panel extends Container() { this.navigation.innerHTML = '' this.tabs = [] - DOM.each(this.wrapper, '> .widget', (tab)=>{ + DOM.each(this.widget, '> .widget', (tab)=>{ let widget = widgetManager.getWidgetByElement(tab), - style = widget.getProp('color') == 'auto' ? '' : `--color-custom:${widget.getProp('color')}` + style = '' + + style += widget.getProp('colorWidget') === 'auto' ? '' : `--color-widget:${widget.getProp('colorWidget')};` + style += widget.getProp('colorFill') === 'auto' ? '' : `--color-fill:${widget.getProp('colorFill')};` + + if (!widget.getProp('visible')) style += 'display:none;' this.tabs.push(widget) this.navigation.appendChild(html` - + `) }) @@ -167,7 +186,7 @@ class Panel extends Container() { this.value = v this.tabs[v].show() - DOM.each(this.navigation, 'li', (el)=>{el.classList.remove('on')})[v].classList.add('on') + DOM.each(this.navigation, 'div', (el)=>{el.classList.remove('on')})[v].classList.add('on') if (options.send) this.sendValue() if (options.sync) this.changed(options) @@ -192,9 +211,18 @@ class Panel extends Container() { switch (propName) { - case 'color': + case 'traversing': + this.setTraversing() + return + + case 'colorWidget': + case 'colorFill': + case 'colorStroke': + case 'alphaStroke': + case 'alphaFillOff': + case 'alphaFillOn': for (var w of this.children) { - if (w) w.onPropChanged('color') + if (w) w.onPropChanged(propName) } return @@ -202,6 +230,30 @@ class Panel extends Container() { } + setContainerStyles(styles = ['geometry', 'label', 'css', 'color', 'visibility']) { + + super.setContainerStyles(styles) + + if (styles.includes('color') && this.getProp('scroll')) { + + setScrollbarColor(this.container) + + } + + } + + setTraversing(update) { + + var traversing = this.getProp('traversing') + + disableTraversingGestures(this.widget) + + if (traversing) { + enableTraversingGestures(this.widget, {smart: typeof traversing === 'string' && traversing.match(/smart|auto/)}) + } + + } + onRemove() { this.off('resize') @@ -211,7 +263,8 @@ class Panel extends Container() { } Panel.dynamicProps = Panel.prototype.constructor.dynamicProps.concat( - 'variables' + 'variables', + 'traversing' ) module.exports = Panel diff --git a/src/client/app/widgets/containers/root.js b/src/client/app/widgets/containers/root.js index df63ccfc..fb7e8f97 100644 --- a/src/client/app/widgets/containers/root.js +++ b/src/client/app/widgets/containers/root.js @@ -1,11 +1,11 @@ var Panel = require('./panel'), Widget = require('../common/widget'), + StaticProperties = require('../mixins/static_properties'), {icon} = require('../../ui/utils'), - {enableTraversingGestures, disableTraversingGestures} = require('../../events/drag'), html = require('nanohtml'), raw = require('nanohtml/raw') -class Root extends Panel { +class Root extends StaticProperties(Panel, {scroll: false, label: false, id: 'root'}) { static description() { @@ -15,17 +15,22 @@ class Root extends Panel { static defaults() { - return Widget.defaults({}, ['label', '_geometry', 'left', 'top', 'width', 'height'], { + return Widget.defaults({ + + + _panel:'panel', + + 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'}, + variables: {type: '*', value: '', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, + + }, ['label', '_geometry', 'left', 'top', 'width', 'height', 'scroll'], { _children:'children', - 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'}, - variables: {type: '*', value: {}, help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - tabs: {type: 'array', value: [{}], help: 'Each element of the array must be a tab object'}, - id: {type: 'string', value: 'root', help: 'Widgets sharing the same id will act as clones and update each other\'s value(s) without sending extra osc messages' }, + tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, value: {type: 'integer', value: '', help: [ - 'Defines currently opened tab in the widget', + 'Defines currently widgeted tab in the widget', 'A tab can be opened only by setting its parent\'s value' ]}, @@ -36,22 +41,15 @@ class Root extends Panel { constructor(options) { options.root = true - options.props.id = 'root' - options.props.scroll = true - options.props.label = false super(options) this.widget.classList.add('root') - this.disabledProps.push('id') - DOM.each(this.widget, '> .navigation', (el)=>{ el.classList.add('main') }) - if (this.getProp('traversing')) this.setTraversing() - } createNavigation() { @@ -59,43 +57,15 @@ class Root extends Panel { super.createNavigation() this.navigation.appendChild(html` -
    1. - ${raw(icon('bars'))} -
    2. +
      ${raw(icon('expand'))}>
      +
      ${raw(icon('pen'))}>
      +
      ${raw(icon('ellipsis-v'))}>
      `) } - setTraversing(update) { - - var traversing = this.getProp('traversing') - - disableTraversingGestures(this.widget) - - if (traversing) { - enableTraversingGestures(this.widget, {smart: typeof traversing === 'string' && traversing.match(/smart|auto/)}) - } - - } - - onPropChanged(propName, options, oldPropValue) { - - if (super.onPropChanged(...arguments)) return true - - switch (propName) { - - case 'traversing': - this.setTraversing() - return - - } - - } } -Root.dynamicProps = Root.prototype.constructor.dynamicProps.concat( - 'traversing' -) module.exports = Root diff --git a/src/client/app/widgets/containers/strip.js b/src/client/app/widgets/containers/strip.js deleted file mode 100644 index 297c59f6..00000000 --- a/src/client/app/widgets/containers/strip.js +++ /dev/null @@ -1,66 +0,0 @@ -var Panel = require('./panel'), - Widget = require('../common/widget') - -module.exports = class Strip extends Panel { - - static description() { - - return 'Widget container that display its children in a single column or row.' - - } - - static defaults() { - - return Widget.defaults({ - - _strip: 'strip', - - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display widgets horizontally'}, - stretch: {type: 'boolean', value: false, help: 'Set to `true` to stretch widgets evenly'}, - border: {type: 'boolean', value: true, help: 'By default, widgets in panels/strip have their border disabled, except for panels and strips. Set to `false` to apply this rule to the panel too'}, - spacing: {type: 'integer|percentage', value: 0, help: 'Adds space between widgets. Percents are always relative to the strips width'} - - }, [], { - - _children:'children', - - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - widgets: {type: 'array', value: [], help: [ - 'Each element of the array must be a widget object', - '- By default, children widgets that don\'t have an explicit `width`/`height` set will be shrinked to respect the sizes specified by others', - '- Adding `flex:1;` to a children\'s `css` will give it the ability the fill the remaining space', - '- Multiple children can have a `flex:x;` css property (`x` will ponderate their expansion)' - ]} - - }) - - } - - constructor(options) { - - var defaults = Panel.defaults()._props() - for (var k in defaults) { - if (!options.props.hasOwnProperty(k)) - options.props[k] = defaults[k] - } - - super(options) - - this.disabledProps = [] - - if (this.getProp('spacing')) { - var spacing = this.getProp('spacing') - if (!isNaN(spacing)) spacing += 'rem' - this.widget.style.setProperty('--spacing', spacing) - } - - this.container.classList.add(this.getProp('horizontal') ? 'horizontal' : 'vertical') - if (this.getProp('stretch')) this.container.classList.add('stretch') - - } - - setValue(){} - getValue(){} - -} diff --git a/src/client/app/widgets/containers/tab.js b/src/client/app/widgets/containers/tab.js index d6089805..eaf5b198 100644 --- a/src/client/app/widgets/containers/tab.js +++ b/src/client/app/widgets/containers/tab.js @@ -1,8 +1,9 @@ var Panel = require('./panel'), Widget = require('../common/widget'), + StaticProperties = require('../mixins/static_properties'), resize = require('../../events/resize') -module.exports = class Tab extends Panel { +module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) { static description() { @@ -16,18 +17,20 @@ 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'} + 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'], help:''}, + 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'}, + variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - }, ['_geometry', 'left', 'top', 'width', 'height'], { + }, ['_geometry', 'left', 'top', 'width', 'height', 'scroll'], { _children:'children', - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A tab cannot contain widgets and tabs simultaneously'}, - tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A tab cannot contain widgets and tabs simultaneously'}, + widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, + tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, value: {type: 'integer', value: '', help: [ - 'Defines currently opened tab in the widget', + 'Defines currently widgeted tab in the widget', 'A tab can be opened only by setting its parent\'s value' ]}, @@ -37,12 +40,9 @@ module.exports = class Tab extends Panel { constructor(options) { - options.props.scroll = true - super(options) this.container.classList.add('show') - this.widget.classList.add('tab') this.detached = false @@ -69,8 +69,14 @@ module.exports = class Tab extends Panel { switch (propName) { + case 'visible': case 'label': - case 'color': + case 'colorWidget': + case 'colorFill': + case 'colorStroke': + case 'alphaStroke': + case 'alphaFillOff': + case 'alphaFillOn': if (this.parent.createNavigation) this.parent.createNavigation() return diff --git a/src/client/app/widgets/plots/frame.js b/src/client/app/widgets/frames/frame.js similarity index 91% rename from src/client/app/widgets/plots/frame.js rename to src/client/app/widgets/frames/frame.js index fcd6e4b5..6f67c92e 100644 --- a/src/client/app/widgets/plots/frame.js +++ b/src/client/app/widgets/frames/frame.js @@ -20,7 +20,7 @@ class Frame extends StaticProperties(Widget, {bypass: true}) { border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'}, - }, ['color', 'precision', 'bypass'], { + }, ['precision', 'bypass'], { label: {type: 'string|boolean', value: 'auto', help: [ 'Set to `false` to hide completely', @@ -37,7 +37,11 @@ class Frame extends StaticProperties(Widget, {bypass: true}) { constructor(options) { - super({...options, html: html`
      `}) + super({...options, html: html` + + + ` + }) if (!this.getProp('border')) this.container.classList.add('noborder') diff --git a/src/client/app/widgets/plots/html.js b/src/client/app/widgets/frames/html.js similarity index 91% rename from src/client/app/widgets/plots/html.js rename to src/client/app/widgets/frames/html.js index fa2b18da..09949db7 100644 --- a/src/client/app/widgets/plots/html.js +++ b/src/client/app/widgets/frames/html.js @@ -31,16 +31,13 @@ class Html extends StaticProperties(Widget, {bypass: true}) { ]}, border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'}, - }, ['color', 'precision', 'bypass'], {}) + }, ['precision', 'bypass'], {}) } constructor(options) { - super({...options, html: html` -
      -
      - `}) + super({...options, html: html``}) if (!this.getProp('border')) this.container.classList.add('noborder') diff --git a/src/client/app/widgets/plots/image.js b/src/client/app/widgets/frames/image.js similarity index 93% rename from src/client/app/widgets/plots/image.js rename to src/client/app/widgets/frames/image.js index 5cd61125..eeed4c72 100644 --- a/src/client/app/widgets/plots/image.js +++ b/src/client/app/widgets/frames/image.js @@ -27,7 +27,7 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) { 'When true, sending `reload` to the widget reloads its image without changing its value' ]} - }, ['color', 'precision', 'bypass'], { + }, ['precision', 'bypass'], { value: {type: 'string', value: '', help: [ '- File `url` or `path` (relative to the session file location by default, falling back to absolute path)', @@ -40,7 +40,7 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) { constructor(options) { - super({...options, html: html`
      `}) + super({...options, html: html``}) if (!this.getProp('border')) this.container.classList.add('noborder') @@ -93,7 +93,6 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) { onRemove() { - if (this.bindedOnStreamUpdate) ipc.off('video', this.bindedOnStreamUpdate) super.onRemove() } diff --git a/src/client/app/widgets/plots/svg.js b/src/client/app/widgets/frames/svg.js similarity index 95% rename from src/client/app/widgets/plots/svg.js rename to src/client/app/widgets/frames/svg.js index 5ed6b395..3220e59b 100644 --- a/src/client/app/widgets/plots/svg.js +++ b/src/client/app/widgets/frames/svg.js @@ -26,16 +26,16 @@ class Svg extends StaticProperties(Widget, {bypass: true}) { border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'}, - }, ['color', 'precision', 'bypass'], {}) + }, ['precision', 'bypass'], {}) } constructor(options) { super({...options, html: html` -
      + -
      + `}) this.height = undefined diff --git a/src/client/app/widgets/plots/_biquad_response.js b/src/client/app/widgets/graphs/eq.js similarity index 56% rename from src/client/app/widgets/plots/_biquad_response.js rename to src/client/app/widgets/graphs/eq.js index f3345a96..dd68e0ee 100644 --- a/src/client/app/widgets/plots/_biquad_response.js +++ b/src/client/app/widgets/graphs/eq.js @@ -1,10 +1,119 @@ +var {clip} = require('../utils'), + Plot = require('./plot') + +module.exports = class Eq extends Plot { + + static description() { + + return 'Draws frequency response between from from an array of filter objects.' + + } + + static defaults() { + + return super.defaults({ + + _eq:'eq', + + pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'}, + resolution: {type: 'number', value: 128, help: 'Defines the number of points used to compute the frequency response'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, + logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, + smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, + + }, ['precision', 'bypass'], { + + value: {type: 'array', value: '', help: [ + 'Each item must be an object with the following properties', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak" or "notch")', + '- `freq`: number (filter\'s resonant frequency)', + '- `q`: number (Q factor)', + '- `gain`: number', + '- `on`: boolean', + + ]} + + }) + + } + + constructor(options) { + + // backward compat + if (options.props.filters && options.props.filters.length) { + options.props.value = options.props.filters + delete options.props.filters + } + + super(options) + + this.rangeX = {min:20,max:22050} + this.pips.x.min = '20' + this.pips.x.max = '22k' + + this.resolution = clip(this.getProp('resolution'),[64,1024]) + + } + + setValue(v, options={}) { + + if (typeof v == 'string') { + try { + v = JSON.parseFlex(v) + } catch(err) {} + } + + if (Array.isArray(v)) { + + var filters = v, + eqResponse = [] + + if (v.length === this.resolution) { + + eqResponse = v + + } else { + + for (let i in filters) { + + var filterResponse + + if (!filters[i].type) filters[i].type = 'peak' + + if (!filters[i].on) { + filterResponse = calcBiquad({type:'peak',freq:1,gain:0,q:1},!this.getProp('logScaleX'), this.resolution) + } else { + filterResponse = calcBiquad(filters[i],!this.getProp('logScaleX'), this.resolution) + } + + for (var k in filterResponse) { + if (eqResponse[k]===undefined) { + eqResponse[k]=[0,0] + } + + eqResponse[k] = [filterResponse[k][0], eqResponse[k][1]+filterResponse[k][1]] + } + + } + + } + + if (eqResponse.length) super.setValue(eqResponse, options) + + } + + } + +} + // // calcBiquad // // Dec 14, 2010 njr // original @ Nigel Redmon -module.exports = function(options,linear,resolution) { +function calcBiquad(options,linear,resolution) { var {type, freq, q, gain} = options, Fs = 44100, a0,a1,a2,b1,b2,norm, diff --git a/src/client/app/widgets/graphs/plot.js b/src/client/app/widgets/graphs/plot.js new file mode 100644 index 00000000..1c6fa184 --- /dev/null +++ b/src/client/app/widgets/graphs/plot.js @@ -0,0 +1,246 @@ +var {mapToScale} = require('../utils'), + Canvas = require('../common/canvas'), + html = require('nanohtml'), + StaticProperties = require('../mixins/static_properties') + +module.exports = class Plot extends StaticProperties(Canvas, {bypass: true}) { + + static description() { + + return 'XY coordinates plot.' + + } + + static defaults() { + + + return super.defaults({ + + _plot:'plot', + + rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, + origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it.'}, + dots: {type: 'boolean', value: true, help: ''}, + bars: {type: 'boolean', value: false, help: 'Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing)'}, + smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, + pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, + + }, ['precision', 'bypass'], { + + value: {type: 'array|string', value: '', help: [ + '- `Array` of `y` values', + '- `Array` of `[x, y]` `array` values', + '- `String` `array`', + '- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points\' coordinates', + ]} + + }) + + } + + constructor(options) { + + super({...options, html: html` + + + + `}) + + this.value = [] + this.rangeX = this.getProp('rangeX') || {min:0,max:1} + this.rangeY = this.getProp('rangeY') || {min:0,max:1} + this.logScaleX = this.getProp('logScaleX') + this.logScaleY = this.getProp('logScaleY') + this.pips = { + x : { + min: Math.abs(this.rangeX.min)>=1000?this.rangeY.min/1000+'k':this.rangeX.min, + max: Math.abs(this.rangeX.max)>=1000?this.rangeY.max/1000+'k':this.rangeX.max + }, + y : { + min: Math.abs(this.rangeY.min)>=1000?this.rangeY.min/1000+'k':this.rangeY.min, + max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max + } + } + this.smooth = this.getProp('smooth') === true ? 0.25 : this.getProp('smooth') === false ? 0 : parseFloat(this.getProp('smooth')) || 0 + + } + + draw() { + + this.ctx.clearRect(0,0,this.width,this.height) + + if (this.getProp('bars')) { + this.draw_bars() + } else { + var points = this.draw_line() + if (this.getProp('dots')) { + this.draw_dots(points) + } + } + + if (this.getProp('pips')) this.draw_pips() + + } + + draw_pips() { + + this.ctx.globalAlpha = 1 + this.ctx.fillStyle = this.colors.textFade + + var margin = this.cssVars.padding + + if (margin < this.fontSize * 1.5) return + + + if (this.pips.x) { + + this.ctx.textAlign = 'center' + this.ctx.fillText(this.pips.x.min, margin, this.height - margin / 2) + this.ctx.fillText(this.pips.x.max, this.width - margin, this.height - margin / 2) + + } + + if (this.pips.y) { + + this.ctx.textAlign = 'right' + this.ctx.fillText(this.pips.y.min, margin / 2 + this.fontSize / 2, this.height - margin) + this.ctx.fillText(this.pips.y.max, margin / 2 + this.fontSize / 2, margin) + + } + + } + + draw_line() { + + var points = [], + padding = this.cssVars.padding + PXSCALE, + x, y + + for (let i in this.value) { + + if (this.value[i].length) { + points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], 0, this.logScaleX, true)) + points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE, 2 * PXSCALE], 0, this.logScaleY, true)) + } else { + let nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], 0, this.logScaleX, true), + ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], 0, this. logScaleY, true) + if (x !== nx || y !== ny) { + points.push(nx) + points.push(ny) + x = nx + y = ny + } + } + + } + + if (points.length < 4) return points + + this.ctx.beginPath() + + if (this.getProp('smooth')) { + this.ctx.curve(points, this.smooth, Math.round(this.width/(points.length/2 - 1))) + } else { + this.ctx.moveTo(points[0], points[1]) + let i + for (i = 2; i < points.length - 2; i += 2) { + this.ctx.lineTo(points[i], points[i + 1]) + } + this.ctx.lineTo(points[i], points[i + 1]) + } + + + + this.ctx.globalAlpha = 1 + this.ctx.lineWidth = 2 * PXSCALE + this.ctx.strokeStyle = this.cssVars.colorWidget + this.ctx.stroke() + + if (this.getProp('origin') !== false) { + + var origin = mapToScale(this.getProp('origin'), [this.rangeY.min, this.rangeY.max], [this.height - padding, padding], 0, this.getProp('logScaleY'), true) + + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.fillStyle = this.cssVars.colorFill + this.ctx.lineTo(this.width - padding, origin) + this.ctx.lineTo(padding, origin) + this.ctx.closePath() + this.ctx.fill() + + } + + return points + + } + + draw_dots(points) { + + this.ctx.globalAlpha = 1 + this.ctx.fillStyle = this.cssVars.colorWidget + this.ctx.strokeStyle = this.cssVars.colorForeground + this.ctx.lineWidth = 2 * PXSCALE + for (var i = 0; i < points.length; i += 2) { + this.ctx.beginPath() + this.ctx.arc(points[i], points[i + 1], 3 * PXSCALE, 0, 2*Math.PI) + this.ctx.fill() + this.ctx.stroke() + } + + } + + draw_bars() { + + var barWidth = Math.round(this.width / this.value.length), + offset = Math.round((this.width - barWidth * this.value.length) / 2) + + var origin = mapToScale(this.getProp('origin') !== false ? this.getProp('origin') : this.rangeY.min, [this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getProp('logScaleY'),true) + + this.ctx.beginPath() + + for (let i in this.value) { + var y = mapToScale(this.value[i].length ? this.value[i][1] : this.value[i],[this.rangeY.min,this.rangeY.max],[this.height-2*PXSCALE,2*PXSCALE],0,this.logScaleY,true) + this.ctx.rect(offset + i * barWidth, Math.min(y, origin), barWidth - PXSCALE, Math.abs(Math.min(y - origin))) + + } + + this.ctx.globalAlpha = 0.4 + this.ctx.fillStyle = this.colors.custom + this.ctx.fill() + + } + + setValue(v, options={}) { + + if (typeof v == 'string') { + try { + v = JSON.parseFlex(v) + } catch(err) {} + } + + if (typeof v == 'object' && v !== null) { + + if (Array.isArray(v)) { + + this.value = v + + } else { + + for (var i in v) { + if (!isNaN(i)) this.value[i] = v[i] + } + + } + + this.batchDraw() + + if (options.sync) this.changed(options) + + } + + + } + +} diff --git a/src/client/app/widgets/plots/visualizer.js b/src/client/app/widgets/graphs/visualizer.js similarity index 66% rename from src/client/app/widgets/plots/visualizer.js rename to src/client/app/widgets/graphs/visualizer.js index b96eb461..056173db 100644 --- a/src/client/app/widgets/plots/visualizer.js +++ b/src/client/app/widgets/graphs/visualizer.js @@ -1,7 +1,10 @@ var {clip} = require('../utils'), - _plots_base = require('./_plots_base') + Widget = require('../common/widget'), + Plot = require('./plot'), + StaticProperties = require('../mixins/static_properties') -module.exports = class Visualizer extends _plots_base { + +module.exports = class Visualizer extends StaticProperties(Plot, {rangeX: {min: '', max: ''}, dots: false, smooth: false}) { static description() { @@ -11,15 +14,14 @@ module.exports = class Visualizer extends _plots_base { static defaults() { - return super.defaults({ + return Widget.defaults({ _visualizer:'visualizer', duration: {type: 'number', value: 1, help: 'Defines visualization duration in seconds'}, - range: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, - logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, }, ['precision', 'bypass'], {}) @@ -28,20 +30,9 @@ module.exports = class Visualizer extends _plots_base { constructor(options) { - // backward compat - if (options.props.widgetId) { - options.props.value = '@{' + options.props.widgetId + '}' - delete options.props.widgetId - } - super(options) this.fps = CANVAS_FRAMERATE - this.pips.y.min = Math.abs(this.getProp('range').min) >= 1000? this.getProp('range').min/1000+'k' : this.getProp('range').min - this.pips.y.max = Math.abs(this.getProp('range').max) >= 1000? this.getProp('range').max/1000+'k' : this.getProp('range').max - this.pips.x = false - this.rangeY = this.getProp('range') || {min:0,max:1} - this.logScaleY = this.getProp('logScale') this.length = Math.round(clip(this.fps * this.getProp('duration'), [8, 4096])) this.value = new Array(this.length).fill(this.rangeY.min) this.cancel = false diff --git a/src/client/app/widgets/index.js b/src/client/app/widgets/index.js index 7e2c1298..98662671 100644 --- a/src/client/app/widgets/index.js +++ b/src/client/app/widgets/index.js @@ -11,15 +11,15 @@ module.exports.widgets = { // buttons toggle: require('./buttons/toggle'), - push: require('./buttons/push'), switch: require('./buttons/switch'), - dropdown: require('./buttons/dropdown'), - menu: require('./buttons/menu'), + dropdown: require('./buttons/dropdown'), // redo as menu derivate ? + menu: require('./buttons/menu'), // redo using canvas // pads xy: require('./pads/xy'), rgb: require('./pads/rgb'), multixy: require('./pads/multixy'), + canvas: require('./pads/canvas'), // implement... // matrices matrix: require('./matrices/matrix'), @@ -27,21 +27,22 @@ module.exports.widgets = { patchbay: require('./matrices/patchbay').PatchBay, patchbaynode: require('./matrices/patchbay').PatchBayNode, - // plots - led: require('./plots/led'), - rgbled: require('./plots/rgbled'), - plot: require('./plots/plot'), - eq: require('./plots/eq'), - visualizer: require('./plots/visualizer'), - meter: require('./plots/meter'), - text: require('./plots/text'), - image: require('./plots/image'), - svg: require('./plots/svg'), - html: require('./plots/html'), - frame: require('./plots/frame'), + // indicators + led: require('./indicators/led'), + text: require('./indicators/text'), + + // graphs + plot: require('./graphs/plot'), + eq: require('./graphs/eq'), + visualizer: require('./graphs/visualizer'), + + // frames + image: require('./frames/image'), + svg: require('./frames/svg'), + html: require('./frames/html'), + frame: require('./frames/frame'), // containers - strip: require('./containers/strip'), panel: require('./containers/panel'), modal: require('./containers/modal'), clone: require('./containers/clone'), @@ -61,12 +62,20 @@ module.exports.widgets = { } module.exports.categories = { - 'Sliders':['fader','knob', 'encoder', 'range'], - 'Buttons':['toggle','push','switch', 'dropdown', 'menu'], - 'Pads':['xy','rgb','multixy'], + 'Buttons':['toggle', 'switch', 'dropdown', 'menu'], + 'Containers':['panel', 'modal', 'clone'], + 'Frames':['frame', 'svg', 'html', 'image'], + 'Graphs':['plot','eq','visualizer'], + 'Indicator':['led', 'text'], + 'Inputs':['input', 'keys', 'script', 'gyroscope', 'file'], 'Matrices':['matrix', 'keyboard', 'patchbay'], - 'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image', 'svg', 'html', 'frame'], - 'Containers':['panel','strip','modal', 'clone'], + 'Pads':['xy','rgb','multixy', 'canvas'], + 'Sliders':['fader','knob', 'encoder', 'range'], 'Switchers':['state', 'switcher','crossfader'], - 'Inputs':['input', 'keys', 'script', 'gyroscope', 'file'] } + +var defaults = {} +for (var k in module.exports.widgets) { + defaults[k] = module.exports.widgets[k].defaults() +} +module.exports.defaults = defaults diff --git a/src/client/app/widgets/indicators/led.js b/src/client/app/widgets/indicators/led.js new file mode 100644 index 00000000..9918f62b --- /dev/null +++ b/src/client/app/widgets/indicators/led.js @@ -0,0 +1,102 @@ +var {mapToScale, clip} = require('../utils'), + Widget = require('../common/widget'), + html = require('nanohtml'), + StaticProperties = require('../mixins/static_properties') + +module.exports = class Led extends StaticProperties(Widget, {bypass: true}) { + + static description() { + + return 'Intensity display.' + + } + + static defaults() { + + return super.defaults({ + + _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.'}, + borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'}, + + }, ['precision', '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`)', + '- `String`: CSS color', + ]} + + }) + + } + + constructor(options) { + + super({...options, html: html``}) + + this.setValueIntensity(this.getProp('mode') === 'intensity' ? this.getProp('range').min : 1) + + var bR = this.getProp('borderRadius') + if (parseInt(bR) == bR) bR += 'rem' + this.container.style.setProperty('--border-radius', bR) + + } + + setValue(v, options={}) { + + + var ret = this.getProp('mode') === 'intensity' ? this.setValueIntensity(v) : this.setValueColor(v) + + + if (options.sync && ret !== false) this.changed(options) + + } + + setValueIntensity(v) { + + if (typeof v != 'number') return false + + this.value = v + this.container.style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true)) + + + } + + setValueColor(v) { + + var c = '' + + if (Array.isArray(v) && v.length >= 3) { + + for (let i in [0,1,2]) { + v[i] = parseInt(clip(v[i],[0,255])) + } + + v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1]) + + c = `rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})` + + } else if (typeof v == 'string') { + + c = v + + } else { + + return false + + } + + this.value = v + + this.container .style.setProperty('--color-led', c) + + } + +} diff --git a/src/client/app/widgets/plots/text.js b/src/client/app/widgets/indicators/text.js similarity index 63% rename from src/client/app/widgets/plots/text.js rename to src/client/app/widgets/indicators/text.js index f6aa4fc0..031662c4 100644 --- a/src/client/app/widgets/plots/text.js +++ b/src/client/app/widgets/indicators/text.js @@ -22,7 +22,7 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true}) { 'Set to `true` to wrap long lines automatically.', 'This will not break overflowing words by default, word-breaking can be enabled by adding `word-break: break-all;` to the `css` property', ]}, - align: {type: 'string', value: '', help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'}, }, ['precision', 'bypass'], {}) @@ -30,17 +30,15 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true}) { constructor(options) { - // backward compat - if (options.props.widgetId) { - options.props.value = '@{' + options.props.widgetId + '}' - delete options.props.widgetId - } - super({...options, html: html`
      `}) + super({...options, html: html``}) + + this.text = this.widget.appendChild(html`
      `) + + if (this.getProp('vertical')) this.text.classList.add('vertical') + if (this.getProp('align') === 'left') this.text.classList.add('left') + if (this.getProp('align') === 'right') this.text.classList.add('right') + if (this.getProp('wrap')) this.text.classList.add('wrap') - if (this.getProp('vertical')) this.widget.classList.add('vertical') - if (this.getProp('align') === 'left') this.widget.classList.add('left') - if (this.getProp('align') === 'right') this.widget.classList.add('right') - if (this.getProp('wrap')) this.widget.classList.add('wrap') this.defaultValue = this.getProp('default') || ( this.getProp('label')===false ? this.getProp('id'): @@ -61,9 +59,9 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true}) { var s = String(this.value) if (s.indexOf('^') > -1) { - this.widget.innerHTML = iconify(s.replace(//g, '>').replace(/\n/g,'
      ')) + this.text.innerHTML = iconify(s.replace(//g, '>').replace(/\n/g,'
      ')) } else { - this.widget.textContent = s.replace(/\n/g,'\r\n') + this.text.textContent = s.replace(/\n/g,'\r\n') } if (options.sync) this.changed(options) diff --git a/src/client/app/widgets/inputs/file.js b/src/client/app/widgets/inputs/file.js index 39938da1..fe4673a9 100644 --- a/src/client/app/widgets/inputs/file.js +++ b/src/client/app/widgets/inputs/file.js @@ -3,7 +3,7 @@ var Widget = require('../common/widget'), raw = require('nanohtml/raw'), {remoteBrowse, icon} = require('../../ui/utils') -module.exports = class Input extends Widget { +module.exports = class File extends Widget { static description() { diff --git a/src/client/app/widgets/inputs/input.js b/src/client/app/widgets/inputs/input.js index 9dea5330..6d452e67 100644 --- a/src/client/app/widgets/inputs/input.js +++ b/src/client/app/widgets/inputs/input.js @@ -16,8 +16,7 @@ module.exports = class Input extends Canvas { _input:'input', - vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, - align: {type: 'string', value: '', help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, editable: {type: 'boolean', value: true, help: 'Set to `false` to make the input non-editable'}, asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'} @@ -29,9 +28,9 @@ module.exports = class Input extends Canvas { constructor(options) { super({...options, html: html` -
      + -
      + `}) this.value = '' @@ -104,17 +103,17 @@ module.exports = class Input extends Canvas { super.resizeHandle(event) - if (this.getProp('vertical')){ - - var ratio = CANVAS_SCALING * this.scaling - - this.ctx.setTransform(1, 0, 0, 1, 0, 0) - this.ctx.rotate(-Math.PI/2) - this.ctx.translate(-this.height * ratio, 0) - - - if (ratio != 1) this.ctx.scale(ratio, ratio) - } + // if (this.getProp('vertical')){ + // + // var ratio = CANVAS_SCALING * this.scaling + // + // this.ctx.setTransform(1, 0, 0, 1, 0, 0) + // this.ctx.rotate(-Math.PI/2) + // this.ctx.translate(-this.height * ratio, 0) + // + // + // if (ratio != 1) this.ctx.scale(ratio, ratio) + // } } @@ -138,8 +137,8 @@ module.exports = class Input extends Canvas { draw() { var v = this.stringValue, - width = this.getProp('vertical') ? this.height : this.width, - height = !this.getProp('vertical') ? this.height : this.width + width = this.width, + height = this.height if (this.getProp('unit') && v.length) v += ' ' + this.getProp('unit') diff --git a/src/client/app/widgets/inputs/keys.js b/src/client/app/widgets/inputs/keys.js index a0dd2804..53d0e5c4 100644 --- a/src/client/app/widgets/inputs/keys.js +++ b/src/client/app/widgets/inputs/keys.js @@ -38,16 +38,10 @@ class Keys extends Widget { constructor(options) { - super({...options, html: html` -
      - ${raw(icon('keyboard'))} -
      - `}) + super({...options, html: null}) if (this.getProp('binding')) { - this.widget.appendChild(html`${this.getProp('binding')}`) - this.keyDownHandler = this.keyDown.bind(this) this.keyUpHandler = this.keyUp.bind(this) @@ -79,7 +73,7 @@ class Keys extends Widget { keyDown(e) { - if (e.target && e.target.classList.contains('no-keybinding')) return + if (e.target && (e.target.tagName === 'INPUT' || e.target.tabName === 'TEXTAREA' || e.target.tabName === 'SELECT')) return if (!this.getProp('repeat') && e) e.preventRepeat() @@ -104,9 +98,6 @@ class Keys extends Widget { } - - this.showKeydown() - } @@ -135,20 +126,6 @@ class Keys extends Widget { } - this.showKeyup() - - } - - showKeydown(){ - - this.widget.style.setProperty('--opacity', 1) - - } - - showKeyup(){ - - this.widget.style.setProperty('--opacity', 0.75) - } setValue(v, options = {}) { diff --git a/src/client/app/widgets/pads/canvas.js b/src/client/app/widgets/pads/canvas.js new file mode 100644 index 00000000..e9e459df --- /dev/null +++ b/src/client/app/widgets/pads/canvas.js @@ -0,0 +1,172 @@ +var Canvas = require('../common/canvas'), + html = require('nanohtml') + +class CanvasWidget extends Canvas { + static description() { + + return 'KANVA !' + + } + + static defaults() { + + return super.defaults({ + + _canvas:'canvas', + + + valueLength: {type: 'number', value: 1, help: ' '}, + multiTouch: {type: 'boolean', value: false, help: ' '}, + sensitivity: {type: 'number', value: 1, help: ' '}, + snap: {type: 'boolean', value: true, help: ' '}, + + coordsToValue: {type: 'script', value: '', help: ' '}, + valueToCoords: {type: 'script', value: '', help: ' '}, + + draw: {type: 'script', value: '', help: ' '}, + autoClear: {type: 'boolean', value: true, help: ' '}, + + }, [], {}) + + } + + constructor(options) { + + super({...options, html: html` +
      + +
      + `}) + + this.nextTouch = 0 + this.value = 1 + this.touchMap = {} + this.touchCoords = [] + for (var i = 0; i < this.getProp('valueLength'); i++) { + this.touchCoords.push([0,0]) + } + + this.localContext = {} + + this.on('draginit',(e)=>{ + + if (this.touchMap[e.pointerId] !== undefined) return + this.touchMap[e.pointerId] = this.nextTouch++ + + if (this.getProp('snap')) this.touchCoords[this.touchMap[e.pointerId]] = [e.offsetX, e.offsetY] + + this.touchCallback(e) + + }, {element: this.widget, multitouch: this.getProp('multiTouch')}) + + this.on('drag',(e)=>{ + + if (this.touchMap[e.pointerId] === undefined) return + console.log(this.touchMap[e.pointerId]) + this.touchCoords[this.touchMap[e.pointerId]][0] += e.movementX / e.inertia * this.getProp('sensitivity') + this.touchCoords[this.touchMap[e.pointerId]][1] += e.movementY / e.inertia * this.getProp('sensitivity') + + this.touchCallback(e) + + }, {element: this.widget, multitouch: this.getProp('multiTouch')}) + + this.on('dragend',(e)=>{ + + if (this.touchMap[e.pointerId] === undefined) return + delete this.touchMap[e.pointerId] + this.nextTouch-- + + this.touchCallback(e) + + }, {element: this.widget, multitouch: this.getProp('multiTouch')}) + + + + } + + touchCallback() { + + var value = this.resolveProp('coordsToValue', undefined, false, false, false, { + coords: this.touchCoords, + value: this.value, + width: this.width, + height: this.height, + local: this.localContext + }) + + if (value !== undefined) this.setValue(value, {send: true, sync: true, dragged: true}) + + } + + setValue(v, options={}) { + + if (v === null || v === undefined || ((v.length || 1) !== this.getProp('valueLength'))) return + + this.value = v + + if (!options.dragged) { + var coords = this.resolveProp('valueToCoords', undefined, false, false, false, { + coords: this.touchCoords, + value: this.value, + width: this.width, + height: this.height, + local: this.localContext + }) || this.touchCoords + + this.touchCoords = coords === undefined ? this.touchCoords : coords + } + + this.batchDraw() + + if (options.send) this.sendValue() + if (options.sync) this.changed(options) + + } + + + draw() { + + if (this.getProp('autoClear')) this.clear() + + this.resolveProp('draw', undefined, false, false, false, { + ctx: this.ctx, + coords: this.touchCoords, + value: this.value, + colors: this.colors, + width: this.width, + height: this.height, + }) + + + if (this.getProp('autoClear')) this.clearRect = [0, 0, this.width, this.height] + + } + + +} + +CanvasWidget.parsersContexts.coordsToValue = CanvasWidget.parsersContexts.valueToCoords = { + coords: [[]], + value: [], + width: 100, + height: 100, + local: {} +} + + +CanvasWidget.parsersContexts.draw = { + value: [], + coords: [[]], + colors: {}, + width: 100, + height: 100, + ctx: ()=>{} +} + + +CanvasWidget.dynamicProps = CanvasWidget.prototype.constructor.dynamicProps.concat([ + 'draw', + 'sensitivity' +]) + +module.exports = CanvasWidget diff --git a/src/client/app/widgets/pads/multixy.js b/src/client/app/widgets/pads/multixy.js index fd8d6fcc..e78eeb8a 100644 --- a/src/client/app/widgets/pads/multixy.js +++ b/src/client/app/widgets/pads/multixy.js @@ -50,14 +50,7 @@ module.exports = class MultiXy extends Pad { 'Can be set as an `object` to specify a different address : `[\'/0/x\', \'/0/y\', \'/1/x\', \'/2/y\']`', 'Note: the widget will only respond to its original osc address, not to the splitted version' ]}, - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--background: background;`: sets the dragging area\'s background', - '- `--pips-color: color;`', - '- `--pips-opacity: number;`', - '- `--color-text: point-color;`', - 'Pads can be targetted individually with the .pad-X selector (where X is the pad\'s index)', - ]} + }) } @@ -88,9 +81,8 @@ module.exports = class MultiXy extends Pad { sensitivity: this.getProp('sensitivity'), input:false }, parent: this}) - this.pads[i].sendValue = ()=>{} - this.pads[i].widget.classList.add('pad-' + i) - this.wrapper.appendChild(this.pads[i].widget) + this.pads[i].canvas.classList.add('pad-' + i) + this.widget.append(this.pads[i].canvas) } @@ -100,7 +92,7 @@ module.exports = class MultiXy extends Pad { this.padsCoords = [] this.touchMap = {} - touchstate(this, {element: this.wrapper, multitouch: true}) + touchstate(this, {element: this.widget, multitouch: true}) this.on('draginit',(e)=>{ @@ -134,7 +126,7 @@ module.exports = class MultiXy extends Pad { this.pads[id].trigger('draginit', e) - }, {element: this.wrapper, multitouch: true}) + }, {element: this.widget, multitouch: true}) this.on('drag',(e)=>{ @@ -144,7 +136,7 @@ module.exports = class MultiXy extends Pad { this.pads[i].trigger('drag', e) - }, {element: this.wrapper[0], multitouch: true}) + }, {element: this.widget, multitouch: true}) this.on('dragend',(e)=>{ @@ -158,7 +150,7 @@ module.exports = class MultiXy extends Pad { delete this.touchMap[e.pointerId] - }, {element: this.wrapper, multitouch: true}) + }, {element: this.widget, multitouch: true}) this.on('change',(e)=>{ if (e.widget == this) return @@ -176,9 +168,16 @@ module.exports = class MultiXy extends Pad { } - resizeHandle() { + resizeHandle(event){ + + super.resizeHandle(event) + + for (var k in this.pads) { + this.pads[k].width = this.width + this.pads[k].height = this.height + this.pads[k].padPadding = this.padPadding + } - super.resizeHandle(...arguments) this.updateHandlesPosition() } @@ -199,7 +198,7 @@ module.exports = class MultiXy extends Pad { this.clear() for (var i=0;i -
      - -
      -
      + + + `}) - this.wrapper = DOM.get(this.widget, '.wrapper')[0] - - this.pointSize = parseInt(this.getProp('pointSize')) - this.widget.style.setProperty('--pointSize', this.pointSize + 'rem') + this.canvas.style.setProperty('--pointSize', parseInt(this.getProp('pointSize')) + 'rem') } @@ -26,9 +21,8 @@ class Pad extends Canvas { super.cacheCanvasStyle(style) - this.colors.pips = style.getPropertyValue('--color-pips') || this.colors.custom - this.colors.pipsOpacity = style.getPropertyValue('--pips-opacity') - this.colors.pointOpacity = style.getPropertyValue('--point-opacity') + this.pointSize = parseFloat(style.getPropertyValue('--pointSize')) * PXSCALE + this.padPadding = (this.cssVars.padding + PXSCALE) } diff --git a/src/client/app/widgets/pads/xy.js b/src/client/app/widgets/pads/xy.js index c651f474..e9889f11 100644 --- a/src/client/app/widgets/pads/xy.js +++ b/src/client/app/widgets/pads/xy.js @@ -1,11 +1,17 @@ var Pad = require('./pad'), Fader = require('./_fake_fader'), doubletab = require('../mixins/double_tap'), - Input = require('../inputs/input'), touchstate = require('../mixins/touch_state') var faderDefaults = Fader.defaults()._props() +class XyFader extends Fader { + + draw(){} + batchDraw(){} + +} + module.exports = class Xy extends Pad { static description() { @@ -31,7 +37,6 @@ module.exports = class Xy extends Pad { rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - input: {type: 'boolean', value: true, help: 'Set to false to hide the built-in input widget'}, doubleTap: {type: 'boolean|string', value: false, help: [ 'Set to `true` to make the fader reset to its default value when receiving a double tap.', 'Can also be an osc address, which case the widget will just send an osc message: `/ `' @@ -46,13 +51,6 @@ module.exports = class Xy extends Pad { 'Can be set as an `object` to specify a different address : [\'/osc_address_x\', \'/osc_address_y\']', 'Note: the widget will only respond to its original osc address, not to the splitted version' ]}, - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--background: background;`: sets the dragging area\'s background', - '- `--pips-color: color;`', - '- `--pips-opacity: number;`', - '- `--point-opacity: number;`', - ]} }) @@ -63,58 +61,36 @@ module.exports = class Xy extends Pad { super(options) this.faders = { - x: new Fader({props:{ + x: new XyFader({props:{ ...faderDefaults, id:0, - compact:true, - pips:false, horizontal:true, - height:'100%', - width:'100%', default:this.getProp('default').length === 2 ? this.getProp('default')[0] : '', snap:this.getProp('snap'), range:this.getProp('rangeX'), - origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScaleX'), sensitivity: this.getProp('sensitivity'), - input:false - }, cancelDraw: true, parent: this}), - y: new Fader({props:{ + }, parent: this}), + y: new XyFader({props:{ ...faderDefaults, id:1, - compact:true, - pips:false, horizontal:false, - height:'100%', - width:'100%', default:this.getProp('default').length === 2 ? this.getProp('default')[1] : '', snap:this.getProp('snap'), range:this.getProp('rangeY'), - origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScaleY'), sensitivity: this.getProp('sensitivity'), - input:false - }, cancelDraw: true, parent: this}), + }, parent: this}), } - this.faders.x.margin = this.faders.y.margin = this.pointSize + 1 - - this.value = [this.faders.x.value, this.faders.y.value] - - this.wrapper.appendChild(this.faders.x.widget) - this.wrapper.appendChild(this.faders.y.widget) - - this.faders.x.on('change',(e)=>{ + this.on('change',(e)=>{ + if (e.widget == this) return e.stopPropagation = true }) - this.faders.y.on('change',(e)=>{ - e.stopPropagation = true - }) - - touchstate(this, {element: this.wrapper}) + touchstate(this, {element: this.canvas}) this.active = false this.on('draginit',(e)=>{ @@ -123,13 +99,13 @@ module.exports = class Xy extends Pad { this.faders.x.trigger('draginit', e) this.faders.y.trigger('draginit', e) this.dragHandle() - }, {element: this.wrapper}) + }, {element: this.canvas}) this.on('drag',(e)=>{ this.faders.x.trigger('drag', e) this.faders.y.trigger('drag', e) this.dragHandle() - }, {element: this.wrapper}) + }, {element: this.canvas}) this.on('dragend', (e)=>{ e.stopPropagation = true @@ -141,7 +117,7 @@ module.exports = class Xy extends Pad { } else { this.batchDraw() } - }, {element: this.wrapper}) + }, {element: this.canvas}) if (this.getProp('doubleTap')) { @@ -153,7 +129,7 @@ module.exports = class Xy extends Pad { } else { - doubletab(this.wrapper, ()=>{ + doubletab(this.widget, ()=>{ this.faders.x.setValue(this.faders.x.getSpringValue(), {sync: false, send:false, dragged:true}) this.faders.y.setValue(this.faders.y.getSpringValue(), {sync: false, send:false, dragged:true}) this.setValue([this.faders.x.getSpringValue(),this.faders.y.getSpringValue()],{sync:true, send:true}) @@ -163,21 +139,6 @@ module.exports = class Xy extends Pad { } - if (this.getProp('input')) { - - this.input = new Input({ - props:{...Input.defaults()._props(), precision:this.getProp('precision'), unit:this.getProp('unit')}, - parent:this, parentNode:this.widget - }) - this.widget.appendChild(this.input.widget) - this.input.on('change', (e)=>{ - e.stopPropagation = true - this.setValue(this.input.getValue(), {sync:true, send:true}) - this.showValue() - }) - - } - this.setValue([0,0]) } @@ -196,6 +157,19 @@ module.exports = class Xy extends Pad { } + resizeHandle(event){ + + super.resizeHandle(event) + + for (var k in this.faders) { + this.faders[k].width = this.width + this.faders[k].height = this.height + this.faders[k].gaugePadding = this.padPadding + + } + + } + setValue(v, options={}) { @@ -217,72 +191,97 @@ module.exports = class Xy extends Pad { this.batchDraw() - this.showValue() - } draw() { - var pointSize = this.pointSize * PXSCALE, - margin = (this.pointSize + 1) * PXSCALE, + var pointSize = this.pointSize, + margin = this.padPadding, x = this.faders.x.percentToCoord(this.faders.x.percent), y = this.faders.y.percentToCoord(this.faders.y.percent) this.clear() - this.ctx.lineWidth = PXSCALE - this.ctx.fillStyle = this.colors.custom + + this.ctx.fillStyle = this.cssVars.colorFill + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.beginPath() + this.ctx.arc(x, y, pointSize - 3 * PXSCALE, Math.PI * 2, false) + this.ctx.fill() + + + var pipsDrawn = false if (this.getProp('pips')) { - this.ctx.strokeStyle = this.colors.pips - this.ctx.globalAlpha = this.colors.pipsOpacity + + var pipTexts = margin >= this.fontSize * 1.5 + + this.ctx.lineWidth = PXSCALE + this.ctx.fillStyle = this.colors.textFade + this.ctx.strokeStyle = this.cssVars.colorStroke + this.ctx.globalAlpha = 1 this.ctx.beginPath() - for (var pip of this.faders.x.rangeKeys.concat(this.faders.x.valueToPercent(this.faders.x.originValue))) { + + for (let i in this.faders.x.rangeKeys) { + + let pip = this.faders.x.rangeKeys[i], + px = Math.round(0.5 * this.faders.x.percentToCoord(pip)) * 2 + + if (parseInt(px) === px) px -= 0.5 + + if (pipTexts) { + this.ctx.textAlign = 'center' + let label = this.faders.x.rangeLabels[i] + this.ctx.fillText(label, px, this.height - margin / 2) + pipsDrawn = true + } + if (pip == 0 || pip == 100) continue - var xpip = Math.round(2 * this.faders.x.percentToCoord(pip)) / 2 - if (xpip === parseInt(xpip)) xpip -= 0.5 - this.ctx.moveTo(xpip, margin) - this.ctx.lineTo(xpip, this.height - margin) + this.ctx.moveTo(px, margin) + this.ctx.lineTo(px, this.height - margin) + pipsDrawn = true + + } - for (pip of this.faders.y.rangeKeys.concat(this.faders.y.valueToPercent(this.faders.y.originValue))) { + for (let i in this.faders.y.rangeKeys) { + + let pip = this.faders.y.rangeKeys[i], + py = Math.round(0.5 * this.faders.y.percentToCoord(pip)) * 2 + + if (parseInt(py) === py) py -= 0.5 + + if (pipTexts) { + this.ctx.textAlign = 'right' + let label = this.faders.y.rangeLabels[i] + this.ctx.fillText(label, margin / 2 + this.fontSize / 2, py) + pipsDrawn = true + } + if (pip == 0 || pip == 100) continue - var ypip = Math.round(2 * this.faders.y.percentToCoord(pip)) / 2 - if (ypip === parseInt(ypip)) ypip -= 0.5 - this.ctx.moveTo(margin, ypip) - this.ctx.lineTo(this.width - margin, ypip) + this.ctx.moveTo(margin, py) + this.ctx.lineTo(this.width - margin, py) + pipsDrawn = true + + } + + this.ctx.globalAlpha = this.cssVars.alphaStroke this.ctx.stroke() - - } else { - - this.clearRect = [x - margin - PXSCALE, y - margin - PXSCALE, (margin + PXSCALE) * 2, (margin + PXSCALE) * 2] - } + if (!pipsDrawn) this.clearRect = [x - this.pointSize - 2 * PXSCALE, y - this.pointSize - 2 * PXSCALE, (this.pointSize + PXSCALE) * 4, (this.pointSize + PXSCALE) * 4] - this.ctx.strokeStyle = this.colors.custom - this.ctx.globalAlpha = this.active ? 1 : 0.7 - this.ctx.lineWidth = 2 * PXSCALE + + this.ctx.strokeStyle = this.cssVars.colorStroke + this.ctx.globalAlpha = this.active ? 1 : 0.75 + this.ctx.lineWidth = 1.5 * PXSCALE this.ctx.beginPath() this.ctx.arc(x, y, pointSize, Math.PI * 2, false) this.ctx.stroke() - this.ctx.fillStyle = this.colors.custom - this.ctx.globalAlpha = this.colors.pointOpacity - this.ctx.beginPath() - this.ctx.arc(x, y, pointSize / 1.5, Math.PI * 2, false) - this.ctx.fill() - - - } - - showValue() { - - if (this.getProp('input')) this.input.setValue(this.value) - } getSplit() { @@ -295,29 +294,12 @@ module.exports = class Xy extends Pad { } - - onPropChanged(propName, options, oldPropValue) { - - if (super.onPropChanged(...arguments)) return true - - switch (propName) { - - case 'color': - for (var w of [this.faders.x, this.faders.y]) { - w.onPropChanged('color') - } - if (this.input) this.input.onPropChanged('color') - return - - } - - } - onRemove() { + this.faders.x.onRemove() this.faders.y.onRemove() - if (this.input) this.input.onRemove() super.onRemove() + } } diff --git a/src/client/app/widgets/plots/_plots_base.js b/src/client/app/widgets/plots/_plots_base.js deleted file mode 100644 index 85a17fd0..00000000 --- a/src/client/app/widgets/plots/_plots_base.js +++ /dev/null @@ -1,209 +0,0 @@ -var {mapToScale} = require('../utils'), - Canvas = require('../common/canvas'), - html = require('nanohtml'), - StaticProperties = require('../mixins/static_properties') - -module.exports = class _plots_base extends StaticProperties(Canvas, {bypass: true}) { - - constructor(options) { - - super({...options, html: html` -
      - -
      - `}) - - this.value = [] - this.rangeX = this.getProp('rangeX') || {min:0,max:1} - this.rangeY = this.getProp('rangeY') || {min:0,max:1} - this.logScaleX = this.getProp('logScaleX') - this.logScaleY = this.getProp('logScaleY') - this.pips = { - x : { - min: Math.abs(this.rangeX.min)>=1000?this.rangeY.min/1000+'k':this.rangeX.min, - max: Math.abs(this.rangeX.max)>=1000?this.rangeY.max/1000+'k':this.rangeX.max - }, - y : { - min: Math.abs(this.rangeY.min)>=1000?this.rangeY.min/1000+'k':this.rangeY.min, - max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max - } - } - this.smooth = this.getProp('smooth') === true ? 0.25 : this.getProp('smooth') === false ? 0 : parseFloat(this.getProp('smooth')) || 0 - - } - - resizeHandle() { - - this.updateData() - super.resizeHandle(...arguments) - - } - - draw() { - - this.ctx.clearRect(0,0,this.width,this.height) - - if (this.getProp('bars')) { - this.draw_bars() - } else { - var points = this.draw_line() - if (this.getProp('dots')) { - this.draw_dots(points) - } - } - - if (this.getProp('pips')) this.draw_pips() - - } - - draw_pips() { - - this.ctx.globalAlpha = 1 - this.ctx.fillStyle = this.colors.text - - if (this.pips.x) { - - this.ctx.textBaseline = 'bottom' - this.ctx.textAlign = 'left' - this.ctx.fillText(this.pips.x.min,(this.pips.y?12:2)*PXSCALE,this.height) - this.ctx.textAlign = 'right' - this.ctx.fillText(this.pips.x.max,this.width-2*PXSCALE,this.height) - - } - - if (this.pips.y) { - - this.ctx.save() - this.ctx.translate(0, this.height) - this.ctx.rotate(-Math.PI/2) - - this.ctx.textBaseline = 'top' - this.ctx.textAlign = 'left' - this.ctx.fillText(this.pips.y.min,(this.pips.x?12:2)*PXSCALE,2*PXSCALE) - this.ctx.textAlign = 'right' - this.ctx.fillText(this.pips.y.max,this.height-2*PXSCALE,2*PXSCALE) - this.ctx.rotate(Math.PI/2) - this.ctx.restore() - - } - - } - - draw_line() { - - var points = [] - - for (let i in this.value) { - - if (this.value[i].length) { - points.push(mapToScale(this.value[i][0],[this.rangeX.min,this.rangeX.max],[0,this.width],0,this.logScaleX,true)) - points.push(mapToScale(this.value[i][1],[this.rangeY.min,this.rangeY.max],[this.height-2*PXSCALE,2*PXSCALE],0,this.logScaleY,true)) - } else { - points.push(mapToScale(i,[0,this.value.length-1],[0,this.width],0,this.logScaleX,true)) - points.push(mapToScale(this.value[i],[this.rangeY.min,this.rangeY.max],[this.height-2*PXSCALE,2*PXSCALE],0,this.logScaleY,true)) - } - - } - - if (points.length < 4) return points - - this.ctx.beginPath() - - this.ctx.curve(points, this.smooth, Math.round(this.width/(points.length/2 - 1))) - - this.ctx.globalAlpha = 0.7 - this.ctx.lineWidth = 2 * PXSCALE - this.ctx.strokeStyle = this.colors.custom - this.ctx.stroke() - - if (this.getProp('origin') !== false) { - - var origin = mapToScale(this.getProp('origin'), [this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getProp('logScaleY'),true) - - this.ctx.globalAlpha = 0.1 - this.ctx.fillStyle = this.colors.custom - this.ctx.lineTo(this.width,origin) - this.ctx.lineTo(0,origin) - this.ctx.closePath() - this.ctx.fill() - - } - - return points - - } - - draw_dots(points) { - - this.ctx.globalAlpha = 1 - this.ctx.fillStyle = this.colors.custom - this.ctx.strokeStyle = this.colors.track - this.ctx.lineWidth = 2 * PXSCALE - for (var i = 0; i < points.length; i += 2) { - this.ctx.beginPath() - this.ctx.arc(points[i], points[i + 1], 3 * PXSCALE, 0, 2*Math.PI) - this.ctx.fill() - this.ctx.stroke() - } - - } - - draw_bars() { - - var barWidth = Math.round(this.width / this.value.length), - offset = Math.round((this.width - barWidth * this.value.length) / 2) - - var origin = mapToScale(this.getProp('origin') !== false ? this.getProp('origin') : this.rangeY.min, [this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getProp('logScaleY'),true) - - this.ctx.beginPath() - - for (let i in this.value) { - var y = mapToScale(this.value[i].length ? this.value[i][1] : this.value[i],[this.rangeY.min,this.rangeY.max],[this.height-2*PXSCALE,2*PXSCALE],0,this.logScaleY,true) - this.ctx.rect(offset + i * barWidth, Math.min(y, origin), barWidth - PXSCALE, Math.abs(Math.min(y - origin))) - - } - - this.ctx.globalAlpha = 0.4 - this.ctx.fillStyle = this.colors.custom - this.ctx.fill() - - } - - setValue(v, options={}) { - - if (typeof v == 'string') { - try { - v = JSON.parseFlex(v) - } catch(err) {} - } - - if (typeof v == 'object' && v !== null) { - - if (Array.isArray(v)) { - - this.value = v - - } else { - - for (var i in v) { - if (!isNaN(i)) this.value[i] = v[i] - } - - } - - this.batchDraw() - - if (options.sync) this.changed(options) - - } - - - } - - updateData() { - - // update the coordinates to draw - - } - -} diff --git a/src/client/app/widgets/plots/eq.js b/src/client/app/widgets/plots/eq.js deleted file mode 100644 index dfc77509..00000000 --- a/src/client/app/widgets/plots/eq.js +++ /dev/null @@ -1,109 +0,0 @@ -var {clip} = require('../utils'), - _biquad_response = require('./_biquad_response'), - _plots_base = require('./_plots_base') - -module.exports = class Eq extends _plots_base { - - static description() { - - return 'Draws frequency response between from from an array of filter objects.' - - } - - static defaults() { - - return super.defaults({ - - _eq:'eq', - - pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'}, - resolution: {type: 'number', value: 128, help: 'Defines the number of points used to compute the frequency response'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, - logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, - - }, ['precision', 'bypass'], { - - value: {type: 'array', value: '', help: [ - 'Each item must be an object with the following properties', - '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak" or "notch")', - '- `freq`: number (filter\'s resonant frequency)', - '- `q`: number (Q factor)', - '- `gain`: number', - '- `on`: boolean', - - ]} - - }) - - } - - constructor(options) { - - // backward compat - if (options.props.filters && options.props.filters.length) { - options.props.value = options.props.filters - delete options.props.filters - } - - super(options) - - this.rangeX = {min:20,max:22050} - this.pips.x.min = '20' - this.pips.x.max = '22k' - - this.resolution = clip(this.getProp('resolution'),[64,1024]) - - } - - setValue(v, options={}) { - - if (typeof v == 'string') { - try { - v = JSON.parseFlex(v) - } catch(err) {} - } - - if (Array.isArray(v)) { - - var filters = v, - eqResponse = [] - - if (v.length === this.resolution) { - - eqResponse = v - - } else { - - for (let i in filters) { - - var filterResponse - - if (!filters[i].type) filters[i].type = 'peak' - - if (!filters[i].on) { - filterResponse = _biquad_response({type:'peak',freq:1,gain:0,q:1},!this.getProp('logScaleX'), this.resolution) - } else { - filterResponse = _biquad_response(filters[i],!this.getProp('logScaleX'), this.resolution) - } - - for (var k in filterResponse) { - if (eqResponse[k]===undefined) { - eqResponse[k]=[0,0] - } - - eqResponse[k] = [filterResponse[k][0], eqResponse[k][1]+filterResponse[k][1]] - } - - } - - } - - if (eqResponse.length) super.setValue(eqResponse, options) - - } - - } - -} diff --git a/src/client/app/widgets/plots/led.js b/src/client/app/widgets/plots/led.js deleted file mode 100644 index ee109c88..00000000 --- a/src/client/app/widgets/plots/led.js +++ /dev/null @@ -1,52 +0,0 @@ -var {mapToScale} = require('../utils'), - Widget = require('../common/widget'), - html = require('nanohtml'), - StaticProperties = require('../mixins/static_properties') - -module.exports = class Led extends StaticProperties(Widget, {bypass: true}) { - - static description() { - - return 'Intensity display.' - - } - - static defaults() { - - return super.defaults({ - - _led:'led', - - 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.'}, - - }, ['precision', 'bypass'], {}) - - } - - constructor(options) { - - // backward compat - if (options.props.widgetId) { - options.props.value = '@{' + options.props.widgetId + '}' - delete options.props.widgetId - } - - super({...options, html: html`
      `}) - - this.setValue(this.getProp('range').min) - - } - - setValue(v, options={}) { - - if (typeof v != 'number') return - - this.value = v - this.widget.style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true)) - - if (options.sync) this.changed(options) - - } - -} diff --git a/src/client/app/widgets/plots/meter.js b/src/client/app/widgets/plots/meter.js deleted file mode 100644 index 91ff0b47..00000000 --- a/src/client/app/widgets/plots/meter.js +++ /dev/null @@ -1,65 +0,0 @@ -var Fader = require('../sliders/fader'), - Widget = require('../common/widget'), - StaticProperties = require('../mixins/static_properties') - -module.exports = class Meter extends StaticProperties(Fader, {bypass: true, compact: true, input: false}) { - - static description() { - - return 'Non-interactable fader.' - - } - - static defaults() { - - return Widget.defaults({ - - _meter:'meter', - - range: {type: 'object', value: {min:0,max:1}, help: 'See fader\'s `range`'}, - logScale: {type: 'boolean', value: false, help: 'See fader\'s `logScale`'}, - origin: {type: 'number', value: 'auto', help: 'See fader\'s `origin`'}, - unit: {type: 'string', value: 'auto', help: 'See fader\'s `unit`'}, - alignRight: {type: 'boolean', value: false, help: 'See fader\'s `alignRight`'}, - horizontal: {type: 'boolean', value: false, help: 'See fader\'s `horizontal`'}, - pips: {type: 'boolean', value: false, help: 'See fader\'s `pips`'}, - dashed: {type: 'boolean', value: false, help: 'See fader\'s `dashed`'}, - gradient: {type: 'array|object', value: [], help: [ - 'When set, the meter\'s gauge will be filled with a linear color gradient', - '- each item must be a CSS color string.', - '- as an `object`: each key must be a number between 0 and 1', - '- each item must be a CSS color string.', - 'Examples: `[\'blue\', \'red\']`, {\'0\': \'blue\', \'0.9\': \'blue\', \'1\': \'red\'} ' - ]}, - - }, ['precision', 'bypass'], { - - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--color-gauge: color;`', - '- `--color-knob: color;`', - '- `--color-pips: color;`', - '- `--gauge-opacity: number;`' - ]}, - - }) - - } - - constructor(options) { - - // backward compat - if (options.props.widgetId) { - options.props.value = '@{' + options.props.widgetId + '}' - delete options.props.widgetId - } - - super(options) - - this.widget.classList.add('meter') - - this.off(/drag(.*)?/) - - } - -} diff --git a/src/client/app/widgets/plots/plot.js b/src/client/app/widgets/plots/plot.js deleted file mode 100644 index 10e6efab..00000000 --- a/src/client/app/widgets/plots/plot.js +++ /dev/null @@ -1,53 +0,0 @@ -var _plots_base = require('./_plots_base') - -module.exports = class Plot extends _plots_base { - - static description() { - - return 'XY coordinates plot.' - - } - - static defaults() { - - - return super.defaults({ - - _plot:'plot', - - rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it.'}, - dots: {type: 'boolean', value: true, help: ''}, - bars: {type: 'boolean', value: false, help: 'Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing)'}, - smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, - pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - - }, ['precision', 'bypass'], { - - value: {type: 'array|string', value: '', help: [ - '- `Array` of `y` values', - '- `Array` of `[x, y]` `array` values', - '- `String` `array`', - '- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points\' coordinates', - ]} - - }) - - } - - constructor(options) { - - // backward compat - if (options.props.points && options.props.points.length) { - options.props.value = options.props.points - delete options.props.points - } - - super(options) - - } - -} diff --git a/src/client/app/widgets/plots/rgbled.js b/src/client/app/widgets/plots/rgbled.js deleted file mode 100644 index 7141965c..00000000 --- a/src/client/app/widgets/plots/rgbled.js +++ /dev/null @@ -1,79 +0,0 @@ -var Widget = require('../common/widget'), - {clip} = require('../utils'), - html = require('nanohtml'), - StaticProperties = require('../mixins/static_properties') - -module.exports = class Rbgled extends StaticProperties(Widget, {bypass: true}) { - - static description() { - - return 'Rgb / rgba color display' - - } - - static defaults() { - - return super.defaults({}, ['color', 'precision', 'bypass'], { - - value: {type: 'array|string', value: '', help: [ - '- `Array`: `[r, g, b]` (`r`, `g` and `b` between `0` and `255`)', - '- `Array`: `[r, g, b, alpha]` (`alpha` between `0` and `255`)', - '- `String`: CSS color', - ]} - - }) - - } - - constructor(options) { - - // backward compat - if (options.props.widgetId) { - options.props.value = '@{' + options.props.widgetId + '}' - delete options.props.widgetId - } - - super({...options, html: html` -
      -
      - `}) - - this.setValue([0,0,0,0]) - - } - - - setValue(v, options={}) { - - var c = '' - - if (Array.isArray(v) && v.length >= 3) { - - for (let i in [0,1,2]) { - v[i] = parseInt(clip(v[i],[0,255])) - } - - v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1]) - - c = `rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})` - - } else if (typeof v == 'string') { - - c = v - - - } else { - - return - - } - - this.value = v - - this.widget.style.setProperty('--color-led', c) - - if (options.sync) this.changed(options) - - } - -} diff --git a/src/client/app/widgets/scripts/script.js b/src/client/app/widgets/scripts/script.js new file mode 100644 index 00000000..8c832ab7 --- /dev/null +++ b/src/client/app/widgets/scripts/script.js @@ -0,0 +1,20 @@ +var {mapToScale} = require('../utils'), + Widget = require('../common/widget'), + StaticProperties = require('../mixins/static_properties') + +module.exports = class Script extends StaticProperties(Widget, {visible: false}) { + + constructor(options) { + + super(options) + + // compile script + + } + + runScript() { + + } + + +} diff --git a/src/client/app/widgets/sliders/encoder.js b/src/client/app/widgets/sliders/encoder.js index 6a8563c6..349a4afc 100644 --- a/src/client/app/widgets/sliders/encoder.js +++ b/src/client/app/widgets/sliders/encoder.js @@ -2,32 +2,11 @@ var {clip} = require('../utils'), Knob = require('./knob'), Widget = require('../common/widget'), doubletab = require('../mixins/double_tap'), - html = require('nanohtml') + html = require('nanohtml'), + StaticProperties = require('../mixins/static_properties') - -var EncoderKnob = class extends Knob { - draginitHandle(e) { - - this.percent = clip(this.percent,[0,100]) - - this.lastOffsetX = e.offsetX - this.lastOffsetY = e.offsetY - - if (!(e.traversing || this.getProp('snap'))) return - - this.percent = this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY)) - - this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true, draginit:!e.traversing}) - - } - mousewheelHandle(){} -} -var DisplayKnob = class extends Knob { - -} - -module.exports = class Encoder extends Widget { +module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range: {min: 0, max: 1}, sensitivity: 1, steps: ''}) { static description() { @@ -37,11 +16,10 @@ module.exports = class Encoder extends Widget { static defaults() { - return super.defaults({ + return Widget.defaults({ _encoder: 'encoder', - compact: {type: 'boolean', value: false, help: 'Set to `true` to display a compact alternative for the widget.'}, ticks: {type: 'number', value: 360, help: 'defines the granularity / verbosity of the encoder (number of step for a 360° arc)'}, back: {type: '*', value: -1, help: 'Defines which value is sent when rotating the encoder anticlockwise'}, forth: {type: '*', value: 1, help: 'Defines which value is sent when rotating the encoder clockwise'}, @@ -50,7 +28,11 @@ module.exports = class Encoder extends Widget { '- Set to `null` to send send no argument in the osc message', '- Can be an `object` if the type needs to be specified' ]}, - snap: {type: 'boolean', value: false, help: 'By default, dragging the widget will modify it\'s value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position'}, + mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], help: [ + '- `circular`: relative move in circular motion', + '- `snap`: snap to touch position and move in vertical motion', + '- `vertical`: relative move in vertical motion', + ]}, doubleTap: {type: 'boolean', value: false, help: [ 'Set to `true` to make the fader reset to its `default` value when receiving a double tap.', 'Can also be an osc address, in which case the widget will just send an osc message (`/ `)' @@ -66,217 +48,213 @@ module.exports = class Encoder extends Widget { constructor(options) { - super({...options, html: html` -
      -
      -
      -
      - `}) + super(options) - this.wrapper = DOM.get(this.widget, '.wrapper')[0] - this.ticks = Math.abs(parseInt(this.getProp('ticks')) || 360) + this.previousPercent = 50 + this.percent = 50 + this.setValue(this.getProp('release'), {dragged: true}) - this.knob = new EncoderKnob({props:{ - label:false, - angle:360, - snap:true, - range:{min:0,max:this.ticks}, - pips:false, - }, parent: this}) + } - this.knob.batchDraw = ()=>{} + angleToPercent(angle, snap) { - this.display = new DisplayKnob({props:{ - label:false, - angle:360, - range:{min:0,max:this.ticks}, - origin:this.ticks/2, - pips:false, - compact: this.getProp('compact') - }, parent: this}) + // knob.js without clipping + if (snap) return super.angleToPercent(angle) - this.knob.widget.classList.add('drag-knob') - this.display.widget.classList.add('display-knob') + var percent = angle - (360 - this.maxAngle) / 2 / this.maxAngle * 100 + if (percent < 0) percent += 100 + else if (percent > 100) percent -= 100 - this.wrapper.appendChild(this.knob.widget) - this.wrapper.appendChild(this.display.widget) + return percent - this.knob.setValue(this.ticks/2) - this.display.setValue(this.ticks/2) + } - this.previousValue = this.ticks/2 + percentToAngle(percent, snap) { - this.on('change',(e)=>{ + // knob.js without clipping + if (snap) return super.percentToAngle(percent) - if (e.widget == this) return + return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle + + Math.PI / 2 // quarter circle offset + + Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle - e.stopPropagation = true - - var value = this.knob.getValue() - - var direction - - if (value < this.previousValue) - direction = this.getProp('back') - if (value > this.previousValue) - direction = this.getProp('forth') - - if ((this.ticks * .75 < value && value < this.ticks) && (0 < this.previousValue && this.previousValue < this.ticks / 4)) - direction = this.getProp('back') - if ((0 < value && value < this.ticks / 4) && (this.ticks * .75 < this.previousValue && this.previousValue < this.ticks)) - direction = this.getProp('forth') + } - if (direction !== undefined && (Math.round(value) != Math.round(this.previousValue))) this.setValue(direction, {sync:true, send:true, dragged: e.options.dragged, draginit: e.options.draginit}) + draginitHandle(e) { - this.previousValue = value + // knob.js without clipping + extra case for snap - }) + this.lastOffsetX = e.offsetX + this.lastOffsetY = e.offsetY - this.knob.on('draginit', (e)=>{ - if (this.getProp('touchAddress') && this.getProp('touchAddress').length - && e.target == this.wrapper) - this.sendValue({ - address:this.getProp('touchAddress'), - v:1 - }) - }) + if (this.getProp('mode') === 'snap') { - this.knob.on('dragend', (e)=>{ - if (this.getProp('release') !== '' && this.value !== this.getProp('release')) { - this.knob.setValue(this.ticks/2) - this.display.setValue(this.ticks/2) - this.setValue(this.getProp('release'), {sync:true, send:true, dragged:false}) - } - if ( - this.getProp('touchAddress') && this.getProp('touchAddress').length - && e.target == this.wrapper - ) { - this.sendValue({ - address:this.getProp('touchAddress'), - v:0 - }) - } - }) - - if (this.getProp('doubleTap')) { - - doubletab(this.wrapper, ()=>{ - this.knob.setValue(this.ticks/2) - this.display.setValue(this.ticks/2) - if (this.getProp('release') !== '' && this.value !== this.getProp('release')) { - this.setValue(this.getProp('release'), {sync:true, send:true, dragged:false}) - } - }) + this.setPercent(this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY), true)) } - this.wrapper.addEventListener('mousewheel', (e)=>{ - if (e.wheelDeltaX || e.wheelDelta == 0) return - var direction = e.wheelDelta / Math.abs(e.wheelDelta) + } - this.display.setValue(this.display.value + direction) - this.setValue(direction < 0 ? this.getProp('back') : this.getProp('forth'), {sync:true, send:true}) + dragHandle(e) { + + // knob.js without clipping + extra case for snap + + if ((this.getProp('mode') === 'vertical' && !e.traversing) || e.ctrlKey) { + // vertical + this.setPercent(-100 * (e.movementY / e.inertia * this.getProp('sensitivity')) / this.height + this.percent) + + } else { + // snap or circular + var offsetX = this.lastOffsetX + e.movementX / e.inertia, + offsetY = this.lastOffsetY + e.movementY / e.inertia + + if (true || e.traversing && this.getProp('mode') === 'circular') { + // circular + var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true) + if (Math.abs(diff) < 50 && diff !== 0) this.setPercent(this.percent + diff) + + } else { + + // snap + this.setPercent(this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true)) - if (this.getProp('release') !== '' && this.value !== this.getProp('release')) { - this.knob.setValue(this.ticks/2) - this.display.setValue(this.ticks/2) - this.setValue(this.getProp('release'), {sync:true, send:true, dragged:false}) } + + this.lastOffsetX = offsetX + this.lastOffsetY = offsetY + + } + + } + + dragendHandle(e, data, traversing) { + + if (this.getProp('release') === '') return + + this.previousPercent = 50 + this.percent = 50 + this.setValue(this.getProp('release'), {sync: true, send: true, dragged: true}) + + } + + mousewheelHandle(e) { + + if (e.wheelDeltaX) return + + e.preventDefault() + e.stopPropagation() + + var direction = e.wheelDelta / Math.abs(e.wheelDelta), + increment = e.ctrlKey?0.25:1 + + this.setPercent(this.percent + Math.max(increment, 10 / Math.pow(10, this.precision + 1)) * direction) + + } + + setPercent(percent) { + + var div = 100 / this.getProp('ticks') + percent = Math.round(percent / div) * div + + this.previousPercent = this.percent + this.percent = percent + + if (this.percent === this.previousPercent) return + + var dir = this.percent > this.previousPercent + + if ( + (this.percent >= 0 && this.percent < 25 && this.previousPercent > 75 && this.previousPercent <= 100) || + (this.previousPercent >= 0 && this.previousPercent < 25 && this.percent > 75 && this.percent <= 100) + + ) dir = !dir + + var val = dir ? this.getProp('forth') : this.getProp('back') + + this.setValue(val, { + sync: true, + send: true, + dragged: true, }) + } + + getSpringValue() { + + return this.getProp('release') } setValue(v,options={}) { - if (this.getProp('snap') || (!this.getProp('snap') && !options.draginit)) { + if (options.fromLocal && v === this.getProp('release')) { + this.percent = 50 + this.previousPercent = 50 + } else if ( + !options.dragged || + (v !== this.getProp('forth') && v !== this.getProp('back') && (this.getProp('release') === '' && v !== this.getProp('release'))) - var match = true + ) return - if (v === this.getProp('back')) { - this.value = this.getProp('back') - } else if (v === this.getProp('forth')) { - this.value = this.getProp('forth') - } else if (v === this.getProp('release') && this.getProp('release') !== '') { - this.value = this.getProp('release') - } else { - match = false - } + this.value = v - } + this.batchDraw() - if (options.sync && match) this.changed(options) - if (options.send && match && !(!this.getProp('snap') && options.draginit)) this.sendValue() - - if (options.dragged || options.draginit) this.updateDisplay(options.draginit) + if (options.send) this.sendValue() + if (options.sync) this.changed(options) } - updateDisplay(init){ + draw() { - if (this.getProp('snap')) { - this.display.setValue(this.knob.value) - return + var percent = this.percent, + d = this.percentToAngle(percent), + angle = 2 * Math.PI / 16, + min = this.percentToAngle(0), + max = this.percentToAngle(100), + minRadius = this.minDimension / 6, + maxRadius = this.minDimension / 2 - PXSCALE, + gaugeWidth = maxRadius - minRadius, + gaugeRadius = maxRadius - gaugeWidth / 2 + + this.clear() + + // fill + this.ctx.globalAlpha = this.cssVars.alphaFill + this.ctx.strokeStyle = this.cssVars.colorFill + this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 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() } - if (init) { - - this.offset = this.knob.value - this.display.value - - } else { - - var v = this.knob.value - this.offset, - updateOffset - - if (v > this.ticks) { - - v = this.ticks - v - updateOffset = true - - - } else if (v < 0) { - - v = v + this.ticks - updateOffset = true - - } - - this.display.setValue(v) - - if (updateOffset) { - this.offset = this.knob.value - this.display.value - } + if (this.cssVars.alphaFillOn) { + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, d - angle, d + angle) + this.ctx.stroke() } - if (this.offset > this.ticks) this.offset = this.ticks - this.offset - if (this.offset < 0) this.offset = this.offset + this.ticks + // stroke - } + this.ctx.globalAlpha = this.cssVars.alphaStroke + 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() - onPropChanged(propName, options, oldPropValue) { + this.ctx.beginPath() + this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI) + this.ctx.stroke() - if (super.onPropChanged(...arguments)) return true - - switch (propName) { - - case 'color': - for (var w of [this.knob, this.display]) { - w.onPropChanged('color') - } - return - - } - - } - - onRemove() { - this.knob.onRemove() - this.display.onRemove() - super.onRemove() } } diff --git a/src/client/app/widgets/sliders/fader.js b/src/client/app/widgets/sliders/fader.js index 0cd472b3..af5a0a89 100644 --- a/src/client/app/widgets/sliders/fader.js +++ b/src/client/app/widgets/sliders/fader.js @@ -20,14 +20,14 @@ module.exports = class Fader extends Slider { horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'}, alignRight: {type: 'boolean', value: false, help: 'Set to `true` to invert the pip\'s and fader\'s position'}, pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - input: {type: 'boolean', value: true, help: 'Set to `false` to hide the built-in input'}, - meter: {type: 'boolean', value: false, help: [ - 'Set to true to display a vu-meter next in the fader', - '- the meter\'s `id` will be the same as the widget\'s with `/meter` appended to it', - '- the meter\'s `address` will be the same as the widget\'s with `/meter` appended to it' - ]}, - compact: {type: 'boolean', value: false, help: 'Set to `true` to display a compact alternative for the widget. If `input` is `true`, the input can be focused with a right-click (mouse only). Disables `pips` when enabled.'}, dashed: {type: 'boolean', value: false, help: 'Set to `true` to display a dashed gauge'}, + gradient: {type: 'array|object', value: [], help: [ + 'When set, the meter\'s gauge will be filled with a linear color gradient', + '- each item must be a CSS color string.', + '- as an `object`: each key must be a number between 0 and 1', + '- each item must be a CSS color string.', + 'Examples: `[\'blue\', \'red\']`, {\'0\': \'blue\', \'0.9\': \'blue\', \'1\': \'red\'} ' + ]}, snap: {type: 'boolean', value: false, help: 'By default, dragging the widget will modify it\'s value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position'}, spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, doubleTap: {type: 'boolean', value: false, help: [ @@ -48,21 +48,12 @@ module.exports = class Fader extends Slider { '- `number`: define a number of evenly spaced steps', '- `array`: use arbitrary values', ]}, - unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'}, }, [], { touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'}, - meterAddress: {type: 'string', value:'', help: 'OSC address for the built-in meter'}, - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--color-gauge: color;`', - '- `--color-knob: color;`', - '- `--color-pips: color;`', - '- `--gauge-opacity: number;`', - '- `--gauge-width: number;` (2-16, requires a manual resize to take effect)' - ]} + }) } @@ -72,50 +63,18 @@ module.exports = class Fader extends Slider { super(options) this.widget.classList.add('fader') - this.margin = 22 - this.gaugeWidth = 2 - + this.gaugeGradient = null if (this.getProp('horizontal')) { this.widget.classList.add('horizontal') this.container.classList.add('horizontal') } - if (this.getProp('compact')) { - this.margin = 0 - } - if (this.getProp('alignRight') && !this.getProp('horizontal')) { this.widget.classList.add('align-right') } - if (this.getProp('meter')) { - var data = { - type:'meter', - id: this.getProp('id') + '/meter', - label:false, - horizontal:this.getProp('horizontal'), - range:this.getProp('range'), - logScale:this.getProp('logScale'), - address: '#{@{parent.meterAddress} ? @{parent.meterAddress} : concat(@{parent.address}, "/meter")}', - preArgs: '@{parent.preArgs}', - target: '@{parent.target}', - color: '@{parent.color}', - pips:false, - dashed:true - } - var meter = parser.parse({ - data: data, - parentNode: this.wrapper, - parent: this - }) - - meter.container.classList.add('not-editable') - this.children.push(meter) - this.widget.classList.add('has-meter') - } - - if (this.getProp('pips')) { + if (false && this.getProp('pips')) { this.widget.classList.add('has-pips') @@ -139,7 +98,7 @@ module.exports = class Fader extends Slider { } - this.wrapper.appendChild(pips) + this.widget.appendChild(pips) } @@ -155,12 +114,12 @@ module.exports = class Fader extends Slider { if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return this.percent = this.getProp('horizontal')? - (e.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100: - (this.height - e.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100 + (e.offsetX - this.gaugePadding) / (this.width - this.gaugePadding * 2) * 100: + (this.height - e.offsetY - this.gaugePadding) / (this.height - this.gaugePadding * 2) * 100 // this.percent = clip(this.percent,[0,100]) - this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true}) + this.setValue(this.percentToValue(this.percent), {send: true, sync: true, dragged: true}) } @@ -169,8 +128,8 @@ module.exports = class Fader extends Slider { super.dragHandle(...arguments) this.percent = this.getProp('horizontal')? - this.percent + ( e.movementX/(this.width - this.margin * PXSCALE * 2)) * 100 / e.inertia * this.getProp('sensitivity'): - this.percent + (-e.movementY/(this.height - this.margin * PXSCALE * 2)) * 100 / e.inertia * this.getProp('sensitivity') + this.percent + ( e.movementX / (this.width - this.gaugePadding * 2)) * 100 / e.inertia * this.getProp('sensitivity'): + this.percent + (-e.movementY / (this.height - this.gaugePadding * 2)) * 100 / e.inertia * this.getProp('sensitivity') this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true}) @@ -179,9 +138,9 @@ module.exports = class Fader extends Slider { percentToCoord(percent) { if (this.getProp('horizontal')) { - return clip(percent / 100,[0,1]) * (this.width - 2 * PXSCALE * this.margin) + this.margin * PXSCALE + return clip(percent / 100,[0,1]) * (this.width - this.gaugePadding * 2) + this.gaugePadding } else { - return (this.height - this.margin * PXSCALE) - clip(percent / 100, [0,1]) * (this.height - 2 * PXSCALE * this.margin) + return (this.height - this.gaugePadding) - clip(percent / 100, [0,1]) * (this.height - this.gaugePadding * 2) } } @@ -190,14 +149,12 @@ module.exports = class Fader extends Slider { var ratio = CANVAS_SCALING * this.scaling - if (this.getProp('compact') && this.getProp('horizontal')) { - event.height = 1 / ratio - } + // if (this.getProp('compact') && this.getProp('horizontal')) { + // event.height = 1 / ratio + // } super.resizeHandle(event) - this.gaugeWidth = Math.max(2, Math.min(16, parseInt(event.style.getPropertyValue('--gauge-width')) || 2)) - if (this.getProp('horizontal')){ this.ctx.setTransform(1, 0, 0, 1, 0, 0) this.ctx.rotate(-Math.PI/2) @@ -223,7 +180,7 @@ module.exports = class Fader extends Slider { for (var i in colors) { grad.addColorStop(i / (colors.length - 1), colors[i]) } - this.colors.gradient = grad + this.gaugeGradient = grad } else { @@ -232,7 +189,7 @@ module.exports = class Fader extends Slider { grad.addColorStop(clip(k, [0, 1]), colors[k]) } } - this.colors.gradient = grad + this.gaugeGradient = grad } } catch(err) { @@ -243,7 +200,6 @@ module.exports = class Fader extends Slider { } - } @@ -255,103 +211,58 @@ module.exports = class Fader extends Slider { var percent = this.getProp('steps') ? this.valueToPercent(this.value) : this.percent, d = Math.round(this.percentToCoord(percent)), o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))), - m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2) + m = this.getProp('horizontal') ? this.height / 2 : this.width / 2 + + // sharp border trick + if (width % 2 && parseInt(m) === m) m -= 0.5 var dashed = this.getProp('dashed') this.clear() - if (this.getProp('compact')) { + this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill + this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2) - this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-o) / (d d) - 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([]) - if (this.getProp('compact')) { - this.ctx.globalAlpha = 1 - let r1 = gaugeRadius - gaugeWidth / 2 + 2 * PXSCALE, - r2 = gaugeRadius + gaugeWidth / 2 - 2 * PXSCALE, - 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)) + // stroke - this.ctx.lineWidth = PXSCALE - this.ctx.strokeStyle = this.colors.knob - this.ctx.stroke() - return - } + this.ctx.globalAlpha = this.cssVars.alphaStroke + 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() + + 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() + + // pips if (pips) { this.ctx.globalAlpha = 1 + this.ctx.lineWidth = 1.5 * PXSCALE + this.ctx.strokeStyle = this.cssVars.colorStroke for (var pip of this.rangeKeys.concat(this.valueToPercent(this.originValue))) { - let a = this.percentToAngle(pip) + let r1 = maxRadius, + r2 = r1 + 4 * PXSCALE, + a = 2 * Math.PI - this.percentToAngle(pip) - this.ctx.lineWidth = gaugeWidth + 2 * PXSCALE - this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, a - 4.5 * rad, a + 4.5 * rad) - this.ctx.strokeStyle = this.colors.fg - this.ctx.stroke() - this.ctx.strokeStyle = this.colors.light - this.ctx.stroke() - this.ctx.lineWidth = gaugeWidth + 1.5 * PXSCALE - this.ctx.strokeStyle = this.colors.pips this.ctx.beginPath() - this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, a - 2 * rad, a + 2 * rad) + 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() } - var radius = gaugeRadius + this.fontSize * PXSCALE + gaugeWidth / 2 + var radius = maxRadius + this.fontSize * 1.5 this.ctx.fillStyle = this.colors.textFade for (var p in this.pipTexts) { if (this.pipTexts[p] == undefined) continue @@ -294,46 +269,6 @@ module.exports = class Knob extends Slider { } - // knob - - this.ctx.lineWidth = PXSCALE - - this.ctx.fillStyle = this.colors.raised - this.ctx.beginPath() - this.ctx.globalAlpha = 1 - this.ctx.arc(this.width / 2, this.height / 2, knobRadius, 0, Math.PI * 2) - this.ctx.fill() - this.ctx.strokeStyle = this.colors.bg - this.ctx.stroke() - - this.ctx.beginPath() - this.ctx.globalAlpha = 1 - this.ctx.arc(this.width / 2, this.height / 2, knobRadius - PXSCALE * 1.5, 0, Math.PI * 2) - this.ctx.strokeStyle = this.colors.light - this.ctx.stroke() - - var g = this.ctx.createLinearGradient(this.width / 2, this.height / 2 - knobRadius / 2,this.width / 2, this.height / 2 + knobRadius / 2) - g.addColorStop(0.5, 'transparent') - g.addColorStop(0, this.colors.light || 'transparent') - - this.ctx.strokeStyle = g - this.ctx.stroke() - - // cursor - this.ctx.globalAlpha = 1 - - let r1 = knobRadius - PXSCALE, - r2 = knobRadius / 4, - 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.lineWidth = gaugeWidth - 4.5 * PXSCALE - this.ctx.strokeStyle = this.colors.knob - this.ctx.stroke() - } } diff --git a/src/client/app/widgets/sliders/range.js b/src/client/app/widgets/sliders/range.js index 03beb588..25ecc348 100644 --- a/src/client/app/widgets/sliders/range.js +++ b/src/client/app/widgets/sliders/range.js @@ -1,5 +1,5 @@ var {clip} = require('../utils'), - Widget = require('../common/widget'), + Canvas = require('../common/canvas'), Fader = require('./fader'), Input = require('../inputs/input'), touchstate = require('../mixins/touch_state'), @@ -7,172 +7,7 @@ var {clip} = require('../utils'), var faderDefaults = Fader.defaults()._props() -var RangeFader = class RangeFader extends Fader { - - constructor(options) { - - super(options) - this.cancelDraw = options.cancelDraw - - } - - sendValue() {} - - draginitHandle() { - - this.percent = clip(this.percent,[ - this.valueToPercent(this.rangeValsMin), - this.valueToPercent(this.rangeValsMax) - ]) - - super.draginitHandle(...arguments) - } - - draw() { - - if (this.cancelDraw || !this.parent.faders) return - - var width = this.getProp('horizontal') ? this.height : this.width, - height = !this.getProp('horizontal') ? this.height : this.width - - var d = Math.round(this.percentToCoord(this.valueToPercent(this.parent.faders[this.getProp('horizontal')?0:1].value))), - d2 = Math.round(this.percentToCoord(this.valueToPercent(this.parent.faders[this.getProp('horizontal')?1:0].value))), - m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2) - - var dashed = this.getProp('dashed') - - this.clear() - - if (this.getProp('compact')) { - - this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-d2) / height - this.ctx.strokeStyle = this.colors.gauge - this.ctx.beginPath() - this.ctx.moveTo(m, d2) - this.ctx.lineTo(m, d) - this.ctx.lineWidth = width + 2 * PXSCALE - if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE]) - this.ctx.stroke() - if (dashed) this.ctx.setLineDash([]) - - this.ctx.globalAlpha = 1 - this.ctx.beginPath() - this.ctx.fillStyle = this.colors.knob - this.ctx.rect(0, Math.min(d, height - PXSCALE), width, PXSCALE) - this.ctx.rect(0, Math.min(d2, height - PXSCALE), width, PXSCALE) - this.ctx.fill() - - this.clearRect = [0, 0, width, height] - - } else { - - this.ctx.lineWidth = 6 * PXSCALE - - this.ctx.beginPath() - this.ctx.globalAlpha = 1 - this.ctx.strokeStyle = this.colors.light - this.ctx.moveTo(m, this.margin * PXSCALE - 2 * PXSCALE) - this.ctx.lineTo(m, height - this.margin * PXSCALE + 2 * PXSCALE) - this.ctx.stroke() - - this.ctx.lineWidth = 4 * PXSCALE - - this.ctx.beginPath() - this.ctx.globalAlpha = 1 - this.ctx.strokeStyle = this.colors.bg - this.ctx.moveTo(m, this.margin * PXSCALE - 1 * PXSCALE) - this.ctx.lineTo(m, height - this.margin * PXSCALE + 1 * PXSCALE) - this.ctx.stroke() - - this.ctx.lineWidth = 2 * PXSCALE - - this.ctx.beginPath() - this.ctx.strokeStyle = this.colors.track - this.ctx.moveTo(m, this.margin * PXSCALE) - this.ctx.lineTo(m, height - this.margin * PXSCALE) - this.ctx.stroke() - - this.ctx.beginPath() - this.ctx.globalAlpha = 0.7 - this.ctx.strokeStyle = this.colors.gauge - this.ctx.moveTo(m, d2) - this.ctx.lineTo(m, d) - if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE]) - this.ctx.stroke() - if (dashed) this.ctx.setLineDash([]) - - this.ctx.globalAlpha = 1 - - // high knob bg - - this.ctx.beginPath() - this.ctx.rect(m - 9 * PXSCALE, d - 14 * PXSCALE, 18 * PXSCALE, 16 * PXSCALE) - this.ctx.lineWidth = PXSCALE - this.ctx.fillStyle = this.colors.bg - this.ctx.fill() - - // low knob bg - - this.ctx.beginPath() - this.ctx.rect(m - 9 * PXSCALE, d2 - PXSCALE, 18 * PXSCALE, 16 * PXSCALE) - this.ctx.lineWidth = PXSCALE - this.ctx.fillStyle = this.colors.bg - this.ctx.fill() - - // high knob - - this.ctx.beginPath() - this.ctx.rect(m - 8 * PXSCALE, d - 13 * PXSCALE, 16 * PXSCALE, 14 * PXSCALE) - this.ctx.fillStyle = this.colors.raised - this.ctx.fill() - this.ctx.lineWidth = PXSCALE - - this.ctx.beginPath() - this.ctx.rect(m - 7.5 * PXSCALE, d - 12.5 * PXSCALE, 15 * PXSCALE, 13.5 * PXSCALE) - this.ctx.lineWidth = PXSCALE - this.ctx.strokeStyle = this.colors.light - this.ctx.stroke() - - this.ctx.beginPath() - this.ctx.rect(m - 8 * PXSCALE, d - 13 * PXSCALE, 16 * PXSCALE, PXSCALE) - this.ctx.lineWidth = PXSCALE - this.ctx.fillStyle = this.colors.light - this.ctx.fill() - - this.ctx.beginPath() - this.ctx.rect(m - 4 * PXSCALE, d, 8 * PXSCALE, PXSCALE) - this.ctx.fillStyle = this.colors.knob - this.ctx.fill() - - // low knob - - this.ctx.beginPath() - this.ctx.rect(m - 8 * PXSCALE, d2, 16 * PXSCALE, 14 * PXSCALE) - this.ctx.fillStyle = this.colors.raised - this.ctx.fill() - this.ctx.lineWidth = PXSCALE - - this.ctx.beginPath() - this.ctx.rect(m - 7.5 * PXSCALE, d2, 15 * PXSCALE, 13.5 * PXSCALE) - this.ctx.lineWidth = PXSCALE - this.ctx.strokeStyle = this.colors.light - this.ctx.stroke() - - this.ctx.beginPath() - this.ctx.rect(m - 4 * PXSCALE, d2, 8 * PXSCALE, PXSCALE) - this.ctx.fillStyle = this.colors.knob - this.ctx.fill() - - - - this.clearRect = [width / 2 - 11 * PXSCALE, 0, 22 * PXSCALE, height] - } - } - -} - - -class Range extends Widget { +class Range extends Fader { static description() { @@ -180,94 +15,43 @@ class Range extends Widget { } - static defaults() { - - return super.defaults({ - - _range:'range', - - range: {type: 'object', value: {min:0,max:1}, help: 'See fader\'s `range`'}, - horizontal: {type: 'boolean', value: false, help: 'See fader\'s `horizontal`'}, - alignRight: {type: 'boolean', value: false, help: 'See fader\'s `alignRight`'}, - input: {type: 'boolean', value: true, help: 'See fader\'s `input`'}, - compact: {type: 'boolean', value: false, help: 'See fader\'s `compact`'}, - pips: {type: 'boolean', value: true, help: 'See fader\'s `pips`'}, - snap: {type: 'boolean', value: false, help: 'See fader\'s `snap`'}, - spring: {type: 'boolean', value: false, help: 'See fader\'s `spring`'}, - logScale: {type: 'boolean', value: false, help: 'See fader\'s `logScale`'}, - sensitivity: {type: 'number', value: 1, help: 'See fader\'s `sensitivity`'}, - - }, [], { - - touchAddress: {type: 'string', value: '', help: 'See fader\'s `touchAddress`'}, - split: {type: 'boolean|object', value: false, help: [ - 'Set to `true` to send separate osc messages for `low` and `high` handles. The `address` will be the same as the widget\'s with `/low` or `/high` appended to it', - 'Can be set as an object to specify a different `address` : `[\'/osc_address_low\', \'/osc_address_high\']`', - 'Note: the widget will only respond to its original osc address, not to the splitted version' - ]}, - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--color-gauge: color;`', - '- `--color-knob: color;`', - '- `--color-pips: color;`', - '- `--gauge-opacity: number;`' - ]} - - }) - - } - constructor(options) { + options.multitouch = true + super({...options, html: html` -
      -
      -
      + `}) - this.wrapper = DOM.get(this.widget, '.wrapper')[0] - this.faders = [ - new RangeFader({props:{ + new Fader({props:{ ...faderDefaults, - compact:this.getProp('compact'), pips:false, - alignRight:false, + visible: false, horizontal:this.getProp('horizontal'), - height:'100%', - width:'100%', default:this.getProp('default').length === 2 ? this.getProp('default')[0] : this.getProp('range').min, snap:this.getProp('snap'), spring:this.getProp('spring'), range:this.getProp('range'), - origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScale'), sensitivity:this.getProp('sensitivity'), - input:false - }, cancelDraw: true, parent: this}), - new RangeFader({props:{ + }, parent: this}), + new Fader({props:{ ...faderDefaults, - compact:this.getProp('compact'), - pips:this.getProp('pips'), - alignRight:this.getProp('alignRight'), + pips:false, + visible: false, horizontal:this.getProp('horizontal'), - height:'100%', - width:'100%', default:this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max, snap:this.getProp('snap'), spring:this.getProp('spring'), range:this.getProp('range'), - origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScale'), sensitivity:this.getProp('sensitivity'), - input:false - }, cancelDraw: false, parent: this}) + }, parent: this}) ] - this.wrapper.appendChild(this.faders[0].widget) - this.wrapper.appendChild(this.faders[1].widget) this.on('change',(e)=>{ @@ -286,110 +70,6 @@ class Range extends Widget { this.touchMap = {} - touchstate(this, {element: this.wrapper, multitouch: true}) - - this.on('draginit',(e)=>{ - - var id - - if (!this.touchMap[e.pointerId]) { - - var ndiff, diff = -1 - - for (var i in this.faders) { - - if (Object.values(this.touchMap).indexOf(i) != -1) continue - - var coord = this.faders[i].percentToCoord(this.faders[i].valueToPercent(this.faders[i].value)) - (this.getProp('horizontal') ? -1 : 1) * (i == 0 ? -20 : 20) - - ndiff = this.getProp('horizontal')? - Math.abs(e.offsetX - coord) : - Math.abs(e.offsetY - coord) - - if (diff == -1 || ndiff < diff) { - id = i - diff = ndiff - } - - } - - this.touchMap[e.pointerId] = id - - - } else if (e.traversing) { - - id = this.touchMap[e.pointerId] - - } - - if (!id) return - - e.stopPropagation = true - this.faders[id].trigger('draginit', e) - - }, {element: this.wrapper, multitouch: true}) - - this.on('drag',(e)=>{ - - var i = this.touchMap[e.pointerId] - - if (!i) return - - if (e.shiftKey) { - this.faders[0].trigger('drag', e) - this.faders[1].trigger('drag', e) - } else { - this.faders[i].trigger('drag', e) - } - - }, {element: this.wrapper, multitouch: true}) - - this.on('dragend',(e)=>{ - - var i = this.touchMap[e.pointerId] - - if (!i) return - - e.stopPropagation = true - this.faders[i].trigger('dragend', e) - delete this.touchMap[e.pointerId] - - }, {element: this.wrapper, multitouch: true}) - - if (this.getProp('input')) { - - this.input = new Input({ - props:{...Input.defaults()._props(), - precision:this.getProp('precision'), - unit:this.getProp('unit'), - vertical: this.getProp('compact') && !this.getProp('horizontal') - }, - parent:this, parentNode:this.widget, - }) - this.widget.appendChild(this.input.widget) - this.input.on('change', (e)=>{ - e.stopPropagation = true - this.setValue(this.input.getValue(), {sync:true, send:true}) - this.showValue() - }) - - } - - - if (this.getProp('horizontal')) { - this.widget.classList.add('horizontal') - this.container.classList.add('horizontal') - } - if (this.getProp('alignRight') && !this.getProp('horizontal')) { - this.widget.classList.add('align-right') - } - if (this.getProp('compact')) { - this.widget.classList.add('compact') - } - if (this.getProp('pips')) { - this.widget.classList.add('has-pips') - } - this.setValue([ this.faders[0].rangeValsMin, this.faders[1].rangeValsMax @@ -397,7 +77,96 @@ class Range extends Widget { } + resizeHandle(event){ + + super.resizeHandle(event) + + for (var f of this.faders) { + f.width = this.width + f.height = this.height + f.gaugePadding = this.gaugePadding + } + + } + + draginitHandle(e) { + + var id + + if (!this.touchMap[e.pointerId]) { + + var ndiff, diff = -1 + + for (var i in this.faders) { + + if (Object.values(this.touchMap).indexOf(i) != -1) continue + + var coord = this.faders[i].percentToCoord(this.faders[i].valueToPercent(this.faders[i].value)) - (this.getProp('horizontal') ? -1 : 1) * (i == 0 ? -20 : 20) + + ndiff = this.getProp('horizontal')? + Math.abs(e.offsetX - coord) : + Math.abs(e.offsetY - coord) + + if (diff == -1 || ndiff < diff) { + id = i + diff = ndiff + } + + } + + this.touchMap[e.pointerId] = id + + + } else if (e.traversing) { + + id = this.touchMap[e.pointerId] + + } + + if (!id) return + + for (var f of this.faders) { + f.percent = clip(f.percent,[ + f.valueToPercent(f.rangeValsMin), + f.valueToPercent(f.rangeValsMax) + ]) + } + + + e.stopPropagation = true + this.faders[id].trigger('draginit', e) + + } + + dragHandle(e) { + + var i = this.touchMap[e.pointerId] + + if (!i) return + + if (e.shiftKey) { + this.faders[0].trigger('drag', e) + this.faders[1].trigger('drag', e) + } else { + this.faders[i].trigger('drag', e) + } + + } + + dragendHandle(e) { + + var i = this.touchMap[e.pointerId] + + if (!i) return + + e.stopPropagation = true + this.faders[i].trigger('dragend', e) + delete this.touchMap[e.pointerId] + + } + setValue(v, options={}) { + if (!v || !v.length || v.length!=2) return @@ -408,7 +177,6 @@ class Range extends Widget { this.faders[0].setValue(v[0]) this.faders[1].setValue(v[1]) } - this.value = [ this.faders[0].getValue(), this.faders[1].getValue() @@ -418,16 +186,7 @@ class Range extends Widget { if (options.send) this.sendValue() if (options.sync) this.changed(options) - this.faders[1].batchDraw() - - this.showValue() - - - } - - showValue() { - - if (this.getProp('input')) this.input.setValue(this.value) + this.batchDraw() } @@ -441,32 +200,91 @@ class Range extends Widget { } - onPropChanged(propName, options, oldPropValue) { + draw() { - if (super.onPropChanged(...arguments)) return true - switch (propName) { + var width = this.getProp('horizontal') ? this.height : this.width, + height = !this.getProp('horizontal') ? this.height : this.width, + fader = this.faders[0] - case 'color': - for (var w of this.faders) { - w.onPropChanged('color') - } - return + var d = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?0:1].value))), + d2 = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?1:0].value))), + m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2) + // sharp border trick + if (width % 2 && parseInt(m) === m) m -= 0.5 + + var dashed = this.getProp('dashed') + + this.clear() + + this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill + this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2) + + if (this.cssVars.alphaFillOff) { + this.ctx.globalAlpha = this.cssVars.alphaFillOff + this.ctx.beginPath() + this.ctx.moveTo(m, height - this.gaugePadding) + this.ctx.lineTo(m, this.gaugePadding) + this.ctx.stroke() } + if (dashed) { + this.ctx.lineDashOffset = d % 2 ? PXSCALE : 0 // avoid flickering + this.ctx.setLineDash([PXSCALE, PXSCALE]) + } + + if (this.cssVars.alphaFillOn) { + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.beginPath() + this.ctx.moveTo(m, d) + this.ctx.lineTo(m, d2) + this.ctx.stroke() + } + + if (dashed) this.ctx.setLineDash([]) + + this.ctx.globalAlpha = this.cssVars.alphaStroke + this.ctx.strokeStyle = this.cssVars.colorStroke + + this.ctx.beginPath() + this.ctx.moveTo(0, 0) + this.ctx.lineTo(width, 0) + this.ctx.lineTo(width, height) + this.ctx.lineTo(0, height) + this.ctx.closePath() + this.ctx.lineWidth = 2 * PXSCALE + this.ctx.stroke() + + + this.ctx.globalAlpha = 1 + this.ctx.fillStyle = this.cssVars.colorFill + + this.ctx.beginPath() + this.ctx.rect(this.gaugePadding, Math.min(d, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE) + this.ctx.fill() + + this.ctx.beginPath() + this.ctx.rect(this.gaugePadding, Math.min(d2, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE) + this.ctx.fill() + + this.clearRect = [0, 0, width, height] + } onRemove() { + this.faders[0].onRemove() this.faders[1].onRemove() - if (this.input) this.input.onRemove() super.onRemove() + } } -Range.dynamicProps = Range.prototype.constructor.dynamicProps.filter(n => n !== 'precision') +Range.dynamicProps = Range.prototype.constructor.dynamicProps + .filter(n => !['spring', 'precision'].includes(n)) + module.exports = Range diff --git a/src/client/app/widgets/sliders/slider.js b/src/client/app/widgets/sliders/slider.js index 595d9d74..b2e7d731 100644 --- a/src/client/app/widgets/sliders/slider.js +++ b/src/client/app/widgets/sliders/slider.js @@ -2,7 +2,6 @@ var {clip, mapToScale} = require('../utils'), Canvas = require('../common/canvas'), touchstate = require('../mixins/touch_state'), doubletab = require('../mixins/double_tap'), - Input = require('../inputs/input'), html = require('nanohtml') class Slider extends Canvas { @@ -10,20 +9,13 @@ class Slider extends Canvas { constructor(options) { super({...options, html: html` -
      -
      - -
      -
      + `}) - this.wrapper = DOM.get(this.widget, '.wrapper')[0] - this.value = undefined this.percent = 0 - this.unit = this.getProp('unit') ? ' ' + this.getProp('unit') : '' - + this.gaugePadding = 0 this.rangeKeys = [] this.rangeVals = [] @@ -68,48 +60,13 @@ class Slider extends Canvas { } - this.wrapper.addEventListener('mousewheel',this.mousewheelHandleProxy.bind(this)) + this.widget.addEventListener('mousewheel',this.mousewheelHandleProxy.bind(this)) - this.on('draginit', this.draginitHandleProxy.bind(this), {element:this.wrapper}) - this.on('drag', this.dragHandleProxy.bind(this), {element:this.wrapper}) - this.on('dragend', this.dragendHandleProxy.bind(this), {element:this.wrapper}) + this.on('draginit', this.draginitHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch}) + this.on('drag', this.dragHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch}) + this.on('dragend', this.dragendHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch}) - touchstate(this, {element: this.wrapper}) - - - if (this.getProp('input')) { - - this.input = new Input({ - props:{ - ...Input.defaults()._props(), - precision:this.getProp('precision'), - unit:this.getProp('unit'), - vertical: this.getProp('type') == 'fader' && this.getProp('compact') && !this.getProp('horizontal') - }, - parent:this, parentNode:this.widget - }) - - this.input.sendValue = ()=>{} - this.widget.appendChild(this.input.widget) - this.input.on('change', (e)=>{ - e.stopPropagation = true - this.setValue(this.input.getValue(), {sync:true, send:true}) - this.showValue() - }) - - } - - if (this.getProp('compact')) { - this.widget.classList.add('compact') - if (this.getProp('input')) { - this.widget.addEventListener('fast-right-click', (e)=>{ - if (e.detail.button == 2 && !EDITING) { - // Mouse only - this.input.focus() - } - }) - } - } + touchstate(this, {element: this.widget, multitouch: options.multitouch}) this.setSteps() @@ -190,9 +147,12 @@ class Slider extends Canvas { this.colors.pips = style.getPropertyValue('--color-pips') || this.colors.custom this.colors.gaugeOpacity = style.getPropertyValue('--gauge-opacity') + this.gaugePadding = this.cssVars.padding + PXSCALE } + + getSpringValue() { return this.getProp('default') !== '' ? this.getProp('default') : this.originValue @@ -249,19 +209,11 @@ class Slider extends Canvas { this.batchDraw() - this.showValue() - if (options.send) this.sendValue() if (options.sync) this.changed(options) } - showValue() { - - if (this.getProp('input')) this.input.setValue(this.value) - - } - setSteps() { if (this.getProp('steps')) { @@ -280,9 +232,6 @@ class Slider extends Canvas { switch (propName) { - case 'color': - if (this.input) this.input.onPropChanged('color') - return case 'steps': this.setSteps() return @@ -292,8 +241,9 @@ class Slider extends Canvas { } onRemove() { - if (this.input) this.input.onRemove() + super.onRemove() + } } diff --git a/src/client/app/widgets/switchers/state.js b/src/client/app/widgets/switchers/state.js index 1afabf58..d0bc32b4 100644 --- a/src/client/app/widgets/switchers/state.js +++ b/src/client/app/widgets/switchers/state.js @@ -1,6 +1,6 @@ var Widget = require('../common/widget'), - Push = require('../buttons/push'), - pushDefaults = Push.defaults()._props(), + Toggle = require('../buttons/toggle'), + pushDefaults = Toggle.defaults()._props(), html = require('nanohtml'), stateManager = require('../../managers/state'), widgetManager = require('../../managers/widgets'), @@ -53,8 +53,8 @@ class State extends Widget { if (this.getProp('horizontal')) this.widget.classList.add('horizontal') - this.saveButton = new Push({props: {...pushDefaults, type: 'push', label: this.getProp('saveLabel')}, parent: this, container: true}) - this.loadButton = new Push({props: {...pushDefaults, type: 'push', label: this.getProp('loadLabel')}, parent: this, container: true}) + this.saveButton = new Toggle({props: {...pushDefaults, type: 'toggle', mode: 'push', label: this.getProp('saveLabel')}, parent: this, container: true}) + this.loadButton = new Toggle({props: {...pushDefaults, type: 'toggle', mode: 'push', label: this.getProp('loadLabel')}, parent: this, container: true}) this.saveButton.container.classList.add('not-editable', 'value') this.loadButton.container.classList.add('not-editable', 'value', 'disabled') diff --git a/src/client/app/widgets/utils.js b/src/client/app/widgets/utils.js index b77203b6..cd5ee873 100644 --- a/src/client/app/widgets/utils.js +++ b/src/client/app/widgets/utils.js @@ -91,7 +91,7 @@ module.exports = { parser.isLocal = ()=>{ return parser.hostname.match(localUrlRe) } - + return (url)=>{ parser.href = url return parser @@ -99,41 +99,6 @@ module.exports = { })(), - math: (()=>{ - var math = require('mathjs/dist/math.min.js').create({ - matrix: 'Array' - }) - math.import({ - unpack: function(a) { return Array.isArray(a) ? a.toString() : a }, - indexOf: function(a, x) { return a.indexOf(x) }, - pad: function(x, padding) { - var str = String(x), - [int, dec] = str.split('.') - while (int.length < padding) { - int = '0' + int - } - return dec ? int + '.' + dec : int - }, - length: function(x) { return x.length }, - values: function(x) { return Object.values(x) }, - keys: function(x) { return Object.keys(x) }, - extend: function(x, y) { return Object.assign(x, y) }, - timestamp: function() { return Date.now() }, - // basic relationnal to keep alphabetical string comparison (v4 change) - equal: function(a, b) { return a == b }, - unequal: function(a, b) { return a != b }, - smaller: function(a, b) { return a < b }, - larger: function(a, b) { return a > b }, - smallerEq: function(a, b) { return a <= b }, - largerEq: function(a, b) { return a >= b } - }, {override:true}) - - // set math's parser array index base to zero - math.expression.mathWithTransform = Object.assign({}, math) - - return math - })(), - evaljs: (function(){ var sandbox = document.createElement('iframe'), @@ -162,7 +127,7 @@ module.exports = { sandbox.contentWindow.console = console sandbox.contentWindow.setTimeout = sandbox.contentWindow.setInterval = ()=>{ - throw 'setTimeout and setInterval can\'t be used in formulas' + throw 'setTimeout and setInterval can\'t be used in the JS sandbox' } sandbox.contentWindow.global = {} diff --git a/src/client/libs/jquery.touch.js b/src/client/libs/jquery.touch.js deleted file mode 100644 index d8f533d4..00000000 --- a/src/client/libs/jquery.touch.js +++ /dev/null @@ -1,183 +0,0 @@ -/*! - * jQuery UI Touch Punch 0.2.3 - * - * Copyright 2011–2014, Dave Furfero - * Dual licensed under the MIT or GPL Version 2 licenses. - * - * Depends: - * jquery.ui.widget.js - * jquery.ui.mouse.js - */ -(function ($) { - - // Detect touch support - $.support.touch = 'ontouchend' in document; - - // Ignore browsers without touch support - if (!$.support.touch) { - return; - } - - var mouseProto = $.ui.mouse.prototype, - _mouseInit = mouseProto._mouseInit, - _mouseDestroy = mouseProto._mouseDestroy, - touchHandled; - - /** - * Simulate a mouse event based on a corresponding touch event - * @param {Object} event A touch event - * @param {String} simulatedType The corresponding mouse event - */ - function simulateMouseEvent (event, simulatedType) { - - // Ignore multi-touch events - if (event.originalEvent.touches.length > 1) { - return; - } - - event.preventDefault(); - - var touch = event.originalEvent.changedTouches[0], - simulatedEvent = document.createEvent('MouseEvents'); - - // Initialize the simulated mouse event using the touch event's coordinates - simulatedEvent.initMouseEvent( - simulatedType, // type - true, // bubbles - true, // cancelable - window, // view - 1, // detail - touch.screenX, // screenX - touch.screenY, // screenY - touch.clientX, // clientX - touch.clientY, // clientY - false, // ctrlKey - false, // altKey - false, // shiftKey - false, // metaKey - 0, // button - null // relatedTarget - ); - - // osc: add a flag to prevent fast-click - simulatedEvent.touchPunch = true - - // Dispatch the simulated event to the target element - event.target.dispatchEvent(simulatedEvent); - } - - /** - * Handle the jQuery UI widget's touchstart events - * @param {Object} event The widget element's touchstart event - */ - mouseProto._touchStart = function (event) { - - var self = this; - - // Ignore the event if another widget is already being handled - if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) { - return; - } - - // Set the flag to prevent other widgets from inheriting the touch event - touchHandled = true; - - // Track movement to determine if interaction was a click - self._touchMoved = false; - - // Simulate the mouseover event - simulateMouseEvent(event, 'mouseover'); - - // Simulate the mousemove event - simulateMouseEvent(event, 'mousemove'); - - // Simulate the mousedown event - simulateMouseEvent(event, 'mousedown'); - }; - - /** - * Handle the jQuery UI widget's touchmove events - * @param {Object} event The document's touchmove event - */ - mouseProto._touchMove = function (event) { - - // Ignore event if not handled - if (!touchHandled) { - return; - } - - // Interaction was not a click - this._touchMoved = true; - - // Simulate the mousemove event - simulateMouseEvent(event, 'mousemove'); - }; - - /** - * Handle the jQuery UI widget's touchend events - * @param {Object} event The document's touchend event - */ - mouseProto._touchEnd = function (event) { - - // Ignore event if not handled - if (!touchHandled) { - return; - } - - // Simulate the mouseup event - simulateMouseEvent(event, 'mouseup'); - - // Simulate the mouseout event - simulateMouseEvent(event, 'mouseout'); - - // If the touch interaction did not move, it should trigger a click - if (!this._touchMoved) { - - // Simulate the click event - simulateMouseEvent(event, 'click'); - } - - // Unset the flag to allow other widgets to inherit the touch event - touchHandled = false; - }; - - /** - * A duck punch of the $.ui.mouse _mouseInit method to support touch events. - * This method extends the widget with bound touch event handlers that - * translate touch events to mouse events and pass them to the widget's - * original mouse event handling methods. - */ - mouseProto._mouseInit = function () { - - var self = this; - - // Delegate the touch handlers to the widget's element - self.element.bind({ - touchstart: $.proxy(self, '_touchStart'), - touchmove: $.proxy(self, '_touchMove'), - touchend: $.proxy(self, '_touchEnd') - }); - - // Call the original $.ui.mouse init method - _mouseInit.call(self); - }; - - /** - * Remove the touch event handlers - */ - mouseProto._mouseDestroy = function () { - - var self = this; - - // Delegate the touch handlers to the widget's element - self.element.unbind({ - touchstart: $.proxy(self, '_touchStart'), - touchmove: $.proxy(self, '_touchMove'), - touchend: $.proxy(self, '_touchEnd') - }); - - // Call the original $.ui.mouse destroy method - _mouseDestroy.call(self); - }; - -})($); diff --git a/src/client/libs/jquery.ui.js b/src/client/libs/jquery.ui.js deleted file mode 100644 index 8ba8cd1d..00000000 --- a/src/client/libs/jquery.ui.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! jQuery UI - v1.12.0 - 2016-07-29 -* http://jqueryui.com -* Includes: widget.js, data.js, disable-selection.js, scroll-parent.js, widgets/draggable.js, widgets/resizable.js, widgets/sortable.js, widgets/mouse.js -* Copyright jQuery Foundation and other contributors; Licensed MIT */ - -(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t($)})(function(t){t.ui=t.ui||{},t.ui.version="1.12.0";var e=0,i=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},l=e.split(".")[0];e=e.split(".")[1];var h=l+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][h.toLowerCase()]=function(e){return!!t.data(e,h)},t[l]=t[l]||{},n=t[l][e],o=t[l][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:l,widgetName:e,widgetFullName:h}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var s,n,o=i.call(arguments,1),a=0,r=o.length;r>a;a++)for(s in o[a])n=o[a][s],o[a].hasOwnProperty(s)&&void 0!==n&&(e[s]=t.isPlainObject(n)?t.isPlainObject(e[s])?t.widget.extend({},e[s],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,s){var n=s.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=i.call(arguments,1),l=this;return a?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new s(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
      ",options:{classes:{},disabled:!1,create:null},_createWidget:function(i,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),i),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var s=!1;t(document).on("mouseup",function(){s=!1}),t.widget("ui.mouse",{version:"1.12.0",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!s){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,n=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return n&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),s=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,s=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.ui.safeActiveElement=function(t){var e;try{e=t.activeElement}catch(i){e=t.body}return e||(e=t.body),e.nodeName||(e=t.body),e},t.ui.safeBlur=function(e){e&&"body"!==e.nodeName.toLowerCase()&&t(e).trigger("blur")},t.widget("ui.draggable",t.ui.mouse,{version:"1.12.0",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this._blurActiveElement(e),this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("
      ").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=t.ui.safeActiveElement(this.document[0]),s=t(e.target);this._getHandle(e)&&s.closest(i).length||t.ui.safeBlur(i)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp(new t.Event("mouseup",e)),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.trigger("focus"),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new t.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),l=t.pageX,h=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.lefti[2]&&(l=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(h=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,h=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((l-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,l=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(l=this.originalPageX),"x"===a.axis&&(h=this.originalPageY)),{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:l-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)l=s.snapElements[d].left-s.margins.left,h=l+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,l-g>_||m>h+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(l-_),r=g>=Math.abs(h-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(l-m),r=g>=Math.abs(h-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.resizable",t.ui.mouse,{version:"1.12.0",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
      ").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show()) -}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
      "),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,l=this._change[o];return this._updatePrevProperties(),l?(i=l.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,l,h=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,l=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,h.animate||this.element.css(t.extend(a,{top:l,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!h.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&c&&(t.top=l-e.minHeight),n&&c&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
      "),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,l={width:i.size.width-r,height:i.size.height-a},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(l,c&&h?{top:c,left:h}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,l=t(this).resizable("instance"),h=l.options,c=l.element,u=h.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(l.containerElement=t(d),/document/.test(u)||u===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=l._num(e.css("padding"+s))}),l.containerOffset=e.offset(),l.containerPosition=e.position(),l.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=l.containerOffset,n=l.containerSize.height,o=l.containerSize.width,a=l._hasScroll(d,"left")?d.scrollWidth:o,r=l._hasScroll(d)?d.scrollHeight:n,l.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,l=a.containerOffset,h=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=l),h.left<(a._helper?l.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-l.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?l.left:0),h.top<(a._helper?l.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-l.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?l.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-l.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-l.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),l=a.outerWidth()-e.sizeDiff.width,h=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:l,height:h})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,l="number"==typeof s.grid?[s.grid,s.grid]:s.grid,h=l[0]||1,c=l[1]||1,u=Math.round((n.width-o.width)/h)*h,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=l,_&&(p+=h),v&&(f+=c),g&&(p-=h),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-h)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-h>0?(i.size.width=p,i.position.left=a.left-u):(p=h-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable,t.widget("ui.sortable",t.ui.mouse,{version:"1.12.0",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return t>=e&&e+i>t},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var e=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),t.each(this.items,function(){e._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):void 0}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+h>r&&l>s+h,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&l>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var e,i,s="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),n="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=s&&n;return o?(e=this._getDragVerticalDirection(),i=this._getDragHorizontalDirection(),this.floating?"right"===i||"down"===e?2:1:e&&("down"===e?2:1)):!1},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],l=[],h=this._connectWith();if(h&&e)for(s=h.length-1;s>=0;s--)for(o=t(h[s],this.document[0]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&l.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(l.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=l.length-1;s>=0;s--)l[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,l,h,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i],this.document[0]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,h=r.length;h>s;s++)l=t(r[s]),l.data(this.widgetName+"-item",a),c.push({item:l,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.floating=this.items.length?"x"===this.options.axis||this._isFloating(this.items[0].item):!1,this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]);return e._addClass(n,"ui-sortable-placeholder",i||e.currentItem[0].className)._removeClass(n,"ui-sortable-helper"),"tbody"===s?e._createTrPlaceholder(e.currentItem.find("tr").eq(0),t("",e.document[0]).appendTo(n)):"tr"===s?e._createTrPlaceholder(e.currentItem,n):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_createTrPlaceholder:function(e,i){var s=this;e.children().each(function(){t(" ",s.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(i)})},_contactContainers:function(e){var i,s,n,o,a,r,l,h,c,u,d=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!t.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(d&&t.contains(this.containers[i].element[0],d.element[0]))continue;d=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",e,this._uiHash(this)),this.containers[i].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,o=null,c=d.floating||this._isFloating(this.currentItem),a=c?"left":"top",r=c?"width":"height",u=c?"pageX":"pageY",s=this.items.length-1;s>=0;s--)t.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(l=this.items[s].item.offset()[a],h=!1,e[u]-l>this.items[s][r]/2&&(h=!0),n>Math.abs(e[u]-l)&&(n=Math.abs(e[u]-l),o=this.items[s],this.direction=h?"up":"down"));if(!o&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return this.currentContainer.containerCache.over||(this.containers[p]._trigger("over",e,this._uiHash()),this.currentContainer.containerCache.over=1),void 0;o?this._rearrange(e,o,null,!0):this._rearrange(e,null,this.containers[p].element,!0),this._trigger("change",e,this._uiHash()),this.containers[p]._trigger("change",e,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",e,this._uiHash(this)),this.containers[p].containerCache.over=1 -}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===n.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===n.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,l=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})}); diff --git a/src/scss/editor.scss b/src/scss/editor.scss index 48fd6e45..3210010c 100644 --- a/src/scss/editor.scss +++ b/src/scss/editor.scss @@ -1,293 +1,10 @@ -#editor { - box-shadow: 0 0 0 1rem var(--color-light) inset; - background: var(--color-fg); - padding: 1rem 8rem 8rem; - margin-top: 2rem; - flex-shrink:0; - &:empty { - padding:0; - margin: 0; - } - ul { - padding: 4rem; - list-style:none; - li { - margin-bottom: 4rem; - position: relative; - &:last-child { - margin: 0; - } - } - } - - .form { - margin-top: 10rem; - } -} -.form { - line-height: 18rem; - .input-wrapper { - display: flex; - // margin-bottom:4rem; - margin-top: -1rem; - // box-shadow: 0 0 0 1 var(--color-bg); - background:var(--color-bg); - align-items: stretch; - z-index: 1; - border-bottom: 1rem solid var(--color-bg); - position: relative; - justify-content: center; - text-transform: none; - font-weight: 500; - - &:last-child { - margin-bottom:0; - } - &.disabled { - label { - opacity: .8; - } - } - label { - flex-shrink: 0; - padding: 6rem 7rem 4rem; - min-width: 29%; - margin: 1rem; - margin-bottom: 0; - margin-right: 0; - &:not(.btn) { - background: var(--color-fg); - box-shadow: 1rem 0 0 0 var(--color-bg) inset; - margin: 0; - margin-top: 1rem; - } - &.dynamic:after { - content:"\f0e7"; - font-family: FontAwesome; - vertical-align:super; - font-size: 75%; - opacity: 0.75!important; - position: absolute; - margin-top: -4rem; - } - } - .input { - background: var(--color-bg); - flex: 1 1 100%; - padding:5rem; - border-top:1rem solid var(--color-fg); - border-radius: 0; - -webkit-appearance:none; - cursor: initial; - width: 1px; - } - .column { - padding: 2rem; - ul { - padding: 0!important; - overflow: auto; - li:not(:last-child) { - margin-bottom: 2rem!important; - } - .sortable-placeholder { - background: transparent; - &:after { - content:"|"; - color: transparent; - } - } - li i { - pointer-events: none - } - } - .btn + span { - position: absolute; - right:0rem; - top:0rem; - padding:8rem; - opacity: 0.6; - cursor: pointer; - &:hover { - opacity: 1; - } - } - } - .checkbox { - line-height: 18rem; - height: 18rem; - width: 18rem; - position: absolute; - right:5rem; - top:6rem; - cursor: pointer; - background: var(--color-fg); - text-align: center; - box-shadow: 0 0 0 1rem var(--color-light) inset; - display: flex; - align-items: center; - justify-content: center; - i { - color: transparent; - margin-top: -1rem; - margin-left: 1rem; - } - &.on i { - color:var(--color-accent); - } - } - } - label { - display: block; - font-size: 10rem; - // background: var(--color-track); - } - .info { - color:var(--color-text-fade); - margin-bottom:10rem; - } - .input { - display:block; - border:0; - font:inherit; - color:var(--color-text); - width:auto; - .btn { - background: var(--color-raised); - box-shadow: 0 0 0 1rem var(--color-light) inset, - 0 0 0 1rem var(--color-bg); - &:not(:last-child){ - cursor: -webkit-grab; - cursor: grab; - } - } - } - textarea { - display:block; - border:0; - font:inherit; - background: none; - color:var(--color-text); - width:100%; - padding:5rem; - overflow-x: auto; - overflow-y: hidden; - white-space: nowrap; - border-top:1rem solid var(--color-fg); - resize: none; - font-size: 12rem!important; - -webkit-user-select: text; - user-select: text; - --scrollbar-size: 6rem; - &::-webkit-scrollbar-button { - width:1rem!important; - } - } - .error label{ - color: red; - } - .select-wrapper { - position: relative; - margin: 2rem; - flex: 1 1 100%; - &:after{ - content:"\f107"; - font-family: FontAwesome; - position: absolute; - padding:5rem; - right:0; - top:1rem; - font-size: 20rem; - pointer-events: none; - } - - .input { - border:0; - width: 100%; - cursor: pointer; - background: var(--color-fg); - box-shadow: 0 0 0 1rem var(--color-light) inset; - } - } - select { - -webkit-appearance:none; - -moz-appearance:none; - appearance:none; - font-size: 12rem!important; - } - .submit { - margin-top:30rem; - } - .separator { - line-height: 30rem; - height: 30rem; - margin-top: 10rem; - position: relative; - display: flex; - align-items: center; - border: 1rem solid var(--color-bg); - box-shadow: 0 0 0 1rem var(--color-light) inset; - padding: 0 10rem; - - span { - text-transform: lowercase; - font-variant: small-caps; - position: relative; - display: block; - width:100%; - text-align:center; - pointer-events: none; - - text-overflow:ellipsis; - overflow:hidden; - &.accent { - color: var(--color-accent); - } - } - } - .separator + .input-wrapper .input { - border-top-color:transparent; - } - .category { - .separator { - cursor: pointer; - } - .separator:before { - font-family: FontAwesome; - content: "\f0d7"; - line-height: 30rem; - width:30rem; - text-align: center; - position: absolute; - opacity: 0.6; - } - &.folded { - .separator:before { - content: "\f0da"; - } - .input-wrapper { - display: none; - } - } - } -} - -// sticky editor header -.editor-container .form > .separator { - background: var(--color-fg); - position: sticky; - top:10rem; - box-shadow: 0 0 0 1rem var(--color-light) inset, - 0 -10rem 0 0 var(--color-fg); - - z-index: 10; -} - - .widget.editing { z-index: 9999!important; // overflow: visible; } -.widget.editing:after, li.editing a:after, a.editing:before, .content.editing:before, #container.editing:before{ +.widget.editing:after, +.tablink.editing:after, +.modal-container.editing .popup-wrapper:after { content:""; z-index: 999!important; position: absolute; @@ -309,194 +26,17 @@ opacity: 1!important; } -.context-menu { - position:fixed; - z-index: 999999999; - background: var(--color-raised); - box-shadow: 0 0 4rem 1rem var(--color-bg); - text-transform: none; - .item { - color:var(--color-text) - } - .context-menu { - position: absolute; - left:100%; - top:0; - opacity:0; - pointer-events: none; - margin-left: 2rem; - &:before { - content:""; - position: absolute; - top:0; - bottom:0; - left:-2rem; - width:2rem; - } - } - > .item { - padding: 10rem 15rem 10rem 10rem; - position:relative; - cursor: pointer; - i { - margin-right:5rem; - width: 15rem; - text-align: center; - } - &.focus, &:focus { - > .context-menu { - pointer-events: auto; - opacity: 1; - } - &:after { - content:""; - position: absolute; - left:0; - top:0; - width: 100%; - height:100%; - background:var(--color-accent); - opacity: 0.5; - z-index: -1; - } - } - &.has-sub:before { - content:"\f105"; - display: block; - font-family: FontAwesome; - float:right; - margin-right:-10rem; - padding-left: 10rem; - } - } -} - -.ui-resizable-handle { - position: absolute; - z-index: 10000; - display: flex; - justify-content: center; - align-items: center; - background: var(--color-accent); - width:8rem; - height:8rem; - padding: 1rem; - background-clip: content-box; - - &:after { - content:""; - position: absolute; - } - &.ui-resizable-se { - content:""; - bottom: 1rem; - right: 1rem; - cursor: se-resize; - &:after { - top:-5rem; - right:-1rem; - left:-5rem; - bottom:-1rem; - } - } - &.ui-resizable-e { - top: 50%; - margin-top:-4rem; - right: 1rem; - cursor: e-resize; - &:after { - top:-5rem; - right:-1rem; - left:-5rem; - bottom:-5rem; - } - } - &.ui-resizable-s { - bottom: 1rem; - left: 50%; - margin-left:-4rem; - cursor: s-resize; - &:after { - top:-5rem; - right:-5rem; - left:-5rem; - bottom:-1rem; - } - } -} - -.ui-helper { - z-index: 10000!important; - opacity: 1!important; - &:before { - content:""; - position: absolute; - top:1rem; - left:1rem; - right:0; - bottom:0; - border:1rem solid var(--color-accent); - --opa1: rgba(0,0,0, 1); - --opa2: rgba(0,0,0, 0.2); - --opa3: rgba(0,0,0, 0.8); - -webkit-mask: linear-gradient(to right, var(--opa1) 10rem, var(--opa1) 10rem, var(--opa2) 10rem, var(--opa2) calc(100% - 10rem), var(--opa1) calc(100% - 10rem), var(--opa1)), - linear-gradient(to bottom, var(--opa2) 10rem, var(--opa2) 10rem, var(--opa3) 10rem, var(--opa3) calc(100% - 10rem), var(--opa2) calc(100% - 10rem), var(--opa2)) ; - -webkit-mask-composite: xor; - - } - &:after { - content:""; - position: absolute; - top:1rem; - left:1rem; - right:0; - bottom:0; - background: var(--color-accent); - opacity: .25; - } -} - -.ui-draggable-handle:not(.label) { - position: absolute; - top: 1rem; - left: 1rem; - z-index: 100000; - height:8rem; - width: 8rem; - display: flex; - justify-content: center; - align-items: center; - background: var(--color-accent); - padding: 1rem; - background-clip: content-box; - &:after { - content:""; - position: absolute; - top:-1rem; - right:-5rem; - left:-1rem; - bottom:-5rem; - } -} - -.ui-draggable-handle { - cursor: -webkit-grab; - &:active { - cursor:-webkit-grabbing; - } -} - // GRID .editor-enabled { &:not(.no-grid) { - .tab:not(.has-tabs), .panel { + .panel { background-image: linear-gradient(to bottom, var(--color-grid) 1rem, transparent 1rem), linear-gradient(to right, var(--color-grid) 1rem, transparent 1rem); --size: calc(var(--grid-width) * 1rem); background-size: var(--size) var(--size); background-attachment: local; - background-position: 0 0; + background-position: 0rem 0; } } @@ -542,21 +82,3 @@ } // selectable - -.select-area { - position:fixed; - z-index:999999; - border: 1rem solid var(--color-accent); - pointer-events: none; - &:after { - content:""; - position: absolute; - top:0;left:0; - right:0;bottom:0; - background: var(--color-accent); - opacity: 0.2; - } - &.hidden { - display: none; - } -} diff --git a/src/scss/index.scss b/src/scss/index.scss index b22db55e..ec6c1dd6 100644 --- a/src/scss/index.scss +++ b/src/scss/index.scss @@ -1,9 +1,8 @@ @import 'reset'; -@import 'scrollbars'; +@import 'mixins'; -@import 'layout'; -@import 'notifications'; +@import 'ui'; @import 'editor'; @import 'sidepanel'; @@ -59,12 +58,12 @@ body { font-size:11rem; line-height:100%; font-weight: 500; - text-transform: uppercase; + // text-transform: uppercase; letter-spacing: 1rem; } .btn { - background: var(--color-raised); + background: var(--color-foreground); display: block; padding:15rem; position: relative; @@ -72,7 +71,6 @@ body { text-overflow: ellipsis; overflow: hidden; cursor: pointer; - box-shadow: 0 0 0 1rem var(--color-light) inset; &.small { padding:8rem; padding-right: 15rem; @@ -493,98 +491,6 @@ body { -.popup { - position: fixed; - top:0; - left:0; - right:0; - bottom:0; - padding:10%; - align-items:center; - justify-content: center; - z-index:1000000; - transform: translate3d(0,0,0); - display: none; - &.show { - display: flex; - } - &:before { - content: ""; - position: absolute; - top:0; - left:0; - right:0; - bottom:0; - background:var(--color-bg); - opacity: .5; - } - .popup-title { - position: relative; - background:var(--color-raised); - border-bottom: 1rem solid var(--color-bg); - box-shadow: 0 0 0 1rem var(--color-light) inset; - height:46rem; - flex-shrink: 0; - display: flex; - padding:0 15rem; - align-items: center; - .title { - flex:1; - overflow: hidden; - text-overflow: ellipsis; - } - i { - margin-right: 5rem; - } - &.closable { - padding-right: 0; - } - .popup-label { - flex:1; - } - .closer { - padding:0 15rem; - height: 100%; - flex-shrink: 0; - display: flex; - align-items: center; - text-align: center; - color:var(--color-text-fade); - cursor: pointer; - i { - pointer-events: none; - } - } - } - .popup-wrapper { - display: flex; - flex-direction: column; - align-items: stretch; - width:auto; - max-width:600rem; - max-height: 100%; - position: relative; - overflow: hidden; - box-shadow: 1rem 0 0 0 var(--color-bg), - 0 1rem 0 0 var(--color-bg), - 1rem 1rem 0 0 var(--color-bg), - 0 1rem 0 0 var(--color-light) inset; - border-left:1rem solid var(--color-bg); - border-top:1rem solid var(--color-bg); - .popup-content { - height:100%; - width:100%; - flex:1; - padding:10rem; - overflow-y:auto; - white-space: normal; - background:var(--color-fg); - box-shadow: 0 0 0 1rem var(--color-light) inset; - text-transform: none; - position: relative; - } - } -} .error-stack { > span { diff --git a/src/scss/layout.scss b/src/scss/layout.scss deleted file mode 100644 index efd17612..00000000 --- a/src/scss/layout.scss +++ /dev/null @@ -1,139 +0,0 @@ -body { - background:var(--color-bg); -} - -#container { - position: absolute; - top:0; - left:0; - bottom:0; - right:0; - display:flex; - flex-direction: column; - background:var(--color-bg); - padding:2rem; - opacity: 0; - transition: opacity .1s; - min-width: 45rem; - &.show { - opacity: 1; - } - &.sidepanel-open { - right:var(--sidepanel-size); - } -} - - -.navigation { - height:var(--nav-height); - margin-bottom: 1rem; - margin-left: 1rem; - flex-shrink:0; - // font-weight:bold; - text-transform: uppercase; - background: transparent; - height:calc(var(--nav-height) - 2rem); - - &:after { - background: var(--color-bg); - } - a.on { - border-color: var(--color-bg); - } - - &.main { - li:last-child { - width:var(--nav-height); - max-width:var(--nav-height); - min-width:var(--nav-height); - i { - margin:0 auto; - } - } - } - ul { - list-style:none; - display: flex; - overflow: hidden; - height:100%; - - li { - display:block; - min-width:0; - flex: 1 1 100%; - cursor:pointer; - height:100%; - margin-right: 1rem; - - - &:last-child { - margin-right:0; - margin-left: auto; - i { - font-size: 14rem; - } - } - a { - background: var(--color-raised); - pointer-events: none; - padding: 0 5rem; - height:100%; - display: flex; - align-items: center; - overflow:hidden; - text-align:center; - position:relative; - box-shadow: 0 0 0 1rem var(--color-light) inset; - letter-spacing: 1rem; - font-size: 109%; - white-space: pre; - span { - display:block; - width:100%; - padding: 2rem 0; - -webkit-mask: linear-gradient(to left, rgba(0, 0, 0, 0), #000000 10rem) no-repeat; - } - - } - #open-toggle { - pointer-events: auto; - i { - pointer-events: none; - font-size:13rem; - } - } - &.on a, .sidepanel-open { - position: relative; - z-index: 0; - // background:var(--color-fg); - color: var(--color-custom); - &:before { - content: ""; - position: absolute; - top:0; - left: 0; - right: 0; - bottom: 0; - opacity: 0.4; - background: radial-gradient( ellipse at center, transparent, var(--color-bg)); - } - - &:after { - content:""; - position: absolute; - top:0; - left: 0; - right: 0; - bottom: 0; - opacity: 0.3; - box-shadow: 0 0 0 1rem var(--color-custom) inset; - border-radius: inherit; - z-index: -1; - } - } - } - .parent + li a { - padding-left: calc(5rem + 0.5 * var(--nav-height)); - } - } -} diff --git a/src/scss/mixins.scss b/src/scss/mixins.scss new file mode 100644 index 00000000..bd36870f --- /dev/null +++ b/src/scss/mixins.scss @@ -0,0 +1,32 @@ +@mixin pseudo-stroke($z: 0) { + &:before { + content:""; + position: absolute; + border: 1rem solid var(--color-stroke); + opacity: var(--alpha-stroke); + top: 0; + left: 0; + right: 0; + bottom: 0; + pointer-events: none; + z-index: $z; + border-radius: inherit; + } +} + +@mixin pseudo-fill($z: 0) { + &:after { + content:""; + position: absolute; + background: var(--color-fill); + opacity: var(--alpha-fill); + top: 1rem; + left: 1rem; + right: 1rem; + bottom: 1rem; + pointer-events: none; + margin: var(--widget-padding); + z-index: $z; + border-radius: inherit; + } +} diff --git a/src/scss/scrollbars.scss b/src/scss/scrollbars.scss deleted file mode 100644 index d92f4603..00000000 --- a/src/scss/scrollbars.scss +++ /dev/null @@ -1,88 +0,0 @@ - -::-webkit-scrollbar { - width: var(--scrollbar-size); - height:var(--scrollbar-size); - opacity:1; - -} - -::-webkit-scrollbar-track-piece { - background: var(--color-bg); - &:vertical { - border-left:2rem solid var(--color-bg); - } - &:horizontal { - border-top:2rem solid var(--color-bg); - } -} -::-webkit-scrollbar-corner { - background: var(--color-fg); - border-left:2rem solid var(--color-bg); - border-top:2rem solid var(--color-bg); -} -::-webkit-scrollbar-thumb { - background: var(--color-raised); - - &:vertical { - border-left:2rem solid var(--color-bg); - } - &:horizontal { - border-top:2rem solid var(--color-bg); - } -} - - -@mixin arrow($r) { - background-image:url('data:image/svg+xml;utf8,'); - background-blend-mode: difference, normal; -} - -::-webkit-scrollbar-button:decrement:start, ::-webkit-scrollbar-button:increment:end { - - background:var(--color-fg); - height:var(--scrollbar-size); - width: var(--scrollbar-size); - - display: block; - color:red; - - background-size:contain; - background-position: center; - - &:vertical { - &:decrement:start { - border-left:2rem solid var(--color-bg); - border-bottom:1rem solid var(--color-bg); - @include arrow(180) - } - - &:increment:end { - border-left:2rem solid var(--color-bg); - border-top:1rem solid var(--color-bg); - @include arrow(0) - } - } - &:horizontal { - &:decrement:start { - border-right:1rem solid var(--color-bg); - border-top:2rem solid var(--color-bg); - @include arrow(90) - } - - &:increment:end { - border-left:1rem solid var(--color-bg); - border-top:2rem solid var(--color-bg); - @include arrow(-90) - } - } - -} - -// ::-webkit-resizer { -// border-left:2rem solid var(--color-bg); -// border-top:2rem solid var(--color-bg); -// background:var(--color-fg); -// background-size:contain; -// background-position: 2rem 2rem; -// @include arrow(-45) -// } diff --git a/src/scss/sidepanel.scss b/src/scss/sidepanel.scss index fc8000ca..96e988cf 100644 --- a/src/scss/sidepanel.scss +++ b/src/scss/sidepanel.scss @@ -1,56 +1,56 @@ - -#sidepanel { - position:absolute; - z-index: 999999; - width:var(--sidepanel-size); - max-width: calc(100% - 45rem); - min-width: 300rem; - border-top: 2rem solid var(--color-bg); - border-bottom: 2rem solid var(--color-bg); - border-right: 2rem solid var(--color-bg); - top:0; - right:0; - bottom:0; - margin-right:calc(-1 * var(--sidepanel-size)); - background:var(--color-bg); - transition:transform .25s, opacity .25s; - transform: translate3d(0,0,0); - opacity: 0; - box-shadow: 0 0 15rem 0 rgba(black, 0.3); - display: flex; - flex-direction: column; - - #sidepanel-wrapper { - overflow-y: auto; - overflow-x: visible; - display: flex; - flex-direction: column; - flex:1; - } - - &.sidepanel-open { - transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0); - opacity: 1; - } - - &.hide { - z-index: -1; - pointer-events: none; - margin-right: 0; -} - - .navigation { - margin-bottom:2rem; - margin-left: 0; - li { - cursor:default; - } - a { - text-transform: none; - color: var(--color-accent); - justify-content: center; - } - } +// +// #sidepanel { +// position:absolute; +// z-index: 999999; +// width:var(--sidepanel-size); +// max-width: calc(100% - 45rem); +// min-width: 300rem; +// border-top: 2rem solid var(--color-bg); +// border-bottom: 2rem solid var(--color-bg); +// border-right: 2rem solid var(--color-bg); +// top:0; +// right:0; +// bottom:0; +// margin-right:calc(-1 * var(--sidepanel-size)); +// background:var(--color-bg); +// transition:transform .25s, opacity .25s; +// transform: translate3d(0,0,0); +// opacity: 0; +// box-shadow: 0 0 15rem 0 rgba(black, 0.3); +// display: flex; +// flex-direction: column; +// +// #sidepanel-wrapper { +// overflow-y: auto; +// overflow-x: visible; +// display: flex; +// flex-direction: column; +// flex:1; +// } +// +// &.sidepanel-open { +// transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0); +// opacity: 1; +// } +// +// &.hide { +// z-index: -1; +// pointer-events: none; +// margin-right: 0; +// } + // + // .navigation { + // margin-bottom:2rem; + // margin-left: 0; + // li { + // cursor:default; + // } + // a { + // text-transform: none; + // color: var(--color-accent); + // justify-content: center; + // } + // } #options { box-shadow: 0 0 0 1rem var(--color-light) inset; @@ -68,7 +68,7 @@ } } -} +// } .actions { padding:0.5rem; background:var(--color-bg); @@ -146,23 +146,3 @@ } } - -#sidepanel-handle { - width: 6rem; - position: fixed; - top:-1rem!important; - bottom:-1rem!important; - left:-1rem!important; - height: auto!important; - background-color: var(--color-custom); - cursor: col-resize; - transition: opacity .25s; - opacity: 0; - &:hover, &.ui-draggable-dragging { - opacity: 0.2; - } -} - -#sidepanel.resizing { - transition: none; -} diff --git a/src/scss/themes/default.scss b/src/scss/themes/default.scss index 54e35c3d..f9d54eef 100644 --- a/src/scss/themes/default.scss +++ b/src/scss/themes/default.scss @@ -12,7 +12,7 @@ $text: white; --color-text-fade: #{transparentize($text, .6)}; --color-accent: #{$accent}; - --color-grid: #{transparentize($accent, 0.95)}; + // --color-grid: #{transparentize($accent, 0.95)}; --color-bg: #{$base}; --color-track: #{desaturate(mix($base, $tone, 95), 2)}; @@ -37,7 +37,27 @@ $text: white; --nav-height:40rem; --sidepanel-size:300rem; - --scrollbar-size:20rem; --grid-width:10; + + + + --color-foreground: #{$base}; + --color-background: #{mix($base, black, 85)}; + --color-grid: rgba(0,0,0, 0.1); + + --color-context-menu: #{mix($base, white, 95)}; + --color-context-menu-text: #{transparentize($text, .2)}; + + --alpha-scrollbar: 0.25; + --alpha-scrollbar-on: 0.5; + --scrollbar-size:12rem; + + --color-text: #{transparentize($text, .4)}; + + --color-widget: var(--color-accent); + + + + } diff --git a/src/scss/ui.scss b/src/scss/ui.scss new file mode 100644 index 00000000..1ea20008 --- /dev/null +++ b/src/scss/ui.scss @@ -0,0 +1,9 @@ +@import 'ui/scrollbars'; +@import 'ui/workspaces'; +@import 'ui/notifications'; +@import 'ui/inspector'; +@import 'ui/tree'; +@import 'ui/dragresize'; +@import 'ui/selectarea'; +@import 'ui/contextmenu'; +@import 'ui/modal'; diff --git a/src/scss/ui/contextmenu.scss b/src/scss/ui/contextmenu.scss new file mode 100644 index 00000000..81680327 --- /dev/null +++ b/src/scss/ui/contextmenu.scss @@ -0,0 +1,60 @@ +$line-height: 30rem; + +.context-menu { + + position:fixed; + z-index: 999999999; + background: var(--color-context-menu); + box-shadow: 0 0 0 1rem rgba(0, 0, 0, 0.1) inset; + text-transform: none; + color: var(--color-context-menu-text); + line-height: $line-height; + --widget-padding: 0rem; + + .context-menu { + position: absolute; + left:100%; + top:0; + opacity:0; + pointer-events: none; + margin-left: 1rem; + &:before { + content:""; + position: absolute; + top:0; + bottom:0; + left:-2rem; + width:2rem; + } + } + > .item { + padding-left: 15rem; + padding-right: 25rem; + position:relative; + cursor: pointer; + i { + margin-right:5rem; + width: 15rem; + text-align: center; + margin-left: -5rem; + } + &.focus, &:focus { + > .context-menu { + pointer-events: auto; + opacity: 1; + } + @include pseudo-fill($z: -1); + color: var(--color-context-menu); + } + &.has-sub:before { + content:"\f105"; + display: block; + font-family: FontAwesome; + float:right; + margin-right:-20rem; + width: 15rem; + text-align: center; + position: relative; + } + } +} diff --git a/src/scss/ui/dragresize.scss b/src/scss/ui/dragresize.scss new file mode 100644 index 00000000..3fe71958 --- /dev/null +++ b/src/scss/ui/dragresize.scss @@ -0,0 +1,80 @@ +#drag-resize { + + --color-fill: var(--color-accent); + --color-stroke: var(--color-accent); + + position: absolute; + z-index: 99999999; + + top: var(--top); + left: var(--left); + + .helper { + + position: absolute; + top:0; + left:0; + width: var(--width); + height: var(--height); + pointer-events: none; + --alpha-fill: 0.5; + --widget-padding: -1rem; + opacity: 0.5; + display: none; + border: 1rem solid var(--color-stroke); + @include pseudo-fill(); + } + + &.dragging .helper { + display: block; + } + + .handle { + + $size: 10rem; + + position: absolute; + background: var(--color-fill); + width: $size; + height: $size; + border: 2rem solid transparent; + background-clip: content-box; + // opacity: 0.75; + + &.nw { + cursor: move; + } + + &.e { + + top: calc(var(--height) / 2); + left: var(--width); + margin-left: -$size; + margin-top: -$size / 2; + cursor: e-resize; + + } + + &.se { + + top: var(--height); + left: var(--width); + margin-left: -$size; + margin-top: -$size; + cursor: se-resize; + + } + + &.s { + + top: var(--height); + left: calc(var(--width) / 2); + margin-left: -$size / 2; + margin-top: -$size; + cursor: s-resize; + + } + + } + +} diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss new file mode 100644 index 00000000..c015c7bf --- /dev/null +++ b/src/scss/ui/inspector.scss @@ -0,0 +1,226 @@ +$header-height: 22rem; +$field-height: 22rem; +$padding: 8rem; + +#osc-inspector { + + // padding: $padding; + + --widget-padding: -1rem; + +} + +osc-inspector-field { + + display: flex; + flex-direction: row; + line-height: $field-height; + margin-top: 4rem; + + label { + width: 90rem; + order: 35; + text-transform: none; + padding-left: 8rem; + cursor: help; + } + + textarea { + font-family: mono; + + line-height: $field-height - 8rem; + padding: 5rem 6rem 3rem; + flex: 1; + overflow-x: auto; + overflow-y: hidden; + resize: none; + white-space: pre; + display: block; + background: var(--color-foreground); + cursor: text; + + -webkit-appearance:none; + -moz-appearance:none; + appearance:none; + + --scrollbar-size: 6rem; + + &::-webkit-scrollbar-thumb:horizontal { + // border-top: 4rem solid var(--color-foreground); + cursor: normal; + } + + } + + + +} + + +osc-inspector-category { + + --alpha-fill: 0.25; + margin-top: 2rem; + display: block; + padding: 0 8rem; + + &:first-child { + margin-top: 0 + } + + .category-header { + position: relative; + text-transform: none; + cursor: pointer; + // color: var(--color-background); + height: $header-height; + line-height: $header-height + 1; + // padding: 0 8rem; + @include pseudo-fill($z: -1); + + &:after { + left:-($padding - 2); + right:-($padding - 1); + } + + &:before { + position: relative; + font-family: FontAwesome; + content: "\f04b"; + width: $field-height; + text-align: left; + display: inline-block; + transform-origin: 2rem 3rem; + font-size: 7rem; + width: 8rem; + height: 8rem; + line-height: 6rem; + margin-right: 8rem; + top: -2rem; + transform: rotate(90deg); + transition: top .1s, transform .1s; + } + + } + + &.folded { + + --alpha-fill: 0.10; + margin-bottom: 0; + + .category-header:before { + transform: rotate(0deg); + top: 0; + } + osc-inspector-field { + display: none; + } + } + + .category-header + osc-inspector-field { + margin-top: 8rem; + } + osc-inspector-field:last-child { + margin-bottom: 8rem; + } +} + + +osc-inspector-checkbox { + + line-height: $field-height; + height: $field-height; + width: $field-height; + cursor: pointer; + background: var(--color-foreground); + text-align: center; + display: flex; + align-items: center; + justify-content: center; + margin-left: 4rem; + + i { + color: transparent; + margin-top: -1rem; + margin-left: 1rem; + } + &.on { + position: relative; + z-index: 1; + @include pseudo-fill($z: -1); + i { + color: inherit; + } + } + +} + +osc-inspector-select { + position: relative; + font-family: mono; + line-height: inherit; + padding: 0; + overflow: hidden; + height: $field-height; + width: $field-height; + background: var(--color-foreground); + margin-left: 4rem; + select { + background: var(--color-foreground); + // width: 100%; + line-height: $field-height - 8rem; + padding: 4rem 6rem; + -webkit-appearance:none; + -moz-appearance:none; + appearance:none; + position: absolute; + left:0; + opacity: 0; + optgroup { + background: var(--color-foreground); + font-weight: bold; + option { + background: var(--color-background); + color: var(--color-text); + margin-left: -4rem; + font-weight: normal; + text-indent: -10px; + margin: 0; + } + } + } + &:after{ + content:"\f0d7"; + font-family: FontAwesome; + position: absolute; + line-height: $field-height; + height: $field-height; + width: $field-height; + text-align: center; + right:0; + top:1rem; + font-size: 16rem; + pointer-events: none; + } +} + + +.osc-inspector-color { + appearance: none; + padding: 0; + border: 0; + box-shadow: 0; + outline: 0; + position: relative; + font-family: mono; + line-height: inherit; + padding: 0; + overflow: hidden; + height: $field-height; + width: $field-height; + background: var(--color-foreground); + margin-left: 4rem; + -webkit-appearance:none; + -moz-appearance:none; + appearance:none; +} diff --git a/src/scss/ui/modal.scss b/src/scss/ui/modal.scss new file mode 100644 index 00000000..49f2c053 --- /dev/null +++ b/src/scss/ui/modal.scss @@ -0,0 +1,78 @@ +.popup { + + position: fixed; + top:0; + left:0; + right:0; + bottom:0; + padding:10%; + align-items:center; + justify-content: center; + z-index: 99999999; + transform: translate3d(0,0,0); + display: none; + // backdrop-filter: blur(1rem); // perf hit + + &.show { + display: flex; + } + &:before { + content: ""; + position: absolute; + top:0rem; + left:0; + right:0; + bottom:0; + background: black; + opacity: .1; + } + .popup-title { + position: relative; + height: var(--nav-height); + display: flex; + padding:0 15rem; + align-items: center; + background: var(--color-background); + .title { + flex:1; + overflow: hidden; + } + i { + margin-right: 5rem; + } + &.closable { + padding-right: 0; + } + .popup-label { + flex:1; + overflow: hidden; + } + .closer { + height: var(--nav-height); + width: var(--nav-height); + flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + i { + pointer-events: none; + } + } + } + .popup-wrapper { + background: var(--color-foreground); + display: flex; + flex-direction: column; + align-items: stretch; + width:auto; + max-width:600rem; + max-height: 100%; + position: relative; + overflow: hidden; + .popup-content { + flex:1; + width: auto; + } + } +} diff --git a/src/scss/notifications.scss b/src/scss/ui/notifications.scss similarity index 100% rename from src/scss/notifications.scss rename to src/scss/ui/notifications.scss diff --git a/src/scss/ui/scrollbars.scss b/src/scss/ui/scrollbars.scss new file mode 100644 index 00000000..bb96f2ee --- /dev/null +++ b/src/scss/ui/scrollbars.scss @@ -0,0 +1,44 @@ +::-webkit-scrollbar { + width: var(--scrollbar-size); + height:var(--scrollbar-size); +} + +::-webkit-scrollbar-track-piece { + background: var(--color-foreground); + &:vertical { + border-left: 1rem solid var(--color-foreground); + } + &:horizontal { + border-top: 1rem solid var(--color-foreground); + } +} + +::-webkit-scrollbar-thumb { + background: var(--color-scrollbar); + &:active { + background: var(--color-scrollbar-on); + } + &:vertical { + border-left: 1rem solid var(--color-foreground); + } + &:horizontal { + border-top: 1rem solid var(--color-foreground); + } +} + +::-webkit-scrollbar-button:decrement:start, ::-webkit-scrollbar-button:increment:end { + height: 0; + width: 0; +} + +::-webkit-scrollbar-corner { + height: 0rem; + width: 0rem; + background: var(--color-foreground); +} + + +* { + scrollbar-color: var(--color-scrollbar) var(--color-background); + scrollbar-width: thin; +} diff --git a/src/scss/ui/selectarea.scss b/src/scss/ui/selectarea.scss new file mode 100644 index 00000000..ce12adb9 --- /dev/null +++ b/src/scss/ui/selectarea.scss @@ -0,0 +1,19 @@ +.select-area { + + position:fixed; + z-index:999999; + border: 1rem solid var(--color-accent); + pointer-events: none; + &:after { + content:""; + position: absolute; + top:0;left:0; + right:0;bottom:0; + background: var(--color-accent); + opacity: 0.2; + } + &.hidden { + display: none; + } + +} diff --git a/src/scss/ui/tree.scss b/src/scss/ui/tree.scss new file mode 100644 index 00000000..fbd3cecd --- /dev/null +++ b/src/scss/ui/tree.scss @@ -0,0 +1,115 @@ +#osc-tree { + + --alpha-fill: 0.5; + --widget-padding: -1rem; + + $padding: 16rem; + $line-height: 22rem; + padding: 0 $padding; + + + text-transform: none; + line-height: $line-height; + + + ol { + + list-style: none; + position: relative; + padding-left: 16rem; + + ol:before { + content: ""; + position: absolute; + top: 0; + bottom: $line-height / 2 - 1; + left: -12rem; + border-left: 1rem solid var(--color-stroke); + opacity: 0.25; + pointer-events: none; + } + } + + li { + + position: relative;user-select: none; + > ol { + display: none; + } + &.expanded > ol { + display: block; + } + + li:before { + content: ""; + position: absolute; + top: $line-height / 2; + left: -27rem; + width: 16rem; + border-bottom: 1rem solid var(--color-stroke); + opacity: 0.25; + pointer-events: none; + } + .container:before { + width: 8rem; + } + + &.invisible { + opacity: 0.5; + font-style: italic; + // &:after { + // content: "\f070"; + // font-family: FontAwesome; + // width: 12rem; + // display: block; + // position: absolute; + // right: -12rem; + // } + } + + } + + .toggle { + &:before { + content: "\f054"; + font-family: FontAwesome; + width: 20rem; + display: block; + position: absolute; + left: -21rem; + font-style: normal; + text-align: center; + } + cursor: pointer; + } + + .container.expanded > .toggle:before { + content: "\f078"; + } + + .editing { + z-index: 1; + @include pseudo-fill($z: -1); + &:after { + left: calc(-1 * var(--depth) * 16rem - #{$padding}); + right: -($padding - 1); + bottom: auto; + height: $line-height; + top: 0; + } + + } + + .contains-editing:not(.expanded):not(.editing) { + z-index: 1; + @include pseudo-fill($z: -1); + &:after { + left: calc(-1 * var(--depth) * 16rem - #{$padding}); + right: -($padding - 1); + bottom: auto; + height: $line-height; + opacity: 0.1; + } + } + +} diff --git a/src/scss/ui/workspaces.scss b/src/scss/ui/workspaces.scss new file mode 100644 index 00000000..e23dd2a7 --- /dev/null +++ b/src/scss/ui/workspaces.scss @@ -0,0 +1,221 @@ +osc-workspace { + + background: var(--color-background); + + --color-fill: var(--color-widget); + --color-stroke: var(--color-widget); + + position: static; + width: 100%; + height: 100%; + display: flex; + flex-direction: row; + overflow: hidden; + +} + +osc-panel-container { + + position: relative; + display:flex; + + + &.center { + flex: 1; + z-index: 1; + min-width: 100rem; + } + + &.left, &.right { + z-index: 2; + min-width: 0; + width: 0; + + &:after { + // hover trap to display toggle-button when closed + content: ""; + position: absolute; + top: 0; + bottom: 0; + width: 1rem; + z-index: 1; + } + + ::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece { + border-color: var(--color-background)!important; + } + + } + &.left:after { + right: -1rem; + } + &.right:after { + left: -1rem; + } + + .resize-handle { + position: absolute; + top: 0; + bottom: 0; + width: 4rem; + cursor: ew-resize; + z-index: 4; + &.right { + left: 0; + } + &.left { + right: 0; + } + } + + .toggle-button { + + position: absolute; + top: 50%; + height: 50rem; + width: 25rem; + margin-top: -25rem; + cursor: pointer; + background: var(--color-background); + font-size: 14rem; + z-index: 2; + transition: transform 0.2s ease-out 0.1s; + will-change: transform; + + &:after { + font-family: FontAwesome; + line-height: 50rem; + width: 25rem; + text-align: center; + display: block; + opacity: 0; + transition: opacity 0.2s ease-out 0s; + } + + &.left { + border-top-right-radius: 25rem; + border-bottom-right-radius: 25rem; + right: -25rem; + transform: translateX(-25rem); + &:after { + content:"\f104"; + margin-left: -4rem; + } + } + &.right { + border-top-left-radius: 25rem; + border-bottom-left-radius: 25rem; + left: -25rem; + transform: translateX(25rem); + + + &:after { + content:"\f105"; + margin-left: 4rem; + } + } + + } + + &:hover .toggle-button, .toggle-button:hover { + transition: transform 0.2s ease-out 0s; + transform: translateX(0); + &:after { + transition: opacity 0.1s ease-in 0.1s; + opacity: 1; + } + } + + &.minimized .toggle-button { + &.left:after { + content:"\f105"; + } + &.right:after { + content:"\f104"; + } + } + + &.disabled .toggle-button { + display: none; + } + +} + +osc-modal-container { + + position: absolute; + top: 0; + left: 0; + right: 0; + +} + +osc-panel-inner { + + display: flex; + flex-direction: column; + flex: 1; + overflow: hidden; + z-index: 3; + min-width: 0; + + + +} + +// @keyframes test{ +// 0% { +// transform: scaleX(0); +// opacity: 0; +// } +// 100% { +// tranform: scaleX(1); +// opacity: var(--alpha-fill); +// } +// } +// +// osc-panel-container:not(.disabled) osc-panel-header:before { +// animation: test 0.1s forwards; +// +// } + +osc-panel-header { + + --alpha-fill: 0.25; + + display: flex; + height: var(--nav-height); + align-items: center; + align-items: center; + justify-content: center; + position:relative; + letter-spacing: 1rem; + font-size: 109%; + text-overflow: ellipsis; + padding: 0 8rem; + + &:before { + content: ""; + position: absolute; + left: 1rem; + right: 1rem; + bottom: 2rem; + opacity: var(--alpha-fill); + height: 4rem; + background: var(--color-fill); + z-index: 101; + } + +} + +osc-panel-content { + + flex: 1; + overflow-y: auto; + + &.left, &.right { + border-right: 1rem solid var(--color-background); + } + + +} diff --git a/src/scss/widgets.old.scss b/src/scss/widgets.old.scss new file mode 100644 index 00000000..d3c00933 --- /dev/null +++ b/src/scss/widgets.old.scss @@ -0,0 +1,107 @@ + +.widget { + height:auto; + overflow: hidden; + position:relative; + vertical-align:top; + box-shadow: 1rem 0 0 0 var(--color-border), + 0 1rem 0 0 var(--color-border), + 1rem 1rem 0 0 var(--color-border), + 0 0 0 1rem var(--color-light) inset; + border-left:1rem solid var(--color-border); + border-top:1rem solid var(--color-border); + -webkit-tap-highlight-color:transparent; + display: inline-flex; + flex-direction: column; + --default-bg: var(--color-fg); + background: var(--default-bg); + max-width: 100%; + max-height: 100%; + text-transform: uppercase; + contain: style size layout; + color: var(--color-text); + --color-glass-1: var(--color-custom); + --color-glass-2: var(--color-track); + + &.absolute-position { + position: absolute; + z-index: 10; + } + + &.nolabel { + > .label { + display:none; + } + } + + > .label ~ div { + border-top-left-radius:0; + border-top-right-radius:0; + border-bottom-right-radius:inherit; + border-bottom-left-radius:inherit; + min-height: 0; + } + &.nolabel > .label ~ div { + border-radius: inherit; + } + + .label { + text-overflow:ellipsis; + overflow:hidden; + text-align:center; + height:30rem; + max-height:30rem; + padding:0 6rem; + width: 100%; + flex-shrink: 0; + display: flex; + justify-content: center; + white-space: pre; + // justify-content: space-around; + align-items: center; + &.accent { + color:var(--color-accent); + } + } +} + +.glass-effect { + position: relative; + &:after { + content:""; + position: absolute; + pointer-events: none; + top:0; + left:0; + right:0; + bottom:0; + background: radial-gradient(ellipse farthest-side at center top, var(--color-glass-1), var(--color-glass-2)); + background-size: 150% 150%; + background-repeat: no-repeat; + background-position: center top; + opacity: var(--glass-opacity); + z-index: 3; + } +} + + +@import 'widgets/fader'; +@import 'widgets/knob'; + +@import 'widgets/matrices'; +@import 'widgets/patchbay'; +@import 'widgets/pads'; + +@import 'widgets/plots'; + + +@import 'widgets/toggle'; +@import 'widgets/push'; +@import 'widgets/switch'; +@import 'widgets/menu'; + +@import 'widgets/panel'; + +@import 'widgets/inputs'; + +@import 'widgets/maths'; diff --git a/src/scss/widgets/fader.scss b/src/scss/widgets.old/fader.scss similarity index 100% rename from src/scss/widgets/fader.scss rename to src/scss/widgets.old/fader.scss diff --git a/src/scss/widgets.old/inputs.scss b/src/scss/widgets.old/inputs.scss new file mode 100644 index 00000000..38398ef9 --- /dev/null +++ b/src/scss/widgets.old/inputs.scss @@ -0,0 +1,238 @@ +.input-container { + width: 100rem; + height: 60rem; + padding:1rem; + .vertical { + position: relative; + input { + transform: rotate(-90deg); + vertical-align: middle; + max-width: initial!important; + position: absolute; + top: 50%; + left: 50%; + transform: translateX(-50%) translateY(-50%) rotate(-90deg); + margin-top: -1px + } + } + .not-editable { + @extend .glass-effect; + } +} +.widget { + .input { + display: flex; + flex: 1 1 100%; + background:transparent; + color:var(--color-text); + overflow: hidden; + text-align:center; + padding:1rem; + border: 1rem solid var(--color-bg); + background: var(--color-track); + &.right { + text-align: right; + } + &.left { + text-align: left; + } + input { + display: block; + flex:1; + max-width: 100%; + font: inherit; + border:0; + padding:0; + background: transparent; + color:var(--color-accent); + border-radius: inherit; + -webkit-appearance:none; + appearance: none; + text-align:inherit; + line-height: 50rem; + vertical-align: top; + letter-spacing: 1rem; + -webkit-user-select: text; + user-select: text; + &:focus { + color:var(--color-text-fade); + } + &:focus::selection { + color:var(--color-custom); + background: transparent; + } + } + canvas { + flex:1; + max-width: 100%; + } + input + canvas { + display: none; + width: 0; + } + + + } + +} + +.panel:not(.tab) > .input-container { + padding: 0rem; + > .input { + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-fg); + margin:1rem; + border: 1rem solid var(--color-bg); + } +} + + +.keys-container { + width: 100rem; + height:60rem; + flex-shrink: 0; + padding:1rem; + --opacity: .75; + .keys { + flex: 1 1 100%; + height:35rem; + padding: 10rem; + justify-content: center; + display: flex; + align-items: center; + background: var(--color-track); + color:var(--color-custom); + border: 1rem solid var(--color-bg); + @extend .glass-effect; + i { + opacity: var(--opacity); + } + span { + font-family: monospace; + letter-spacing: 0; + margin-left: 4rem; + } + } +} + +.panel:not(.tab) > .keys-container { + --color-border:transparent; + padding: 0rem; + .keys { + margin: 1rem; + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-fg); + border: 1rem solid var(--color-bg); + } +} + +.script-container { + width: 100rem; + height:60rem; + flex-shrink: 0; + padding:1rem; + --opacity: .75; + .script { + flex: 1 1 100%; + height:35rem; + padding: 10rem; + justify-content: center; + display: flex; + align-items: center; + background: var(--color-track); + color:var(--color-custom); + border: 1rem solid var(--color-bg); + @extend .glass-effect; + i { + opacity: var(--opacity); + } + span { + font-family: monospace; + letter-spacing: 0; + margin-left: 4rem; + } + } +} + +.panel:not(.tab) > .script-container { + --color-border:transparent; + padding: 0rem; + .script { + margin: 1rem; + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-fg); + border: 1rem solid var(--color-bg); + } +} + + +.gyroscope-container { + width: 100rem; + height:60rem; + flex-shrink: 0; + padding:1rem; + --opacity: .75; + .gyroscope { + flex: 1 1 100%; + height:35rem; + padding: 10rem; + justify-content: center; + display: flex; + align-items: center; + background: var(--color-track); + color:var(--color-custom); + border: 1rem solid var(--color-bg); + @extend .glass-effect; + i { + opacity: var(--opacity); + } + span { + font-family: monospace; + letter-spacing: 0; + margin-left: 4rem; + } + } +} + +.panel:not(.tab) > .gyroscope-container { + --color-border:transparent; + padding: 0rem; + .gyroscope { + margin: 1rem; + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-fg); + border: 1rem solid var(--color-bg); + } +} + + +.file-container { + width: 100rem; + height:60rem; + padding:1rem; + &.nolabel { + --color-border:var(--color-bg); + padding: 0; + .file { + border: 0; + } + } + .file { + border: 1rem solid var(--color-bg); + flex: 1 1 100%; + display: flex; + align-items: center; + justify-content: center; + padding: 0 10rem; + text-transform: none; + i { + margin: 0 5rem; + pointer-events: none; + } + span { + pointer-events: none; + text-overflow: ellipsis; + overflow: hidden; + } + } +} diff --git a/src/scss/widgets/knob.scss b/src/scss/widgets.old/knob.scss similarity index 100% rename from src/scss/widgets/knob.scss rename to src/scss/widgets.old/knob.scss diff --git a/src/scss/widgets/maths.scss b/src/scss/widgets.old/maths.scss similarity index 100% rename from src/scss/widgets/maths.scss rename to src/scss/widgets.old/maths.scss diff --git a/src/scss/widgets/matrices.scss b/src/scss/widgets.old/matrices.scss similarity index 100% rename from src/scss/widgets/matrices.scss rename to src/scss/widgets.old/matrices.scss diff --git a/src/scss/widgets/menu.scss b/src/scss/widgets.old/menu.scss similarity index 100% rename from src/scss/widgets/menu.scss rename to src/scss/widgets.old/menu.scss diff --git a/src/scss/widgets.old/pads.scss b/src/scss/widgets.old/pads.scss new file mode 100644 index 00000000..9828b379 --- /dev/null +++ b/src/scss/widgets.old/pads.scss @@ -0,0 +1,206 @@ +.xy-container, .rgb-container, .multixy-container { + width:200rem; + height:230rem; + padding:2rem; + + --background: var(--color-track); + --pips-opacity: 0.2; + --point-opacity: 0.3; + + .label { + flex-shrink: 0; + z-index: 1; + } + + > .pad > .wrapper:after { + content:""; + position: absolute; + pointer-events: none; + top:var(--pointSize); + left:var(--pointSize); + height:calc(100% - 2 * var(--pointSize)); + width:calc(100% - 2 * var(--pointSize)); + background: var(--background); + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-bg) inset; + + } + + .pad { + height:100%; + width: 100%; + overflow: hidden; + display: flex; + flex-direction: column; + > .input { + margin-top: 2rem; + height: 25rem; + flex:initial!important; + flex-shrink: 0!important; + background: transparent!important; + border: 0!important; + } + > .wrapper { + position: relative; + flex:1; + touch-action: none; + + > canvas { + width:100%; + height:100%; + position: absolute; + pointer-events: none; + z-index: 1; + } + > .fader { + pointer-events: none; + position: absolute; + width:100%; + height:100%; + z-index: 0; + --color-knob:transparent; + --color-gauge:transparent; + box-shadow: none; + border: 0; + * { + background: transparent!important; + + } + .wrapper { + border:none; + } + .input { + display: none; + } + } + } + } + + +} + +.rgb-container { + + --point-opacity: .7; + + > .pad { + + > .wrapper { + + display: flex; + flex-direction: column; + + image-rendering:pixelated; + > .pad { + --color-custom:var(--color-white); + position: absolute; + .wrapper { + border:0; + background: transparent; + } + canvas { + border:0; + left:0; + background: transparent; + } + .input { + display: none; + } + } + > canvas { + top:var(--pointSize); + left:var(--pointSize); + flex:0; + height:calc(100% - 2 * var(--pointSize)); + width:calc(100% - 2 * var(--pointSize)); + background-color: red; + background-clip: content-box; + background-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%), linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); + border: 1rem solid var(--color-bg); + } + + background: transparent; + border: none; + box-shadow: none; + + } + .alpha-wrapper, .hue-wrapper { + flex-shrink: 0; + padding: calc(var(--pointSize) / 2) var(--pointSize); + .fader { + box-shadow: 0 0 0 1rem var(--color-light); + height: calc(2 * var(--pointSize)); + } + } + .hue-wrapper { + --color-gauge:transparent; + --color-knob:var(--color-white); + .wrapper { + &:after { + content:""; + display: block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%; + box-shadow: 0 0 0 4rem var(--color-track); + // z-index: 1; + opacity: 0.7; + } + canvas { + background: transparent; + -webkit-background-blend-mode: color-burn; + + } + } + } + + } +} + + +.multixy-container { + > .pad { + text-align: center; + font-size: 109%; + + > .wrapper { + + > canvas { + top:0; + left:0; + z-index: 2; + } + + > .pad { + pointer-events: none; + position: absolute; + .wrapper { + border:0; + background: transparent; + } + canvas { + border:0; + left:0; + } + .input { + display: none; + } + } + } + } +} + +.canvas-container { + width:200rem; + height:230rem; + .canvas { + flex: 1; + } + canvas { + width:100%; + height: 100%; + } +} diff --git a/src/scss/widgets/panel.scss b/src/scss/widgets.old/panel.scss similarity index 100% rename from src/scss/widgets/panel.scss rename to src/scss/widgets.old/panel.scss diff --git a/src/scss/widgets/patchbay.scss b/src/scss/widgets.old/patchbay.scss similarity index 100% rename from src/scss/widgets/patchbay.scss rename to src/scss/widgets.old/patchbay.scss diff --git a/src/scss/widgets.old/plots.scss b/src/scss/widgets.old/plots.scss new file mode 100644 index 00000000..a0ec1fb1 --- /dev/null +++ b/src/scss/widgets.old/plots.scss @@ -0,0 +1,265 @@ +.led-container, .rgbled-container { + width:100rem; + height:100rem; + padding:1rem; + .led { + --opacity: 0; + --color-led: var(--color-custom); + display: flex; + flex-direction: row; + flex: 1 1 100%; + background: var(--color-track); + border:1rem solid var(--color-bg); + &:before { + content:""; + width:100%; + height: 100%; + background: var(--color-led); + border-radius: inherit; + opacity: var(--opacity); + box-shadow: inset 0 0 10rem var(--color-track); + } + @extend .glass-effect; + + } +} + +.rgbled-container .led { + --opacity: 1; +} + +.plot-container, .visualizer-container, .eq-container { + height: 200rem; + width: 200rem; + padding:1rem; + .plot { + display: flex; + flex-direction: row; + flex: 1 1 100%; + background: var(--color-track); + border:1rem solid var(--color-bg); + @extend .glass-effect; + } + canvas { + flex:1; + image-rendering:pixelated; + width: 100%; + } +} + + +.meter-container { + @extend .fader-container; + --color-knob: transparent; + .wrapper { + pointer-events: none; + @extend .glass-effect; + } +} + +.text-container { + width: 100rem; + height:60rem; + flex-shrink: 0; + padding:1rem; + .text { + flex: 1 1 100%; + height:35rem; + padding: 0 10rem; + justify-content: center; + display: flex; + align-items: center; + white-space: pre; + background: var(--color-track); + color:var(--color-custom); + border: 1rem solid var(--color-bg); + line-height: 100%; + overflow: hidden; + text-align: center; + &.right { + text-align: right; + justify-content: flex-end; + } + &.left { + text-align: left; + justify-content: flex-start; + } + &.wrap { + white-space: pre-wrap; + } + &.vertical { + transform: rotate(180deg); + text-overflow: ellipsis; + -webkit-writing-mode:vertical-rl; + writing-mode:vertical-rl; + padding: 10rem 0; + &:after { + transform: rotate(-180deg); + } + } + @extend .glass-effect; + } +} + +.image-container { + width:100rem; + height:100rem; + padding:1rem; + .image { + display: flex; + flex-direction: row; + flex: 1 1 100%; + background-size:cover; + border:1rem solid var(--color-bg); + background-repeat: no-repeat; + } + &.noborder { + --color-border:transparent; + --color-light:transparent; + --color-light:transparent; + background: transparent; + padding: 0!important; + .image { + outline:transparent!important; + border:0!important; + box-shadow:none!important; + margin: 0!important; + } + } +} + +.svg-container { + width:100rem; + height:100rem; + padding:1rem; + .svg { + display: flex; + flex-direction: row; + flex: 1 1 100%; + background: var(--color-track); + border:1rem solid var(--color-bg); + svg { + flex: 1 1 100%; + } + } + &.noborder { + --color-border:transparent; + --color-light:transparent; + --color-light:transparent; + background: transparent; + padding: 0!important; + .svg { + background: transparent; + outline:transparent!important; + border:0!important; + box-shadow:none!important; + margin: 0!important; + } + } + &:not(.noborder) .svg { + @extend .glass-effect; + } +} + +.html-container { + width:100rem; + height:100rem; + padding:1rem; + .html { + display: flex; + flex-direction: row; + flex: 1 1 100%; + background: var(--color-track); + border:1rem solid var(--color-bg); + } + &.noborder { + --color-border:transparent; + --color-light:transparent; + --color-light:transparent; + background: transparent; + padding: 0!important; + .html { + background: transparent; + outline:transparent!important; + border:0!important; + box-shadow:none!important; + margin: 0!important; + } + } + &:not(.noborder) .html { + @extend .glass-effect; + } +} + +.frame-container { + width:100rem; + height:100rem; + padding:1rem; + .frame { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + flex: 1 1 100%; + background-size:cover; + border:1rem solid var(--color-bg); + background-repeat: no-repeat; + iframe { + flex: 1 1 100%; + height: 100%; + width: 100%; + border: 0; + display: block; + } + iframe[src=""] { + pointer-events: none; + } + &.error { + iframe { + display: none; + } + } + } + &.noborder { + --color-border:transparent; + --color-light:transparent; + --color-light:transparent; + background: transparent; + padding: 0!important; + .frame { + outline:transparent!important; + border:0!important; + box-shadow:none!important; + margin: 0!important; + } + } +} +.editor-enabled .frame-container.nolabel iframe { + pointer-events: none; +} + +.panel:not(.tab) > .led-container, +.panel:not(.tab) > .rgbled-container, +.panel:not(.tab) > .text-container, +.panel:not(.tab) > .visualizer-container, +.panel:not(.tab) > .eq-container, +.panel:not(.tab) > .plot-container, +.panel:not(.tab) > .image-container, +.panel:not(.tab) > .frame-container, +.panel:not(.tab) > .svg-container, +.panel:not(.tab) > .html-container { + --color-border:transparent; + padding: 0rem; + .plot, .text, .led, .image, .svg, .html, .frame { + margin: 1rem; + box-shadow: 0 0 0 1rem var(--color-light), + 0 0 0 1rem var(--color-fg); + border: 1rem solid var(--color-bg); + } +} + +.panel:not(.tab) > .image-container { + .image { + background-clip: content-box; + } +} diff --git a/src/scss/widgets/push.scss b/src/scss/widgets.old/push.scss similarity index 100% rename from src/scss/widgets/push.scss rename to src/scss/widgets.old/push.scss diff --git a/src/scss/widgets/switch.scss b/src/scss/widgets.old/switch.scss similarity index 100% rename from src/scss/widgets/switch.scss rename to src/scss/widgets.old/switch.scss diff --git a/src/scss/widgets/toggle.scss b/src/scss/widgets.old/toggle.scss similarity index 100% rename from src/scss/widgets/toggle.scss rename to src/scss/widgets.old/toggle.scss diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss index d3c00933..1a79e4cc 100644 --- a/src/scss/widgets.scss +++ b/src/scss/widgets.scss @@ -1,27 +1,32 @@ - .widget { - height:auto; + overflow: hidden; position:relative; vertical-align:top; - box-shadow: 1rem 0 0 0 var(--color-border), - 0 1rem 0 0 var(--color-border), - 1rem 1rem 0 0 var(--color-border), - 0 0 0 1rem var(--color-light) inset; - border-left:1rem solid var(--color-border); - border-top:1rem solid var(--color-border); - -webkit-tap-highlight-color:transparent; + display: inline-flex; flex-direction: column; - --default-bg: var(--color-fg); - background: var(--default-bg); + max-width: 100%; max-height: 100%; - text-transform: uppercase; + width: 100rem; + height: 100rem; + contain: style size layout; + -webkit-tap-highlight-color:transparent; + + --widget-padding: 1rem; + + --color-stroke:var(--color-widget); + --color-fill:var(--color-widget); + + --alpha-stroke: 0.5; + --alpha-fill-off: 0.0; + --alpha-fill-on: 0.25; + --alpha-fill: var(--alpha-fill-off); + color: var(--color-text); - --color-glass-1: var(--color-custom); - --color-glass-2: var(--color-track); + &.absolute-position { position: absolute; @@ -29,23 +34,12 @@ } &.nolabel { - > .label { + > label { display:none; } } - > .label ~ div { - border-top-left-radius:0; - border-top-right-radius:0; - border-bottom-right-radius:inherit; - border-bottom-left-radius:inherit; - min-height: 0; - } - &.nolabel > .label ~ div { - border-radius: inherit; - } - - .label { + label { text-overflow:ellipsis; overflow:hidden; text-align:center; @@ -57,51 +51,28 @@ display: flex; justify-content: center; white-space: pre; - // justify-content: space-around; align-items: center; - &.accent { - color:var(--color-accent); - } + order: -1; } -} -.glass-effect { - position: relative; - &:after { - content:""; - position: absolute; - pointer-events: none; - top:0; - left:0; - right:0; - bottom:0; - background: radial-gradient(ellipse farthest-side at center top, var(--color-glass-1), var(--color-glass-2)); - background-size: 150% 150%; - background-repeat: no-repeat; - background-position: center top; - opacity: var(--glass-opacity); - z-index: 3; + canvas { + flex: 1; + min-height: 0; } + + > inner { + overflow: hidden; + position: relative; + flex: 1; + } + } -@import 'widgets/fader'; -@import 'widgets/knob'; - -@import 'widgets/matrices'; -@import 'widgets/patchbay'; -@import 'widgets/pads'; - -@import 'widgets/plots'; - - -@import 'widgets/toggle'; -@import 'widgets/push'; -@import 'widgets/switch'; -@import 'widgets/menu'; - -@import 'widgets/panel'; - +@import 'widgets/containers'; +@import 'widgets/sliders'; @import 'widgets/inputs'; - -@import 'widgets/maths'; +@import 'widgets/buttons'; +@import 'widgets/pads'; +@import 'widgets/plots'; +@import 'widgets/indicators'; diff --git a/src/scss/widgets/buttons.scss b/src/scss/widgets/buttons.scss new file mode 100644 index 00000000..4b9711e7 --- /dev/null +++ b/src/scss/widgets/buttons.scss @@ -0,0 +1,299 @@ +.toggle-container, .push-container { + + --alpha-fill-off: 0; + --alpha-fill-on: .75; + --widget-padding: -1rem; + + inner { + + position: absolute; + top:0; + left:0; + right:0; + bottom:0; + margin: calc(var(--widget-spacing) / 2); + flex: 1; + display: flex; + flex-direction: column; + + @include pseudo-stroke(); + @include pseudo-fill(); + + } + + > label { + + flex: 1; + max-height: initial; + text-align: center; + pointer-events:none; + display: flex; + justify-content: center; + align-items: center; + z-index: 1; + color: var(--color-text); + + + } + + &.on { + + --alpha-fill:var(--alpha-fill-on); + + label { + color: var(--color-foreground) + } + + } + +} + +.switch-container { + + --alpha-fill: 0.75; + + inner { + + position: relative; + flex: 1; + display: flex; + flex-direction: column; + + @include pseudo-stroke(); + + } + + &.horizontal inner { + + flex-direction: row; + + } + + value { + + position: relative; + z-index: 1; + padding: 4rem; + flex: 1; + display: flex; + align-items: center; + justify-content: center; + text-overflow: clip; + overflow: hidden; + + &.on { + @include pseudo-fill($z: -1); + color: var(--color-foreground); + } + + } + +} + +.menu-container { + + --alpha-fill: 0.75; + --widget-padding: 1rem; + + border-radius: 0!important; // border radius breaks it somehow + z-index: initial!important; + contain: style size; + + --size: 300rem; + --grid-columns: 2; + overflow: hidden; + + inner { + flex:1; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + position: relative; + @include pseudo-stroke(); + + padding: 4rem; + &:after { + content:"\f0d7"; + font-family: FontAwesome; + position: absolute; + color: var(--color-stroke); + right: calc(var(--widget-padding) + 8rem); + margin-top: -1rem; + font-size: 120%; + opacity: var(--alpha-fill) + } + } + + menu { + + // animation: menu-widget-fade .1s forwards; + + position: fixed; + z-index: 999999999; + + + overflow: hidden; + + background: var(--color-foreground); + + @include pseudo-stroke($z: 2); + &:before { + border-width: 1rem; + } + + + .item { + + z-index: 1; + overflow: hidden; + div { + text-align: center; + pointer-events: none; + } + + } + + } + + &.circular menu { + + border-radius: 100%; + width:var(--size); + height:var(--size); + margin-left: calc(var(--x) - var(--size) / 2); + margin-top: calc(var(--y) - var(--size) / 2); + + &:after { + content:""; + position: absolute; + width: calc(var(--size) / 4 - 12rem); + height: calc(var(--size) / 4 - 12rem); + top:50%; + left: 50%; + margin-left: calc(-1 * var(--size) / 8 + 6rem); + margin-top: calc(-1 * var(--size) / 8 + 6rem); + background: var(--color-foreground); + box-shadow: 0 0 0 2rem var(--color-foreground), 0 0 0 3rem var(--color-stroke); + border-radius: 100%; + z-index: 10; + opacity: var(--alpha-stroke); + } + + .item { + top: calc(-1 * var(--size) / 2); + left: calc(-1 * var(--size) / 2); + width: 100%; + height: 100%; + transform-origin: 100% 100%; + position: absolute; + box-shadow: 0 0 0 2rem var(--color-foreground); + + + div { + position: absolute; + bottom: 0; + right: 0; + &:before { + content:""; + position: absolute; + width: calc(var(--size) / 4); + height: calc(var(--size) / 4); + left: calc(-1 * var(--size) / 8); + top: calc(-1 * var(--size) / 8); + border-radius: 100%; + pointer-events: none; + box-shadow: 0 0 0 4rem var(--color-fill); + opacity: 0; + } + } + + &.on { + color: var(--color-fill); + } + + &.on div:before { + opacity: var(--alpha-fill)!important; + } + &.active div:before, &:hover div:before { + opacity: calc(var(--alpha-fill) / 2); + } + + + span { + position: absolute; + top: calc(-1 * var(--size) / 3); + width: calc(var(--size) / 2); + margin-left: calc(-1 * var(--size) / 4); + } + + } + + + } + + &.box menu { + + width:var(--size-box-w); + height:var(--size-box-h); + margin-left: calc(var(--x) - var(--size-box-w) / 2); + margin-top: calc(var(--y) - var(--size-box-h) / 2); + // top:var(--size-box-h); + // margin-top: 0; + + display: flex; + + flex-direction: row; + padding: calc(var(--widget-padding) / 2 + 1rem); + + .item { + position: relative; + margin: calc(var(--widget-padding) / 2); + + + div { + @include pseudo-fill($z: -1); + display: flex; + justify-content: center; + align-items: center; + height: 100%; + flex: 1; + &:after { + opacity: 0; + margin: 0; + top:0;left:0;right:0;bottom:0; + } + } + + &.on { + color: var(--color-foreground); + div:after { + opacity: var(--alpha-fill)!important; + } + } + + &.active, &:hover { + div:after, div:after { + opacity: calc(var(--alpha-fill) / 2); + } + } + + + } + + } + + &.grid.on menu { + + display: grid; + grid-template-columns: repeat(var(--grid-columns), 1fr); + + } + + &.vertical menu { + + flex-direction: column; + + } + +} diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss new file mode 100644 index 00000000..f8f9e19f --- /dev/null +++ b/src/scss/widgets/containers.scss @@ -0,0 +1,418 @@ +.root-container { + + --widget-spacing: 1rem; + --alpha-fill-on: 0.75; + + width: 100%; + height: 100%; + background-color: var(--color-foreground); + > .panel { + + transform: rotateZ(0); + + flex: 1; + flex-direction: column; + display: flex; + width: 100%; + overflow: hidden; + > .widget { + flex: 1; + width: 100%; + height: auto; + > .panel { + margin: calc(var(--widget-spacing) / 2); + } + } + } + +} + +.widget-panel-base { + + --widget-padding: 4rem; + + background-color: var(--color-foreground); + background-clip: content-box; + + + > .panel { + --widget-spacing: var(--widget-padding); + flex: 1; + position: relative; + overflow: auto; + margin: calc(var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2); + } + + &.contains-widgets { + + > .panel > .widget { + padding: calc(var(--widget-spacing) / 2); + } + + &.layout-default > .panel { + display: block; + } + &.layout-horizontal > .panel { + display: flex; + flex-direction: row; + align-items: stretch; + > .widget { + top:auto!important; + left:auto!important; + position: relative!important; + height: auto!important; + min-height: auto!important; + max-height: 100%; + } + } + &.layout-vertical > .panel { + display: flex; + flex-direction: column; + align-items: stretch; + > .widget { + top:auto!important; + left:auto!important; + position: relative!important; + width: auto!important; + min-width: auto!important; + max-width: 100%; + } + + } + + } + + + &.contains-tabs { + + > .panel { + + --widget-spacing: 0; + + display: flex; + flex-direction: column; + overflow: hidden; + + > .widget { + flex: 1; + width: 100%; + height: auto; + padding: 0; + } + } + } + +} + +.tab-container { + @extend .widget-panel-base; + + // --widget-padding: 0rem; + --alpha-fill-on: 0.75; + + width: 100%; + flex: 1; + height: 100%; + background-color: var(--color-foreground); + + &:not(.show) { + display:none + } + + > label { + display: none; + } + + &.contains-widgets > .panel { + + transform: rotateZ(0); + + } +} + +.panel-container { + + @extend .widget-panel-base; + + --alpha-fill-on: 0.75; + + @include pseudo-stroke($z: 1); + &:before { + margin: calc(var(--widget-spacing) / 2); + } + + > label { + + position: relative; + // background-color: var(--color-foreground); + @include pseudo-stroke($z: 10); + &:before { + border-width: 0 0 1rem 0; + margin: 0 1rem; + } + } + + &.contains-widgets.nolabel > .panel { + border-top: 1rem solid var(--color-foreground); + } + + &.contains-tabs > .panel > .navigation { + margin: 0 1rem; + } + + +} + + +.navigation { + + background-color: var(--color-background); + + height:calc(var(--nav-height) - 1rem); + flex-shrink:0; + display: flex; + padding-bottom: 1rem; + position: relative; + + color: var(--color-text); + + &.main { + :last-child, .tools { + width:var(--nav-height); + max-width:var(--nav-height); + min-width:var(--nav-height); + margin-left: 1rem; + text-align: center; + } + } + + &:before { + content:""; + position: absolute; + // border-bottom: 1rem solid var(--color-stroke); + opacity: var(--alpha-stroke); + left: 0; + right: 0; + bottom: 0; + } + + div { + + --color-stroke:var(--color-widget); + --color-fill:var(--color-widget); + + line-height:calc(var(--nav-height) - 1rem); + display:flex; + min-width:0; + flex: 1 1 100%; + cursor:pointer; + height:100%; + align-items: center; + align-items: center; + justify-content: center; + position:relative; + letter-spacing: 1rem; + font-size: 109%; + text-overflow: ellipsis; + padding: 0 8rem; + overflow: hidden!important; + + i { + pointer-events: none; + position: relative; + } + + &.on { + z-index: 1;overflow: visible; + &:before { + content: ""; + position: absolute; + left: 0rem; + right: 0rem; + bottom: 0rem; + opacity: var(--alpha-fill-on); + height: 4rem; + background: var(--color-fill); + z-index: 101; + } + &:last-child { + margin-right:0; + margin-left: auto; + i { + font-size: 14rem; + } + } + &:first-child:before { + margin-left: 1rem; + } + &:last-child:before { + margin-right: 1rem; + } + + } + } +} + + +.clone-container { + + &.empty { + @include pseudo-stroke(); + &:before { + content:"clone" + } + } + + > label { + display: none; + } + + > .clone { + + --widget-spacing: 0; + flex: 1; + + > .widget { + border:0!important; + box-shadow: none!important; + background: transparent!important; + position: relative!important; + left:auto!important; + bottom:auto!important; + right:auto!important; + top: auto!important; + width: 100%!important; + height: 100%!important; + min-height: initial!important; + max-height: initial!important; + min-width: initial!important; + max-width: initial!important; + padding: 0!important; + } + } +} + + + +.modal-container { + + + > .toggle { + + --alpha-fill-off: 0; + --alpha-fill-on: .75; + --widget-padding: -1rem; + position: absolute; + top:0; + left:0; + right:0; + bottom:0; + margin: calc(var(--widget-spacing) / 2); + flex: 1; + display: flex; + flex-direction: column; + + @include pseudo-stroke(); + @include pseudo-fill(); + + } + + > label { + + flex: 1; + max-height: initial; + text-align: center; + pointer-events:none; + display: flex; + justify-content: center; + align-items: center; + z-index: 1; + color: var(--color-text); + + + &:after { + content:"\f0da"; + font-family: FontAwesome; + transform: rotateZ(-45deg); + font-size: 20rem; + display: block; + width:8rem; + height:6rem; + right:2rem; + top:1rem; + line-height: 10rem; + text-align: center; + float:right; + position: absolute; + box-shadow: none; + background: none!important; + color: var(--color-stroke); + opacity: var(--alpha-stroke); + margin: calc(var(--widget-spacing) / 2); + } + + } + + &.on { + > .toggle { + --alpha-fill:var(--alpha-fill-on); + } + > label, > label:after { + color: var(--color-foreground); + opacity: 1; + } + + } + + + + + + + > .panel { + display: none; + } + > .popup { + padding:0; + + > .popup-wrapper { + max-width: 100%; + max-height: 100%; + width: var(--width, 100%); + height: var(--height, 100%); + display: flex; + .popup-content { + &:before { + content: none; + } + // margin: -1rem; + > .panel { + margin: calc(var(--widget-spacing) / 2) calc(var(--widget-spacing) / 2) calc(var(--widget-spacing) / 2); + } + } + } + + &.x-positionned { + justify-content: flex-start; + > .popup-wrapper { + left: var(--left); + } + } + &.y-positionned { + align-items:flex-start; + > .popup-wrapper { + top: var(--top); + } + } + + } + + &.on { + z-index: initial; + > .toggle:after { + color:var(--color-custom); + } + border-radius: 0!important; // border radius breaks it somehow + } + +} diff --git a/src/scss/widgets/indicators.scss b/src/scss/widgets/indicators.scss new file mode 100644 index 00000000..d33f5be0 --- /dev/null +++ b/src/scss/widgets/indicators.scss @@ -0,0 +1,74 @@ +.led-container { + + --color-led: var(--color-fill); + --alpha-fill-off: 0; + --alpha-fill-on: 1; + + inner { + --color-fill: var(--color-led); + --alpha-fill: calc(var(--alpha-fill-off) + var(--opacity) * (var(--alpha-fill-on) - var(--alpha-fill-off))); + + position: relative; + flex: 1; + padding: --widget-padding; + + @include pseudo-stroke(); + @include pseudo-fill(); + + &:before, &:after { + border-radius: var(--border-radius); + } + } + +} + +.text-container { + + width: 100rem; + height:60rem; + --alpha-fill-on: 75; + + inner { + @include pseudo-stroke(); + @include pseudo-fill($z: -1); + + padding: var(--widget-padding); + + display: flex; + + + } + + div { + color: var(--color-fill); + opacity: var(--alpha-fill-on); + flex: 1; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + white-space: pre; + line-height: 100%; + overflow: hidden; + text-align: center; + word-wrap: break-word; + &.right { + text-align: right; + justify-content: flex-end; + } + &.left { + text-align: left; + justify-content: flex-start; + } + &.wrap { + white-space: pre-wrap; + word-break: break-all; + } + &.vertical { + transform: rotate(180deg); + text-overflow: ellipsis; + -webkit-writing-mode:vertical-rl; + writing-mode:vertical-rl; + } + } +} diff --git a/src/scss/widgets/inputs.scss b/src/scss/widgets/inputs.scss index 38398ef9..9ae77afe 100644 --- a/src/scss/widgets/inputs.scss +++ b/src/scss/widgets/inputs.scss @@ -1,238 +1,66 @@ + .input-container { - width: 100rem; - height: 60rem; - padding:1rem; - .vertical { + + --alpha-fill-off: 0.05; + + inner { position: relative; - input { - transform: rotate(-90deg); - vertical-align: middle; - max-width: initial!important; - position: absolute; - top: 50%; - left: 50%; - transform: translateX(-50%) translateY(-50%) rotate(-90deg); - margin-top: -1px - } - } - .not-editable { - @extend .glass-effect; - } -} -.widget { - .input { + @include pseudo-stroke(); + @include pseudo-fill(0.05); + display: flex; - flex: 1 1 100%; - background:transparent; - color:var(--color-text); - overflow: hidden; - text-align:center; - padding:1rem; - border: 1rem solid var(--color-bg); - background: var(--color-track); + flex: 1; + padding: var(--widget-padding); + text-align: center; &.right { text-align: right; } &.left { text-align: left; } - input { - display: block; - flex:1; - max-width: 100%; - font: inherit; - border:0; - padding:0; + } + + input + canvas { + display: none; + width: 0; + } + + canvas { + flex:1; + max-width: 100%; + } + + input { + display: block; + flex:1; + max-width: 100%; + font: inherit; + border:0; + padding:0; + background: transparent; + border-radius: inherit; + -webkit-appearance:none; + appearance: none; + text-align:inherit; + line-height: 50rem; + vertical-align: top; + letter-spacing: 1rem; + -webkit-user-select: text; + user-select: text; + + color:var(--color-fill); + caret-color: var(--color-fill); + + + &:focus { + color:var(--color-text-fade); + } + + &:focus::selection { + color:var(--color-fill); background: transparent; - color:var(--color-accent); - border-radius: inherit; - -webkit-appearance:none; - appearance: none; - text-align:inherit; - line-height: 50rem; - vertical-align: top; - letter-spacing: 1rem; - -webkit-user-select: text; - user-select: text; - &:focus { - color:var(--color-text-fade); - } - &:focus::selection { - color:var(--color-custom); - background: transparent; - } } - canvas { - flex:1; - max-width: 100%; - } - input + canvas { - display: none; - width: 0; - } - } } - -.panel:not(.tab) > .input-container { - padding: 0rem; - > .input { - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-fg); - margin:1rem; - border: 1rem solid var(--color-bg); - } -} - - -.keys-container { - width: 100rem; - height:60rem; - flex-shrink: 0; - padding:1rem; - --opacity: .75; - .keys { - flex: 1 1 100%; - height:35rem; - padding: 10rem; - justify-content: center; - display: flex; - align-items: center; - background: var(--color-track); - color:var(--color-custom); - border: 1rem solid var(--color-bg); - @extend .glass-effect; - i { - opacity: var(--opacity); - } - span { - font-family: monospace; - letter-spacing: 0; - margin-left: 4rem; - } - } -} - -.panel:not(.tab) > .keys-container { - --color-border:transparent; - padding: 0rem; - .keys { - margin: 1rem; - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-fg); - border: 1rem solid var(--color-bg); - } -} - -.script-container { - width: 100rem; - height:60rem; - flex-shrink: 0; - padding:1rem; - --opacity: .75; - .script { - flex: 1 1 100%; - height:35rem; - padding: 10rem; - justify-content: center; - display: flex; - align-items: center; - background: var(--color-track); - color:var(--color-custom); - border: 1rem solid var(--color-bg); - @extend .glass-effect; - i { - opacity: var(--opacity); - } - span { - font-family: monospace; - letter-spacing: 0; - margin-left: 4rem; - } - } -} - -.panel:not(.tab) > .script-container { - --color-border:transparent; - padding: 0rem; - .script { - margin: 1rem; - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-fg); - border: 1rem solid var(--color-bg); - } -} - - -.gyroscope-container { - width: 100rem; - height:60rem; - flex-shrink: 0; - padding:1rem; - --opacity: .75; - .gyroscope { - flex: 1 1 100%; - height:35rem; - padding: 10rem; - justify-content: center; - display: flex; - align-items: center; - background: var(--color-track); - color:var(--color-custom); - border: 1rem solid var(--color-bg); - @extend .glass-effect; - i { - opacity: var(--opacity); - } - span { - font-family: monospace; - letter-spacing: 0; - margin-left: 4rem; - } - } -} - -.panel:not(.tab) > .gyroscope-container { - --color-border:transparent; - padding: 0rem; - .gyroscope { - margin: 1rem; - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-fg); - border: 1rem solid var(--color-bg); - } -} - - -.file-container { - width: 100rem; - height:60rem; - padding:1rem; - &.nolabel { - --color-border:var(--color-bg); - padding: 0; - .file { - border: 0; - } - } - .file { - border: 1rem solid var(--color-bg); - flex: 1 1 100%; - display: flex; - align-items: center; - justify-content: center; - padding: 0 10rem; - text-transform: none; - i { - margin: 0 5rem; - pointer-events: none; - } - span { - pointer-events: none; - text-overflow: ellipsis; - overflow: hidden; - } - } -} diff --git a/src/scss/widgets/pads.scss b/src/scss/widgets/pads.scss index eac97a76..21af9da8 100644 --- a/src/scss/widgets/pads.scss +++ b/src/scss/widgets/pads.scss @@ -1,194 +1,35 @@ -.xy-container, .rgb-container, .multixy-container { - width:200rem; - height:230rem; - padding:2rem; +.xy-container, .multixy-container { - --background: var(--color-track); - --pips-opacity: 0.2; - --point-opacity: 0.3; + --alpha-fill: var(--alpha-fill-off); + --widget-padding: 20rem; - .label { - flex-shrink: 0; - z-index: 1; - } - - > .pad > .wrapper:after { - content:""; - position: absolute; - pointer-events: none; - top:var(--pointSize); - left:var(--pointSize); - height:calc(100% - 2 * var(--pointSize)); - width:calc(100% - 2 * var(--pointSize)); - background: var(--background); - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-bg) inset; - - } - - .pad { - height:100%; - width: 100%; - overflow: hidden; + inner { + position: relative; + flex: 1; display: flex; - flex-direction: column; - > .input { - margin-top: 2rem; - height: 25rem; - flex:initial!important; - flex-shrink: 0!important; - background: transparent!important; - border: 0!important; - } - > .wrapper { - position: relative; - flex:1; - touch-action: none; - > canvas { - width:100%; - height:100%; - position: absolute; - pointer-events: none; - z-index: 1; - } - > .fader { - pointer-events: none; - position: absolute; - width:100%; - height:100%; - z-index: 0; - --color-knob:transparent; - --color-gauge:transparent; - box-shadow: none; - border: 0; - * { - background: transparent!important; - - } - .wrapper { - border:none; - } - .input { - display: none; - } - } - } + @include pseudo-fill($z: -1); + @include pseudo-stroke(); + // padding: var(--widget-padding); } - -} - -.rgb-container { - - --point-opacity: .7; - - > .pad { - - > .wrapper { - - display: flex; - flex-direction: column; - - image-rendering:pixelated; - > .pad { - --color-custom:var(--color-white); - position: absolute; - .wrapper { - border:0; - background: transparent; - } - canvas { - border:0; - left:0; - background: transparent; - } - .input { - display: none; - } - } - > canvas { - top:var(--pointSize); - left:var(--pointSize); - flex:0; - height:calc(100% - 2 * var(--pointSize)); - width:calc(100% - 2 * var(--pointSize)); - background-color: red; - background-clip: content-box; - background-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%), linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); - border: 1rem solid var(--color-bg); - } - - background: transparent; - border: none; - box-shadow: none; - - } - .alpha-wrapper, .hue-wrapper { - flex-shrink: 0; - padding: calc(var(--pointSize) / 2) var(--pointSize); - .fader { - box-shadow: 0 0 0 1rem var(--color-light); - height: calc(2 * var(--pointSize)); - } - } - .hue-wrapper { - --color-gauge:transparent; - --color-knob:var(--color-white); - .wrapper { - &:after { - content:""; - display: block; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%; - box-shadow: 0 0 0 4rem var(--color-track); - // z-index: 1; - opacity: 0.7; - } - canvas { - background: transparent; - -webkit-background-blend-mode: color-burn; - - } - } - } - + canvas { + // margin: var(--widget-padding); + width: 100%; + text-align: center; } -} +} .multixy-container { - > .pad { - text-align: center; - font-size: 109%; - > .wrapper { - - > canvas { - top:0; - left:0; - z-index: 2; - } - - > .pad { - pointer-events: none; - position: absolute; - .wrapper { - border:0; - background: transparent; - } - canvas { - border:0; - left:0; - } - .input { - display: none; - } - } - } + canvas:not(:first-child) { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + pointer-events: none; } + } diff --git a/src/scss/widgets/plots.scss b/src/scss/widgets/plots.scss index a0ec1fb1..9e9abae2 100644 --- a/src/scss/widgets/plots.scss +++ b/src/scss/widgets/plots.scss @@ -1,265 +1,24 @@ -.led-container, .rgbled-container { - width:100rem; - height:100rem; - padding:1rem; - .led { - --opacity: 0; - --color-led: var(--color-custom); +.eq-container, +.visualizer-container, +.plot-container { + + --alpha-fill-off: 0.05; + --alpha-fill-on: 0.1; + --widget-padding: 20rem; + + inner { + position: relative; + flex: 1; display: flex; - flex-direction: row; - flex: 1 1 100%; - background: var(--color-track); - border:1rem solid var(--color-bg); - &:before { - content:""; - width:100%; - height: 100%; - background: var(--color-led); - border-radius: inherit; - opacity: var(--opacity); - box-shadow: inset 0 0 10rem var(--color-track); - } - @extend .glass-effect; + @include pseudo-fill($z: -1); + @include pseudo-stroke(); + // padding: var(--widget-padding); } -} -.rgbled-container .led { - --opacity: 1; -} - -.plot-container, .visualizer-container, .eq-container { - height: 200rem; - width: 200rem; - padding:1rem; - .plot { - display: flex; - flex-direction: row; - flex: 1 1 100%; - background: var(--color-track); - border:1rem solid var(--color-bg); - @extend .glass-effect; - } canvas { - flex:1; - image-rendering:pixelated; + // margin: var(--widget-padding); width: 100%; } -} - -.meter-container { - @extend .fader-container; - --color-knob: transparent; - .wrapper { - pointer-events: none; - @extend .glass-effect; - } -} - -.text-container { - width: 100rem; - height:60rem; - flex-shrink: 0; - padding:1rem; - .text { - flex: 1 1 100%; - height:35rem; - padding: 0 10rem; - justify-content: center; - display: flex; - align-items: center; - white-space: pre; - background: var(--color-track); - color:var(--color-custom); - border: 1rem solid var(--color-bg); - line-height: 100%; - overflow: hidden; - text-align: center; - &.right { - text-align: right; - justify-content: flex-end; - } - &.left { - text-align: left; - justify-content: flex-start; - } - &.wrap { - white-space: pre-wrap; - } - &.vertical { - transform: rotate(180deg); - text-overflow: ellipsis; - -webkit-writing-mode:vertical-rl; - writing-mode:vertical-rl; - padding: 10rem 0; - &:after { - transform: rotate(-180deg); - } - } - @extend .glass-effect; - } -} - -.image-container { - width:100rem; - height:100rem; - padding:1rem; - .image { - display: flex; - flex-direction: row; - flex: 1 1 100%; - background-size:cover; - border:1rem solid var(--color-bg); - background-repeat: no-repeat; - } - &.noborder { - --color-border:transparent; - --color-light:transparent; - --color-light:transparent; - background: transparent; - padding: 0!important; - .image { - outline:transparent!important; - border:0!important; - box-shadow:none!important; - margin: 0!important; - } - } -} - -.svg-container { - width:100rem; - height:100rem; - padding:1rem; - .svg { - display: flex; - flex-direction: row; - flex: 1 1 100%; - background: var(--color-track); - border:1rem solid var(--color-bg); - svg { - flex: 1 1 100%; - } - } - &.noborder { - --color-border:transparent; - --color-light:transparent; - --color-light:transparent; - background: transparent; - padding: 0!important; - .svg { - background: transparent; - outline:transparent!important; - border:0!important; - box-shadow:none!important; - margin: 0!important; - } - } - &:not(.noborder) .svg { - @extend .glass-effect; - } -} - -.html-container { - width:100rem; - height:100rem; - padding:1rem; - .html { - display: flex; - flex-direction: row; - flex: 1 1 100%; - background: var(--color-track); - border:1rem solid var(--color-bg); - } - &.noborder { - --color-border:transparent; - --color-light:transparent; - --color-light:transparent; - background: transparent; - padding: 0!important; - .html { - background: transparent; - outline:transparent!important; - border:0!important; - box-shadow:none!important; - margin: 0!important; - } - } - &:not(.noborder) .html { - @extend .glass-effect; - } -} - -.frame-container { - width:100rem; - height:100rem; - padding:1rem; - .frame { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - flex: 1 1 100%; - background-size:cover; - border:1rem solid var(--color-bg); - background-repeat: no-repeat; - iframe { - flex: 1 1 100%; - height: 100%; - width: 100%; - border: 0; - display: block; - } - iframe[src=""] { - pointer-events: none; - } - &.error { - iframe { - display: none; - } - } - } - &.noborder { - --color-border:transparent; - --color-light:transparent; - --color-light:transparent; - background: transparent; - padding: 0!important; - .frame { - outline:transparent!important; - border:0!important; - box-shadow:none!important; - margin: 0!important; - } - } -} -.editor-enabled .frame-container.nolabel iframe { - pointer-events: none; -} - -.panel:not(.tab) > .led-container, -.panel:not(.tab) > .rgbled-container, -.panel:not(.tab) > .text-container, -.panel:not(.tab) > .visualizer-container, -.panel:not(.tab) > .eq-container, -.panel:not(.tab) > .plot-container, -.panel:not(.tab) > .image-container, -.panel:not(.tab) > .frame-container, -.panel:not(.tab) > .svg-container, -.panel:not(.tab) > .html-container { - --color-border:transparent; - padding: 0rem; - .plot, .text, .led, .image, .svg, .html, .frame { - margin: 1rem; - box-shadow: 0 0 0 1rem var(--color-light), - 0 0 0 1rem var(--color-fg); - border: 1rem solid var(--color-bg); - } -} - -.panel:not(.tab) > .image-container { - .image { - background-clip: content-box; - } } diff --git a/src/scss/widgets/sliders.scss b/src/scss/widgets/sliders.scss new file mode 100644 index 00000000..0eff0290 --- /dev/null +++ b/src/scss/widgets/sliders.scss @@ -0,0 +1,31 @@ +.fader-container, +.knob-container, +.encoder-container, +.range-container { + + inner { + flex: 1; + } + + canvas { + image-rendering: pixelated; + width: 100%; + height: 100%; + } + +} + +.fader-container, +.range-container { + + --widget-padding: 1rem; + +} + +.knob-container, +.encoder-container { + + --widget-padding: 1rem; + --alpha-stroke: 0.75; + +}