From 1fadea7a6b49eda036addd7b432e425e3e829123 Mon Sep 17 00:00:00 2001
From: bordun
Date: Tue, 25 Feb 2020 18:45:25 +0100
Subject: [PATCH] ui progress
---
src/client/editor/index.js | 3 +-
src/client/index.js | 4 +-
src/client/ipc/callbacks.js | 3 +-
src/client/managers/session.js | 41 ++-
src/client/managers/state.js | 11 +-
src/client/ui/fullscreen.js | 4 +-
src/client/ui/init.js | 10 +-
src/client/ui/lobby.js | 51 ---
src/client/ui/ui-dragresize.js | 4 +-
src/client/ui/ui-filebrowser.js | 206 +++++++++++
src/client/ui/ui-fileupload.js | 40 +++
src/client/ui/ui-inspector-field.js | 4 +-
src/client/ui/ui-loading.js | 12 +
src/client/ui/ui-lobby.js | 44 +++
src/client/ui/ui-modal.js | 157 +++++----
src/client/ui/ui-tree.js | 5 +-
src/client/ui/utils.js | 328 ------------------
src/client/widgets/buttons/menu.js | 10 +-
.../{matrices => containers}/matrix.js | 30 +-
src/client/widgets/containers/modal.js | 3 +-
src/client/widgets/containers/panel.js | 12 +-
src/client/widgets/containers/tab.js | 7 +-
src/client/widgets/index.js | 6 +-
src/client/widgets/inputs/file.js | 5 +-
src/client/widgets/matrices/keyboard.js | 30 +-
src/scss/editor.scss | 3 +-
src/scss/index.scss | 232 -------------
src/scss/reset.scss | 7 +
src/scss/ui.scss | 3 +
src/scss/ui/button.scss | 14 +
src/scss/ui/filebrowser.scss | 97 ++++++
src/scss/ui/inspector.scss | 13 +-
src/scss/ui/lobby.scss | 71 ++++
src/scss/ui/modal.scss | 1 +
src/scss/widgets.scss | 1 +
src/scss/widgets/containers.scss | 21 +-
src/scss/widgets/keyboard.scss | 68 ++++
37 files changed, 773 insertions(+), 788 deletions(-)
delete mode 100644 src/client/ui/lobby.js
create mode 100644 src/client/ui/ui-filebrowser.js
create mode 100644 src/client/ui/ui-fileupload.js
create mode 100644 src/client/ui/ui-loading.js
create mode 100644 src/client/ui/ui-lobby.js
rename src/client/widgets/{matrices => containers}/matrix.js (84%)
create mode 100644 src/scss/ui/button.scss
create mode 100644 src/scss/ui/filebrowser.scss
create mode 100644 src/scss/ui/lobby.scss
create mode 100644 src/scss/widgets/keyboard.scss
diff --git a/src/client/editor/index.js b/src/client/editor/index.js
index a27e50b7..c91f364b 100644
--- a/src/client/editor/index.js
+++ b/src/client/editor/index.js
@@ -1,5 +1,4 @@
-var editField = require('./edit-field'),
- {updateWidget, incrementWidget} = require('./data-workers'),
+var {updateWidget, incrementWidget} = require('./data-workers'),
keyboardJS = require('keyboardjs'),
{diff, diffToWidget} = require('./diff'),
widgetManager = require('../managers/widgets'),
diff --git a/src/client/index.js b/src/client/index.js
index be528b10..b5b4784b 100644
--- a/src/client/index.js
+++ b/src/client/index.js
@@ -1,14 +1,14 @@
require('./stacktrace')
require('./globals')
-var {loading} = require('./ui/utils'),
+var uiLoading = require('./ui/ui-loading'),
locales = require('./locales')
document.addEventListener('DOMContentLoaded', function(event) {
DOM.init()
- LOADING = loading(locales('loading_server'))
+ LOADING = uiLoading(locales('loading_server'))
setTimeout(()=>{
diff --git a/src/client/ipc/callbacks.js b/src/client/ipc/callbacks.js
index 9e6388f5..dabd8e16 100644
--- a/src/client/ipc/callbacks.js
+++ b/src/client/ipc/callbacks.js
@@ -7,6 +7,7 @@ var utils = require('../ui/utils'),
locales = require('../locales'),
{deepCopy} = require('../utils'),
sidepanel = require('../ui/sidepanel'),
+ UiModal = require('../ui/ui-modal'),
notifications = require('../ui/notifications'),
{TRAVERSING_SAMEWIDGET} = require('../events/utils'),
raw = require('nanohtml/raw'),
@@ -82,7 +83,7 @@ module.exports = {
},
error: function(data){
- new utils.Popup({title: raw(utils.icon('exclamation-triangle') + ' ' + locales('error')), content: raw(data), closable:true})
+ new UiModal({title: raw(utils.icon('exclamation-triangle') + ' ' + locales('error')), content: raw(data), closable:true})
},
reloadCss: function(){
diff --git a/src/client/managers/session.js b/src/client/managers/session.js
index 36d2f58d..85370038 100644
--- a/src/client/managers/session.js
+++ b/src/client/managers/session.js
@@ -1,8 +1,13 @@
var ipc = require('../ipc/'),
parser = require('../parser'),
editor = require('../editor/'),
- lobby = require('../ui/lobby'),
- {loading, icon, Popup, upload, remoteBrowse} = require('../ui/utils'),
+ {icon} = require('../ui/utils'),
+ UiModal = require('../ui/ui-modal'),
+ UiModal = require('../ui/ui-modal'),
+ uiLobby = require('../ui/ui-lobby'),
+ uiFilebrowser = require('../ui/ui-filebrowser'),
+ uiFileupload = require('../ui/ui-fileupload'),
+ uiLoading = require('../ui/ui-loading'),
{saveAs} = require('file-saver'),
widgetManager = require('./widgets'),
html = require('nanohtml'),
@@ -32,7 +37,7 @@ var SessionManager = class SessionManager {
this.lock = true
var container = DOM.get('#osc-container')[0],
- loader = loading(locales('loading_session'))
+ loader = uiLoading(locales('loading_session'))
setTimeout(()=>{
try {
@@ -55,7 +60,7 @@ var SessionManager = class SessionManager {
} catch (err) {
loader.close()
- new Popup({title: locales('session_parsingerror'), content: err.message, icon: 'exclamation-triangle', closable:true})
+ new UiModal({title: locales('session_parsingerror'), content: err.message, icon: 'exclamation-triangle', closable:true})
this.lock = false
ipc.send('sessionSetPath', {path: this.sessionPath})
throw err
@@ -77,7 +82,7 @@ var SessionManager = class SessionManager {
DOM.dispatchEvent(window, 'resize')
setTimeout(()=>{
- lobby.close()
+ uiLobby.close()
loader.close()
container.classList.add('show')
this.lock = false
@@ -109,7 +114,7 @@ var SessionManager = class SessionManager {
if (!this.session || READ_ONLY) return
- remoteBrowse({extension: 'json', save:true, directory: this.lastDir}, (path)=>{
+ uiFilebrowser({extension: 'json', save:true, directory: this.lastDir}, (path)=>{
this.lastDir = path[0]
this.save(path)
})
@@ -142,7 +147,7 @@ var SessionManager = class SessionManager {
path = path.substr(0,Math.floor((path.length)/2)-(length-max)/2) + '...' + path.substr(Math.ceil((path.length)/2)+(length-max)/2, path.length)
}
- lobby.list.appendChild(html`
+ uiLobby.list.appendChild(html`
${file} (${path})
${READ_ONLY? '' : html`${raw(icon('times'))}`}
@@ -151,21 +156,21 @@ var SessionManager = class SessionManager {
}
- lobby.list.addEventListener('click', function(e){
+ uiLobby.list.addEventListener('click', function(e){
e.preventDefault()
if (e.target.hasAttribute('data-session')) {
ipc.send('sessionOpen',{path:e.target.getAttribute('data-session')})
} else if (!READ_ONLY && e.target.tagName == 'SPAN') {
ipc.send('sessionRemoveFromHistory',e.target.parentNode.getAttribute('data-session'))
- lobby.list.removeChild(e.target.parentNode)
+ uiLobby.list.removeChild(e.target.parentNode)
}
})
if (!READ_ONLY) {
- var brw = lobby.footer.appendChild(html`${raw(icon('folder-open'))} ${locales('session_browse')}`)
- var imp = lobby.footer.appendChild(html`${raw(icon('upload'))} ${locales('editor_import')}`)
- var nws = lobby.footer.appendChild(html`${raw(icon('file'))} ${locales('session_new')}`)
+ var brw = uiLobby.footer.appendChild(html`${raw(icon('folder-open'))} ${locales('session_browse')}`)
+ var imp = uiLobby.footer.appendChild(html`${raw(icon('upload'))} ${locales('editor_import')}`)
+ var nws = uiLobby.footer.appendChild(html`${raw(icon('file'))} ${locales('session_new')}`)
brw.addEventListener('click', (e)=>{
this.browse()
@@ -181,12 +186,12 @@ var SessionManager = class SessionManager {
}
- DOM.addEventListener(lobby.html, 'mousedown touchstart', function(e){
+ DOM.addEventListener(uiLobby.container, 'mousedown touchstart', function(e){
if (e.type == 'mousedown') e.preventDefault()
e.target.blur()
})
- lobby.open()
+ uiLobby.open()
}
@@ -203,7 +208,7 @@ var SessionManager = class SessionManager {
if (READ_ONLY) return
- remoteBrowse({extension: 'json', directory: this.lastDir}, (path)=>{
+ uiFilebrowser({extension: 'json', directory: this.lastDir}, (path)=>{
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
this.lastDir = path[0]
ipc.send('sessionOpen',{path:path})
@@ -215,12 +220,12 @@ var SessionManager = class SessionManager {
if (READ_ONLY) return
- upload('.json', (path, result)=>{
+ uiFileupload('.json', (path, result)=>{
var session
try {
session = JSON.parse(result)
} catch (err) {
- new Popup({title: locales('session_parsingerror'), content: err, icon: 'exclamation-triangle', closable:true})
+ new UiModal({title: locales('session_parsingerror'), content: err, icon: 'exclamation-triangle', closable:true})
}
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
if (session) sessionManager.load(session, ()=>{
@@ -228,7 +233,7 @@ var SessionManager = class SessionManager {
})
}, ()=>{
- new Popup({title: locales('error'), content: locales('session_uploaderror'), icon: 'exclamation-triangle', closable:true})
+ new UiModal({title: locales('error'), content: locales('session_uploaderror'), icon: 'exclamation-triangle', closable:true})
})
}
diff --git a/src/client/managers/state.js b/src/client/managers/state.js
index ce2f4f5e..8dc89212 100644
--- a/src/client/managers/state.js
+++ b/src/client/managers/state.js
@@ -1,6 +1,7 @@
var ipc = require('../ipc'),
widgetManager = require('./widgets'),
- {upload, remoteBrowse} = require('../ui/utils'),
+ uiFilebrowser = require('../ui/ui-filebrowser'),
+ uiFileupload = require('../ui/ui-fileupload'),
notifications = require('../ui/notifications'),
{saveAs} = require('file-saver'),
locales = require('../locales'),
@@ -103,7 +104,7 @@ var StateManager = class StateManager {
saveAs() {
- remoteBrowse({extension: 'state', save:true, directory: this.lastDir}, (path)=>{
+ uiFilebrowser({extension: 'state', save:true, directory: this.lastDir}, (path)=>{
this.lastDir = path[0]
this.save(path)
})
@@ -112,7 +113,7 @@ var StateManager = class StateManager {
browse() {
- remoteBrowse({extension: 'state', directory: this.lastDir}, (path)=>{
+ uiFilebrowser({extension: 'state', directory: this.lastDir}, (path)=>{
this.lastDir = path[0]
ipc.send('stateOpen',{path: path})
})
@@ -162,7 +163,7 @@ var StateManager = class StateManager {
import() {
- upload('.state', (path, result)=>{
+ uiFileupload('.state', (path, result)=>{
this.load(result, true)
}, (e)=>{
this.loadError()
@@ -194,7 +195,7 @@ var StateManager = class StateManager {
if (!path) return
this.statePath = path
-
+
}
pushValueState(id, value) {
diff --git a/src/client/ui/fullscreen.js b/src/client/ui/fullscreen.js
index 5a347c7f..7825f7fc 100644
--- a/src/client/ui/fullscreen.js
+++ b/src/client/ui/fullscreen.js
@@ -1,5 +1,5 @@
var screenfull = require('screenfull'),
- {Popup} = require('./utils'),
+ UiModal = require('./ui-modal'),
locales = require('../locales')
var fullscreen
@@ -21,7 +21,7 @@ if (screenfull.isEnabled) {
toggle(){
- new Popup({
+ new UiModal({
title: locales('fs_unnavailable'),
content: locales('fs_addtohome'),
closable: true
diff --git a/src/client/ui/init.js b/src/client/ui/init.js
index 690e4402..a83086c4 100644
--- a/src/client/ui/init.js
+++ b/src/client/ui/init.js
@@ -1,16 +1,8 @@
require('./zoom')
-require('./lobby').create()
+// require('./lobby').create()
// 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/ui/lobby.js b/src/client/ui/lobby.js
deleted file mode 100644
index 48aeb8a1..00000000
--- a/src/client/ui/lobby.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var html = require('nanohtml')
-
-class Lobby {
-
- constructor() {
-
- this.state = 0
-
- }
-
- create() {
-
- this.html = html`
-
- `
-
- this.main = DOM.get(this.html, '.main')[0]
- this.list = DOM.get(this.html, '.list')[0]
- this.footer = DOM.get(this.html, '.footer')[0]
-
- }
-
- open() {
- if (this.state) return
- this.state = 1
- document.body.appendChild(this.html)
- setTimeout(()=>{
- this.main.classList.add('show')
- })
- }
-
- close() {
- if (!this.state) return
- this.state = 0
- this.main.classList.remove('show')
- document.body.removeChild(this.html)
- }
-
-}
-
-var lobby = new Lobby()
-
-module.exports = lobby
diff --git a/src/client/ui/ui-dragresize.js b/src/client/ui/ui-dragresize.js
index b7c6dc81..8bfda91f 100644
--- a/src/client/ui/ui-dragresize.js
+++ b/src/client/ui/ui-dragresize.js
@@ -144,8 +144,8 @@ class UiDragResize extends UiWidget {
var handlesVisibility = [
!(widget instanceof Tab) && widget.parent.getProp('layout') === 'default', // nw
- widget.parent.getProp('layout') !== 'vertical', // e
- widget.parent.getProp('layout') !== 'horizontal', // s
+ widget.parent.getProp('layout').match(/horizontal|default/), // e
+ widget.parent.getProp('layout').match(/vertical|default/), // s
]
handlesVisibility.push(handlesVisibility[1] && handlesVisibility[2]) // se
diff --git a/src/client/ui/ui-filebrowser.js b/src/client/ui/ui-filebrowser.js
new file mode 100644
index 00000000..5134bcc3
--- /dev/null
+++ b/src/client/ui/ui-filebrowser.js
@@ -0,0 +1,206 @@
+var locales = require('../locales'),
+ html = require('nanohtml'),
+ raw = require('nanohtml/raw'),
+ ipc = require('../ipc'),
+ doubleClick = require('../events/double-click'),
+ {icon} = require('./utils'),
+ UiModal = require('./ui-modal')
+
+
+module.exports = function UiFilebrowser(options, callback) {
+
+ var save = options.save,
+ saveInputFocus = undefined
+
+ var popup = new UiModal({
+ closable: true,
+ title: locales(save ? 'remotesave_save' : 'remotesave_open'),
+ hide: true
+ })
+
+ var container = DOM.get(popup.container, '.popup-content')[0],
+ browser = html``,
+ ariane = html``,
+ list = html``,
+ saveInput = html``,
+ actions = html`
+
+ ${saveInput}
+
${raw(icon('times'))} Cancel
+ ${
+ save ?
+ html`
${raw(icon('save'))} Save
` :
+ html`
${raw(icon('folder-open'))} Open
`
+ }
+
+ `
+
+ var files = [],
+ path = ''
+
+ var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
+
+ if (save) {
+ saveInput.addEventListener('change', ()=>{
+ if (!saveInput.value.match(extRe)) saveInput.value += '.' + options.extension
+ })
+ saveInput.addEventListener('focus', ()=>{
+ saveInputFocus = true
+ })
+ list.addEventListener('change', ()=>{
+ saveInputFocus = false
+ var choice = DOM.get(list, ':checked')[0]
+ if (choice && choice.classList.contains('file')) {
+ saveInput.value = choice.value
+ }
+ })
+ }
+
+ doubleClick(list, submit, {click: true})
+
+ function submit(){
+
+ var choice = DOM.get(list, ':checked')[0]
+
+ if (!choice && (!save || !saveInput.value) && !options.loadDir) return
+
+ if (choice && choice.classList.contains('folder') && (!save || !saveInputFocus)) {
+ ipc.send('listDir', {path: [path, choice.value]})
+ } else {
+ if (save) {
+ if (files.some(x=>x.name===saveInput.value)) {
+ if (!confirm(locales('remotesave_overwrite'))) return
+ }
+ callback([path, saveInput.value])
+ popup.close()
+ } else {
+ callback([path, choice ? choice.value : ''])
+ popup.close()
+ }
+ }
+
+ }
+
+ actions.addEventListener('click', (e)=>{
+ if (e.target.classList.contains('submit')) {
+ submit()
+ } else if ((e.target.classList.contains('cancel'))){
+ popup.close()
+ }
+ })
+
+ function keyDownHandler(e){
+
+ if (e.keyCode === 13) {
+ if (save) {
+ document.addEventListener('keyup', keyUpHandler)
+ } else {
+ submit()
+ }
+ } else if (e.target === saveInput) {
+ return
+ } else if (e.keyCode === 8) {
+ list.childNodes[0].firstElementChild.checked = true
+ submit()
+ } else if (e.key.length === 1) {
+ var letter = e.key.toLowerCase(),
+ current = DOM.get(list, ':checked')[0],
+ minIndex = -1,
+ index = -1
+
+ if (current) minIndex = DOM.index(current.parentNode)
+
+ for (let i in files) {
+ if (files[i].name[0].toLowerCase() === letter && !list.childNodes[i].firstElementChild.checked) {
+ if (index === -1) index = i
+ if (minIndex !== -1 && i < minIndex) continue
+ index = i
+ break
+ }
+ }
+
+ if (index !== -1) {
+ list.childNodes[index].firstElementChild.click()
+ list.childNodes[index].firstElementChild.focus()
+ }
+ }
+ }
+ function keyUpHandler(e){
+
+ if (e.keyCode === 13) {
+ setTimeout(submit, 100)
+ document.removeEventListener('keyup', keyUpHandler)
+ }
+
+ }
+
+ document.addEventListener('keydown', keyDownHandler)
+
+ ipc.on('listDir', (data)=>{
+
+ ariane.textContent = path = data.path
+
+ files = data.files.filter(x=>x.folder || x.name.match(extRe))
+
+
+ function alphaSort(a, b){
+ // convert to strings and force lowercase
+ a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()
+ b = typeof b.name === 'string' ? b.name.toLowerCase() : b.name.toString()
+ return a.localeCompare(b)
+ }
+
+ var fo = files.filter(x=>x.folder),
+ fi = files.filter(x=>!x.folder)
+
+ fo.sort(alphaSort)
+ fi.sort(alphaSort)
+
+ files = fo.concat(fi)
+
+ files.unshift({
+ name: '..',
+ folder: true
+ })
+
+
+ browser.removeChild(list)
+ list.innerHTML = ''
+ for (let i in files) {
+ var file = files[i]
+ list.appendChild(html`
+
+
+
${raw(icon(file.folder ? 'folder' : 'osc'))} ${file.name}
+
+ `)
+ }
+
+
+ browser.insertBefore(list, actions)
+
+
+ if (save && saveInputFocus === undefined) {
+ saveInput.focus()
+ } else {
+ list.childNodes[0].firstElementChild.focus()
+ }
+
+ }, {context: popup})
+
+ popup.on('close', ()=>{
+ ipc.off('listDir', null, popup)
+ document.removeEventListener('keydown', keyDownHandler)
+ document.removeEventListener('keyup', keyUpHandler)
+ })
+
+ browser.appendChild(ariane)
+ browser.appendChild(list)
+ browser.appendChild(actions)
+ container.appendChild(browser)
+
+ ipc.send('listDir', {extension: options.extension, path: options.directory ? [options.directory] : null})
+
+ popup.open()
+
+}
diff --git a/src/client/ui/ui-fileupload.js b/src/client/ui/ui-fileupload.js
new file mode 100644
index 00000000..8f51ed8a
--- /dev/null
+++ b/src/client/ui/ui-fileupload.js
@@ -0,0 +1,40 @@
+var locales = require('../locales'),
+ uiLoading = require('./ui-loading'),
+ html = require('nanohtml'),
+ SINGLETON = null,
+ CONTAINER = null
+
+module.exports = function uiFileUpload(types, ok, error) {
+
+ if (!CONTAINER) CONTAINER = DOM.get('osc-modal-container')[0]
+
+ if (SINGLETON) CONTAINER.removeChild(uploadSingleton)
+
+ SINGLETON = html``
+
+ CONTAINER.appendChild(SINGLETON)
+
+ SINGLETON.addEventListener('change',function(e){
+
+
+ var reader = new FileReader(),
+ file = e.target.files[0],
+ loader = uiLoading(locales('loading_upload'))
+
+ reader.onerror = reader.onabort = function() {
+ loader.close()
+ error()
+ }
+
+ reader.onload = function(e) {
+ loader.close()
+ ok(file.path, e.target.result)
+ }
+
+ reader.readAsText(file, 'utf-8')
+
+ })
+
+ SINGLETON.click()
+
+}
diff --git a/src/client/ui/ui-inspector-field.js b/src/client/ui/ui-inspector-field.js
index 03238aa7..b805a8a8 100644
--- a/src/client/ui/ui-inspector-field.js
+++ b/src/client/ui/ui-inspector-field.js
@@ -2,7 +2,7 @@ var UiWidget = require('./ui-widget'),
{categories} = require('../widgets/'),
html = require('nanohtml'),
raw = require('nanohtml/raw'),
- {icon, Popup} = require('../ui/utils'),
+ {icon} = require('../ui/utils'),
chroma = require('chroma-js')
@@ -21,7 +21,7 @@ class UiInspectorField extends UiWidget {
this.container = html``
this.label = this.container.appendChild(html``)
- if (this.name === 'type') this.createTypeSelect()
+ if (this.name === 'type' || this.name === 'widgetType') this.createTypeSelect()
else this.createInput()
}
diff --git a/src/client/ui/ui-loading.js b/src/client/ui/ui-loading.js
new file mode 100644
index 00000000..2193c687
--- /dev/null
+++ b/src/client/ui/ui-loading.js
@@ -0,0 +1,12 @@
+var html = require('nanohtml'),
+ UiModal = require('./ui-modal')
+
+module.exports = function uiLoading(title) {
+
+ return new UiModal({
+ title: title,
+ content: html`
`,
+ closable: false
+ })
+
+}
diff --git a/src/client/ui/ui-lobby.js b/src/client/ui/ui-lobby.js
new file mode 100644
index 00000000..f63e31d9
--- /dev/null
+++ b/src/client/ui/ui-lobby.js
@@ -0,0 +1,44 @@
+var html = require('nanohtml'),
+ UiModal = require('./ui-modal')
+
+class UiLobby {
+
+ constructor() {
+
+ this.state = 0
+
+ this.container = html`
+
+ `
+
+ this.list = DOM.get(this.container, '.list')[0]
+ this.footer = DOM.get(this.container, '.footer')[0]
+
+ this.modal = new UiModal({
+ content: this.container,
+ closable: false,
+ title: `${PACKAGE.productName} v${PACKAGE.version}`
+ })
+
+ }
+
+ open() {
+
+ this.modal.open()
+
+ }
+
+ close() {
+
+ this.modal.close()
+
+ }
+
+}
+
+var uiLobby = new UiLobby()
+
+module.exports = uiLobby
diff --git a/src/client/ui/ui-modal.js b/src/client/ui/ui-modal.js
index 9af18fe0..44464d71 100644
--- a/src/client/ui/ui-modal.js
+++ b/src/client/ui/ui-modal.js
@@ -1,97 +1,100 @@
var UiWidget = require('./ui-widget'),
+ {icon} = require('./utils'),
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')
-
- }
-
-}
+ SINGLETON = null,
+ CONTAINER = null
class UiModal extends UiWidget {
- constructor(options) {
+ constructor(options) {
- super(options)
+ super(options)
- this.modals = {}
- this.openedModals = []
+ if (!CONTAINER) CONTAINER = DOM.get('osc-modal-container')[0]
- }
+ if (options.closable) {
- create(id, options) {
+ if (SINGLETON) SINGLETON.close()
+ SINGLETON = this
- if (this.modals[id]) this.destroy(id)
+ }
- this.modals[id] = new UiModalWindow(options)
- this.container.appendChild(this.modals[id].container)
+ this.escKey = options.closable || options.escKey
+ this.enterKey = options.enterKey
+ this.state = 0
+
+ this.container = html`
+
+ `
+
+ if (options.closable) {
+ var closer = DOM.get(this.container, '.popup-title .closer')[0]
+ this.container.addEventListener('fast-click',(e)=>{
+ if (e.target === this.container || e.target === closer) {
+ e.detail.preventOriginalEvent = true
+ this.close()
+ }
+ })
+ }
+
+ if (this.escKey) {
+ this.escKeyHandler = ((e)=>{
+ if (e.keyCode==27) this.close()
+ }).bind(this)
+ }
+
+ if (this.enterKey) {
+ this.enterKeyHandler = ((e)=>{
+ if (e.keyCode == 13) this.enterKey.call(this, e)
+ }).bind(this)
+ }
+
+ if (!options.hide) this.open()
- }
-
- 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()
-
- }
+ }
+ close() {
+
+ if (!this.state) return
+ this.state = 0
+
+ if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
+ if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
+ CONTAINER.removeChild(this.container)
+
+ this.trigger('close')
+
+ }
+
+ open() {
+
+ if (this.state) return
+ this.state = 1
+
+ if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
+ if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
+ CONTAINER.appendChild(this.container)
+
+ this.trigger('open')
+ }
+
}
module.exports = UiModal
diff --git a/src/client/ui/ui-tree.js b/src/client/ui/ui-tree.js
index 57c3d4e9..31c51e28 100644
--- a/src/client/ui/ui-tree.js
+++ b/src/client/ui/ui-tree.js
@@ -3,13 +3,14 @@ var UiWidget = require('./ui-widget'),
doubleClick = require('../events/double-click'),
Sortable = require('sortablejs'),
morph = require('nanomorph'),
- Panel, widgetManager
+ Panel, Matrix, widgetManager
class UiTree extends UiWidget {
constructor(options) {
Panel = require('../widgets/containers/panel')
+ Matrix = require('../widgets/containers/matrix')
widgetManager = require('../managers/widgets')
super(options)
@@ -139,7 +140,7 @@ class UiTree extends UiWidget {
data-id="${id}"">
${id}`
- if (widget instanceof Panel) {
+ if (widget instanceof Panel && !(widget instanceof Matrix)) {
node.insertBefore(html``, node.childNodes[0])
node.classList.add('container')
if (this.expanded[id]) node.classList.add('expanded')
diff --git a/src/client/ui/utils.js b/src/client/ui/utils.js
index 6ebbe6c1..a9cd2e4f 100644
--- a/src/client/ui/utils.js
+++ b/src/client/ui/utils.js
@@ -9,342 +9,14 @@ var popupSingleton = null,
module.exports = {
- Popup: class Popup extends EventEmitter {
- constructor(options) {
-
- super()
-
- if (options.closable) {
-
- if (popupSingleton) {
- popupSingleton.close()
- popupSingleton = null
- }
-
- popupSingleton = this
-
- }
-
- this.closable = options.closable
- this.escKey = options.closable || options.escKey
- this.enterKey = options.enterKey
- this.content = options.content
- this.title = options.title
- this.state = 0
-
- this.html = html`
-
- `
-
- if (this.closable) {
- var closer = DOM.get(this.html, '.popup-title .closer')[0]
- this.html.addEventListener('fast-click',(e)=>{
- if (e.target === this.html || e.target === closer) {
- e.detail.preventOriginalEvent = true
- this.close()
- }
- })
- }
-
- if (this.escKey) {
- this.escKeyHandler = ((e)=>{
- if (e.keyCode==27) this.close()
- }).bind(this)
- }
-
- if (this.enterKey) {
- this.enterKeyHandler = ((e)=>{
- if (e.keyCode == 13) this.enterKey.call(this, e)
- }).bind(this)
- }
-
- if (!options.hide) this.open()
-
-
- }
-
-
-
- close() {
-
- if (!this.state) return
- this.state = 0
-
- if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
- if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
- document.body.removeChild(this.html)
-
- this.trigger('close')
-
- }
-
- open() {
-
- if (this.state) return
- this.state = 1
-
- if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
- if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
- document.body.appendChild(this.html)
-
- this.trigger('open')
- }
- },
-
- loading: function(title){
- return new module.exports.Popup({
- title: title,
- content: html``,
- closable: false
- })
- },
icon: function(i) {
return ``
},
iconify:function(string){
return String(string).replace(/\^[^\s]*/g,(x)=>{return module.exports.icon(x.substring(1))})
},
- upload: function(types, ok, error) {
-
- if (uploadSingleton) document.body.removeChild(uploadSingleton)
-
- uploadSingleton = html``
- document.body.appendChild(uploadSingleton)
-
- uploadSingleton.addEventListener('change',function(e){
- var reader = new FileReader(),
- file = e.target.files[0],
- loader = module.exports.loading(locales('loading_upload'))
-
- reader.onerror = reader.onabort = function() {
- loader.close()
- error()
- }
-
- reader.onload = function(e) {
- loader.close()
- ok(file.path, e.target.result)
- }
-
- reader.readAsText(file, 'utf-8')
-
- })
-
- uploadSingleton.click()
-
- },
- remoteBrowse: function(options, callback) {
-
- var save = options.save,
- saveInputFocus = undefined
-
- var popup = new module.exports.Popup({
- closable: true,
- title: locales(save ? 'remotesave_save' : 'remotesave_open'),
- hide: true
- })
-
- var container = DOM.get(popup.html, '.popup-content')[0],
- browser = html``,
- ariane = html``,
- list = html``,
- saveInput = html``,
- actions = html`
-
- ${saveInput}
-
${raw(module.exports.icon('times'))} Cancel
- ${
- save ?
- html`
${raw(module.exports.icon('save'))} Save
` :
- html`
${raw(module.exports.icon('folder-open'))} Open
`
- }
-
- `
-
- var files = [],
- path = ''
-
- var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
-
- if (save) {
- saveInput.addEventListener('change', ()=>{
- if (!saveInput.value.match(extRe)) saveInput.value += '.' + options.extension
- })
- saveInput.addEventListener('focus', ()=>{
- saveInputFocus = true
- })
- list.addEventListener('change', ()=>{
- saveInputFocus = false
- var choice = DOM.get(list, ':checked')[0]
- if (choice && choice.classList.contains('file')) {
- saveInput.value = choice.value
- }
- })
- }
-
- doubleTap(list, submit, {click: true})
-
- function submit(){
-
- var choice = DOM.get(list, ':checked')[0]
-
- if (!choice && (!save || !saveInput.value) && !options.loadDir) return
-
- if (choice && choice.classList.contains('folder') && (!save || !saveInputFocus)) {
- ipc.send('listDir', {path: [path, choice.value]})
- } else {
- if (save) {
- if (files.some(x=>x.name===saveInput.value)) {
- if (!confirm(locales('remotesave_overwrite'))) return
- }
- callback([path, saveInput.value])
- popup.close()
- } else {
- callback([path, choice ? choice.value : ''])
- popup.close()
- }
- }
-
- }
-
- actions.addEventListener('click', (e)=>{
- if (e.target.classList.contains('submit')) {
- submit()
- } else if ((e.target.classList.contains('cancel'))){
- popup.close()
- }
- })
-
- function keyDownHandler(e){
-
- if (e.keyCode === 13) {
- if (save) {
- document.addEventListener('keyup', keyUpHandler)
- } else {
- submit()
- }
- } else if (e.target === saveInput) {
- return
- } else if (e.keyCode === 8) {
- list.childNodes[0].firstElementChild.checked = true
- submit()
- } else if (e.key.length === 1) {
- var letter = e.key.toLowerCase(),
- current = DOM.get(list, ':checked')[0],
- minIndex = -1,
- index = -1
-
- if (current) minIndex = DOM.index(current.parentNode)
-
- for (let i in files) {
- if (files[i].name[0].toLowerCase() === letter && !list.childNodes[i].firstElementChild.checked) {
- if (index === -1) index = i
- if (minIndex !== -1 && i < minIndex) continue
- index = i
- break
- }
- }
-
- if (index !== -1) {
- list.childNodes[index].firstElementChild.click()
- list.childNodes[index].firstElementChild.focus()
- }
- }
- }
- function keyUpHandler(e){
-
- if (e.keyCode === 13) {
- setTimeout(submit, 100)
- document.removeEventListener('keyup', keyUpHandler)
- }
-
- }
-
- document.addEventListener('keydown', keyDownHandler)
-
- ipc.on('listDir', (data)=>{
-
- ariane.textContent = path = data.path
-
- files = data.files.filter(x=>x.folder || x.name.match(extRe))
-
-
- function alphaSort(a, b){
- // convert to strings and force lowercase
- a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()
- b = typeof b.name === 'string' ? b.name.toLowerCase() : b.name.toString()
- return a.localeCompare(b)
- }
-
- var fo = files.filter(x=>x.folder),
- fi = files.filter(x=>!x.folder)
-
- fo.sort(alphaSort)
- fi.sort(alphaSort)
-
- files = fo.concat(fi)
-
- files.unshift({
- name: '..',
- folder: true
- })
-
-
- browser.removeChild(list)
- list.innerHTML = ''
- for (let i in files) {
- var file = files[i]
- list.appendChild(html`
-
-
-
${raw(module.exports.icon(file.folder ? 'folder' : 'osc'))} ${file.name}
-
- `)
- }
-
-
- browser.insertBefore(list, actions)
-
-
- if (save && saveInputFocus === undefined) {
- saveInput.focus()
- } else {
- list.childNodes[0].firstElementChild.focus()
- }
-
- }, {context: popup})
-
- popup.on('close', ()=>{
- ipc.off('listDir', null, popup)
- document.removeEventListener('keydown', keyDownHandler)
- document.removeEventListener('keyup', keyUpHandler)
- })
-
- browser.appendChild(ariane)
- browser.appendChild(list)
- browser.appendChild(actions)
- container.appendChild(browser)
-
- ipc.send('listDir', {extension: options.extension, path: options.directory ? [options.directory] : null})
-
- popup.open()
-
- }
}
diff --git a/src/client/widgets/buttons/menu.js b/src/client/widgets/buttons/menu.js
index c80913f2..a5edc7e4 100644
--- a/src/client/widgets/buttons/menu.js
+++ b/src/client/widgets/buttons/menu.js
@@ -25,9 +25,7 @@ class Menu extends Widget {
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'
]},
- columns: {type: 'number', value: '', help: [
- 'If `layout` is `grid`, defines the number of columns'
- ]},
+ gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
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: [1, 2, 3], help: [
@@ -241,7 +239,11 @@ class Menu extends Widget {
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')))
+
+ if (layout === 'grid') {
+ var template = this.getProp('gridTemplate') || Math.round(this.values.length / 2)
+ this.menu.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
+ }
}
diff --git a/src/client/widgets/matrices/matrix.js b/src/client/widgets/containers/matrix.js
similarity index 84%
rename from src/client/widgets/matrices/matrix.js
rename to src/client/widgets/containers/matrix.js
index 80b1b888..95f30c21 100644
--- a/src/client/widgets/matrices/matrix.js
+++ b/src/client/widgets/containers/matrix.js
@@ -1,10 +1,14 @@
-var _matrix_base = require('./_matrix_base'),
+var Panel = require('./panel'),
+ Widget = require('../common/widget'),
+ StaticProperties = require('../mixins/static_properties'),
parser = require('../../parser'),
- {deepCopy} = require('../../utils')
+ {deepCopy} = require('../../utils'),
+ html = require('nanohtml'),
+ {enableTraversingGestures, disableTraversingGestures} = require('../../events/drag')
-class Matrix extends _matrix_base {
+class Matrix extends StaticProperties(Panel, {scroll: false}) {
static description() {
@@ -14,16 +18,16 @@ class Matrix extends _matrix_base {
static defaults() {
- return super.defaults({
+ return Widget.defaults({
_matrix: 'matrix',
widgetType: {type: 'string', value: 'toggle', help: 'Defines the type of the widgets in the matrix'},
- matrix: {type: 'array', value: [2,2], help: 'Defines the number of columns and and rows in the matrix'},
+ layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', '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.'},
+ quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
- spacing: {type: 'integer', value: 0, help: 'Adds space between widgets'},
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
- border: {type: 'boolean', value: true, help: 'Set to `false` to disables the widgets\' borders'},
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: `$`',
@@ -36,7 +40,9 @@ class Matrix extends _matrix_base {
constructor(options) {
- super(options)
+ super({...options, html: html``})
+
+ this.value = []
this.on('change',(e)=>{
@@ -61,17 +67,13 @@ class Matrix extends _matrix_base {
})
- this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
- this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
- this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
- if (this.getProp('borders') === false) this.widget.classList.add('noborders')
this.start = parseInt(this.getProp('start'))
if (parser.widgets[this.getProp('widgetType')]) {
- for (let i = 0; i < this.getProp('matrix')[0] * this.getProp('matrix')[1]; i++) {
+ for (let i = 0; i < this.getProp('quantity'); i++) {
var props = this.resolveProp('props', undefined, false, false, false, {'$':i + this.start})
var data = this.defaultProps(i + this.start)
@@ -99,6 +101,8 @@ class Matrix extends _matrix_base {
}
+
+
}
defaultProps(i) {
diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js
index 29e76e2f..0c5c2d1d 100644
--- a/src/client/widgets/containers/modal.js
+++ b/src/client/widgets/containers/modal.js
@@ -26,7 +26,8 @@ class Modal extends Panel {
popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
- layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
+ 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.'},
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'},
diff --git a/src/client/widgets/containers/panel.js b/src/client/widgets/containers/panel.js
index efeb4477..bd5e02da 100644
--- a/src/client/widgets/containers/panel.js
+++ b/src/client/widgets/containers/panel.js
@@ -20,8 +20,9 @@ class Panel extends Container() {
_panel:'panel',
+ 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.'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
- 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'},
@@ -45,9 +46,13 @@ class Panel extends Container() {
super({...options, html: html``})
- if (this.getProp('scroll') === false) this.container.classList.add('noscroll')
+ this.container.classList.toggle('noscroll', this.getProp('scroll') === false)
this.container.classList.add('layout-' + this.getProp('layout'))
+ if (this.getProp('layout') === 'grid') {
+ var template = this.getProp('gridTemplate') || 2
+ this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
+ }
if (this.getProp('tabs') && this.getProp('tabs').length) {
@@ -62,11 +67,12 @@ class Panel extends Container() {
- this.value = -1
this.tabs = []
if (this.getProp('tabs') && this.getProp('tabs').length) {
+ this.value = -1
+
this.navigation = this.widget.appendChild(html``)
this.children = options.children || new Array(this.getProp('tabs').length)
diff --git a/src/client/widgets/containers/tab.js b/src/client/widgets/containers/tab.js
index 599fecd4..777a9a15 100644
--- a/src/client/widgets/containers/tab.js
+++ b/src/client/widgets/containers/tab.js
@@ -1,9 +1,8 @@
var Panel = require('./panel'),
Widget = require('../common/widget'),
- StaticProperties = require('../mixins/static_properties'),
resize = require('../../events/resize')
-module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
+module.exports = class Tab extends Panel {
static description() {
@@ -18,7 +17,9 @@ module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
_tab:'tab',
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
- layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
+ 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.'},
+ scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
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'},
diff --git a/src/client/widgets/index.js b/src/client/widgets/index.js
index 4a0c39c4..05a8714b 100644
--- a/src/client/widgets/index.js
+++ b/src/client/widgets/index.js
@@ -22,7 +22,6 @@ module.exports.widgets = {
canvas: require('./pads/canvas'), // implement...
// matrices
- matrix: require('./matrices/matrix'),
keyboard: require('./matrices/keyboard'),
patchbay: require('./matrices/patchbay').PatchBay,
patchbaynode: require('./matrices/patchbay').PatchBayNode,
@@ -46,6 +45,7 @@ module.exports.widgets = {
panel: require('./containers/panel'),
modal: require('./containers/modal'),
clone: require('./containers/clone'),
+ matrix: require('./containers/matrix'),
// state switchers
switcher: require('./switchers/switcher'),
@@ -63,12 +63,12 @@ module.exports.widgets = {
module.exports.categories = {
'Buttons':['toggle', 'switch', 'dropdown', 'menu'],
- 'Containers':['panel', 'modal', 'clone'],
+ 'Containers':['panel', 'modal', 'clone', 'matrix'],
'Frames':['frame', 'svg', 'html', 'image'],
'Graphs':['plot','eq','visualizer'],
'Indicators':['led', 'text'],
'Inputs':['input', 'keys', 'script', 'gyroscope', 'file'],
- 'Matrices':['matrix', 'keyboard', 'patchbay'],
+ 'Matrices':['keyboard', 'patchbay'],
'Pads':['xy','rgb','multixy', 'canvas'],
'Sliders':['fader','knob', 'encoder', 'range'],
'Switchers':['state', 'switcher','crossfader'],
diff --git a/src/client/widgets/inputs/file.js b/src/client/widgets/inputs/file.js
index fe4673a9..205cc07a 100644
--- a/src/client/widgets/inputs/file.js
+++ b/src/client/widgets/inputs/file.js
@@ -1,7 +1,8 @@
var Widget = require('../common/widget'),
html = require('nanohtml'),
raw = require('nanohtml/raw'),
- {remoteBrowse, icon} = require('../../ui/utils')
+ uiFilebrowser = require('../../ui/ui-filebrowser'),
+ {icon} = require('../../ui/utils')
module.exports = class File extends Widget {
@@ -37,7 +38,7 @@ module.exports = class File extends Widget {
if (e.capturedByEditor === true) return
- remoteBrowse({
+ uiFilebrowser({
extension: this.getProp('extension').replace(/^\.?(.*)$/, '$1'),
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
loadDir: this.getProp('allowDir')
diff --git a/src/client/widgets/matrices/keyboard.js b/src/client/widgets/matrices/keyboard.js
index b42aa428..18b34c2d 100644
--- a/src/client/widgets/matrices/keyboard.js
+++ b/src/client/widgets/matrices/keyboard.js
@@ -1,8 +1,10 @@
var _matrix_base = require('./_matrix_base'),
+ Panel = require('../containers/panel'),
+ Widget = require('../common/widget'),
parser = require('../../parser')
-module.exports = class Keyboard extends _matrix_base {
+module.exports = class Keyboard extends Panel {
static description() {
@@ -12,7 +14,7 @@ module.exports = class Keyboard extends _matrix_base {
static defaults() {
- return super.defaults({
+ return Widget.defaults({
_matrix: 'matrix',
@@ -32,7 +34,7 @@ module.exports = class Keyboard extends _matrix_base {
]},
toggles: {type: 'boolean', value: false, help: 'Set to `true` to make keys bahave like toggle buttons'}
- }, ['_value', 'default', 'value'], {
+ }, ['_value', 'default', 'value', 'linkId'], {
css: {type: 'string', value: '', help: [
'Available CSS variables:',
@@ -48,6 +50,8 @@ module.exports = class Keyboard extends _matrix_base {
super(options)
+ this.value = []
+
this.on('change',(e)=>{
if (e.widget === this) return
@@ -68,12 +72,15 @@ module.exports = class Keyboard extends _matrix_base {
if (pattern[i % 12] == 'w') whiteKeys++
}
+ this.container.style.setProperty('--nkeys', whiteKeys)
+
for (i = start; i < keys + start && i < 109; i++) {
var data = JSON.parse(strData)
data.top = data.left = data.height = data.width = 'auto'
- data.type = this.getProp('toggles') ? 'toggle' : 'push'
+ data.type = 'toggle'
+ data.mode = this.getProp('toggles') ? 'toggle' : 'push'
data.id = this.getProp('id') + '/' + i
data.label = false
data.css = ''
@@ -82,11 +89,11 @@ module.exports = class Keyboard extends _matrix_base {
data.precision = '@{parent.precision}'
data.address = '@{parent.address}'
- data.preArgs = `#{
- a = @{parent.preArgs};
- b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
- concat(b, [${i}])
- }`
+ data.preArgs = `JS{{
+ var a = @{parent.preArgs};
+ var b = typeof a === 'string' and a === '' ? [] : Array.isArray(a) ? a : [a];
+ return b.concat([${i}])
+ }}`
var key = parser.parse({
data: data,
@@ -96,15 +103,14 @@ module.exports = class Keyboard extends _matrix_base {
key._index = i - start
key.container.classList.add('not-editable')
+ key.container.classList.add('key')
if (pattern[i % 12] == 'w') {
key.container.classList.add('white')
- key.container.style.width = `${100/whiteKeys}%`
whiteKeys2++
} else {
key.container.classList.add('black')
- key.container.style.width = `${60 / whiteKeys}%`
- key.container.style.left = `${100 / whiteKeys * (whiteKeys2 - 3/10)}%`
+ key.container.style.setProperty('--rank', whiteKeys2)
}
this.value[i - start] = this.getProp('off')
diff --git a/src/scss/editor.scss b/src/scss/editor.scss
index 3210010c..18fcf575 100644
--- a/src/scss/editor.scss
+++ b/src/scss/editor.scss
@@ -1,6 +1,5 @@
.widget.editing {
z-index: 9999!important;
- // overflow: visible;
}
.widget.editing:after,
.tablink.editing:after,
@@ -40,7 +39,7 @@
}
}
- .widget {
+ .widget:not(.not-editable) {
pointer-events: initial!important;
}
diff --git a/src/scss/index.scss b/src/scss/index.scss
index ec6c1dd6..ec8716eb 100644
--- a/src/scss/index.scss
+++ b/src/scss/index.scss
@@ -62,33 +62,6 @@ body {
letter-spacing: 1rem;
}
-.btn {
- background: var(--color-foreground);
- display: block;
- padding:15rem;
- position: relative;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- cursor: pointer;
- &.small {
- padding:8rem;
- padding-right: 15rem;
- }
- &.tiny {
- padding:6rem;
- }
- &.warning {
- background:firebrick;
- }
- &.disabled {
- pointer-events: none;
- color:var(--color-text-fade);
- }
- &.align-center {
- text-align: center
- }
-}
@@ -99,122 +72,6 @@ body {
-#lobby {
- background: var(--color-bg);
- position: absolute;
- top:0;
- left:0;
- right: 0;
- bottom:0;
- z-index: 2;
- display: flex;
- align-items: center;
- justify-content: center;
- overflow-y: auto;
- padding:20rem;
-
- .main {
- width:600rem;
- max-width: 100%;
- max-height:100%;
- display: flex;
- flex-direction: column;
- opacity: 0;
- transition: opacity .1s;
- &.show {
- opacity: 1;
- overflow: auto;
- }
- }
- .list {
- overflow: auto;
- background: var(--color-fg);
- border-top:2rem solid var(--color-bg);
- text-transform: none;
- font-weight: 500;
- flex: 1 1 auto;
- a {
- &:focus {
- &:after {
- content:"";
- position: absolute;
- top:0;
- left:0;
- bottom:0;
- right:0;
- background: var(--color-accent);
- opacity: 0.1;
- }
- }
- }
- }
- .header {
- padding:22rem 20rem 20rem;
- white-space: nowrap;
- text-overflow: ellipsis;
- flex-grow: 0;
- background-color: var(--color-fg);
- color:var(--color-accent);
- letter-spacing: 1rem;
- font-size: 12rem;
- background:var(--color-raised);
- box-shadow: 0 0 0 1rem var(--color-light) inset;
- }
- .footer {
- background: var(--color-fg);
- white-space: nowrap;
- text-overflow: ellipsis;
- flex-grow: 0;
- border-top:2rem solid var(--color-bg);
- a {
- background:var(--color-raised);
- &:focus {
- &:after {
- content:"";
- position: absolute;
- top:0;
- left:0;
- bottom:0;
- right:0;
- background: var(--color-accent);
- opacity: 0.1;
- }
- }
- }
- }
- a {
- display: block;
- overflow: hidden;
- padding:17rem;
- padding-right:39rem;
- position: relative;
- white-space: nowrap;
- text-overflow: ellipsis;
- background: none;
- border-bottom:1rem solid var(--color-bg);
- em {
- pointer-events: none;
- }
- &:last-child {
- border-bottom:0;
- }
- span {
- position: absolute;
- right:0rem;
- top:0rem;
- padding:17rem;
- color:var(--color-text-fader);
- z-index: 1;
- &:hover {
- color:var(--color-accent);
- }
- i {
- pointer-events: none;
- }
- }
- }
-}
-
#launcher {
overflow: initial;
@@ -523,93 +380,4 @@ body {
background-repeat: no-repeat;
}
-.file-browser {
- width: 540px;
- height: 360px;
- max-width: 100%;
- display: flex;
- flex-direction: column;
- flex: 1;
- .ariane {
- height: 40rem;
- flex-shrink: 0;
- line-height: 40rem;
- padding-left: 10rem;
- }
- .file-list {
- overflow-y: auto;
- flex:1;
- background: var(--color-bg);
- padding: 0 10rem;
- }
- .file {
- position: relative;
- height: 40rem;
- line-height: 40rem;
- input {
- position: absolute;
- width:100%;
- height: 100%;
- opacity: 0;
- cursor: pointer;
- }
- .label {
- position: absolute;
- width:100%;
- height: 100%;
- pointer-events: none;
- white-space: nowrap;
- span {
- display: block;
- width: 100%;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- }
- input:checked + .label {
- color: var(--color-custom);
- &:before {
- content:"";
- position: absolute;
- left:-10rem;
- right:-10rem;
- height: 100%;
- background: var(--color-custom);
- opacity: 0.1;
- }
- }
- }
- .file-actions {
- display: flex;
- flex-direction: row;
- align-items: flex-end;
- justify-content: flex-end;
- height: 40rem;
- flex-shrink: 0;
- margin-top: 10rem;
- div {
- margin-left: 10rem;
- text-transform: uppercase;
- text-overflow: clip;
- }
- i {
- pointer-events: none;
- }
- .save-as {
- flex:1;
- height: 40rem;
- line-height: 40rem;
- border: 0;
- padding: 0 10rem;
- font-size: 120%;
- top: -1rem;
- position: relative;
- background: var(--color-bg);
- &[disabled] {
- pointer-events: none;
- }
- }
- }
-}
-
@import 'themes/default';
diff --git a/src/scss/reset.scss b/src/scss/reset.scss
index ba991012..d4d9a88a 100644
--- a/src/scss/reset.scss
+++ b/src/scss/reset.scss
@@ -14,3 +14,10 @@
-moz-user-select: none;
user-select: none;
}
+
+
+select, input, textarea {
+ -webkit-appearance:none;
+ -moz-appearance:none;
+ appearance:none;
+}
diff --git a/src/scss/ui.scss b/src/scss/ui.scss
index 1ea20008..b7111a67 100644
--- a/src/scss/ui.scss
+++ b/src/scss/ui.scss
@@ -1,3 +1,4 @@
+@import 'ui/button';
@import 'ui/scrollbars';
@import 'ui/workspaces';
@import 'ui/notifications';
@@ -7,3 +8,5 @@
@import 'ui/selectarea';
@import 'ui/contextmenu';
@import 'ui/modal';
+@import 'ui/filebrowser';
+@import 'ui/lobby';
diff --git a/src/scss/ui/button.scss b/src/scss/ui/button.scss
new file mode 100644
index 00000000..82802d4f
--- /dev/null
+++ b/src/scss/ui/button.scss
@@ -0,0 +1,14 @@
+.btn {
+ background: var(--color-foreground);
+ display: block;
+ padding:15rem;
+ position: relative;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ cursor: pointer;
+ &.disabled {
+ pointer-events: none;
+ opacity: 0.5;
+ }
+}
diff --git a/src/scss/ui/filebrowser.scss b/src/scss/ui/filebrowser.scss
new file mode 100644
index 00000000..f8814292
--- /dev/null
+++ b/src/scss/ui/filebrowser.scss
@@ -0,0 +1,97 @@
+
+.file-browser {
+
+ width: 540rem;
+ height: 360rem;
+ max-width: 100%;
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ padding: 2rem 8rem 8rem;
+ background: var(--color-background);
+
+ .ariane {
+ height: 40rem;
+ flex-shrink: 0;
+ line-height: 40rem;
+ padding-left: 10rem;
+ background: var(--color-foreground);
+ margin-bottom: 2rem;
+
+ }
+ .file-list {
+ overflow-y: auto;
+ flex:1;
+ background: var(--color-foreground);
+ padding: 0 10rem;
+ }
+ .file {
+ position: relative;
+ height: 40rem;
+ line-height: 40rem;
+ input {
+ position: absolute;
+ width:100%;
+ height: 100%;
+ opacity: 0;
+ cursor: pointer;
+ }
+ .label {
+ position: absolute;
+ width:100%;
+ height: 100%;
+ pointer-events: none;
+ white-space: nowrap;
+ span {
+ display: block;
+ width: 100%;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ }
+ input:checked + .label {
+ color: var(--color-widget);
+ &:before {
+ content:"";
+ position: absolute;
+ left:-10rem;
+ right:-10rem;
+ height: 100%;
+ background: var(--color-widget);
+ opacity: 0.1;
+ }
+ }
+ }
+ .file-actions {
+ display: flex;
+ flex-direction: row;
+ align-items: flex-end;
+ justify-content: flex-end;
+ height: 40rem;
+ flex-shrink: 0;
+ margin-top: 10rem;
+ div {
+ margin-left: 10rem;
+ text-overflow: clip;
+ min-width: 0;
+ }
+ i {
+ pointer-events: none;
+ }
+ .save-as {
+ flex:1;
+ height: 40rem;
+ line-height: 40rem;
+ border: 0;
+ padding: 0 10rem;
+ font-size: 120%;
+ top: -1rem;
+ position: relative;
+ background: var(--color-foreground);
+ min-width: 0;
+ &[disabled] {
+ display: none
+ }
+ }
+ }
+}
diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss
index dc1314b5..a81601d3 100644
--- a/src/scss/ui/inspector.scss
+++ b/src/scss/ui/inspector.scss
@@ -40,10 +40,6 @@ osc-inspector-field {
background: var(--color-foreground);
cursor: text;
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
-
--scrollbar-size: 6rem;
&::-webkit-scrollbar-thumb:horizontal {
@@ -181,9 +177,7 @@ osc-inspector-select {
// width: 100%;
line-height: $field-height - 8rem;
padding: 4rem 6rem;
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
+
position: absolute;
left:0;
opacity: 0;
@@ -217,7 +211,6 @@ osc-inspector-select {
.osc-inspector-color {
- appearance: none;
padding: 0;
border: 0;
box-shadow: 0;
@@ -234,9 +227,7 @@ osc-inspector-select {
cursor: pointer;
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
+
&::-webkit-color-swatch {
border: none;
diff --git a/src/scss/ui/lobby.scss b/src/scss/ui/lobby.scss
new file mode 100644
index 00000000..132d6729
--- /dev/null
+++ b/src/scss/ui/lobby.scss
@@ -0,0 +1,71 @@
+
+.lobby {
+
+ width: 540rem;
+ height: 360rem;
+ max-width: 100%;
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ background: var(--color-background);
+ padding: 2rem 8rem 8rem;
+
+ .list {
+ overflow: auto;
+ text-transform: none;
+ flex: 1;
+ background: var(--color-foreground);
+ padding: 0 10rem;
+ a {
+ padding-right: 30rem;
+ }
+
+ }
+
+ .footer {
+ margin-top: 10rem;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ flex-grow: 0;
+ display: flex;
+ flex-direction: row;
+ a {
+ margin-left: 10rem;
+ text-align: center;
+ background: var(--color-foreground);
+ &:first-child {
+ margin: 0;
+ }
+ }
+ }
+ a {
+ padding: 0;
+ position: relative;
+ height: 40rem;
+ line-height: 40rem;
+ width: 100%;
+ display: block;
+ overflow: hidden;
+ position: relative;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ background: none;
+ em, i {
+ pointer-events: none;
+ }
+
+ span {
+ position: absolute;
+ right:0rem;
+ top:0rem;
+ z-index: 1;
+ height: 40rem;
+ line-height: 40rem;
+ opacity: 0.5;
+ &:hover {
+ opacity: 1;
+ }
+ }
+
+ }
+}
diff --git a/src/scss/ui/modal.scss b/src/scss/ui/modal.scss
index 7edefa3a..7ba3a14b 100644
--- a/src/scss/ui/modal.scss
+++ b/src/scss/ui/modal.scss
@@ -27,6 +27,7 @@
}
.popup-title {
position: relative;
+ min-height: var(--nav-height);
height: var(--nav-height);
display: flex;
padding:0 15rem;
diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss
index d274baae..0e246545 100644
--- a/src/scss/widgets.scss
+++ b/src/scss/widgets.scss
@@ -88,3 +88,4 @@
@import 'widgets/indicators';
@import 'widgets/frames';
@import 'widgets/patchbay';
+@import 'widgets/keyboard';
diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss
index f478171f..05c19997 100644
--- a/src/scss/widgets/containers.scss
+++ b/src/scss/widgets/containers.scss
@@ -41,6 +41,10 @@
margin: calc(var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2) calc(1rem + var(--widget-spacing) / 2);
}
+ &.noscroll > .panel {
+ overflow: hidden;
+ }
+
&.contains-widgets {
> .panel > .widget {
@@ -77,6 +81,20 @@
}
}
+ &.layout-grid > .panel {
+ display: grid;
+ > .widget {
+ top:auto!important;
+ left:auto!important;
+ position: relative!important;
+ height: auto!important;
+ width: auto!important;
+ min-height: auto!important;
+ max-height: auto!important;
+ min-width: auto!important;
+ max-width: auto!important;
+ }
+ }
}
@@ -123,7 +141,8 @@
}
-.panel-container {
+.panel-container,
+.matrix-container {
@extend .widget-panel-base;
diff --git a/src/scss/widgets/keyboard.scss b/src/scss/widgets/keyboard.scss
new file mode 100644
index 00000000..049adf79
--- /dev/null
+++ b/src/scss/widgets/keyboard.scss
@@ -0,0 +1,68 @@
+.keyboard-container {
+
+ --widget-padding: 0;
+ --alpha-fill-off: 0;
+ --alpha-fill-on: .75;
+
+ --color-key-on: var(--color-fill);
+ --alpha-key-off: var(--alpha-fill-off);
+ --alpha-key-on: var(--alpha-fill-on);
+ --color-white-key: #ddd;
+ --color-black-key: #111;
+
+ --widget-keypad: var(--widget-padding);
+
+ .panel {
+
+ padding: var(--widget-padding);
+ flex: 1;
+ @include pseudo-stroke($z: 2);
+ position: relative;
+ display: flex;
+ flex-direction: row;
+ overflow: hidden;
+ }
+
+ .key {
+
+ --alpha-fill-off: var(--alpha-key-off);
+ --alpha-fill-on: var(--alpha-key-on);
+ inner {
+ margin: 1rem 0.5rem!important;
+ --widget-padding: -1rem;
+ &:before {
+ content: none;
+ }
+ &:after {
+ background: var(--color-key-on);
+ }
+ }
+ }
+
+ .white {
+ flex: 1;
+ width: auto;
+ min-width: auto;
+ height: auto;
+ inner {
+ background: var(--color-white-key);
+ }
+ }
+
+ .black {
+ position: absolute;
+ z-index: 1;
+
+ left: calc((100% - var(--widget-keypad) * 2) / var(--nkeys) * var(--rank));
+ width: calc(100% / var(--nkeys) * 0.6);
+ margin-left: calc(100% / var(--nkeys) * -0.3 + var(--widget-keypad));
+ height: calc((100% - var(--widget-keypad) * 2) * 0.65);
+
+ inner {
+ margin-left: 0!important;
+ margin-right: 0!important;
+ background: var(--color-black-key);
+ }
+ }
+
+}