diff --git a/src/client/editor/data-workers.js b/src/client/editor/data-workers.js
index f2a19991..e945ae71 100644
--- a/src/client/editor/data-workers.js
+++ b/src/client/editor/data-workers.js
@@ -107,7 +107,6 @@ function updateWidget(widget, options={}) {
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
if (newWidget.getProp('type') === 'tab') newWidget.parent.trigger('tab-created', {widget: widget})
- if (newWidget.getProp('id') === 'root') DOM.get('.editor-root')[0].setAttribute('data-widget', newWidget.hash)
if (reuseChildren && !(newWidget instanceof Panel)) {
diff --git a/src/client/editor/index.js b/src/client/editor/index.js
index c91f364b..bdbd3d6d 100644
--- a/src/client/editor/index.js
+++ b/src/client/editor/index.js
@@ -399,12 +399,8 @@ var Editor = class Editor {
this.unselect()
this.selectedWidgets = []
- DOM.get('.disable-editor')[0].classList.add('on')
- DOM.get('.enable-editor')[0].classList.remove('on')
- document.body.classList.remove('editor-enabled')
- var gridForm = DOM.get('#grid-width-form')[0]
- if (gridForm) gridForm.parentNode.removeChild(gridForm)
+ document.body.classList.remove('editor-enabled')
keyboardJS.setContext('global')
diff --git a/src/client/events/drag.js b/src/client/events/drag.js
index 922f2058..a24d9c90 100644
--- a/src/client/events/drag.js
+++ b/src/client/events/drag.js
@@ -216,7 +216,7 @@ module.exports = {
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
- !options
+ !options || options.ignoreCustomBindings
) {
return
}
@@ -243,7 +243,7 @@ module.exports = {
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
- !options
+ !options || options.ignoreCustomBindings
) {
return
}
diff --git a/src/client/events/transform-coords.js b/src/client/events/transform-coords.js
new file mode 100644
index 00000000..5425ac7d
--- /dev/null
+++ b/src/client/events/transform-coords.js
@@ -0,0 +1,52 @@
+/*
+
+ Adapted from https://gist.github.com/Yaffle/1145197#file-convertpointfrompagetonode-js
+
+ Disabled for now
+
+*/
+
+
+var I = new WebKitCSSMatrix()
+
+function Point(x, y, z) {
+ this.x = x
+ this.y = y
+ this.z = z
+}
+
+Point.prototype.transformBy = function(matrix) {
+ var tmp = matrix.multiply(I.translate(this.x, this.y, this.z))
+ return new Point(tmp.m41, tmp.m42, tmp.m43)
+}
+
+function getTransformationMatrix(w) {
+
+ var transformationMatrix = I,
+ node = w
+
+ while (node) {
+ if (node._ignore_css_transforms) break
+ if (node._drag_widget) {
+
+ var transform = node._drag_widget.cssTransform || 'none',
+ c = transform === 'none' ? I : new WebKitCSSMatrix(transform)
+
+ transformationMatrix = c.multiply(transformationMatrix)
+
+ }
+ node = node.parentNode
+
+ }
+
+ transformationMatrix = I.multiply(transformationMatrix)
+
+ return transformationMatrix
+
+}
+
+module.export = function cssTransformCoords(node, x, y) {
+
+ return new Point(pageX, pageY, 0).transformBy(getTransformationMatrix(element).inverse())
+
+}
diff --git a/src/client/events/utils.js b/src/client/events/utils.js
index cacc968c..e44e4b8d 100644
--- a/src/client/events/utils.js
+++ b/src/client/events/utils.js
@@ -1,4 +1,6 @@
const Touch = window.Touch || class Touch {}
+// const cssTransformCoords = require('./transform-coords')
+
module.exports = {
@@ -76,6 +78,12 @@ module.exports = {
}
+ // if (!event.traversing) {
+ // // css transfom fix (doesn't work well with traversing gestures)
+ // var transformedCoords = cssTransformCoords(event.firstTarget, event.movementX, event.movementY)
+ // event.movementX = transformedCoords.x
+ // event.movementY = transformedCoords.y
+ // }
return event
@@ -88,6 +96,13 @@ module.exports = {
event.offsetX = event.pageX - off.left
event.offsetY = event.pageY - off.top
+ // if (!event.traversing) {
+ // // css transfom fix (doesn't work well with traversing gestures)
+ // var transformedCoords = cssTransformCoords(event.firstTarget, event.offsetX, event.offsetY)
+ // event.offsetX = transformedCoords.x
+ // event.offsetY = transformedCoords.y
+ // }
+
},
TRAVERSING_SAMEWIDGET: 1
diff --git a/src/client/ipc/callbacks.js b/src/client/ipc/callbacks.js
index dabd8e16..3ba1f286 100644
--- a/src/client/ipc/callbacks.js
+++ b/src/client/ipc/callbacks.js
@@ -6,7 +6,6 @@ var utils = require('../ui/utils'),
editor = require('../editor/'),
locales = require('../locales'),
{deepCopy} = require('../utils'),
- sidepanel = require('../ui/sidepanel'),
UiModal = require('../ui/ui-modal'),
notifications = require('../ui/notifications'),
{TRAVERSING_SAMEWIDGET} = require('../events/utils'),
@@ -168,8 +167,6 @@ module.exports = {
editor.historyState = data.historyState
if (data.editorEnabled) editor.enable()
- if (data.sidepanelOpened) sidepanel.open()
-
if (data.traversing === TRAVERSING_SAMEWIDGET) {
DOM.get('.traversingSmart')[0].click()
} else if (data.traversing) {
diff --git a/src/client/locales/en.js b/src/client/locales/en.js
index 3ef064de..f83f1bb5 100644
--- a/src/client/locales/en.js
+++ b/src/client/locales/en.js
@@ -33,6 +33,11 @@ module.exports = {
fs_unnavailable: 'Fullscreen not available',
fs_addtohome: 'You must add this page to your home screen to launch it in fullscreen',
+ // inspector
+ inspector_title: 'Inspector',
+ inspector_color_confirm: 'Confirm',
+ inspector_color_apply: 'Apply',
+
// remote save
remotesave_open: 'Open (on the server)',
remotesave_save: 'Save (on the server)',
diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js
index 70d3924e..f8b63988 100644
--- a/src/client/locales/fr.js
+++ b/src/client/locales/fr.js
@@ -32,6 +32,12 @@ module.exports = {
fs_unnavailable: 'Plein écran indisponible',
fs_addtohome: 'Vous devez ajouter cette page à votre écran d\'accueil pour pouvoir l\'ouvrir en plein écran.',
+
+ // inspector
+ inspector_title: 'Inspecteur',
+ inspector_color_confirm: 'Confirmer',
+ inspector_color_apply: 'Appliquer',
+
// remote save
remotesave_open: 'Ouvrir (sur le serveur)',
remotesave_save: 'Enregistrer (sur le serveur)',
diff --git a/src/client/locales/ru.js b/src/client/locales/ru.js
index 11bfa9b6..511733b7 100644
--- a/src/client/locales/ru.js
+++ b/src/client/locales/ru.js
@@ -32,6 +32,11 @@ module.exports = { // @https://github.com/suhr
fs_unnavailable: 'Полный экран не доступен',
fs_addtohome: 'Необходимо добавить эту страницу на главный экран чтобы запустить её в полноэкранном режиме',
+ // inspector
+ inspector_title: 'Inspector',
+ inspector_color_confirm: 'Confirm',
+ inspector_color_apply: 'Apply',
+
// remote save
remotesave_open: 'Open (on the server)',
remotesave_save: 'Save (on the server)',
diff --git a/src/client/managers/session.js b/src/client/managers/session.js
index 85370038..cde0c0c9 100644
--- a/src/client/managers/session.js
+++ b/src/client/managers/session.js
@@ -240,7 +240,6 @@ var SessionManager = class SessionManager {
create() {
this.load({type: 'root'},function(){
- require('../ui/sidepanel').open()
editor.enable()
editor.select(widgetManager.getWidgetById('root'))
})
diff --git a/src/client/ui/ui-colorpicker.js b/src/client/ui/ui-colorpicker.js
new file mode 100644
index 00000000..c562ec91
--- /dev/null
+++ b/src/client/ui/ui-colorpicker.js
@@ -0,0 +1,114 @@
+var UiWidget = require('./ui-widget'),
+ Rgb = require('../widgets/pads/rgb'),
+ UiModal = require('./ui-modal'),
+ html = require('nanohtml'),
+ raw = require('nanohtml/raw'),
+ chroma = require('chroma-js'),
+ resize = require('../events/resize'),
+ locales = require('../locales')
+
+
+class ColorPicker extends UiWidget {
+
+ constructor() {
+
+ super({})
+
+ this.name = ''
+ this.value = ''
+
+ this.rgb = new Rgb({props: {
+ ...Rgb.defaults()._props(),
+ type: 'rgb',
+ label: false,
+ width: 250,
+ height: 200,
+ alphaStroke: 0,
+ snap: true
+ // height: '100%',
+ }, parent: this})
+ this.rgb.container.classList.add('not-editable')
+
+ this.modal = new UiModal({
+ closable: true,
+ title: '',
+ hide: true,
+ content: html`
+
+ ${this.rgb.container}
+
+
${locales('inspector_color_apply')}
+
${locales('inspector_color_confirm')}
+
+
+ `,
+ enterKey: this.confirm.bind(this)
+ })
+
+ DOM.get(this.modal.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this))
+ DOM.get(this.modal.container, '.color-apply')[0].addEventListener('click', this.apply.bind(this))
+
+ this.rgb.on('change', (e)=>{
+ e.stopPropagation = true
+ })
+ // this.rgb.on('dragend', (e)=>{
+ // this.value = chroma(this.rgb.value).hex()
+ // this.trigger('change')
+ // })
+
+ this.opened = 0
+
+ }
+
+ open() {
+
+ this.modal.open()
+ resize.check(this.rgb.container)
+ this.opened = 1
+
+ }
+
+ close() {
+
+ this.modal.close()
+ this.setName()
+ this.opened = 0
+
+ }
+
+ apply() {
+
+ this.value = chroma(this.rgb.value).hex()
+ this.trigger('change')
+
+ }
+
+ confirm() {
+
+ this.value = chroma(this.rgb.value).hex()
+ this.trigger('change')
+ this.close()
+
+ }
+
+ isVisible() {
+
+ return true
+
+ }
+
+ setName(n = '') {
+
+ this.name = n
+
+ }
+
+ setValue(v) {
+
+ this.rgb.setValue(chroma(v).rgb())
+
+ }
+
+}
+
+module.exports = ColorPicker
diff --git a/src/client/ui/ui-dragresize.js b/src/client/ui/ui-dragresize.js
index 8bfda91f..42871f3f 100644
--- a/src/client/ui/ui-dragresize.js
+++ b/src/client/ui/ui-dragresize.js
@@ -14,7 +14,6 @@ class UiDragResize extends UiWidget {
this.container = html`
-
@@ -42,12 +41,13 @@ class UiDragResize extends UiWidget {
this.on('draginit', (event)=>{
var node = event.firstTarget
- if (!this.handles.includes(node)) return
+ if (event.shiftKey || !this.handles.includes(node)) return
this.initLeft = this.left
this.initTop = this.top
this.initWidth = this.width
this.initHeight = this.height
+ this.matrix = ''
this.container.classList.add('dragging')
this.dragging = node.getAttribute('data-action').split(',')
@@ -94,15 +94,7 @@ class UiDragResize extends UiWidget {
}, {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' : ''
- }
+ // this.handles[0]._ignore_css_transforms = true
}
@@ -110,13 +102,6 @@ class UiDragResize extends UiWidget {
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
@@ -129,13 +114,6 @@ class UiDragResize extends UiWidget {
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 ||
@@ -153,8 +131,6 @@ class UiDragResize extends UiWidget {
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),
@@ -166,6 +142,9 @@ class UiDragResize extends UiWidget {
this.width = (Math.max(...rights) - Math.min(...lefts)) / PXSCALE
this.height = (Math.max(...bottoms) - Math.min(...tops)) / PXSCALE
+ // this.cssTransform = widget.cssTransform || 'none'
+ // this.cssTransformOrigin = widget.cssTransformOrigin
+
this.updateCss()
parent.appendChild(this.container)
@@ -184,6 +163,9 @@ class UiDragResize extends UiWidget {
this.container.style.setProperty('--' + k, val + 'rem')
+ // this.container.style.transform = this.cssTransform
+ // this.container.style.transformOrigin = this.cssTransformOrigin
+
}
}
diff --git a/src/client/ui/ui-filebrowser.js b/src/client/ui/ui-filebrowser.js
index 5134bcc3..c49ff30d 100644
--- a/src/client/ui/ui-filebrowser.js
+++ b/src/client/ui/ui-filebrowser.js
@@ -4,13 +4,15 @@ var locales = require('../locales'),
ipc = require('../ipc'),
doubleClick = require('../events/double-click'),
{icon} = require('./utils'),
- UiModal = require('./ui-modal')
+ UiModal = require('./ui-modal'),
+ keyboardJS = require('keyboardjs')
module.exports = function UiFilebrowser(options, callback) {
var save = options.save,
- saveInputFocus = undefined
+ saveInputFocus = undefined,
+ previousKbContext = keyboardJS.getContext()
var popup = new UiModal({
closable: true,
@@ -192,6 +194,7 @@ module.exports = function UiFilebrowser(options, callback) {
ipc.off('listDir', null, popup)
document.removeEventListener('keydown', keyDownHandler)
document.removeEventListener('keyup', keyUpHandler)
+ keyboardJS.setContext(previousKbContext)
})
browser.appendChild(ariane)
@@ -202,5 +205,6 @@ module.exports = function UiFilebrowser(options, callback) {
ipc.send('listDir', {extension: options.extension, path: options.directory ? [options.directory] : null})
popup.open()
+ keyboardJS.setContext('filebrowser')
}
diff --git a/src/client/ui/ui-inspector-field.js b/src/client/ui/ui-inspector-field.js
index b805a8a8..c4cf1893 100644
--- a/src/client/ui/ui-inspector-field.js
+++ b/src/client/ui/ui-inspector-field.js
@@ -101,7 +101,7 @@ class UiInspectorField extends UiWidget {
val = chroma(style.getPropertyValue('--' + this.name.replace(/([A-Z])/g, (a,s)=>'-' + s.toLowerCase())).trim()).hex('rgb')
} catch(e) {console.log(e)}
- let picker = html`
`
+ let picker = html`
`
this.container.appendChild(picker)
diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js
index ea97e6fa..c2c2754d 100644
--- a/src/client/ui/ui-inspector.js
+++ b/src/client/ui/ui-inspector.js
@@ -1,10 +1,14 @@
var UiWidget = require('./ui-widget'),
UiInspectorField = require('./ui-inspector-field'),
+ UiColorPicker = require('./ui-colorpicker'),
morph = require('nanomorph'),
{widgets, defaults} = require('../widgets/'),
{deepCopy} = require('../utils'),
html = require('nanohtml')
+
+
+
class UiInspector extends UiWidget {
constructor(options) {
@@ -31,6 +35,15 @@ class UiInspector extends UiWidget {
})
+ this.colorPicker = new UiColorPicker()
+ this.colorPicker.on('change', ()=>{
+ var textarea = DOM.get(this.container, `textarea[name="${this.colorPicker.name}"]`)
+ if (textarea) {
+ textarea[0].value = this.colorPicker.value
+ DOM.dispatchEvent(textarea[0], 'change')
+ }
+ })
+
this.container.addEventListener('click', (e)=>{
var node = e.target
@@ -45,6 +58,12 @@ class UiInspector extends UiWidget {
DOM.dispatchEvent(textarea[0], 'change')
}
+ } else if (node.tagName === 'OSC-INSPECTOR-COLOR') {
+
+ this.colorPicker.setName(node.getAttribute('name'))
+ this.colorPicker.setValue(node.getAttribute('value'))
+ this.colorPicker.open()
+
}
})
@@ -67,6 +86,7 @@ class UiInspector extends UiWidget {
this.container.innerHTML = ''
this.mounted = false
this.clearTimeout = null
+ this.colorPicker.close()
})
}
@@ -124,11 +144,6 @@ class UiInspector extends UiWidget {
} 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,
@@ -137,6 +152,7 @@ class UiInspector extends UiWidget {
default: defaults[w.props.type][propName],
tabIndex: tabIndex++
}).container
+
if (!field) continue
}
@@ -146,6 +162,7 @@ class UiInspector extends UiWidget {
content.appendChild(field)
}
+
}
if (category) content.appendChild(category)
@@ -159,6 +176,17 @@ class UiInspector extends UiWidget {
this.mounted = true
+ if (this.colorPicker.opened) {
+
+ var picker = DOM.get(this.container, `osc-inspector-color[name="${this.colorPicker.name}"]`)
+ if (picker) {
+ this.colorPicker.setValue(picker[0].getAttribute('value'))
+ } else {
+ this.colorPicker.close()
+ }
+
+ }
+
}
onChange(event) {
diff --git a/src/client/ui/ui-modal.js b/src/client/ui/ui-modal.js
index 44464d71..472a490e 100644
--- a/src/client/ui/ui-modal.js
+++ b/src/client/ui/ui-modal.js
@@ -2,8 +2,9 @@ var UiWidget = require('./ui-widget'),
{icon} = require('./utils'),
html = require('nanohtml'),
raw = require('nanohtml/raw'),
- SINGLETON = null,
- CONTAINER = null
+ MODAL_SINGLETON = null,
+ MODAL_CONTAINER = null,
+ OPENED_MODALS = 0
class UiModal extends UiWidget {
@@ -11,12 +12,12 @@ class UiModal extends UiWidget {
super(options)
- if (!CONTAINER) CONTAINER = DOM.get('osc-modal-container')[0]
+ if (!MODAL_CONTAINER) MODAL_CONTAINER = DOM.get('osc-modal-container')[0]
if (options.closable) {
- if (SINGLETON) SINGLETON.close()
- SINGLETON = this
+ if (MODAL_SINGLETON) MODAL_SINGLETON.close()
+ MODAL_SINGLETON = this
}
@@ -77,7 +78,11 @@ class UiModal extends UiWidget {
if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
- CONTAINER.removeChild(this.container)
+
+
+ if (--OPENED_MODALS === 0) MODAL_CONTAINER.classList.remove('backdrop')
+
+ MODAL_CONTAINER.removeChild(this.container)
this.trigger('close')
@@ -90,7 +95,10 @@ class UiModal extends UiWidget {
if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
- CONTAINER.appendChild(this.container)
+
+ if (++OPENED_MODALS === 1) MODAL_CONTAINER.classList.add('backdrop')
+
+ MODAL_CONTAINER.appendChild(this.container)
this.trigger('open')
}
diff --git a/src/client/ui/ui-tree.js b/src/client/ui/ui-tree.js
index 31c51e28..a0a03dc6 100644
--- a/src/client/ui/ui-tree.js
+++ b/src/client/ui/ui-tree.js
@@ -62,6 +62,10 @@ class UiTree extends UiWidget {
})
}
+ widgetManager.on('prop-changed', (e)=>{
+ console.log(e)
+ })
+
}
clear() {
diff --git a/src/client/widgets/common/canvas.js b/src/client/widgets/common/canvas.js
index 5b0836d9..04325beb 100644
--- a/src/client/widgets/common/canvas.js
+++ b/src/client/widgets/common/canvas.js
@@ -1,64 +1,6 @@
var Widget = require('./widget'),
- resize = require('../../events/resize')
-
-
-class CanvasQueue {
-
- constructor() {
-
- this.queue = {}
- this.flushed = 0
- this.running = false
- this.frameLength = 1000 / CANVAS_FRAMERATE
- this.lastFrame = 0
- this.bindedLoop = this.loop.bind(this)
-
- }
-
- push(widget) {
-
- this.queue[widget.hash] = widget
- this.flushed = 0
-
- if (!this.running) {
- this.running = true
- requestAnimationFrame(this.bindedLoop)
- }
-
- }
-
- flush() {
-
- for (var h in this.queue) {
- this.queue[h].draw()
- }
-
- this.queue = {}
- this.flushed++
-
- }
-
- loop(timestamp) {
-
- if (this.flushed >= 10) {
- this.running = false
- return
- }
-
- requestAnimationFrame(this.bindedLoop)
-
- var delta = timestamp - this.lastFrame
-
- if (delta > this.frameLength) {
- this.lastFrame = timestamp - (delta % this.frameLength)
- this.flush()
- }
-
- }
-
-}
-
-var canvasQueue = new CanvasQueue()
+ resize = require('../../events/resize'),
+ canvasQueue = require('./queue')
class Canvas extends Widget {
@@ -82,7 +24,7 @@ class Canvas extends Widget {
this.clearRect = []
- this.visible = false
+ this.hasSize = false
this.colors = {}
this.cssVars = {}
@@ -123,7 +65,10 @@ class Canvas extends Widget {
this.cacheCanvasStyle(style)
- if (!this.visible) this.visible = true
+ if (!this.hasSize) {
+ this.hasSize = true
+ this.setVisibility()
+ }
this.batchDraw()
@@ -172,11 +117,15 @@ class Canvas extends Widget {
}
+ isVisible() {
+
+ return this.hasSize && super.isVisible()
+
+ }
+
batchDraw() {
- if (this.visible) {
- canvasQueue.push(this)
- }
+ if (this.visible) canvasQueue.push(this)
}
diff --git a/src/client/widgets/common/queue.js b/src/client/widgets/common/queue.js
new file mode 100644
index 00000000..21911f58
--- /dev/null
+++ b/src/client/widgets/common/queue.js
@@ -0,0 +1,62 @@
+var EventEmitter = require('../../events/event-emitter')
+
+class CanvasQueue extends EventEmitter{
+
+ constructor() {
+
+ super()
+
+ this.queue = {}
+ this.flushed = 0
+ this.running = false
+ this.frameLength = 1000 / CANVAS_FRAMERATE
+ this.lastFrame = 0
+ this.bindedLoop = this.loop.bind(this)
+
+ }
+
+ push(widget) {
+
+ this.queue[widget.hash] = widget
+ this.flushed = 0
+
+ if (!this.running) {
+ this.running = true
+ requestAnimationFrame(this.bindedLoop)
+ }
+
+ }
+
+ flush() {
+
+ for (var h in this.queue) {
+ this.queue[h].draw()
+ }
+
+ this.queue = {}
+ this.flushed++
+
+ }
+
+ loop(timestamp) {
+
+ if (this.flushed >= 10) {
+ this.running = false
+ return
+ }
+
+ requestAnimationFrame(this.bindedLoop)
+
+ var delta = timestamp - this.lastFrame
+
+ if (delta > this.frameLength) {
+ this.lastFrame = timestamp - (delta % this.frameLength)
+ this.trigger('frame', {timestamp})
+ this.flush()
+ }
+
+ }
+
+}
+
+module.exports = new CanvasQueue()
diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js
index f633eb63..1d8d44af 100644
--- a/src/client/widgets/common/widget.js
+++ b/src/client/widgets/common/widget.js
@@ -168,6 +168,7 @@ class Widget extends EventEmitter {
this.reCreateOptions = options.reCreateOptions
this.removed = false
this.mounted = false
+ this.visible = true
this.createPropsCache()
@@ -197,6 +198,7 @@ class Widget extends EventEmitter {
this.setContainerStyles()
this.setCssVariables()
+ this.setVisibility()
}
@@ -758,7 +760,7 @@ class Widget extends EventEmitter {
return
case 'visible':
- this.setContainerStyles(['visibility'])
+ this.setVisibility()
resize.check(this.container)
return
@@ -775,7 +777,6 @@ class Widget extends EventEmitter {
case 'css':
this.setContainerStyles(['css'])
- this.onPropChanged('color')
var re = /width|height|display/
if (re.test(oldPropValue) || re.test(this.getProp('css'))) {
resize.check(this.container)
@@ -821,10 +822,6 @@ class Widget extends EventEmitter {
setContainerStyles(styles = ['geometry', 'label', 'css', 'visibility']) {
- if (styles.includes('visibility')) {
- this.container.style.display = this.getProp('visible') ? '' : 'none'
- }
-
if (styles.includes('geometry')) {
// geometry
@@ -941,6 +938,19 @@ class Widget extends EventEmitter {
this.extraCssClasses = extraCssClasses
}
+
+ // store transform matrix if any
+ // if (css.includes('transform')) {
+ // setTimeout(()=>{
+ // var style = window.getComputedStyle(this.container)
+ // this.cssTransform = style.transform || 'none'
+ // this.cssTransformOrigin = style.transformOrigin
+ // })
+ // } else {
+ // this.cssTransform = 'none'
+ // }
+
+
}
return style
@@ -960,6 +970,28 @@ class Widget extends EventEmitter {
}
+ isVisible() {
+
+ return this.getProp('visible') && this.parent.isVisible()
+
+ }
+
+ setVisibility() {
+
+
+ var visible = this.isVisible()
+ if (visible !== this.visible) {
+ this.visible = visible
+ this.container.style.display = this.getProp('visible') ? '' : 'none'
+
+ for (var c of this.children) {
+ c.setVisibility()
+ }
+
+ }
+
+ }
+
reCreateWidget(options={}){
if (!this.removed) return updateWidget(this, options)
diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js
index 95f30c21..40aa9fda 100644
--- a/src/client/widgets/containers/matrix.js
+++ b/src/client/widgets/containers/matrix.js
@@ -28,6 +28,7 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) {
quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
+ restrainModals: {type: 'boolean', value: true, help: 'Set to `false` to let modal widgets ignore this container\'s boundaries.'},
props: {type: 'object', value: {}, help: [
'Defines a set of property to override the widgets\' defaults.',
'Formulas in this field are resolved with an extra variable representing each widget\'s index: `$`',
@@ -40,7 +41,7 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) {
constructor(options) {
- super({...options, html: html`
`})
+ super(options)
this.value = []
diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js
index 0c5c2d1d..b189e392 100644
--- a/src/client/widgets/containers/modal.js
+++ b/src/client/widgets/containers/modal.js
@@ -28,6 +28,7 @@ class Modal extends Panel {
popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
+ traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
@@ -47,7 +48,7 @@ class Modal extends Panel {
super(options)
this.popup = html`
-