Compare commits
No commits in common. "master" and "v0.6.2" have entirely different histories.
374 changed files with 26549 additions and 52167 deletions
|
|
@ -1,3 +0,0 @@
|
|||
node_modules
|
||||
app
|
||||
sessions
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-prototype-builtins": "off",
|
||||
"no-console": "off",
|
||||
"no-useless-escape": "off",
|
||||
"no-self-assign": "off",
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
"allowEmptyCatch": true
|
||||
}
|
||||
],
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"args": "none"
|
||||
}
|
||||
],
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"indent": [
|
||||
"error",
|
||||
4,
|
||||
{
|
||||
"SwitchCase": 1,
|
||||
"ObjectExpression": 1,
|
||||
"ArrayExpression": 1,
|
||||
"MemberExpression": "off",
|
||||
"ignoredNodes": ["ConditionalExpression", "TemplateElement"]
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single",
|
||||
{ "allowTemplateLiterals": true }
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"never"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
name: Build
|
||||
on: [workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
Deploy:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: ghcr.io/catthehacker/ubuntu:act-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: 'true'
|
||||
|
||||
- name: Docker Login
|
||||
run: |
|
||||
docker login -u riksolo -p ${{secrets.CONTAINER_REGISTRY_TOKEN}} git.riksolo.com
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
docker build -t git.riksolo.com/riksolo/open-stage-control:latest -t git.riksolo.com/riksolo/open-stage-control:${{github.sha}} .
|
||||
docker push git.riksolo.com/riksolo/open-stage-control:latest
|
||||
docker push git.riksolo.com/riksolo/open-stage-control:${{github.sha}}
|
||||
17
.gitignore
vendored
17
.gitignore
vendored
|
|
@ -1,17 +1,2 @@
|
|||
# npmg
|
||||
node_modules/
|
||||
|
||||
# build
|
||||
/app/
|
||||
|
||||
# python/midi build
|
||||
src/server/python/*
|
||||
!src/server/python/*.py
|
||||
|
||||
# docs build
|
||||
src/docs/widgets-reference.js
|
||||
properties-reference.md
|
||||
|
||||
# packaging
|
||||
dist/
|
||||
sessions/
|
||||
config.json
|
||||
|
|
|
|||
42
.travis.yml
Normal file
42
.travis.yml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
sudo: required
|
||||
dist: trusty
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4.1"
|
||||
before_install:
|
||||
- sudo dpkg --add-architecture i386
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq wine
|
||||
install: npm install --save-optional --production
|
||||
deploy:
|
||||
provider: releases
|
||||
api-key:
|
||||
secure: Nb4qJlmLEE2/ETHEYe8V8eGI08d4GuE5kdQef5ZnB4PrstppLlAjShv5E4DNTsyalMOMDjpw9v+9aQNzxGiGv+lCVVL5oFvqvDpcYusRuF9Qua7oJtFh+5FvjgC1DDjauk5Z7WQWMvzWwfNmqbY/lxPbA4zVy4kdYkGV/8WnzA9AL5fU0ZU8gDsFjcr9Pz81XDsDXtPH/+iMuclMsEl8V/ZuswWlZaFn1Jnb1tcGC5WUCsuNQo/+gGfSK6Qcf9AKsIrOjdzi55s4jqH1N7P/kKi4a2tWUTwmSLrOxdUmSYjXVOxMu0cAEnHSeYREv/5o6J0MbfQrDoxh2y5roPZzqE+FAuFLl+b/+bYlW0mrfYfSuP/VX9LYh5JSvrhN7rZuUfMqS1iM7c9Dx8sZadMnvYEAAJhH8IV/9SkuRa/8QoIpXf7YB9v1jERxs4gk5CPT5Aml6nY/CvMWiEQ/wJhC7iZd/QRHshgfNLfAGlbbNU2KP6ZsVAGD601fyST/8neoQqLqS9mteOr1QME3c5EFw+XaauIQNYZSl+wJr8Y1YMcKY+fbJqqR0TXkbsoxFgV9PRf/4ZCjIJYtmelQVlM7j20XavOHM/Ko6/y7a3pohFz+ql3YR9jGF5XW2foXb4+e6DwTGL91/f75hYcsvXxoKbeaBjWpaSK8532UTeVkhPM=
|
||||
file:
|
||||
- "./dist/open-stage-control-i386.deb"
|
||||
- "./dist/open-stage-control-amd64.deb"
|
||||
- "./dist/open-stage-control-armv7l.deb"
|
||||
- "./dist/open-stage-control-linux-ia32.zip"
|
||||
- "./dist/open-stage-control-linux-x64.zip"
|
||||
- "./dist/open-stage-control-linux-armv7l.zip"
|
||||
- "./dist/open-stage-control-osx.zip"
|
||||
- "./dist/open-stage-control-win32.zip"
|
||||
- "./dist/open-stage-control-win64.zip"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
before_deploy:
|
||||
- cd dist
|
||||
- zip -q -r --symlinks open-stage-control-osx open-stage-control-darwin-x64/open-stage-control.app
|
||||
- zip -q -r open-stage-control-win32 open-stage-control-win32-ia32
|
||||
- zip -q -r open-stage-control-win64 open-stage-control-win32-x64
|
||||
- zip -q -r open-stage-control-linux-ia32 open-stage-control-linux-ia32
|
||||
- zip -q -r open-stage-control-linux-x64 open-stage-control-linux-x64
|
||||
- zip -q -r open-stage-control-linux-armv7l open-stage-control-linux-armv7l
|
||||
- cd ..
|
||||
- npm run deb32
|
||||
- npm run deb64
|
||||
- npm run debarm
|
||||
- mv dist/open-stage-control-linux-ia32/*.deb dist/open-stage-control-i386.deb
|
||||
- mv dist/open-stage-control-linux-x64/*.deb dist/open-stage-control-amd64.deb
|
||||
- mv dist/open-stage-control-linux-armv7l/*.deb dist/open-stage-control-armv7l.deb
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
Anything AI-related is strictly prohibited from this project.
|
||||
|
||||
If you think this project could benefit from a smart use of AI, think harder.
|
||||
|
||||
Think harder about the (hundreds of) millions of data workers that make your AI "smart", not to mention the monumental ecological waste it represents.
|
||||
|
||||
If you still think this way, don't tell me.
|
||||
1865
CHANGELOG.md
1865
CHANGELOG.md
File diff suppressed because it is too large
Load diff
1843
CHANGELOG.v0.md
1843
CHANGELOG.v0.md
File diff suppressed because it is too large
Load diff
29
Dockerfile
29
Dockerfile
|
|
@ -1,29 +0,0 @@
|
|||
FROM node:24-alpine
|
||||
|
||||
RUN apk --no-cache add git
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
RUN mkdir /sessions
|
||||
RUN touch /sessions/session.json
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENV ELECTRON_RUN_AS_NODE=1
|
||||
|
||||
ENV SEND="127.0.0.1:8080"
|
||||
ENV LOAD="/sessions/main.json"
|
||||
ENV PORT=8080
|
||||
ENV OSC_PORT=8080
|
||||
ENV READ_ONLY=false
|
||||
|
||||
RUN chmod +x entrypoint.sh
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
1
Procfile
Normal file
1
Procfile
Normal file
|
|
@ -0,0 +1 @@
|
|||
web: node index.js -n $PORT
|
||||
59
README.md
59
README.md
|
|
@ -1,21 +1,56 @@
|
|||
<img src="resources/images/logo.png" alt="Open Stage Control" height="50px"/>
|
||||
# <img src="resources/images/logo.png" height="80px"/> Open Stage Control
|
||||
|
||||
Open Stage Control
|
||||
Open Stage Control is a libre desktop OSC bi-directionnal control surface application. It's built with HTML, JavaScript & CSS on top of [Electron](http://electron.atom.io/) framework.
|
||||
|
||||
*Libre and modular OSC / MIDI controller*
|
||||
## Documentation
|
||||
|
||||
[Read the documentation](http://jean-emmanuel.github.io/open-stage-control/)
|
||||
|
||||
*The docs' sources are located in [resources/](resources/)*
|
||||
|
||||
## Download
|
||||
|
||||
Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page.
|
||||
|
||||
## Demo
|
||||
|
||||
You can try the app here [http://openstagecontrol.herokuapp.com/](http://openstagecontrol.herokuapp.com/)
|
||||
|
||||
Please note that :
|
||||
|
||||
- Chrome/Chromium **49** at least is required
|
||||
- Since there is only one instance running, all connected guests are synchronized (widgets using the same osc paths update each other's states) : you might experience some unwanted synchronization with other users unless you specify custom parameters for your widgets.
|
||||
- You might want to download the examples sessions files under *examples/* and load them in the app to get started.
|
||||
|
||||
|
||||
- Website: https://openstagecontrol.ammd.net/
|
||||
- Forum: https://openstagecontrol.discourse.group/
|
||||
- IRC: Libera.chat #openstagecontrol
|
||||
## Features
|
||||
|
||||
----
|
||||
- mouse & multi-touch sensitive widgets
|
||||
- modular & responsive layout
|
||||
- built-in live editor
|
||||
- bi-directionnal osc bindings
|
||||
- headless server mode with any number of clients using chromium
|
||||
- app state store / recall & import / export
|
||||
- themes !
|
||||
|
||||
Docker additions by Rik Berkelder.
|
||||
## Supported platforms
|
||||
|
||||
mount `/sessions` directory. default session file is created and loaded there.
|
||||
Same as [Electron's supported platforms](https://github.com/electron/electron/blob/master/docs/tutorial/supported-platforms.md)
|
||||
|
||||
---
|
||||
|
||||
Copyleft © Jean-Emmanuel Doucet 2014-2025.
|
||||
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
|
||||
## License & credits
|
||||
|
||||
Copyleft © Jean-Emmanuel @ [AMMD](http://ammd.net). This program is released under the GNU/GPL3 license.
|
||||
|
||||
It relies on the use of several libraries :
|
||||
|
||||
- [Node.js](https://nodejs.org/)
|
||||
- [Electron](http://electron.atom.io/)
|
||||
- [node-osc](https://github.com/TheAlphaNerd/node-osc)
|
||||
- [socket.io](http://socket.io)
|
||||
- [browserify](http://browserify.org)
|
||||
- [express](http://expressjs.com)
|
||||
- [node-sass](https://github.com/sass/node-sass)
|
||||
- [jQuery](http://jquery.com/)
|
||||
- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
|
||||
- [Font Awesome](http://fontawesome.io/)
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"createdWith": "Open Stage Control",
|
||||
"version": "1.31.2",
|
||||
"type": "session",
|
||||
"content": {
|
||||
"type": "root",
|
||||
"lock": false,
|
||||
"id": "root",
|
||||
"visible": true,
|
||||
"interaction": true,
|
||||
"comments": "",
|
||||
"width": "auto",
|
||||
"height": "auto",
|
||||
"colorText": "auto",
|
||||
"colorWidget": "auto",
|
||||
"alphaFillOn": "auto",
|
||||
"borderRadius": "auto",
|
||||
"padding": "auto",
|
||||
"html": "",
|
||||
"css": "",
|
||||
"colorBg": "auto",
|
||||
"layout": "default",
|
||||
"justify": "start",
|
||||
"gridTemplate": "",
|
||||
"contain": true,
|
||||
"scroll": true,
|
||||
"innerPadding": true,
|
||||
"tabsPosition": "top",
|
||||
"hideMenu": false,
|
||||
"variables": "@{parent.variables}",
|
||||
"traversing": false,
|
||||
"value": "",
|
||||
"default": "",
|
||||
"linkId": "",
|
||||
"address": "auto",
|
||||
"preArgs": "",
|
||||
"typeTags": "",
|
||||
"decimals": 2,
|
||||
"target": "",
|
||||
"ignoreDefaults": false,
|
||||
"bypass": false,
|
||||
"onCreate": "",
|
||||
"onValue": "",
|
||||
"onTouch": "",
|
||||
"onPreload": "",
|
||||
"widgets": [],
|
||||
"tabs": []
|
||||
}
|
||||
}
|
||||
1
browser/css/style.css
Normal file
1
browser/css/style.css
Normal file
File diff suppressed because one or more lines are too long
1
browser/favicon.ico
Symbolic link
1
browser/favicon.ico
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../resources/images/logo.ico
|
||||
6
browser/fonts/droid-sans.css
Normal file
6
browser/fonts/droid-sans.css
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Droid Sans'), local('DroidSans'), url('droid-sans.woff2') format('woff2');
|
||||
}
|
||||
BIN
browser/fonts/droid-sans.woff2
Normal file
BIN
browser/fonts/droid-sans.woff2
Normal file
Binary file not shown.
4
browser/fonts/font-awesome.min.css
vendored
Normal file
4
browser/fonts/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
browser/fonts/fontawesome-webfont.woff2
Normal file
BIN
browser/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
17
browser/index-headless.html
Normal file
17
browser/index-headless.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no"/>
|
||||
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="fonts/droid-sans.css"/>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<script src="/js/browser-headless.bundle.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="lobby"></div>
|
||||
<div id="container"></div>
|
||||
<div id="sidepanel"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
19
browser/index.html
Normal file
19
browser/index.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
|
||||
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="fonts/droid-sans.css"/>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<script>
|
||||
require( __dirname + "/js/browser.js")
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="lobby"></div>
|
||||
<div id="container"></div>
|
||||
<div id="sidepanel"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
54
browser/js/app.js
Normal file
54
browser/js/app.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
///////////////////////
|
||||
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_BY_PATH = {}
|
||||
SESSION = []
|
||||
STATE = []
|
||||
|
||||
CLIPBOARD = null
|
||||
EDITING = false
|
||||
|
||||
TRAVERSING = false
|
||||
|
||||
TABS = {}
|
||||
|
||||
|
||||
MISC = {
|
||||
iterators: {
|
||||
widget:{},
|
||||
tab:{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PXSCALE = getComputedStyle(document.documentElement).getPropertyValue("--pixel-scale")
|
||||
INITIALZOOM = PXSCALE
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
$ = jQuery = require('./jquery/jquery.min')
|
||||
require('./jquery/jquery.ui')
|
||||
require('./jquery/jquery.drag')
|
||||
require('./jquery/jquery.resize')
|
||||
require('./jquery/jquery.fake-input')
|
||||
|
||||
///////////////////////
|
||||
|
||||
var callbacks = require('./app/callbacks')
|
||||
|
||||
var bindCallback = function(i) {
|
||||
IPC.on(i,function(event,data){
|
||||
callbacks[i](event,data)
|
||||
})
|
||||
}
|
||||
|
||||
for (i in callbacks) {
|
||||
bindCallback(i)
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
||||
IPC.send('ready')
|
||||
156
browser/js/app/actions.js
Normal file
156
browser/js/app/actions.js
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
module.exports = {
|
||||
|
||||
stateQuickSave: function(preset){
|
||||
if (preset) {
|
||||
STATE = preset
|
||||
} else {
|
||||
STATE = module.exports.stateGet()
|
||||
}
|
||||
$('.quickload').removeClass('disabled')
|
||||
},
|
||||
|
||||
stateQuickLoad: function(){
|
||||
module.exports.stateSet(STATE,true)
|
||||
},
|
||||
|
||||
stateSave: function() {
|
||||
state = JSON.stringify(module.exports.stateGet(),null,' ')
|
||||
if (WEBFRAME) {
|
||||
IPC.send('stateSave',state)
|
||||
} else {
|
||||
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.preset"></a>')
|
||||
var blob = new Blob([state],{type : 'text/plain'});
|
||||
down.attr('href', window.URL.createObjectURL(blob))
|
||||
down[0].click()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
stateGet: function (){
|
||||
var data = []
|
||||
for (i in WIDGETS) {
|
||||
var widget = WIDGETS[i]
|
||||
for (var j=widget.length-1;j>=0;j--) {
|
||||
if (widget[j].setValue && widget[j].getValue) {
|
||||
var v = widget[j].getValue()
|
||||
if (v!=undefined) data.push([i,v])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return data
|
||||
},
|
||||
|
||||
stateLoad: function() {
|
||||
if (WEBFRAME) {
|
||||
IPC.send('stateLoad')
|
||||
} else {
|
||||
var prompt = $('<input type="file" accept=".preset"/>')
|
||||
prompt.click()
|
||||
prompt.on('change',function(e){
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
var preset = e.target.result
|
||||
module.exports.stateSet(JSON.parse(preset),true)
|
||||
STATE = preset
|
||||
}
|
||||
reader.readAsText(e.target.files[0],'utf-8');
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
stateSend: function(){
|
||||
var data = module.exports.stateGet()
|
||||
module.exports.stateSet(data,true)
|
||||
|
||||
},
|
||||
|
||||
stateSet: function(preset,send){
|
||||
|
||||
for (i in preset) {
|
||||
var data = preset[i]
|
||||
if (WIDGETS[data[0]]!=undefined) {
|
||||
for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
|
||||
if (WIDGETS[data[0]][i].setValue) {
|
||||
WIDGETS[data[0]][i].setValue(data[1],send,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggleFullscreen: function(){
|
||||
|
||||
if (WEBFRAME) {
|
||||
IPC.send('fullscreen')
|
||||
} else {
|
||||
var isInFullScreen = document.webkitIsFullScreen
|
||||
|
||||
if (isInFullScreen) {
|
||||
document.webkitExitFullscreen()
|
||||
} else {
|
||||
document.documentElement.webkitRequestFullScreen()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
sessionBrowse: function(){
|
||||
|
||||
if (WEBFRAME) {
|
||||
IPC.send('sessionBrowse')
|
||||
} else {
|
||||
var prompt = $('<input type="file" accept=".js"/>')
|
||||
prompt.click()
|
||||
prompt.on('change',function(e){
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
var session = e.target.result
|
||||
IPC.send('sessionOpen',{file:session})
|
||||
}
|
||||
reader.readAsText(e.target.files[0],'utf-8');
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
sessionSave: function() {
|
||||
var sessionfile = JSON.stringify(SESSION,null,' ')
|
||||
if (WEBFRAME) {
|
||||
IPC.send('sessionSave',sessionfile)
|
||||
} else {
|
||||
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.js"></a>')
|
||||
var blob = new Blob([sessionfile],{type : 'text/plain'});
|
||||
down.attr('href', window.URL.createObjectURL(blob))
|
||||
down[0].click()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
editorEnable: function(){
|
||||
$('.editor-root').attr('data-tab','#container').removeClass('disabled')
|
||||
$('.enable-editor').addClass('on')
|
||||
$('.disable-editor').removeClass('on')
|
||||
|
||||
EDITING = true
|
||||
},
|
||||
editorDisable: function(){
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root').addClass('disabled')
|
||||
$('.editor-container').remove()
|
||||
$('.disable-editor').addClass('on')
|
||||
$('.enable-editor').removeClass('on')
|
||||
|
||||
EDITING = false
|
||||
},
|
||||
|
||||
traversingDisable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
$(document).trigger('disableTraversingGestures')
|
||||
},
|
||||
traversingEnable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
$(document).enableTraversingGestures()
|
||||
}
|
||||
|
||||
}
|
||||
102
browser/js/app/callbacks.js
Normal file
102
browser/js/app/callbacks.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
var init = require('./init'),
|
||||
actions = require('./actions'),
|
||||
utils = require('./utils'),
|
||||
icon = utils.icon
|
||||
|
||||
module.exports = {
|
||||
|
||||
receiveOsc: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
// fetch ids corresponding to the osc path
|
||||
var path = data.path,
|
||||
pathref = path,
|
||||
args = data.args
|
||||
|
||||
if (typeof data.args == 'object') {
|
||||
for (var i=data.args.length-1;i>=0;i--) {
|
||||
var ref = path+'||||'+data.args.slice(0,i).join('||||')
|
||||
if (WIDGETS_BY_PATH[ref]) {
|
||||
pathref = ref
|
||||
args = data.args.slice(i,data.args.length)
|
||||
args = args.length==1?args[0]:args
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args = data.args
|
||||
}
|
||||
for (i in WIDGETS_BY_PATH[pathref]) {
|
||||
if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true)
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
stateLoad: function(event,data){
|
||||
var data = data || event
|
||||
data = JSON.parse(data)
|
||||
actions.stateSet(data,true)
|
||||
actions.stateQuickSave(data)
|
||||
},
|
||||
|
||||
sessionList: function(event,data){
|
||||
var data = data || event
|
||||
$('#lobby').append(`
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
Open Stage Control
|
||||
</div>
|
||||
<div class="list"></div>
|
||||
<div class="footer"></div>
|
||||
</div>`)
|
||||
|
||||
for (i in data) {
|
||||
$('#lobby .list').append('<a class="btn load" data-session="'+data[i]+'">'+data[i]+'<span>'+icon('remove')+'</span></a>')
|
||||
}
|
||||
$('#lobby .footer').append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
|
||||
$('#lobby .footer').append('<a class="btn new">'+icon('file-o')+' New</a>')
|
||||
$('#lobby .load').click(function(e){
|
||||
e.stopPropagation()
|
||||
IPC.send('sessionOpen',{path:$(this).data('session')})
|
||||
})
|
||||
$('#lobby a span').click(function(e){
|
||||
e.stopPropagation()
|
||||
IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
|
||||
$(this).parents('a').remove()
|
||||
})
|
||||
$('#lobby .browse').click(function(e){
|
||||
e.stopPropagation()
|
||||
actions.sessionBrowse()
|
||||
})
|
||||
$('#lobby .new').click(function(e){
|
||||
e.stopPropagation()
|
||||
init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
|
||||
})
|
||||
},
|
||||
|
||||
sessionOpen: function(event,data){
|
||||
var data = data || event
|
||||
var session = JSON.parse(data)
|
||||
init(session)
|
||||
|
||||
},
|
||||
|
||||
error: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
utils.createPopup(icon('warning')+' '+data.title,data.text)
|
||||
},
|
||||
|
||||
applyStyle: function(event,data){
|
||||
var data = data || event
|
||||
var style = document.createElement('style');
|
||||
style.innerHTML = data.join('');
|
||||
document.body.appendChild(style);
|
||||
if (data.indexOf('--pixel-scale')!=-1) {
|
||||
PXSCALE = data.match(/--pixel-scale\s*:\s*([^;]*)/)[1]
|
||||
INITIALZOOM = PXSCALE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
59
browser/js/app/editor/context-menu.js
Normal file
59
browser/js/app/editor/context-menu.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
var correctPosition = function (m, parent){
|
||||
var pos = m.offset(),
|
||||
width = m.outerWidth(),
|
||||
height = m.outerHeight(),
|
||||
totalWidth = $('body').outerWidth(),
|
||||
totalHeight = $('body').outerHeight(),
|
||||
leftAdjust = parent=='body'?0:parent.outerWidth()-2
|
||||
|
||||
if (width + pos.left > totalWidth) {
|
||||
m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
|
||||
}
|
||||
if (height + pos.top > totalHeight) {
|
||||
m.css({'margin-top':totalHeight-(height + pos.top)})
|
||||
}
|
||||
}
|
||||
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var menu = function(e,actions,parent){
|
||||
|
||||
var m = $('<div class="context-menu"></div>')
|
||||
if (parent=='body') {
|
||||
m.css({top:e.pageY+'px',left:e.pageX+'px'})
|
||||
}
|
||||
|
||||
for (label in actions) {
|
||||
|
||||
if (typeof actions[label] == 'object') {
|
||||
|
||||
var item = $(`<div class="item has-sub" tabIndex="1">${label}</div>`).appendTo(m).on(ev,function(e){e.stopPropagation()})
|
||||
menu(e,actions[label],item)
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$(`<div class="item">${label}</div>`).on(ev + '.editor',function(){
|
||||
var callback = actions[label]
|
||||
return function(e){
|
||||
callback()
|
||||
$('.context-menu').remove()
|
||||
}
|
||||
}()).appendTo(m)
|
||||
}
|
||||
}
|
||||
|
||||
m.appendTo(parent)
|
||||
|
||||
|
||||
|
||||
if (parent=='body') {
|
||||
correctPosition(m,parent)
|
||||
} else {
|
||||
parent.hover(function(){correctPosition(m,parent)})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = menu
|
||||
170
browser/js/app/editor/data-workers.js
Normal file
170
browser/js/app/editor/data-workers.js
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
var widgets = require('../widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
sync = widgets.sync,
|
||||
parser = require('../parser')
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs,
|
||||
ui = require('../ui'),
|
||||
actions = require('../actions'),
|
||||
sidepanelCreateToggle = require('../sidepanel').createToggle,
|
||||
editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
|
||||
editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
|
||||
purgeStores = require('./purge')
|
||||
|
||||
|
||||
var getObjectData = function(obj){
|
||||
var path = []
|
||||
|
||||
if (obj.hasClass('tab')) {
|
||||
return TABS['#'+obj.attr('id')].data
|
||||
}
|
||||
|
||||
if (obj.is('#container')) {
|
||||
return SESSION
|
||||
}
|
||||
|
||||
while(true) {
|
||||
if (obj.hasClass('widget')) {
|
||||
path.unshift(obj.index())
|
||||
path.unshift('widgets')
|
||||
} else if (obj.hasClass('tab')){
|
||||
path.unshift(obj.data('index'))
|
||||
path.unshift('tabs')
|
||||
} else if (obj.is('#container')) {
|
||||
break
|
||||
}
|
||||
|
||||
obj = obj.parent()
|
||||
}
|
||||
|
||||
path.splice(0,1)
|
||||
|
||||
for (var i=0,data=SESSION, path=path, len=path.length; i<len; i++){
|
||||
data = data[path[i]]
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
}
|
||||
|
||||
var updateDom = function(container,data) {
|
||||
|
||||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
state = actions.stateGet(),
|
||||
purgetabs = data.tabs?true:false
|
||||
|
||||
|
||||
|
||||
if (container.hasClass('widget')) {
|
||||
// widget
|
||||
var newContainer = parsewidgets([data],container.parent())
|
||||
container.replaceWith(newContainer)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.hasClass('tab')) {
|
||||
// tab
|
||||
var newContainer = container.empty()
|
||||
|
||||
if (data.widgets && data.widgets.length) parsewidgets(data.widgets,container)
|
||||
if (data.tabs && data.tabs.length) {
|
||||
parsetabs(data.tabs,container,false,data.label)
|
||||
container.addClass('has-tabs')
|
||||
} else {
|
||||
container.removeClass('has-tabs')
|
||||
}
|
||||
|
||||
$(`[data-tab="#${container.attr('id')}"]`).html(`<a><span>${data.label}</span></a>`)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.attr('id')=='container') {
|
||||
// session
|
||||
var newContainer = $('#container')
|
||||
container.empty()
|
||||
parsetabs(data,container,true)
|
||||
|
||||
editSession(newContainer,data)
|
||||
sidepanelCreateToggle()
|
||||
|
||||
}
|
||||
|
||||
newContainer.find('[data-tab]:first-child').click()
|
||||
|
||||
$(window).resize()
|
||||
|
||||
purgeStores(purgetabs)
|
||||
|
||||
// restore state
|
||||
actions.stateSet(state,false)
|
||||
sync()
|
||||
ui.scrolls()
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
|
||||
|
||||
// return updated node
|
||||
return newContainer
|
||||
|
||||
}
|
||||
|
||||
|
||||
var incrementWidget = function(data){
|
||||
|
||||
if (!data) return
|
||||
|
||||
delete data.linkId
|
||||
|
||||
var id = data.id,
|
||||
label = data.label,
|
||||
path = data.path
|
||||
|
||||
if (id && id==label) {
|
||||
data.label = 'auto'
|
||||
}
|
||||
if (id && path == '/'+id) {
|
||||
|
||||
data.path = 'auto'
|
||||
|
||||
} else if (path){
|
||||
var pathref
|
||||
while (WIDGETS_BY_PATH[pathref]) {
|
||||
path = path.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
pathref = data.preArgs&&data.preArgs.length?data.path+'||||'+data.preArgs.join('||||'):data.path
|
||||
}
|
||||
WIDGETS_BY_PATH[pathref] = []
|
||||
data.path = path
|
||||
|
||||
}
|
||||
|
||||
if (id) {
|
||||
while (WIDGETS[id]) {
|
||||
id = id.replace(/([0-9]*)$/,function(m){
|
||||
var n = parseInt(m)+1
|
||||
n = isNaN(n)?1:n
|
||||
return n
|
||||
})
|
||||
}
|
||||
WIDGETS[id] = []
|
||||
data.id = id
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i in data) {
|
||||
if (typeof data[i] == 'object') data[i] = incrementWidget(data[i])
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateDom:updateDom,
|
||||
getObjectData:getObjectData,
|
||||
incrementWidget:incrementWidget
|
||||
}
|
||||
310
browser/js/app/editor/edit-objects.js
Normal file
310
browser/js/app/editor/edit-objects.js
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var editObject = function(container, data, refresh){
|
||||
|
||||
if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
|
||||
|
||||
var isWidget = container.hasClass('widget')
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
|
||||
if (isWidget) {
|
||||
$(container).addClass('editing')
|
||||
} else {
|
||||
$(`[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
|
||||
$(container).parent().addClass('editing')
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container')
|
||||
|
||||
|
||||
var params = isWidget?widgetOptions[data.type]:{label:''}
|
||||
|
||||
for (i in params) {
|
||||
|
||||
if (i.indexOf('separator')!=-1) {
|
||||
$(`<div class="separator"><span>${params[i]}</span></div>`).appendTo(form)
|
||||
continue
|
||||
} else if (data[i]===undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Common options edit
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
|
||||
var type = typeof data[i],
|
||||
value = type == 'object'?JSON.stringify(data[i]):data[i],
|
||||
wrapper = $('<div class="input-wrapper"></div>').appendTo(form),
|
||||
label = $(`<label>${i}</label>`).appendTo(wrapper),
|
||||
input
|
||||
|
||||
if (i=='type') {
|
||||
|
||||
input = $(`<select class="input" data-type="${type}" title="${i}"/>`)
|
||||
|
||||
for (t in widgetOptions) {
|
||||
input.append(`<option ${t==value?'selected=':''} value="${t}">${t}</option>`)
|
||||
}
|
||||
select = $('<div class="select-wrapper"></div>').append(input)
|
||||
select.appendTo(wrapper)
|
||||
|
||||
} else if (typeof params[i]=='boolean') {
|
||||
|
||||
input = $(`<input class="checkbox" data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.click(function(){
|
||||
$(this).val(!eval($(this).val())).trigger('change')
|
||||
})
|
||||
input.appendTo(wrapper)
|
||||
|
||||
} else {
|
||||
|
||||
input = $(`<input data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.appendTo(wrapper)
|
||||
|
||||
}
|
||||
|
||||
|
||||
input.on('change',function(){
|
||||
// var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
|
||||
var v
|
||||
try {
|
||||
eval(`v=${$(this).val()}`)
|
||||
} catch(err) {
|
||||
v = $(this).val()
|
||||
}
|
||||
|
||||
data[$(this).attr('title')] = v
|
||||
if (v==='') delete data[$(this).attr('title')]
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// widget list edit
|
||||
if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
var list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.widget').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.widgets) {
|
||||
|
||||
|
||||
var item = $(`<li data-index="${i}" class="sortables" data-id="${data.widgets[i].id}"><a class="btn small">${data.widgets[i].id||data.widgets[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.widgets.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>widgets</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
|
||||
}
|
||||
|
||||
// tab list edit
|
||||
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.tabs) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data.tabs[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.tabs.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>tabs</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('width')) {
|
||||
var handleTarget
|
||||
container.resizable({
|
||||
handles:'s, e, se',
|
||||
helper: "ui-helper",
|
||||
start: function(event, ui){
|
||||
handleTarget = $(event.originalEvent.target)
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('top')) {
|
||||
container.draggable({
|
||||
cursor:'-webkit-grabbing',
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
|
||||
data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
|
||||
ui.helper.remove()
|
||||
updateDom(container,data)
|
||||
},
|
||||
handle:'.ui-draggable-handle, > .label',
|
||||
snap:'.widget',
|
||||
snapTolerance:5,
|
||||
helper:function(){return $('<div class="ui-helper"></div>').css({height:container.outerHeight(),width:container.outerWidth()})}
|
||||
}).append('<div class="ui-draggable-handle"></div>')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var editSession = function(container,data,refresh){
|
||||
|
||||
if (!refresh && $('.editor-root').hasClass('editing')) return
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root, #container').addClass('editing')
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
|
||||
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container'),
|
||||
list = $('<ul class="input"></ul>'),
|
||||
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
|
||||
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data = data || []
|
||||
data.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>tabs</label>').appendTo(wrapper)
|
||||
list.appendTo(wrapper)
|
||||
|
||||
|
||||
$('.editor-container').append(form)
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
editObject:editObject,
|
||||
editSession:editSession
|
||||
}
|
||||
182
browser/js/app/editor/init.js
Normal file
182
browser/js/app/editor/init.js
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
var data = require('./data-workers'),
|
||||
getObjectData = data.getObjectData,
|
||||
updateDom = data.updateDom,
|
||||
incrementWidget = data.incrementWidget,
|
||||
edit = require('./edit-objects'),
|
||||
editObject = edit.editObject,
|
||||
editSession = edit.editSession,
|
||||
createPopup = require('../utils').createPopup,
|
||||
widgetOptions = require('../widgets').widgetOptions,
|
||||
widgetCategories = require('../widgets').categories,
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
||||
var init = function(){
|
||||
|
||||
$('body').off('.editor').on('fake-click fake-right-click',function(e,d){
|
||||
|
||||
if (!EDITING) return
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.type=='mousedown' && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
$('.context-menu').remove()
|
||||
|
||||
var target = $(e.target).is('.widget:not(.not-editable), .tab, [data-tab], #container')?
|
||||
$(e.target):
|
||||
$(e.target).closest('.widget:not(.not-editable), .tab, [data-tab], #container')
|
||||
|
||||
if (!target.length) return
|
||||
|
||||
var container = target.attr('data-tab')?TABS[target.attr('data-tab')].tab:target,
|
||||
type = target.hasClass('widget')?'widget':'tab',
|
||||
parent = container.parent(),
|
||||
index = container.index(),
|
||||
data = getObjectData(container)
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
editSession(container,SESSION)
|
||||
} else {
|
||||
editObject(container,data)
|
||||
}
|
||||
|
||||
|
||||
if (e.type!='fake-right-click') return
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
menu(d,{
|
||||
'<i class="fa fa-plus"></i> Add tab': function(){
|
||||
data.push({})
|
||||
updateDom(container,data)
|
||||
}
|
||||
},'body')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var actions = {}
|
||||
|
||||
// actions['<i class="fa fa-edit"></i> Edit'] = function(){editObject(container,data)}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-copy"></i> Copy'] = function(){CLIPBOARD=data}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-cut"></i> Cut'] = function(){
|
||||
CLIPBOARD=JSON.parse(JSON.stringify(data))
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
updateDom(parentContainer,parentData)
|
||||
}
|
||||
|
||||
if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
if (CLIPBOARD!=null) {
|
||||
actions['<i class="fa fa-paste"></i> Paste'] = {
|
||||
'<i class="fa fa-plus-circle"></i> ID + 1':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
|
||||
|
||||
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
},
|
||||
'<i class="fa fa-clone"></i> Clone':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = JSON.parse(JSON.stringify(CLIPBOARD))
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
} else {
|
||||
delete newData.top
|
||||
delete newData.left
|
||||
}
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add widget'] = {}
|
||||
var createFunction = function(widgetType,container,data){
|
||||
return function() {
|
||||
data.widgets = data.widgets || []
|
||||
var newData = {type:widgetType}
|
||||
if (!target.attr('data-tab')) {
|
||||
newData.top = d.offsetY
|
||||
newData.left= d.offsetX
|
||||
}
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
for (category in widgetCategories) {
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category] = {}
|
||||
for (t in widgetCategories[category]) {
|
||||
var wtype = widgetCategories[category][t]
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category][wtype] = createFunction(wtype,container,data)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add tab'] = function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
updateDom(container,data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-trash"></i> Delete'] = function(){
|
||||
var popup = createPopup('Are you sure ?',`
|
||||
<div class="actions">
|
||||
<div class="btn warning confirm-delete">DELETE</div>
|
||||
<div class="btn cancel-delete">CANCEL</div>
|
||||
</div>
|
||||
`)
|
||||
$('.confirm-delete').click(function(){
|
||||
popup.close()
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
|
||||
if (type=='widget') {
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
} else if (type=='tab' && parentContainer.attr('id')!='container') {
|
||||
parentData.tabs.splice(container.data('index'),1)
|
||||
} else {
|
||||
parentData.splice(container.data('index'),1)
|
||||
}
|
||||
|
||||
updateDom(parentContainer,parentData)
|
||||
})
|
||||
$('.cancel-delete').click(function(){
|
||||
popup.close()
|
||||
})
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==13) $('.confirm-delete').click()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
menu(d,actions,'body')
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = init
|
||||
70
browser/js/app/editor/purge.js
Normal file
70
browser/js/app/editor/purge.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
module.exports = function(purgetabs) {
|
||||
|
||||
// prune tabs store
|
||||
var count, newcount, formerBuffuredTabs, bufferedTabs
|
||||
|
||||
if (purgetabs) {
|
||||
while (true) {
|
||||
// we need to do that several times since tabs are referenced in each of their parents
|
||||
|
||||
// get all buffered tabs
|
||||
formerBuffuredTabs = []
|
||||
for (i in TABS) {
|
||||
formerBuffuredTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// remove deleted tabs that are not referenced (have no navigation link pointing to them)
|
||||
var $f = $(formerBuffuredTabs)
|
||||
for (i in TABS) {
|
||||
if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
|
||||
delete TABS[i]
|
||||
}
|
||||
}
|
||||
|
||||
newcount = Object.keys(TABS).length
|
||||
if (count == newcount) break
|
||||
count = newcount
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bufferedTabs = []
|
||||
for (i in TABS) {
|
||||
bufferedTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// prune widget stores
|
||||
// if widgets cannot be found in buffered tabs, it must be unreferenced
|
||||
var $b = $(bufferedTabs)
|
||||
for (i in WIDGETS) {
|
||||
for (var j=WIDGETS[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS[i][j]).length) {
|
||||
WIDGETS[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS[i].length) {
|
||||
delete WIDGETS[i]
|
||||
}
|
||||
}
|
||||
for (i in WIDGETS_LINKED) {
|
||||
for (var j=WIDGETS_LINKED[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS_LINKED[i][j]).length) {
|
||||
WIDGETS_LINKED[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS_LINKED[i].length) {
|
||||
delete WIDGETS_LINKED[i]
|
||||
}
|
||||
}
|
||||
for (i in WIDGETS_BY_PATH) {
|
||||
for (var j=WIDGETS_BY_PATH[i].length-1;j>=0;j--) {
|
||||
if (!$b.find(WIDGETS_BY_PATH[i][j]).length) {
|
||||
WIDGETS_BY_PATH[i].splice(j,1)
|
||||
}
|
||||
}
|
||||
if (!WIDGETS_BY_PATH[i].length) {
|
||||
delete WIDGETS_BY_PATH[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
42
browser/js/app/init.js
Normal file
42
browser/js/app/init.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
var parsetabs = require('./parser').tabs,
|
||||
ui = require('./ui'),
|
||||
sync = require('./widgets').sync,
|
||||
editorDisable = require('./actions').editorDisable,
|
||||
editorInit = require('./editor/init')
|
||||
|
||||
module.exports = function(session,callback) {
|
||||
|
||||
$('#lobby').remove()
|
||||
$('#container').empty()
|
||||
var spinner = $('<div id="loading"><div class="spinner"></div></div>').appendTo('#container')
|
||||
|
||||
setTimeout(function(){
|
||||
parsetabs(session,$('#container'),true)
|
||||
|
||||
// var t = $('<div></div>').appendTo('body')
|
||||
// for (id in TABS) {
|
||||
// if (id!='#container') {
|
||||
// t[0].appendChild(TABS[id].tab[0])
|
||||
// }
|
||||
// }
|
||||
// setTimeout(function(){
|
||||
// t.detach()
|
||||
// },250)
|
||||
|
||||
|
||||
ui.init()
|
||||
editorDisable()
|
||||
editorInit()
|
||||
sync()
|
||||
|
||||
|
||||
setTimeout(function(){
|
||||
spinner.remove()
|
||||
if (!callback) return
|
||||
setTimeout(function(){
|
||||
callback()
|
||||
},25)
|
||||
},25)
|
||||
},25)
|
||||
|
||||
}
|
||||
184
browser/js/app/parser.js
Normal file
184
browser/js/app/parser.js
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
createWidget = widgets.createWidget,
|
||||
icon = require('./utils').icon
|
||||
|
||||
var getIterator = function(id,type){
|
||||
var iterator = MISC.iterators[type]
|
||||
if (iterator[id]==undefined) iterator[id] = 0
|
||||
iterator[id] += 1
|
||||
return iterator[id]
|
||||
}
|
||||
|
||||
var hashCode = function(s){
|
||||
return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
|
||||
}
|
||||
|
||||
module.exports.tabs = function(data,parent,main,parentLabel){
|
||||
|
||||
if (main) {
|
||||
// Reset Globals
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_BY_PATH = {}
|
||||
SESSION = data
|
||||
for (i in TABS) {
|
||||
if (i!='#container') {
|
||||
TABS[i].parent.remove()
|
||||
TABS[i].tab.remove()
|
||||
}
|
||||
}
|
||||
TABS['#container'] = {
|
||||
tab:$('#container')
|
||||
}
|
||||
|
||||
MISC.iterators.tab = {}
|
||||
}
|
||||
|
||||
var main = main?'main ':'',
|
||||
nav = $(document.createElement('div')).addClass(main + 'navigation'),
|
||||
navtabs = $(document.createElement('ul')).addClass('tablist'),
|
||||
content = $(document.createElement('div')).addClass('content')
|
||||
|
||||
|
||||
for (i in data) {
|
||||
var tabData = data[i]
|
||||
|
||||
|
||||
var label = tabData.label||tabData.id||'Unnamed',
|
||||
hash = hashCode(label),
|
||||
id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
|
||||
|
||||
tabData.label = label
|
||||
delete tabData.id
|
||||
|
||||
navtabs.append(`<li data-tab="#${id}"><a><span>${label}</span></a></li>`)
|
||||
|
||||
var tabContent = $(`<div class="tab ${tabData.tabs&&tabData.tabs.length?'has-tabs':''}" id="${id}" data-index="${i}"></div>`)
|
||||
tabContent.data(tabData)
|
||||
|
||||
|
||||
if (tabData.tabs && tabData.tabs.length) {
|
||||
module.exports.tabs(tabData.tabs,tabContent,false,label)
|
||||
} else if (tabData.widgets && tabData.widgets.length) {
|
||||
module.exports.widgets(tabData.widgets,tabContent)
|
||||
}
|
||||
|
||||
// content.append(tabContent)
|
||||
TABS['#'+id]= {
|
||||
parent:content,
|
||||
tab:tabContent,
|
||||
data:tabData
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nav[0].appendChild(navtabs[0])
|
||||
parent[0].appendChild(nav[0])
|
||||
parent[0].appendChild(content[0])
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports.widgets = function(data,parent) {
|
||||
|
||||
for (i in data) {
|
||||
var widgetData = data[i]
|
||||
|
||||
widgetData.type = widgetData.type || 'fader'
|
||||
|
||||
var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
|
||||
|
||||
for (i in tmpWidgetOptions[widgetData.type]) {
|
||||
if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
|
||||
}
|
||||
|
||||
if (widgetData.id=='auto') {
|
||||
var id
|
||||
while (!id || WIDGETS[id]) {
|
||||
id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
|
||||
}
|
||||
widgetData.id = id
|
||||
}
|
||||
|
||||
widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
|
||||
widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
|
||||
|
||||
for (i in widgetData) {
|
||||
if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
|
||||
}
|
||||
|
||||
|
||||
for (t in {width:'',height:'',top:'',left:''}) {
|
||||
widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
|
||||
}
|
||||
|
||||
if (parent.hasClass('strip')) {
|
||||
delete widgetData.top
|
||||
delete widgetData.left
|
||||
}
|
||||
|
||||
if (widgetData.preArgs!=undefined) {
|
||||
widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
|
||||
}
|
||||
if (widgetData.target!=undefined) {
|
||||
widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
|
||||
}
|
||||
|
||||
var width = parseFloat(widgetData.width)==widgetData.width?parseFloat(widgetData.width)+'rem' : widgetData.width,
|
||||
height = parseFloat(widgetData.height)==widgetData.height?parseFloat(widgetData.height)+'rem' : widgetData.height,
|
||||
left = parseFloat(widgetData.left)==widgetData.left?parseFloat(widgetData.left)+'rem' : widgetData.left,
|
||||
top = parseFloat(widgetData.top)==widgetData.top?parseFloat(widgetData.top)+'rem' : widgetData.top
|
||||
|
||||
|
||||
var styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:auto;`:'',
|
||||
styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:auto;`:'',
|
||||
styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
|
||||
styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
|
||||
|
||||
var label = widgetData.label == 'auto'?
|
||||
widgetData.id:
|
||||
typeof widgetData.label == 'string' && widgetData.label.indexOf('icon:')!=-1?
|
||||
icon(widgetData.label.split(':')[1].trim().replace('fa-','')):
|
||||
widgetData.label
|
||||
|
||||
var widgetContainer = $(`
|
||||
<div class="widget ${widgetData.type}-container ${styleL.length || styleT.length?'absolute-position':''}" style="${styleW + styleH + styleL + styleT + widgetData.css}">
|
||||
<div class="label"><span>${label}</span></div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (widgetData.color && widgetData.color!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetData.color)
|
||||
|
||||
if (widgetData.label===false) widgetContainer.addClass('nolabel')
|
||||
|
||||
// create widget
|
||||
var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
|
||||
|
||||
|
||||
widgetContainer[0].appendChild(widgetInner[0])
|
||||
|
||||
// store widget reference for cross widget sync
|
||||
if (WIDGETS[widgetData.id]==undefined) WIDGETS[widgetData.id] = []
|
||||
WIDGETS[widgetData.id].push(widgetInner)
|
||||
|
||||
// store widget with linkId for widgte linking
|
||||
if (widgetData.linkId && widgetData.linkId.length) {
|
||||
if (WIDGETS_LINKED[widgetData.linkId]==undefined) WIDGETS_LINKED[widgetData.linkId] = []
|
||||
WIDGETS_LINKED[widgetData.linkId].push(widgetInner)
|
||||
}
|
||||
|
||||
// store widget by path and encode preArgs for perfect cross-app sync
|
||||
if (widgetData.path) {
|
||||
var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path
|
||||
if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = []
|
||||
WIDGETS_BY_PATH[pathref].push(widgetInner)
|
||||
}
|
||||
|
||||
parent[0].appendChild(widgetContainer[0])
|
||||
}
|
||||
|
||||
// Editor needs to get the container object
|
||||
if (data && data.length==1) return widgetContainer
|
||||
|
||||
}
|
||||
143
browser/js/app/sidepanel.js
Normal file
143
browser/js/app/sidepanel.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var data = [
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
title:'Fullscreen (F11)',
|
||||
action:actions.toggleFullscreen
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('sliders') + ' State',
|
||||
actions: [
|
||||
{
|
||||
title:'Store',
|
||||
action:actions.stateQuickSave
|
||||
},
|
||||
{
|
||||
title:'Recall',
|
||||
action:actions.stateQuickLoad,
|
||||
class:'disabled quickload'
|
||||
},
|
||||
{
|
||||
title:'Send All',
|
||||
action:actions.stateSend
|
||||
},
|
||||
{
|
||||
title:'Import',
|
||||
action:actions.stateLoad
|
||||
},
|
||||
{
|
||||
title:'Export',
|
||||
action:actions.stateSave
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('magic') + ' Traversing gestures',
|
||||
actions: [
|
||||
{
|
||||
title:'On',
|
||||
action:actions.traversingEnable,
|
||||
class:'traversingEnable'
|
||||
},
|
||||
{
|
||||
title:'Off',
|
||||
action:actions.traversingDisable,
|
||||
class:'traversingDisable on'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: icon('edit') + ' Editor',
|
||||
class:'editor',
|
||||
actions: [
|
||||
{
|
||||
title:'On',
|
||||
action:actions.editorEnable,
|
||||
class:'enable-editor'
|
||||
},
|
||||
{
|
||||
title:'Off',
|
||||
action:actions.editorDisable,
|
||||
class:'on disable-editor'
|
||||
},
|
||||
{
|
||||
title:'Root',
|
||||
class:'editor-root disabled'
|
||||
},
|
||||
{
|
||||
title:'Load',
|
||||
action:actions.sessionBrowse
|
||||
},
|
||||
{
|
||||
title:'Save',
|
||||
action:actions.sessionSave
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
var sidepanel = function(data){
|
||||
|
||||
var bindAction = function(el,callback) {
|
||||
el.click(function(){callback()})
|
||||
}
|
||||
|
||||
var html = $('<ul id="options"></ul>')
|
||||
|
||||
for (i in data) {
|
||||
var itemData = data[i]
|
||||
|
||||
var item = $('<li></li>'),
|
||||
inner = $('<div></div>').appendTo(item)
|
||||
wrapper = $('<div class="actions"></div>').appendTo(inner)
|
||||
|
||||
if (itemData.title) $('<div class="title">'+itemData.title+'</div>').prependTo(wrapper)
|
||||
if (itemData.class) inner.attr('class',itemData.class)
|
||||
|
||||
for (j in itemData.actions) {
|
||||
var actionData = itemData.actions[j]
|
||||
var el = $('<a class="btn">'+actionData.title+'</a>').appendTo(wrapper)
|
||||
if (actionData.action) bindAction(el, actionData.action)
|
||||
|
||||
if (actionData.class) el.addClass(actionData.class)
|
||||
|
||||
}
|
||||
item.appendTo(html)
|
||||
|
||||
}
|
||||
|
||||
return html
|
||||
|
||||
}(data)
|
||||
|
||||
var toggle = function(){
|
||||
$(`<li><a id="open-toggle">${icon('navicon')}</a></li>`).appendTo('.navigation.main ul').click(function(e){
|
||||
var t = 0
|
||||
if (!$('#sidepanel').hasClass('sidepanel-open')) t = 250
|
||||
|
||||
$('#open-toggle, #sidepanel').toggleClass('sidepanel-open')
|
||||
setTimeout(function(){
|
||||
$('#container').toggleClass('sidepanel-open')
|
||||
$(window).resize()
|
||||
},t)
|
||||
}).on('mousedown touchstart',function(e){e.stopPropagation()})
|
||||
|
||||
// in case where are hot loading a session
|
||||
if ($('#sidepanel').hasClass('sidepanel-open')) {
|
||||
$('#open-toggle, #container').addClass('sidepanel-open')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init:function(){
|
||||
$('#sidepanel').append(sidepanel)
|
||||
toggle()
|
||||
},
|
||||
createToggle:toggle
|
||||
}
|
||||
71
browser/js/app/ui.js
Normal file
71
browser/js/app/ui.js
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var sidepanel = require('./sidepanel').init
|
||||
|
||||
// Tabs...
|
||||
var tabs = function() {
|
||||
$('#container').click(function(e){
|
||||
var link = e.target
|
||||
|
||||
if (!link.hasAttribute('data-tab') || link.classList.contains('on')) return
|
||||
|
||||
var id = link.getAttribute('data-tab')
|
||||
|
||||
link.classList.add('on')
|
||||
|
||||
var previous = $(link).siblings('.on').removeClass('on').data('tab')
|
||||
|
||||
// TABS[id].tab.appendTo(TABS[id].parent)
|
||||
TABS[id].parent[0].appendChild(TABS[id].tab[0])
|
||||
$(previous).detach()
|
||||
|
||||
|
||||
$(id).find('li[data-tab]:first-child, li.parent + li[data-tab]').each(function(){
|
||||
if (!$(this).siblings('.on').length) $(this).click()
|
||||
})
|
||||
|
||||
$(window).resize()
|
||||
|
||||
})
|
||||
$('li[data-tab]').first().click()
|
||||
}
|
||||
|
||||
// horizontal scrolling & zoom with mousewheel
|
||||
// if shift is pressed (native), or if there is no vertical scrollbar,
|
||||
// or if mouse is on h-scrollbar
|
||||
var scrollbarHeight = 20
|
||||
var scrolls = function(){
|
||||
$('html').on('mousewheel.zoom',function(e) {
|
||||
// console.log(e)
|
||||
if (e.ctrlKey) {
|
||||
e.preventDefault()
|
||||
if (e.originalEvent.deltaY==0) return
|
||||
var d = -e.originalEvent.deltaY/(10*Math.abs(e.originalEvent.deltaY))
|
||||
|
||||
PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
|
||||
document.documentElement.style.setProperty("--pixel-scale",'')
|
||||
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
|
||||
|
||||
}
|
||||
})
|
||||
$(document).on('keydown.resetzoom', function(e){
|
||||
if (e.keyCode==96||e.keyCode==48) {
|
||||
PXSCALE = INITIALZOOM
|
||||
document.documentElement.style.setProperty("--pixel-scale",'')
|
||||
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
init: function(){
|
||||
sidepanel()
|
||||
tabs()
|
||||
scrolls()
|
||||
},
|
||||
tabs:tabs,
|
||||
scrolls:scrolls
|
||||
}
|
||||
39
browser/js/app/utils.js
Normal file
39
browser/js/app/utils.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
module.exports = {
|
||||
|
||||
createPopup: function(title,content) {
|
||||
|
||||
var popup = $(`
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title">${title}<span class="closer">${module.exports.icon('remove')}</span></div>
|
||||
<div class="popup-content"></div>
|
||||
</div>
|
||||
</div>`),
|
||||
closer = popup.find('.popup-title .closer')
|
||||
|
||||
closer.click(function(){
|
||||
popup.close()
|
||||
})
|
||||
|
||||
|
||||
popup.close = function(){
|
||||
$(document).off('.popup')
|
||||
popup.remove()
|
||||
}
|
||||
|
||||
popup.find('.popup-content').append(content)
|
||||
$('body').append(popup)
|
||||
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==27) popup.close()
|
||||
})
|
||||
|
||||
|
||||
|
||||
return popup
|
||||
},
|
||||
icon: function(i) {
|
||||
return `<i class="fa fa-fw fa-${i}"></i>`
|
||||
}
|
||||
|
||||
}
|
||||
80
browser/js/app/widgets.js
Normal file
80
browser/js/app/widgets.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
var widgets = {
|
||||
// sliders
|
||||
fader: require('./widgets/fader'),
|
||||
knob: require('./widgets/knob'),
|
||||
|
||||
// buttons
|
||||
toggle: require('./widgets/toggle'),
|
||||
switch: require('./widgets/switch'),
|
||||
push: require('./widgets/push'),
|
||||
|
||||
// pads
|
||||
xy: require('./widgets/xy'),
|
||||
rgb: require('./widgets/rgb'),
|
||||
|
||||
// matrices
|
||||
multitoggle: require('./widgets/multitoggle'),
|
||||
multipush: require('./widgets/multipush'),
|
||||
multifader: require('./widgets/multifader'),
|
||||
|
||||
// plots
|
||||
led: require('./widgets/led'),
|
||||
plot: require('./widgets/plot'),
|
||||
visualizer: require('./widgets/visualizer'),
|
||||
meter: require('./widgets/meter'),
|
||||
text: require('./widgets/text'),
|
||||
|
||||
// containers
|
||||
strip: require('./widgets/strip'),
|
||||
panel: require('./widgets/panel'),
|
||||
}
|
||||
|
||||
module.exports.categories = {
|
||||
'Sliders':['fader','knob'],
|
||||
'Buttons':['toggle','push','switch'],
|
||||
'Pads':['xy','rgb'],
|
||||
'Matrices':['multifader','multitoggle','multipush'],
|
||||
'Plots':['plot','visualizer','led','meter','text'],
|
||||
'Containers':['panel','strip']
|
||||
}
|
||||
|
||||
module.exports.widgetOptions = function(){
|
||||
var r = {}
|
||||
for (i in widgets) {
|
||||
r[i] = widgets[i].options
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
||||
module.exports.createWidget = function(){
|
||||
var r = {}
|
||||
for (i in widgets) {
|
||||
r[i] = widgets[i].create
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
||||
module.exports.sync = function() {
|
||||
$('body').off('sync.global').on('sync.global',function(e,id,widget,linkId){
|
||||
// Widget that share the same id will update each other
|
||||
// without sending any extra osc message
|
||||
if (WIDGETS[id] && WIDGETS[id].length>1) {
|
||||
var v = widget.getValue()
|
||||
for (i in WIDGETS[id]) {
|
||||
if (!WIDGETS[id][i].is(widget) && WIDGETS[id][i].setValue) {
|
||||
WIDGETS[id][i].setValue(v,false,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
// widgets that share the same linkId will update each other.
|
||||
// Updated widgets will send osc messages normally
|
||||
if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
|
||||
var v = widget.getValue()
|
||||
for (i in WIDGETS_LINKED[linkId]) {
|
||||
if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
|
||||
WIDGETS_LINKED[linkId][i].setValue(v,true,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
299
browser/js/app/widgets/fader.js
Normal file
299
browser/js/app/widgets/fader.js
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'fader',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
alignRight:false,
|
||||
horizontal:false,
|
||||
noPip:false,
|
||||
compact:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
meter:false,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="fader-wrapper-outer">
|
||||
<div class="fader-wrapper">
|
||||
<div class="fader">
|
||||
<div class="gauge"></div>
|
||||
<div class="knob"></div>
|
||||
<div class="pips"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input"></div>
|
||||
</div>
|
||||
`),
|
||||
gauge = widget.find('.gauge'),
|
||||
knob = widget.find('.knob'),
|
||||
wrapper = widget.find('.fader-wrapper'),
|
||||
fader = widget.find('.fader'),
|
||||
pips = widget.find('.pips'),
|
||||
input = widget.find('.input').fakeInput({align:'center'}),
|
||||
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
|
||||
dimension = widgetData.horizontal?'width':'height',
|
||||
snap = widgetData.snap,
|
||||
logScale = widgetData.logScale,
|
||||
roundFactor = Math.pow(10,widgetData.precision)
|
||||
|
||||
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
if (widgetData.alignRight) container.addClass('align-right')
|
||||
}
|
||||
|
||||
if (widgetData.compact) container.addClass('compact')
|
||||
if (widgetData.noPip) wrapper.addClass('no-pip')
|
||||
|
||||
gauge.size = 0
|
||||
fader.size = 0
|
||||
wrapper.size = 0
|
||||
widget.value = undefined
|
||||
|
||||
if (widgetData.meter) {
|
||||
var parsewidgets = require('../parser').widgets
|
||||
var data = {
|
||||
type:'meter',
|
||||
id: widgetData.id + '/meter',
|
||||
label:false,
|
||||
horizontal:widgetData.horizontal,
|
||||
range:widgetData.range,
|
||||
logScale:widgetData.logScale,
|
||||
path:widgetData.path + '/meter',
|
||||
preArgs:widgetData.preArgs,
|
||||
color:widgetData.color
|
||||
}
|
||||
var element = parsewidgets([data],fader)
|
||||
element[0].classList.add('not-editable')
|
||||
widget[0].classList.add('has-meter')
|
||||
}
|
||||
|
||||
|
||||
var rangeKeys = [],
|
||||
rangeVals = [],
|
||||
rangeLabels = []
|
||||
|
||||
for (k in widgetData.range) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof widgetData.range[k] == 'object'?
|
||||
widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
|
||||
widgetData.range[k],
|
||||
label = typeof widgetData.range[k] == 'object'?
|
||||
Object.keys(widgetData.range[k])[0]:
|
||||
val
|
||||
|
||||
rangeKeys.push(key)
|
||||
rangeVals.push(val)
|
||||
rangeLabels.push(label)
|
||||
}
|
||||
|
||||
var rangeValsMax = Math.max.apply(Math, rangeVals),
|
||||
rangeValsMin = Math.min.apply(Math, rangeVals)
|
||||
|
||||
if (!widgetData.noPip&&!widgetData.compact) {
|
||||
var pipTexts = {}
|
||||
for (k in rangeKeys) {
|
||||
pipTexts[rangeKeys[k]]=rangeLabels[k]
|
||||
}
|
||||
|
||||
var pipsInner = ''
|
||||
for (var i=0;i<=100;i++) {
|
||||
if (pipTexts[i]==undefined) continue
|
||||
|
||||
var pos = dimension=='height'?'bottom':'left';
|
||||
|
||||
var piptext = `<span>${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]}</span>`
|
||||
|
||||
var add = `
|
||||
<div class="pip val" style="${pos}:${i}%">${piptext}</div>
|
||||
`
|
||||
pipsInner = pipsInner + add
|
||||
}
|
||||
pips[0].innerHTML = pipsInner
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fader.resize(function(){
|
||||
fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
|
||||
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
|
||||
widget.updateUi(gauge.size)
|
||||
})
|
||||
|
||||
wrapper.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
input.focus()
|
||||
}
|
||||
})
|
||||
|
||||
wrapper.on('mousewheel',function(e){
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var divider = e.ctrlKey?4:.25
|
||||
gauge.size = clip(gauge.size+e.originalEvent.wheelDelta/(fader.size*divider),[0,100])
|
||||
|
||||
widget.updateUi(gauge.size)
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
})
|
||||
|
||||
var off = 0
|
||||
wrapper.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var d = (dimension=='height')?
|
||||
((fader.size-data.offsetY+(wrapper.size-fader.size)/2) * 100 / fader.size):
|
||||
(data.offsetX - (wrapper.size-fader.size)/2) * 100 / fader.size
|
||||
d = clip(d,[0,100])
|
||||
|
||||
widget.updateUi(d)
|
||||
gauge.size = d
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
off = gauge.size
|
||||
|
||||
})
|
||||
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
|
||||
var d = (dimension=='height')?-data.deltaY:data.deltaX
|
||||
d = clip(d*100/fader.size+off,[0,100])
|
||||
|
||||
widget.updateUi(d)
|
||||
|
||||
gauge.size = d
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
widget.updateUi = function(v){
|
||||
var s = v/100,
|
||||
t = dimension=='height'?
|
||||
['1,'+s+',1','0,'+ Math.round(-s*fader.size) +'px,0']
|
||||
:[s+',1,1',Math.round(s*fader.size) +'px,0,0']
|
||||
gauge[0].setAttribute('style','transform:scale3d('+t[0]+')')
|
||||
knob[0].setAttribute('style','transform:translate3d('+t[1]+')')
|
||||
}
|
||||
|
||||
widget.getValue = function(){
|
||||
var h = clip(gauge.size,[0,100])
|
||||
for (var i=0;i<rangeKeys.length-1;i++) {
|
||||
if (h <= rangeKeys[i+1] && h >= rangeKeys[i]) {
|
||||
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (typeof v != 'number') return
|
||||
|
||||
var h,
|
||||
v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax])
|
||||
for (var i=0;i<rangeVals.length-1;i++) {
|
||||
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
|
||||
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],false,logScale,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
widget.updateUi(h)
|
||||
|
||||
gauge.size = h
|
||||
|
||||
widget.value = v
|
||||
widget.showValue(v)
|
||||
|
||||
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
|
||||
widget.showValue = function(v) {
|
||||
input.val(v+unit)
|
||||
}
|
||||
|
||||
input.change(function(){
|
||||
widget.setValue(parseFloat(input.val()),true,true)
|
||||
})
|
||||
|
||||
widget.setValue(rangeVals[0])
|
||||
|
||||
return widget
|
||||
}
|
||||
276
browser/js/app/widgets/knob.js
Normal file
276
browser/js/app/widgets/knob.js
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'knob',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
noPip:false,
|
||||
compact:false,
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="knob-wrapper-outer">
|
||||
<div class="knob-wrapper">
|
||||
<div class="knob-mask">
|
||||
<div class="knob"><span></span></div>
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="pips">
|
||||
<div class="pip min"></div>
|
||||
<div class="pip max"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input"></div>
|
||||
</div>
|
||||
`),
|
||||
wrapper = widget.find('.knob-wrapper'),
|
||||
mask = widget.find('.knob-mask'),
|
||||
knob = widget.find('.knob'),
|
||||
handle = widget.find('.handle'),
|
||||
input = widget.find('.input').fakeInput({align:'center'}),
|
||||
range = widgetData.range,
|
||||
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
|
||||
snap = widgetData.snap,
|
||||
logScale = widgetData.logScale,
|
||||
roundFactor = Math.pow(10,widgetData.precision)
|
||||
|
||||
if (widgetData.noPip) wrapper.addClass('no-pip')
|
||||
if (widgetData.compact) container.addClass('compact')
|
||||
|
||||
|
||||
var rangeKeys = [],
|
||||
rangeVals = [],
|
||||
rangeLabels = []
|
||||
|
||||
for (k in widgetData.range) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof widgetData.range[k] == 'object'?
|
||||
widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
|
||||
widgetData.range[k],
|
||||
label = typeof widgetData.range[k] == 'object'?
|
||||
Object.keys(widgetData.range[k])[0]:
|
||||
val
|
||||
|
||||
rangeKeys.push(key)
|
||||
rangeVals.push(val)
|
||||
rangeLabels.push(label)
|
||||
}
|
||||
|
||||
var rangeValsMax = Math.max.apply(Math, rangeVals),
|
||||
rangeValsMin = Math.min.apply(Math, rangeVals)
|
||||
|
||||
|
||||
var pipmin = Math.abs(rangeLabels[0])>=1000?rangeLabels[0]/1000+'k':rangeLabels[0],
|
||||
pipmax = Math.abs(rangeLabels[rangeLabels.length-1])>=1000?rangeLabels[rangeLabels.length-1]/1000+'k':rangeLabels[rangeLabels.length-1]
|
||||
|
||||
|
||||
|
||||
widget.find('.pip.min').text(pipmin)
|
||||
widget.find('.pip.max').text(pipmax)
|
||||
|
||||
mask.size = 0
|
||||
widget.value = undefined
|
||||
|
||||
wrapper.resize(function(e,width,height){
|
||||
|
||||
var w = Math.floor(Math.min(height,width)*.58)
|
||||
|
||||
if (!w || mask.size==w) return
|
||||
mask.size=w
|
||||
mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
|
||||
wrapper.size = {width:wrapper[0].clientWidth,height:wrapper[0].clientHeight}
|
||||
})
|
||||
|
||||
wrapper.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
input.focus()
|
||||
}
|
||||
})
|
||||
|
||||
wrapper.on('mousewheel',function(e){
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var divider = e.ctrlKey?48:8
|
||||
knob.rotation = clip(knob.rotation+e.originalEvent.wheelDeltaY/divider,[0,270])
|
||||
|
||||
widget.updateUi(knob.rotation)
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
knob.rotation = 0
|
||||
|
||||
var offR = 0,
|
||||
offX = 0,
|
||||
offY = 0
|
||||
wrapper.on('draginit',function(e,data,traversing){
|
||||
|
||||
if (snap || traversing) {
|
||||
|
||||
var w = wrapper.size.width,
|
||||
h = wrapper.size.height,
|
||||
x = data.offsetX-w/2,
|
||||
y = data.offsetY-h/2,
|
||||
angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
|
||||
r = angle<-90?angle+360:angle
|
||||
r = (angle>=-90 && angle<-45)?270:r
|
||||
r = clip(r,[0,270])
|
||||
|
||||
offX = x
|
||||
offY = y
|
||||
|
||||
widget.updateUi(r)
|
||||
|
||||
knob.rotation = r
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
offR = knob.rotation
|
||||
})
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
|
||||
var r = clip(-data.deltaY*2+offR,[0,270])
|
||||
|
||||
if (snap || data.ctrlKey || data.shiftKey) {
|
||||
var w = data.target.clientWidth,
|
||||
h = data.target.clientHeight,
|
||||
x = data.deltaX + offX,
|
||||
y = data.deltaY + offY,
|
||||
angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
|
||||
r = angle<-90?angle+360:angle
|
||||
r = (angle>=-90 && angle<-45)?270:r
|
||||
r = clip(r,[0,270])
|
||||
}
|
||||
|
||||
widget.updateUi(r)
|
||||
|
||||
knob.rotation = r
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v!=widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
})
|
||||
|
||||
widget.updateUi = function(r) {
|
||||
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
|
||||
handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
|
||||
|
||||
if (r>180) {knob.addClass('d3')}
|
||||
else if (r>90) {knob.removeClass('d3').addClass('d2')}
|
||||
else {knob.removeClass('d3 d2')}
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
var h = knob.rotation
|
||||
for (var i=0;i<rangeKeys.length-1;i++) {
|
||||
if (h <= rangeKeys[i+1]*2.7 && h >= rangeKeys[i]*2.7) {
|
||||
return mapToScale(h,[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
|
||||
}
|
||||
}
|
||||
}
|
||||
widget.showValue = function(v) {
|
||||
input.val(v+unit)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (typeof v != 'number') return
|
||||
|
||||
var v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax]),
|
||||
r
|
||||
|
||||
for (var i=0;i<rangeVals.length-1;i++) {
|
||||
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
|
||||
r = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],false,logScale,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
knob.rotation = r
|
||||
|
||||
widget.updateUi(r)
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.value = v
|
||||
|
||||
widget.showValue(v)
|
||||
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
input.change(function(){
|
||||
widget.setValue(parseFloat(input.val()),true,true)
|
||||
})
|
||||
|
||||
widget.setValue(rangeVals[0])
|
||||
return widget
|
||||
}
|
||||
42
browser/js/app/widgets/led.js
Normal file
42
browser/js/app/widgets/led.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
var utils = require('./utils'),
|
||||
mapToScale = utils.mapToScale
|
||||
|
||||
module.exports.options = {
|
||||
type:'led',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
preArgs:[],
|
||||
path:'auto'
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="led">
|
||||
<div><span></span></div>
|
||||
</div>
|
||||
`),
|
||||
led = widget.find('span'),
|
||||
range = widgetData.range
|
||||
|
||||
widget.setValue = function(v,send,sync){
|
||||
if (typeof v != 'number') return
|
||||
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale,true))
|
||||
}
|
||||
|
||||
widget.setValue(range.min)
|
||||
|
||||
return widget
|
||||
}
|
||||
87
browser/js/app/widgets/meter.js
Normal file
87
browser/js/app/widgets/meter.js
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale
|
||||
|
||||
module.exports.options = {
|
||||
type:'fader',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
path:'auto',
|
||||
preArgs:[]
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="meter">
|
||||
<div class="level"></div>
|
||||
</div>
|
||||
`),
|
||||
level = widget.find('.level'),
|
||||
logScale = widgetData.logScale,
|
||||
dimension = widgetData.horizontal?'width':'height',
|
||||
axe = dimension=='height'?'X':'Y'
|
||||
|
||||
|
||||
if (widgetData.horizontal) widget.addClass('horizontal')
|
||||
|
||||
|
||||
var rangeKeys = [],
|
||||
rangeVals = []
|
||||
|
||||
for (k in widgetData.range) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof widgetData.range[k] == 'object'?
|
||||
widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
|
||||
widgetData.range[k]
|
||||
|
||||
rangeKeys.push(key)
|
||||
rangeVals.push(val)
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.updateUi = function(v){
|
||||
var s = v/100,
|
||||
t = dimension=='height'?
|
||||
'1,'+s+',1'
|
||||
:s+',1,1'
|
||||
level[0].setAttribute('style','transform:scale3d('+t+')')
|
||||
}
|
||||
|
||||
|
||||
widget.setValue = function(v) {
|
||||
if (typeof v != 'number') return
|
||||
|
||||
var h,
|
||||
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
|
||||
for (var i=0;i<rangeVals.length-1;i++) {
|
||||
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
|
||||
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],2,logScale,true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
widget.updateUi(h)
|
||||
|
||||
}
|
||||
|
||||
widget.setValue(rangeVals[0])
|
||||
|
||||
return widget
|
||||
}
|
||||
85
browser/js/app/widgets/multifader.js
Normal file
85
browser/js/app/widgets/multifader.js
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
module.exports.options = {
|
||||
type:'multifader',
|
||||
id:'auto',
|
||||
|
||||
separator0:'Matrix',
|
||||
|
||||
strips:2,
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
unit:'',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
compact:false,
|
||||
css:'',
|
||||
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
logScale:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="matrix">
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = []
|
||||
|
||||
for (var i=0;i<widgetData.strips;i++) {
|
||||
var data = {
|
||||
type:'fader',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
horizontal:false,
|
||||
snap:true,
|
||||
range:widgetData.range,
|
||||
logScale:widgetData.logScale,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target,
|
||||
noPip:true,
|
||||
compact:widgetData.compact
|
||||
}
|
||||
var element = parsewidgets([data],widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.strips}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
element.find('.fader-wrapper').off('drag')
|
||||
|
||||
widget.value[i] = widgetData.range.min
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.on('sync',function(e,id,w){
|
||||
if (id==widgetData.id) return
|
||||
widget.value[w.parent().index()] = w.getValue()
|
||||
widget.trigger('sync',[widgetData.id,widget])
|
||||
})
|
||||
|
||||
|
||||
widget.getValue = function(){
|
||||
return widget.value
|
||||
}
|
||||
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
76
browser/js/app/widgets/multipush.js
Normal file
76
browser/js/app/widgets/multipush.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
module.exports.options = {
|
||||
type:'multipush',
|
||||
id:'auto',
|
||||
|
||||
separator0: 'Matrix',
|
||||
|
||||
matrix: [2,2],
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="matrix">
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = []
|
||||
|
||||
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
|
||||
var data = {
|
||||
type:'push',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
on:widgetData.on,
|
||||
off:widgetData.off,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target
|
||||
}
|
||||
var element = parsewidgets([data],widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
widget.value[i] = widgetData.off
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.on('sync',function(e,id,w){
|
||||
if (id==widgetData.id) return
|
||||
widget.value[w.parent().index()] = w.getValue()
|
||||
widget.trigger('sync',[widgetData.id,widget])
|
||||
})
|
||||
|
||||
|
||||
widget.getValue = function(){
|
||||
return widget.value
|
||||
}
|
||||
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
76
browser/js/app/widgets/multitoggle.js
Normal file
76
browser/js/app/widgets/multitoggle.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
module.exports.options = {
|
||||
type:'multitoggle',
|
||||
id:'auto',
|
||||
|
||||
separator0: 'Matrix',
|
||||
|
||||
matrix: [2,2],
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="matrix">
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = []
|
||||
|
||||
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
|
||||
var data = {
|
||||
type:'toggle',
|
||||
id: widgetData.id + '/' + i,
|
||||
label:i,
|
||||
on:widgetData.on,
|
||||
off:widgetData.off,
|
||||
precision:widgetData.precision,
|
||||
path:widgetData.path + '/' + i,
|
||||
preArgs:widgetData.preArgs,
|
||||
target:widgetData.target
|
||||
}
|
||||
var element = parsewidgets([data],widget)
|
||||
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
widget.value[i] = widgetData.off
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.on('sync',function(e,id,w){
|
||||
if (id==widgetData.id) return
|
||||
widget.value[w.parent().index()] = w.getValue()
|
||||
widget.trigger('sync',[widgetData.id,widget])
|
||||
})
|
||||
|
||||
|
||||
widget.getValue = function(){
|
||||
return widget.value
|
||||
}
|
||||
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
41
browser/js/app/widgets/panel.js
Normal file
41
browser/js/app/widgets/panel.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
module.exports.options = {
|
||||
type:'panel',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
scroll:true,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'chilren',
|
||||
|
||||
widgets:[],
|
||||
tabs:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parser = require('../parser'),
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs
|
||||
|
||||
var widget = $(`
|
||||
<div class="panel">
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (!widgetData.scroll) widget.addClass('noscroll')
|
||||
|
||||
if (widgetData.tabs.length) {
|
||||
parsetabs(widgetData.tabs,widget)
|
||||
widget.addClass('has-tabs')
|
||||
} else {
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
}
|
||||
return widget
|
||||
}
|
||||
214
browser/js/app/widgets/plot.js
Normal file
214
browser/js/app/widgets/plot.js
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
var utils = require('./utils'),
|
||||
mapToScale = utils.mapToScale
|
||||
|
||||
module.exports.options = {
|
||||
type:'plot',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'plot',
|
||||
|
||||
points:[],
|
||||
rangeX: {min:0,max:1},
|
||||
rangeY: {min:0,max:1},
|
||||
logScaleX: false,
|
||||
logScaleY: false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="plot">
|
||||
<canvas></canvas>
|
||||
</div>
|
||||
`),
|
||||
canvas = widget.find('canvas'),
|
||||
ctx = canvas[0].getContext('2d')
|
||||
|
||||
widget.data = []
|
||||
widget.height = undefined
|
||||
widget.width = undefined
|
||||
widget.linkedWidgets = []
|
||||
widget.visible = false
|
||||
widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
|
||||
widget.pips = {
|
||||
x : {
|
||||
min: Math.abs(widgetData.rangeX.min)>=1000?widgetData.rangeX.min/1000+'k':widgetData.rangeX.min,
|
||||
max: Math.abs(widgetData.rangeX.max)>=1000?widgetData.rangeX.max/1000+'k':widgetData.rangeX.max
|
||||
},
|
||||
y : {
|
||||
min: Math.abs(widgetData.rangeY.min)>=1000?widgetData.rangeY.min/1000+'k':widgetData.rangeY.min,
|
||||
max: Math.abs(widgetData.rangeY.max)>=1000?widgetData.rangeY.max/1000+'k':widgetData.rangeY.max
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (typeof widgetData.points=='string') {
|
||||
|
||||
widget.linkedWidgets.push(widgetData.points)
|
||||
|
||||
} else if (typeof widgetData.points=='object') {
|
||||
|
||||
for (i in widgetData.points) {
|
||||
for (j in widgetData.points[i]) {
|
||||
if (typeof widgetData.points[i][j] == 'string') {
|
||||
widget.linkedWidgets.push(widgetData.points[i][j])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
canvas.resize(function(){
|
||||
var width = canvas.width(),
|
||||
height = canvas.height()
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
if (!self.visible) {
|
||||
widget.visible = true
|
||||
widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
|
||||
}
|
||||
|
||||
|
||||
widget.height=height
|
||||
widget.width=width
|
||||
|
||||
canvas[0].setAttribute('width',width)
|
||||
canvas[0].setAttribute('height',height)
|
||||
|
||||
widget.fetchValues()
|
||||
requestAnimationFrame(widget.draw)
|
||||
|
||||
})
|
||||
|
||||
|
||||
widget.handleSync = function(e,id,w) {
|
||||
if (widget.linkedWidgets.indexOf(id)==-1 || !WIDGETS[id]) return
|
||||
widget.fetchValues()
|
||||
requestAnimationFrame(widget.draw)
|
||||
}
|
||||
|
||||
$('body').on('sync',widget.handleSync)
|
||||
|
||||
widget.draw = function(){
|
||||
|
||||
|
||||
ctx.clearRect(0,0,widget.width,widget.height)
|
||||
ctx.beginPath()
|
||||
|
||||
var first = true
|
||||
var point = []
|
||||
|
||||
for (i in widget.data) {
|
||||
var newpoint = widget.data[i].length?
|
||||
[
|
||||
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
|
||||
]
|
||||
:
|
||||
[
|
||||
mapToScale(i,[0,widget.data.length-1],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
|
||||
mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
|
||||
]
|
||||
|
||||
|
||||
|
||||
if (first) {
|
||||
ctx.moveTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
} else {
|
||||
ctx.moveTo(point[0],point[1])
|
||||
if (widgetData.logScaleX&&!widgetData.logScaleY) {
|
||||
ctx.quadraticCurveTo(point[0], newpoint[1], newpoint[0], newpoint[1])
|
||||
} else if (widgetData.logScaleY&&!widgetData.logScaleX) {
|
||||
ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
|
||||
} else {
|
||||
ctx.lineTo(newpoint[0],newpoint[1])
|
||||
}
|
||||
|
||||
}
|
||||
ctx.arc(newpoint[0],newpoint[1],1,0,2*Math.PI)
|
||||
point = newpoint
|
||||
}
|
||||
|
||||
ctx.lineWidth = 1.5*PXSCALE
|
||||
ctx.strokeStyle= widget.lineColor
|
||||
ctx.stroke()
|
||||
|
||||
ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
ctx.fillStyle = widget.textColor
|
||||
|
||||
|
||||
ctx.textBaseline = "bottom"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.x.min,12*PXSCALE,widget.height)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.x.max,widget.width-10,widget.height)
|
||||
|
||||
ctx.save()
|
||||
ctx.translate(0, widget.height)
|
||||
ctx.rotate(-Math.PI/2)
|
||||
|
||||
ctx.textBaseline = "top"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.y.min,12*PXSCALE,2*PXSCALE)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.y.max,widget.height-10*PXSCALE,2*PXSCALE)
|
||||
ctx.rotate(Math.PI/2)
|
||||
ctx.restore()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.fetchValues = function(){
|
||||
var data = [],
|
||||
points = widgetData.points
|
||||
|
||||
if (typeof points=='string' && WIDGETS[points]) {
|
||||
|
||||
data = WIDGETS[points][WIDGETS[points].length-1].getValue()
|
||||
|
||||
} else if (typeof points=='object') {
|
||||
|
||||
for (i in points) {
|
||||
|
||||
data[i] = []
|
||||
for (k in [0,1]) {
|
||||
if (typeof points[i][k] == 'string' && WIDGETS[points[i][k]]) {
|
||||
data[i][k] = WIDGETS[points[i][k]][WIDGETS[points[i][k]].length-1].getValue()
|
||||
} else {
|
||||
data[i][k] = points[i][k]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data.length) widget.data = data
|
||||
}
|
||||
|
||||
widget.setValue = function(v) {
|
||||
widget.data = v
|
||||
requestAnimationFrame(widget.draw)
|
||||
}
|
||||
|
||||
return widget
|
||||
}
|
||||
109
browser/js/app/widgets/push.js
Normal file
109
browser/js/app/widgets/push.js
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'push',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
|
||||
var widget = $(`
|
||||
<div class="push toggle">
|
||||
<div class="light"</div>
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document),
|
||||
light = widget.find('.light')[0]
|
||||
|
||||
widget.value = widget.find('span')
|
||||
widget.state = 0
|
||||
widget.active = 0
|
||||
widget.lastChanged = 'state'
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
if (!widget.active) widget.setValuePrivate(widgetData.on,true,true)
|
||||
$document.on('dragend.push',function(){
|
||||
widget.setValuePrivate(widgetData.off,true,true)
|
||||
$document.off('dragend.push')
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget[widget.lastChanged]?widgetData.on:widgetData.off
|
||||
}
|
||||
|
||||
widget.setValuePrivate = function(v,send,sync) {
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
widget.addClass('active')
|
||||
widget.active = 1
|
||||
if (send) widget.sendValue(v)
|
||||
widget.lastChanged = 'active'
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
widget.removeClass('active')
|
||||
widget.active = 0
|
||||
if (send) widget.sendValue(v)
|
||||
widget.lastChanged = 'active'
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
}
|
||||
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (send) widget.sendValue(v)
|
||||
widget.lastChanged = 'state'
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (send) widget.sendValue(v)
|
||||
widget.lastChanged = 'state'
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
}
|
||||
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
292
browser/js/app/widgets/rgb.js
Normal file
292
browser/js/app/widgets/rgb.js
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
hsbToRgb = utils.hsbToRgb,
|
||||
rgbToHsb = utils.rgbToHsb,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'rgb',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
precision:0,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
split:false,
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="xy-wrapper rgb-wrapper">
|
||||
<div class="xy rgb">
|
||||
<div class="bg"></div>
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="hue">
|
||||
<div class="bg"></div>
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="value">
|
||||
<div class="input disabled">R</div><div class="input disabled">G</div><div class="input disabled">B</div>
|
||||
<div class="input r"></div><div class="input g"></div><div class="input b"></div>
|
||||
</div>
|
||||
</div>`),
|
||||
rgbHandle = widget.find('.rgb .handle'),
|
||||
hueHandle = widget.find('.hue .handle'),
|
||||
pad = widget.find('.xy'),
|
||||
huePad = widget.find('.hue'),
|
||||
rgbBg = pad.find('.bg')[0],
|
||||
value = {r:widget.find('.r').fakeInput({align:'center'}),g:widget.find('.g').fakeInput({align:'center'}),b:widget.find('.b').fakeInput({align:'center'})},
|
||||
snap = widgetData.snap,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
|
||||
:false
|
||||
|
||||
|
||||
pad.width = 0
|
||||
pad.height = 0
|
||||
rgbHandle.height = 0
|
||||
rgbHandle.width = 0
|
||||
hueHandle.width = 0
|
||||
widget.value = undefined
|
||||
|
||||
pad.resize(function(){
|
||||
var width = pad.innerWidth(),
|
||||
height = pad.innerHeight()
|
||||
if (!width || (pad.height==height && pad.width==width)) return
|
||||
pad.width = width
|
||||
pad.height = height
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*rgbHandle.width/100}px, -${pad.height*rgbHandle.height/100}px,0)`)
|
||||
|
||||
})
|
||||
|
||||
|
||||
var rgbOff = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
|
||||
w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
var hueOff = 0
|
||||
huePad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var d = (data.offsetX * 100 / pad.width)
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
|
||||
hueHandle.width = d
|
||||
|
||||
|
||||
var h = clip(hueHandle.width*3.6,[0,360]),
|
||||
rgb = hsbToRgb({h:h,s:100,b:100})
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hueOff = hueHandle.width
|
||||
|
||||
})
|
||||
|
||||
|
||||
huePad.on('drag',function(e,data){
|
||||
|
||||
var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
|
||||
hueHandle.width = w
|
||||
|
||||
var h = clip(hueHandle.width*3.6,[0,360]),
|
||||
rgb = hsbToRgb({h:h,s:100,b:100})
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
var s = clip(rgbHandle.width,[0,100]),
|
||||
l = clip(rgbHandle.height,[0,100]),
|
||||
h = mapToScale(hueHandle.width,[0,100],[0,360],widgetData.precision),
|
||||
rgb = hsbToRgb({h:h,s:s,b:l})
|
||||
return [rgb.r,rgb.g,rgb.b]
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (!v || v.length!=3) return
|
||||
|
||||
for (i in [0,1,2]) {
|
||||
v[i] = clip(v[i],[0,255])
|
||||
}
|
||||
|
||||
|
||||
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
|
||||
|
||||
var w = mapToScale(hsb.s,[0,100],[0,100],false),
|
||||
h = mapToScale(hsb.b,[0,100],[0,100],false),
|
||||
hueW = mapToScale(hsb.h,[0,360],[0,100],false)
|
||||
|
||||
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*hueW/100}px,0,0)`)
|
||||
|
||||
rgbHandle.height = h
|
||||
rgbHandle.width = w
|
||||
hueHandle.width = hueW
|
||||
widget.value = v
|
||||
|
||||
|
||||
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
widget.showValue(v)
|
||||
|
||||
|
||||
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:args,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.r,
|
||||
args:widgetData.preArgs.concat(v[0]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.g,
|
||||
args:widgetData.preArgs.concat(v[1]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.b,
|
||||
args:widgetData.preArgs.concat(v[2]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.showValue = function(v) {
|
||||
value.r.val(v[0])
|
||||
value.g.val(v[1])
|
||||
value.b.val(v[2])
|
||||
}
|
||||
value.r.change(function(){
|
||||
var r = clip(value.r.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([r,v[1],v[2]],true,true)
|
||||
})
|
||||
value.g.change(function(){
|
||||
var g = clip(value.g.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([v[0],g,v[2]],true,true)
|
||||
})
|
||||
value.b.change(function(){
|
||||
var b = clip(value.b.val(),[0,255])
|
||||
var v = widget.getValue()
|
||||
widget.setValue([v[0],v[1],b],true,true)
|
||||
})
|
||||
|
||||
widget.setValue([0,0,0])
|
||||
|
||||
return widget
|
||||
}
|
||||
38
browser/js/app/widgets/strip.js
Normal file
38
browser/js/app/widgets/strip.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
module.exports.options = {
|
||||
type:'strip',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'children',
|
||||
|
||||
widgets:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var parsewidgets = require('../parser').widgets
|
||||
|
||||
var widget = $(`
|
||||
<div class="strip">
|
||||
</div>
|
||||
`)
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
|
||||
return widget
|
||||
}
|
||||
83
browser/js/app/widgets/switch.js
Normal file
83
browser/js/app/widgets/switch.js
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'switch',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="switch">
|
||||
</div>
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
if (widgetData.horizontal) {
|
||||
widget.addClass('horizontal')
|
||||
}
|
||||
|
||||
widget.values = []
|
||||
|
||||
for (k in widgetData.values) {
|
||||
widget.values.push(widgetData.values[k])
|
||||
$('<div class="value">'+k+'</div>').data({value:widgetData.values[k]}).appendTo(widget)
|
||||
}
|
||||
|
||||
widget.value = undefined
|
||||
|
||||
widget.find('.value').on('draginit',function(e,dd){
|
||||
var data = $(this).data()
|
||||
if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
|
||||
})
|
||||
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.value
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
var i = widget.values.indexOf(v)
|
||||
if (i!=-1) {
|
||||
widget.value = widget.values[i]
|
||||
widget.find('.on').removeClass('on')
|
||||
widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
|
||||
$(this).removeClass('ripple')
|
||||
next()
|
||||
})
|
||||
if (send) widget.sendValue(widget.value)
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
return widget
|
||||
}
|
||||
54
browser/js/app/widgets/text.js
Normal file
54
browser/js/app/widgets/text.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
var utils = require('./utils'),
|
||||
mapToScale = utils.mapToScale
|
||||
|
||||
module.exports.options = {
|
||||
type:'text',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
vertical:false,
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
preArgs:[],
|
||||
path:'auto',
|
||||
defaultText:''
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="text">
|
||||
</div>
|
||||
`),
|
||||
label = widgetData.defaultText!==''?
|
||||
widgetData.defaultText:
|
||||
widgetData.label===false?
|
||||
widgetData.id:
|
||||
widgetData.label=='auto'?
|
||||
widgetData.id:
|
||||
widgetData.label,
|
||||
text = label
|
||||
|
||||
|
||||
if (widgetData.vertical) widget.addClass('vertical')
|
||||
|
||||
widget.setValue = function(v,send,sync){
|
||||
text = typeof v=='object' && !v.length?label:v
|
||||
widget.text(text)
|
||||
}
|
||||
|
||||
widget.getValue = function(){
|
||||
return text
|
||||
}
|
||||
|
||||
widget.setValue(label)
|
||||
|
||||
return widget
|
||||
}
|
||||
89
browser/js/app/widgets/toggle.js
Normal file
89
browser/js/app/widgets/toggle.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
var sendOsc = require('./utils').sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'toggle',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="toggle">
|
||||
<div class="light"></div>
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document),
|
||||
light = widget.find('.light')[0]
|
||||
|
||||
widget.value = widget.find('span')
|
||||
widget.state = 0
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.toggle',function(){
|
||||
widget.off('draginit.toggle')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
var newVal = widget.state?widgetData.off:widgetData.on
|
||||
widget.setValue(newVal,true,true)
|
||||
$document.on('dragend.toggle',function(){
|
||||
$document.off('dragend.toggle')
|
||||
widget.on('draginit.toggle',function(){
|
||||
widget.off('draginit.toggle')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.state?widgetData.on:widgetData.off
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
|
||||
widget.addClass('on')
|
||||
widget.state = 1
|
||||
if (send) widget.sendValue(widgetData.on)
|
||||
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
|
||||
widget.removeClass('on')
|
||||
widget.state = 0
|
||||
if (send) widget.sendValue(widgetData.off)
|
||||
}
|
||||
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:args
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
78
browser/js/app/widgets/utils.js
Normal file
78
browser/js/app/widgets/utils.js
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
module.exports = {
|
||||
|
||||
sendOsc: function(data){
|
||||
IPC.send('sendOsc', data)
|
||||
},
|
||||
|
||||
clip: function(value,range) {
|
||||
var value = parseFloat(value)
|
||||
|
||||
if (isNaN(value)) value = range[0]
|
||||
return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
|
||||
|
||||
},
|
||||
|
||||
// map a value from a scale to another input and output must be range arrays
|
||||
mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
|
||||
|
||||
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
|
||||
roundFactor = precision!=undefined?Math.pow(10,precision):100,
|
||||
|
||||
|
||||
value = log?
|
||||
revertlog?
|
||||
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
|
||||
|
||||
value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
|
||||
|
||||
if (precision!==false) value = Math.round(value*roundFactor)/roundFactor
|
||||
|
||||
|
||||
return value
|
||||
|
||||
},
|
||||
|
||||
hsbToRgb: function (hsb) {
|
||||
var rgb = {}
|
||||
var h = hsb.h
|
||||
var s = hsb.s*255/100
|
||||
var v = hsb.b*255/100
|
||||
if(s == 0) {
|
||||
rgb.r = rgb.g = rgb.b = v
|
||||
} else {
|
||||
var t1 = v
|
||||
var t2 = (255-s)*v/255
|
||||
var t3 = (t1-t2)*(h%60)/60
|
||||
if(h==360) h = 0
|
||||
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
||||
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
||||
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
||||
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
||||
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
||||
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
||||
}
|
||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}
|
||||
},
|
||||
|
||||
rgbToHsb: function (rgb) {
|
||||
var hsb = {h: 0, s: 0, b: 0}
|
||||
var min = Math.min(rgb.r, rgb.g, rgb.b)
|
||||
var max = Math.max(rgb.r, rgb.g, rgb.b)
|
||||
var delta = max - min
|
||||
hsb.b = max
|
||||
hsb.s = max != 0 ? 255 * delta / max : 0
|
||||
if (hsb.s != 0) {
|
||||
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
|
||||
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
|
||||
else hsb.h = 4 + (rgb.r - rgb.g) / delta
|
||||
} else hsb.h = 0
|
||||
hsb.h *= 60
|
||||
if (hsb.h < 0) hsb.h += 360
|
||||
hsb.s *= 100/255
|
||||
hsb.b *= 100/255
|
||||
return hsb
|
||||
}
|
||||
}
|
||||
176
browser/js/app/widgets/visualizer.js
Normal file
176
browser/js/app/widgets/visualizer.js
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
var utils = require('./utils'),
|
||||
mapToScale = utils.mapToScale,
|
||||
clip = utils.clip
|
||||
|
||||
module.exports.options = {
|
||||
type:'visualizer',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'plot',
|
||||
|
||||
widgetId:'',
|
||||
duration:1,
|
||||
range: {min:0,max:1},
|
||||
logScale: false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="plot">
|
||||
<canvas></canvas>
|
||||
</div>
|
||||
`),
|
||||
canvas = widget.find('canvas'),
|
||||
ctx = canvas[0].getContext('2d')
|
||||
|
||||
widget.height = 0
|
||||
widget.width = 0
|
||||
widget.visible = false
|
||||
widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
|
||||
widget.pips = {
|
||||
min: Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min,
|
||||
max: Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
|
||||
}
|
||||
widget.length = Math.round(clip(60*widgetData.duration,[8,4096]))
|
||||
widget.data = new Array(widget.length)
|
||||
widget.value = widgetData.range.min
|
||||
|
||||
canvas.resize(function(){
|
||||
var width = canvas.width(),
|
||||
height = canvas.height()
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
if (!self.visible) {
|
||||
widget.visible = true
|
||||
widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
|
||||
}
|
||||
|
||||
widget.height=height
|
||||
widget.width=width
|
||||
|
||||
canvas[0].setAttribute('width',width)
|
||||
canvas[0].setAttribute('height',height)
|
||||
|
||||
requestAnimationFrame(widget.draw)
|
||||
|
||||
})
|
||||
|
||||
|
||||
widget.handleSync = function(e,id,w) {
|
||||
if (widgetData.widgetId!=id || !WIDGETS[id]) return
|
||||
widget.startLoop()
|
||||
}
|
||||
|
||||
$('body').on('sync',widget.handleSync)
|
||||
|
||||
|
||||
widget.cancel = false
|
||||
widget.loop = false
|
||||
|
||||
widget.startLoop = function(){
|
||||
|
||||
if (widget.cancel) clearTimeout(widget.cancel)
|
||||
|
||||
widget.cancel = setTimeout(function(){
|
||||
clearInterval(widget.loop)
|
||||
widget.loop = false
|
||||
widget.cancel = false
|
||||
},1000*widgetData.duration)
|
||||
|
||||
if (widget.loop) return
|
||||
|
||||
widget.loop = setInterval(function(){
|
||||
widget.fetchValue()
|
||||
widget.draw()
|
||||
},1000*widgetData.duration/widget.length)
|
||||
}
|
||||
|
||||
|
||||
widget.draw = function(){
|
||||
ctx.clearRect(0,0,widget.width,widget.height)
|
||||
ctx.beginPath()
|
||||
|
||||
var first = true
|
||||
var point = []
|
||||
|
||||
for (var i=widget.length-1;i>=0;i=i-1) {
|
||||
var newpoint = [
|
||||
mapToScale(i,[0,widget.length-1],[15*PXSCALE,widget.width-15*PXSCALE],1),
|
||||
mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15*PXSCALE,15*PXSCALE],1,widgetData.logScale,true),
|
||||
]
|
||||
if (first) {
|
||||
ctx.moveTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
} else {
|
||||
if (widgetData.logScale) {
|
||||
ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
|
||||
} else {
|
||||
ctx.lineTo(newpoint[0],newpoint[1])
|
||||
}
|
||||
|
||||
}
|
||||
point = newpoint
|
||||
}
|
||||
|
||||
ctx.lineWidth = 1.5*PXSCALE
|
||||
ctx.strokeStyle= widget.lineColor
|
||||
ctx.stroke()
|
||||
|
||||
ctx.font = PXSCALE * 10 + 'px sans-serif'
|
||||
ctx.fillStyle = widget.textColor
|
||||
|
||||
|
||||
ctx.save()
|
||||
ctx.translate(0, widget.height)
|
||||
ctx.rotate(-Math.PI/2)
|
||||
|
||||
ctx.textBaseline = "top"
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(widget.pips.min,12*PXSCALE,2*PXSCALE)
|
||||
ctx.textAlign = 'right'
|
||||
ctx.fillText(widget.pips.max,widget.height-10*PXSCALE,2*PXSCALE)
|
||||
ctx.rotate(Math.PI/2)
|
||||
ctx.restore()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
widget.fetchValue = function(){
|
||||
var id = widgetData.widgetId
|
||||
|
||||
if (typeof id == 'string' && WIDGETS[id]) {
|
||||
var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
|
||||
widget.data.push(v)
|
||||
widget.value = v
|
||||
} else {
|
||||
widget.data.push(widget.value)
|
||||
}
|
||||
|
||||
widget.data.splice(0,1)
|
||||
|
||||
}
|
||||
|
||||
widget.setValue = function(v) {
|
||||
widget.value = v
|
||||
widget.startLoop()
|
||||
}
|
||||
|
||||
return widget
|
||||
}
|
||||
209
browser/js/app/widgets/xy.js
Normal file
209
browser/js/app/widgets/xy.js
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
var utils = require('./utils'),
|
||||
clip = utils.clip,
|
||||
mapToScale = utils.mapToScale,
|
||||
sendOsc = utils.sendOsc
|
||||
|
||||
module.exports.options = {
|
||||
type:'xy',
|
||||
id:'auto',
|
||||
linkId:'',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
color:'auto',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
snap:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
rangeX:{min:0,max:1},
|
||||
rangeY:{min:0,max:1},
|
||||
logScaleX:false,
|
||||
logScaleY:false,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
preArgs:[],
|
||||
split:false,
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="xy-wrapper">
|
||||
<div class="xy">
|
||||
<div class="handle"></div>
|
||||
</div>
|
||||
<div class="value">
|
||||
<div class="input disabled">X</div><div class="input disabled">Y</div>
|
||||
<div class="input x"></div><div class="input y"></div>
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
handle = widget.find('.handle'),
|
||||
pad = widget.find('.xy'),
|
||||
value = {x:widget.find('.x').fakeInput({align:'center'}),y:widget.find('.y').fakeInput({align:'center'})},
|
||||
range = {x:widgetData.rangeX,y:widgetData.rangeY},
|
||||
snap = widgetData.snap,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
|
||||
:false;
|
||||
logScaleX = widgetData.logScaleX,
|
||||
logScaleY = widgetData.logScaleY,
|
||||
roundFactor = Math.pow(10,widgetData.precision)
|
||||
|
||||
|
||||
if (widgetData.height!='auto') widget.addClass('manual-height')
|
||||
|
||||
pad.width = 0
|
||||
pad.height = 0
|
||||
handle.height = 0
|
||||
handle.width = 0
|
||||
widget.value = undefined
|
||||
|
||||
pad.resize(function(){
|
||||
var width = pad.innerWidth(),
|
||||
height = pad.innerHeight()
|
||||
if (!width || (pad.height==height && pad.width==width)) return
|
||||
pad.width = width
|
||||
pad.height = height
|
||||
|
||||
widget.updateUi(handle.width,handle.height)
|
||||
})
|
||||
|
||||
var off = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
|
||||
if (snap || traversing) {
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
off = {x:handle.width,y:handle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
|
||||
w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
|
||||
if (v<widget.value||v>widget.value) {
|
||||
widget.value = v
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
widget.updateUi = function(w,h) {
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,logScaleX),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,logScaleY)
|
||||
|
||||
return [x,y]
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (!v || v.length!=2) return
|
||||
|
||||
for (i in [0,1]) {
|
||||
v[i] = clip(Math.round(v[i]*roundFactor)/roundFactor,[range[['x','y'][i]].min,range[['x','y'][i]].max])
|
||||
}
|
||||
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],false,logScaleX,true)
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],false,logScaleY,true),
|
||||
|
||||
|
||||
widget.updateUi(w,h)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
widget.value = v
|
||||
|
||||
widget.showValue(v)
|
||||
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
var args = widgetData.preArgs.concat(v)
|
||||
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:args,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.x,
|
||||
args:widgetData.preArgs.concat(v[0]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.y,
|
||||
args:widgetData.preArgs.concat(v[1]),
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
widget.showValue = function(v) {
|
||||
value.x.val(v[0])
|
||||
value.y.val(v[1])
|
||||
}
|
||||
|
||||
value.x.change(function(){
|
||||
var v = widget.getValue()
|
||||
v[0] = clip(value.x.val(),[range.x.min,range.x.max])
|
||||
widget.setValue(v,true,true)
|
||||
})
|
||||
value.y.change(function(){
|
||||
var v = widget.getValue()
|
||||
v[1] = clip(value.y.val(),[range.y.min,range.y.max])
|
||||
widget.setValue(v,true,true)
|
||||
})
|
||||
|
||||
widget.setValue([range.x.min,range.y.min])
|
||||
return widget
|
||||
}
|
||||
11861
browser/js/browser-headless.bundle.js
Normal file
11861
browser/js/browser-headless.bundle.js
Normal file
File diff suppressed because one or more lines are too long
11
browser/js/browser-headless.js
Normal file
11
browser/js/browser-headless.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
WEBFRAME = false
|
||||
|
||||
// mainProcess & renderProcess communication engine
|
||||
// electron's ipc module is not available here, we use socket.io as a replacement
|
||||
var socket = require('socket.io-client')
|
||||
|
||||
IPC = socket.connect()
|
||||
IPC.send = IPC.emit
|
||||
|
||||
|
||||
require('./app')
|
||||
7
browser/js/browser.js
Normal file
7
browser/js/browser.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var electron = require('electron')
|
||||
WEBFRAME = electron.webFrame
|
||||
|
||||
// mainProcess & renderProcess communication engine
|
||||
IPC = electron.ipcRenderer
|
||||
|
||||
require('./app')
|
||||
337
browser/js/jquery/jquery.drag.js
Normal file
337
browser/js/jquery/jquery.drag.js
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
// jQuery drag event handler
|
||||
// note: triggerHandler() is used instead of trigger() when event bubblig is not
|
||||
// necessary, this increases performances a lot.
|
||||
;(function($){
|
||||
var events = {
|
||||
touch:{start:'touchstart',stop:'touchend touchcancel',move:'touchmove',touch:true},
|
||||
mouse:{start:'mousedown',stop:'mouseup',move:'mousemove',out:'mouseout',touch:false}
|
||||
},
|
||||
|
||||
|
||||
$document = $(document),
|
||||
getOffset = function(obj) {
|
||||
var offsetLeft = 0
|
||||
var offsetTop = 0
|
||||
if (obj) {
|
||||
do {
|
||||
if (!isNaN(obj.offsetLeft)) {
|
||||
offsetLeft += obj.offsetLeft - obj.scrollLeft
|
||||
}
|
||||
if (!isNaN(obj.offsetTop)) {
|
||||
offsetTop += obj.offsetTop - obj.scrollTop
|
||||
}
|
||||
} while(obj = obj.offsetParent )
|
||||
}
|
||||
|
||||
return {left: offsetLeft, top: offsetTop}
|
||||
}
|
||||
|
||||
|
||||
$.event.special.draginit = $.event.special.drag = {
|
||||
setup:function(){
|
||||
|
||||
var $this = $(this)
|
||||
|
||||
if ($this.data('dragSetup')) return
|
||||
$this.data('dragSetup','true')
|
||||
|
||||
|
||||
// mouse single touch handler
|
||||
var previousEvent = null,
|
||||
target = null,
|
||||
traversing = false,
|
||||
mouseStartHandler = function(e){
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
isPointerDown = true
|
||||
target = $this
|
||||
previousEvent = e
|
||||
|
||||
e.speedX = 0
|
||||
e.speedY = 0
|
||||
e.deltaX = 0
|
||||
e.deltaY = 0
|
||||
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
|
||||
$document.on(events.mouse.move,mouseMoveHandler)
|
||||
$document.on(events.mouse.stop,mouseStopHandler)
|
||||
$document.on(events.mouse.out,mouseOutHandler)
|
||||
|
||||
},
|
||||
mouseMoveHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.speedX + previousEvent.deltaX
|
||||
e.deltaY = e.speedY + previousEvent.deltaY
|
||||
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
target = $(e.target)
|
||||
e.preventDefault()
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
} else {
|
||||
target.triggerHandler('drag',[e,e.originalEvent.traversing])
|
||||
}
|
||||
|
||||
previousEvent = e
|
||||
},
|
||||
mouseStopHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
isPointerDown = false
|
||||
$document.off(events.mouse.move,mouseMoveHandler)
|
||||
$document.off(events.mouse.stop,mouseStopHandler)
|
||||
$document.off(events.mouse.out,mouseOutHandler)
|
||||
},
|
||||
mouseOutHandler = function(e){
|
||||
if (e.originalEvent.traversing) {
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
|
||||
previousEvent = e
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this.on(events.mouse.start,mouseStartHandler)
|
||||
|
||||
|
||||
// multi touch hanlder
|
||||
window.targets = window.targets || {}
|
||||
window.previousTouches = window.previousTouches || {}
|
||||
window.touchActive = window.touchActive || false
|
||||
|
||||
var self = this,
|
||||
touchStartHandler = function(e){
|
||||
e.preventDefault()
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
targets[id] = $(touch.target)
|
||||
previousTouches[id] = touch
|
||||
|
||||
touch.speedX = 0
|
||||
touch.speedY = 0
|
||||
|
||||
touch.deltaX = 0
|
||||
touch.deltaY = 0
|
||||
|
||||
var off = getOffset(touch.target)
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
|
||||
targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
if (!touchActive) {
|
||||
$document.on(events.touch.move,touchMoveHandler)
|
||||
$document.on(events.touch.stop,touchStopHandler)
|
||||
touchActive = true
|
||||
}
|
||||
|
||||
},
|
||||
touchMoveHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY))
|
||||
}
|
||||
|
||||
// touched[targets[id]] = touched[targets[id]]?touched[targets[id]]+1:1
|
||||
|
||||
touch.speedX = touch.pageX - previousTouches[id].pageX
|
||||
touch.speedY = touch.pageY - previousTouches[id].pageY
|
||||
|
||||
touch.deltaX = touch.speedX + previousTouches[id].deltaX
|
||||
touch.deltaY = touch.speedY + previousTouches[id].deltaY
|
||||
|
||||
touch.offsetX = previousTouches[id].offsetX+touch.speedX
|
||||
touch.offsetY = previousTouches[id].offsetY+touch.speedY
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
touch.traversing = true
|
||||
var previousTarget = document.elementFromPoint(previousTouches[id].clientX, previousTouches[id].clientY)
|
||||
if (targets[id][0]!=previousTarget) {
|
||||
var off = getOffset(targets[id][0])
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(previousTarget).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
}
|
||||
e.preventDefault()
|
||||
if (oE.traversingContainer.contains(targets[id][0])) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
} else {
|
||||
|
||||
targets[id].triggerHandler('drag',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
previousTouches[id] = touch
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
touchStopHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
$(oE.changedTouches[i].target).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
|
||||
delete previousTouches[id]
|
||||
delete targets[id]
|
||||
|
||||
}
|
||||
|
||||
if (oE.touches.length==0) {
|
||||
$document.off(events.touch.move,touchMoveHandler)
|
||||
$document.off(events.touch.stop,touchStopHandler)
|
||||
touchActive = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this.on(events.touch.start,touchStartHandler)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var makeEventTraversing = function(e){
|
||||
e.traversing=true
|
||||
if (!e.traversingContainer) e.traversingContainer=this
|
||||
}
|
||||
|
||||
|
||||
$.fn.enableTraversingGestures = function() {
|
||||
|
||||
var self = this[0]
|
||||
|
||||
var down = function(e){
|
||||
makeEventTraversing(e)
|
||||
self.addEventListener("mousemove", makeEventTraversing, true)
|
||||
self.addEventListener("touchmove", makeEventTraversing, true)
|
||||
self.addEventListener("mouseout", makeEventTraversing, true)
|
||||
document.addEventListener("mouseup",up,true)
|
||||
document.addEventListener("touchend",up,true)
|
||||
},
|
||||
up = function(){
|
||||
self.removeEventListener("mousemove", makeEventTraversing, true)
|
||||
self.removeEventListener("touchmove", makeEventTraversing, true)
|
||||
self.removeEventListener("mouseout", makeEventTraversing, true)
|
||||
document.removeEventListener("mouseup",up,true)
|
||||
document.removeEventListener("touchend",up,true)
|
||||
}
|
||||
|
||||
self.addEventListener("mousedown", down, true)
|
||||
self.addEventListener("touchstart", down, true)
|
||||
|
||||
|
||||
this.on('disableTraversingGestures',function() {
|
||||
self.removeEventListener("mousedown", down, true)
|
||||
self.removeEventListener("touchstart", down, true)
|
||||
})
|
||||
|
||||
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
|
||||
$document.on('mousedown',function(e){
|
||||
|
||||
if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (e.button==2) {
|
||||
e.preventDefault()
|
||||
$(e.target).trigger('fake-right-click',e)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
var touchTapTimer = false,
|
||||
clearTouchTapTimer = function() {
|
||||
clearTimeout(touchTapTimer)
|
||||
touchTapTimer = false
|
||||
}
|
||||
|
||||
$document.on(events.touch.start,function(e){
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (!touchTapTimer&&e.originalEvent.touches.length==1) {
|
||||
touchTapTimer = setTimeout(function(){
|
||||
if (touchTapTimer) {
|
||||
var touch = e.originalEvent.changedTouches[0],
|
||||
off = getOffset(touch.target)
|
||||
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(e.originalEvent.changedTouches[0].target).trigger('fake-right-click',touch)
|
||||
}
|
||||
touchTapTimer = false
|
||||
},600)
|
||||
} else {
|
||||
clearTouchTapTimer()
|
||||
}
|
||||
})
|
||||
|
||||
$document.on(events.touch.stop + ' ' + events.touch.move,function(e){
|
||||
clearTouchTapTimer()
|
||||
})
|
||||
|
||||
$document.on('contextmenu',function(){return false})
|
||||
|
||||
})(jQuery)
|
||||
87
browser/js/jquery/jquery.fake-input.js
Normal file
87
browser/js/jquery/jquery.fake-input.js
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
;(function ($) {
|
||||
$.fn.fakeInput = function(options) {
|
||||
|
||||
var settings = $.extend({
|
||||
align:'left'
|
||||
}, options );
|
||||
|
||||
var self= this,
|
||||
canvas = $('<canvas></canvas>').appendTo(self),
|
||||
ctx = canvas[0].getContext('2d')
|
||||
|
||||
self.value = undefined
|
||||
self.height = undefined
|
||||
self.width = undefined
|
||||
self.color = undefined
|
||||
self.center = settings.align == 'center'
|
||||
|
||||
self.attr('tabindex',"0")
|
||||
|
||||
canvas.resize(function(e,width,height){
|
||||
e.stopPropagation()
|
||||
|
||||
var width = width*2,
|
||||
height = height*2
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
self.color = getComputedStyle(document.documentElement).getPropertyValue("--color-text")
|
||||
self.height=height
|
||||
self.width=width
|
||||
|
||||
canvas[0].setAttribute('width',width)
|
||||
canvas[0].setAttribute('height',height)
|
||||
|
||||
self.val(self.value)
|
||||
})
|
||||
|
||||
self.val = function(newVal) {
|
||||
if (newVal==undefined) return self.value
|
||||
|
||||
self.value = newVal
|
||||
|
||||
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
|
||||
|
||||
ctx.clearRect(0,0,self.width,self.height)
|
||||
ctx.font = PXSCALE * 2 * 13 + 'px Droid Sans'
|
||||
ctx.textBaseline = "top"
|
||||
ctx.fillStyle = self.color
|
||||
|
||||
if (self.center) {
|
||||
ctx.textAlign = settings.align
|
||||
ctx.fillText(newVal,self.width/2,0)
|
||||
} else {
|
||||
ctx.fillText(newVal,0,0)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
self.on('focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
i.blur()
|
||||
setTimeout(function(){self.focus()},1)
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('.fakeInput')
|
||||
})
|
||||
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
|
||||
if (e.originalEvent.target!=i[0]) {
|
||||
i.blur()
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
return self
|
||||
|
||||
}
|
||||
})(jQuery)
|
||||
4
browser/js/jquery/jquery.min.js
vendored
Normal file
4
browser/js/jquery/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
95
browser/js/jquery/jquery.resize.js
Normal file
95
browser/js/jquery/jquery.resize.js
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/* jquery.resize
|
||||
* based on jQuery resize event (@ "Cowboy" Ben Alman http://benalman.com/projects/jquery-resize-plugin/)
|
||||
* just lighter and faster
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var elems = [],
|
||||
pollInterval = 250,
|
||||
resizeTimeout
|
||||
|
||||
$.event.special.resize = {
|
||||
setup: function() {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
var elem = this
|
||||
|
||||
// Add this element to the list of internal elements to monitor.
|
||||
elems.push( elem )
|
||||
|
||||
// If this is the first element added, start the polling loop.
|
||||
if ( elems.length === 1 ) {
|
||||
resizePollingLoop()
|
||||
}
|
||||
},
|
||||
teardown: function() {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
var elem = this
|
||||
|
||||
// Remove this element from the list of internal elements to monitor.
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
if(elems[i] == this){
|
||||
elems.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ( !elems.length ) {
|
||||
clearTimeout(resizeTimeout)
|
||||
}
|
||||
|
||||
},
|
||||
add: function(handleObj) {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
// Save a reference to the bound event handler.
|
||||
var old_handler = handleObj.handler
|
||||
|
||||
handleObj.handler = function(event,data) {
|
||||
// Call the originally-bound event handler and return its result.
|
||||
return old_handler.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkResizes(){
|
||||
// Iterate over all elements to which the 'resize' event is bound.
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
var elem = elems[i],
|
||||
width = elem.offsetWidth,
|
||||
height = elem.offsetHeight
|
||||
|
||||
if (!width) continue
|
||||
|
||||
var data = {
|
||||
w:elem.resizedataw,
|
||||
h:elem.resizedatah
|
||||
}
|
||||
|
||||
// If element size has changed since the last time, update the element
|
||||
// data store and trigger the 'resize' event.
|
||||
if ( width != data.w || height != data.h ) {
|
||||
elem.resizedataw = width
|
||||
elem.resizedatah = height
|
||||
$(elem).triggerHandler('resize',[width,height])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Loop.
|
||||
resizePollingLoop()
|
||||
}
|
||||
|
||||
function resizePollingLoop() {
|
||||
// yep, setTimeout, 'cuz requestAnimation doesn't seem to perform that well
|
||||
resizeTimeout = window.setTimeout(checkResizes, pollInterval)
|
||||
|
||||
}
|
||||
|
||||
$(window).resize(checkResizes)
|
||||
|
||||
})(jQuery)
|
||||
20
browser/js/jquery/jquery.ui.js
Normal file
20
browser/js/jquery/jquery.ui.js
Normal file
File diff suppressed because one or more lines are too long
272
browser/scss/_editor.scss
Normal file
272
browser/scss/_editor.scss
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
|
||||
.form {
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
margin-bottom:4rem;
|
||||
background:var(--color-bg);
|
||||
align-items: center;
|
||||
&:last-child {
|
||||
margin-bottom:0;
|
||||
}
|
||||
label {
|
||||
background: var(--color-fg);
|
||||
flex-shrink: 0;
|
||||
padding: 5rem;
|
||||
border:1rem solid var(--color-bg);
|
||||
}
|
||||
.input, input {
|
||||
background: var(--color-bg);
|
||||
width:100%;
|
||||
padding:5rem;
|
||||
}
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
label {
|
||||
width:100%;
|
||||
padding:7rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
font-size: 10rem;
|
||||
background: var(--color-faded);
|
||||
}
|
||||
.info {
|
||||
color:var(--color-text-fade);
|
||||
margin-bottom:10rem;
|
||||
}
|
||||
input, .input {
|
||||
display:block;
|
||||
border:0;
|
||||
font:inherit;
|
||||
color:var(--color-text);
|
||||
width:100%;
|
||||
&:focus {
|
||||
border-color:var(--color-accent);
|
||||
}
|
||||
.btn {
|
||||
background:var(--color-raised);
|
||||
box-shadow: 0 0 0 1rem var(--color-bg);
|
||||
}
|
||||
}
|
||||
.checkbox {
|
||||
background:var(--color-raised);
|
||||
cursor: pointer;
|
||||
}
|
||||
.select-wrapper {
|
||||
position: relative;
|
||||
width:100%;
|
||||
&:after{
|
||||
content:"\f107";
|
||||
font-family: FontAwesome;
|
||||
position: absolute;
|
||||
padding:5rem;
|
||||
right:0;
|
||||
top:0;
|
||||
font-size: 20rem;
|
||||
}
|
||||
}
|
||||
select {
|
||||
-webkit-appearance:none;
|
||||
}
|
||||
.submit {
|
||||
margin-top:30rem;
|
||||
}
|
||||
.separator {
|
||||
line-height: 30rem;
|
||||
height: 30rem;
|
||||
margin-bottom: 5rem;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
&:before, &:after {
|
||||
content:"";
|
||||
top:14rem;
|
||||
width: 100%;
|
||||
height: 1rem;
|
||||
background: var(--color-text-fade);
|
||||
}
|
||||
span {
|
||||
font-variant: small-caps;
|
||||
position: relative;
|
||||
display: block;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.widget.editing {
|
||||
z-index: 11!important;
|
||||
overflow: visible;
|
||||
}
|
||||
.widget.editing:after, li.editing a:before, a.editing:before, .content.editing:before, #container.editing:before{
|
||||
content:"";
|
||||
z-index: 999;
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
border:1rem dashed var(--color-accent);
|
||||
pointer-events: none;
|
||||
}
|
||||
.widget.editing:after {
|
||||
// right:-1rem;
|
||||
// bottom:-1rem;
|
||||
}
|
||||
|
||||
.context-menu {
|
||||
position:fixed;
|
||||
z-index: 999999999;
|
||||
background: var(--color-raised);
|
||||
box-shadow: 0 0 4rem 0;
|
||||
color:var(--color-track);
|
||||
.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;
|
||||
}
|
||||
&:hover, &:focus {
|
||||
> .context-menu {
|
||||
pointer-events: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
background:var(--color-accent);
|
||||
}
|
||||
&.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: 1000000;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: var(--color-accent);
|
||||
width:20rem;
|
||||
height:20rem;
|
||||
border-radius:100%;
|
||||
box-shadow: 0 0 4rem 0 var(--color-bg);
|
||||
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-5rem;
|
||||
right:-5rem;
|
||||
left:-5rem;
|
||||
bottom:-5rem;
|
||||
}
|
||||
&.ui-resizable-se {
|
||||
content:"";
|
||||
bottom: 5rem;
|
||||
right: 5rem;
|
||||
cursor: se-resize;
|
||||
&:before {
|
||||
content:"\f065";
|
||||
font-family: FontAwesome;
|
||||
transform:rotate(90deg)
|
||||
}
|
||||
}
|
||||
&.ui-resizable-e {
|
||||
top: 50%;
|
||||
margin-top:-10rem;
|
||||
right: 5rem;
|
||||
cursor: e-resize;
|
||||
&:before {
|
||||
content:"\f051";
|
||||
font-family: FontAwesome;
|
||||
}
|
||||
}
|
||||
&.ui-resizable-s {
|
||||
bottom: 5rem;
|
||||
left: 50%;
|
||||
margin-left:-10rem;
|
||||
cursor: s-resize;
|
||||
&:before {
|
||||
content:"\f051";
|
||||
font-family: FontAwesome;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ui-helper {
|
||||
border: 1rem dashed var(--color-accent);
|
||||
min-width:30rem!important;
|
||||
min-height:30rem!important;
|
||||
z-index: 12!important;
|
||||
opacity: 1!important;
|
||||
&:after {
|
||||
content:"";
|
||||
display: block;
|
||||
width:100%;
|
||||
height:100%;
|
||||
background: var(--color-accent);
|
||||
opacity: .25;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-draggable-handle:not(.label) {
|
||||
position: absolute;
|
||||
top: 5rem;
|
||||
left: 5rem;
|
||||
z-index: 100000;
|
||||
height:20rem;
|
||||
width: 20rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius:100%;
|
||||
background: var(--color-accent);
|
||||
box-shadow: 0 0 4rem 0 var(--color-bg);
|
||||
|
||||
&:before {
|
||||
content:"\f0b2";
|
||||
font-family: FontAwesome;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.ui-draggable-handle {
|
||||
cursor: -webkit-grab;
|
||||
&:active {
|
||||
cursor:-webkit-grabbing;
|
||||
}
|
||||
}
|
||||
126
browser/scss/_layout.scss
Normal file
126
browser/scss/_layout.scss
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
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;
|
||||
// transition:right .2s;
|
||||
&.sidepanel-open {
|
||||
right:var(--sidepanel-size);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background:var(--color-fg);
|
||||
padding:2rem;
|
||||
}
|
||||
|
||||
.tab {
|
||||
position: absolute;
|
||||
overflow: auto;
|
||||
left:0;
|
||||
right:0;
|
||||
top:0;
|
||||
bottom:0;
|
||||
background:var(--color-bg);
|
||||
transform: rotateZ(0);
|
||||
&.has-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
> .navigation {
|
||||
background:var(--color-bg);
|
||||
}
|
||||
> .content {
|
||||
background:none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.navigation {
|
||||
height:var(--nav-height);
|
||||
margin-bottom: 2rem;
|
||||
flex-shrink:0;
|
||||
font-weight:bold;
|
||||
text-transform: uppercase;
|
||||
|
||||
&.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;
|
||||
cursor:pointer;
|
||||
height:100%;
|
||||
margin-right: 1rem;
|
||||
|
||||
|
||||
&:last-child {
|
||||
margin-right:0;
|
||||
}
|
||||
a {
|
||||
background: var(--color-fg);
|
||||
pointer-events: none;
|
||||
padding: 5rem;
|
||||
height:100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow:hidden;
|
||||
text-align:center;
|
||||
position:relative;
|
||||
span {
|
||||
display:block;
|
||||
width:100%;
|
||||
-webkit-mask: linear-gradient(to left, rgba(0, 0, 0, 0), #000000 10rem) no-repeat;
|
||||
}
|
||||
}
|
||||
a:after {
|
||||
content:"";
|
||||
background:var(--color-accent);
|
||||
position: absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
right:0;
|
||||
height:1rem;
|
||||
opacity: 0;
|
||||
transition: all .2s;
|
||||
transform: scale(0);
|
||||
}
|
||||
&.on a, .sidepanel-open {
|
||||
position: relative;
|
||||
background: var(--color-raised);
|
||||
&:after {
|
||||
opacity:1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
.parent + li a {
|
||||
padding-left: calc(5rem + 0.5 * var(--nav-height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
|
|
@ -10,6 +11,4 @@
|
|||
cursor: inherit;
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
29
browser/scss/_scrollbars.scss
Normal file
29
browser/scss/_scrollbars.scss
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
::-webkit-scrollbar {
|
||||
width: 20rem;
|
||||
height:20rem;
|
||||
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: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background:var(--color-raised);
|
||||
&:vertical {
|
||||
border-left:2rem solid var(--color-bg);
|
||||
}
|
||||
&:horizontal {
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
}
|
||||
144
browser/scss/_sidepanel.scss
Normal file
144
browser/scss/_sidepanel.scss
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
|
||||
#sidepanel {
|
||||
position:absolute;
|
||||
z-index: 999999;
|
||||
width:var(--sidepanel-size);
|
||||
border: 8rem solid var(--color-fg);
|
||||
top:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
margin-right:calc(-1 * var(--sidepanel-size));
|
||||
background:var(--color-fg);
|
||||
transition:transform .25s, opacity .25s;
|
||||
transform: translate3d(0,0,0);
|
||||
opacity: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: visible;
|
||||
|
||||
&.sidepanel-open {
|
||||
transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#options {
|
||||
position:absolute;
|
||||
left:0;top:0;
|
||||
right:0;bottom:0;
|
||||
list-style:none;
|
||||
|
||||
li {
|
||||
display:block;
|
||||
margin-bottom:8rem;
|
||||
position: relative;
|
||||
|
||||
&:last-child {
|
||||
margin: 0;
|
||||
}
|
||||
.btn + span {
|
||||
position: absolute;
|
||||
right:0rem;
|
||||
top:0rem;
|
||||
padding:8rem;
|
||||
color:var(--color-text-fade);
|
||||
&:hover {
|
||||
color:var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 4rem;
|
||||
li {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.editor .form {
|
||||
margin-top: 10rem;
|
||||
}
|
||||
.help {
|
||||
margin-top:10rem;
|
||||
font-size: .75em;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
&::-webkit-scrollbar-track-piece {
|
||||
background: var(--color-bg);
|
||||
&:vertical {
|
||||
border-left:8rem solid var(--color-fg);
|
||||
}
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background:var(--color-raised);
|
||||
&:vertical {
|
||||
border-left:8rem solid var(--color-fg);
|
||||
}
|
||||
}
|
||||
}
|
||||
.actions {
|
||||
padding:1rem;
|
||||
background:var(--color-bg);
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex-wrap:wrap;
|
||||
.title {
|
||||
background: var(--color-faded);
|
||||
min-width: 100%;
|
||||
flex-grow: 2;
|
||||
padding: 10rem;
|
||||
position: relative;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
box-shadow: 0 0 0 1rem;
|
||||
color:var(--color-bg);
|
||||
}
|
||||
|
||||
}
|
||||
a {
|
||||
min-width:33%;
|
||||
flex-grow:4;
|
||||
padding:10rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
color:var(--color-text);
|
||||
overflow: visible;
|
||||
|
||||
&.on {
|
||||
pointer-events: none;
|
||||
&:after {
|
||||
opacity:1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
box-shadow: 0 0 0 1rem;
|
||||
color:var(--color-bg);
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
background:var(--color-accent);
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
height:1rem;
|
||||
opacity: 0;
|
||||
transition: all .2s;
|
||||
transform: scale(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
browser/scss/_vars.scss
Normal file
26
browser/scss/_vars.scss
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
:root {
|
||||
|
||||
--color-text:rgba(white,.8);
|
||||
--color-text-fade:rgba(white,0.5);
|
||||
|
||||
--color-bg:darken(#2b2f37,5%); // secondary
|
||||
--color-fg:lighten(#2b2f37,1%); // primary
|
||||
--color-raised:lighten(#2b2f37,5%); // raised
|
||||
--color-faded: darken(#2b2f37,1%); // raised
|
||||
|
||||
--color-track: lighten(#1a1d22,1%); // widgets unfilled value
|
||||
|
||||
--color-accent:#528bff;
|
||||
|
||||
|
||||
--nav-height:40rem;
|
||||
--sidepanel-size:300rem;
|
||||
|
||||
--pixel-scale:1;
|
||||
|
||||
/* Unset variables by default
|
||||
|
||||
--display-input:none; // Hides widgets' numeric inputs
|
||||
|
||||
*/
|
||||
}
|
||||
107
browser/scss/_widgets.scss
Normal file
107
browser/scss/_widgets.scss
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
|
||||
.widget {
|
||||
display:inline-block;
|
||||
height:auto;
|
||||
overflow: hidden;
|
||||
position:relative;
|
||||
vertical-align:top;
|
||||
box-shadow: -0.5rem -0.5rem 0 0.5rem;
|
||||
color:var(--color-bg);
|
||||
border-right:1rem solid var(--color-bg);
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
background:var(--color-fg);
|
||||
-webkit-tap-highlight-color:transparent;
|
||||
min-height:30rem;
|
||||
min-width:30rem;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
|
||||
> * {
|
||||
color:var(--color-text)
|
||||
}
|
||||
|
||||
&.absolute-position {
|
||||
position: absolute;
|
||||
// z-index: 10;
|
||||
}
|
||||
|
||||
&.nolabel {
|
||||
> .label {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
padding:10rem 10rem;
|
||||
text-overflow:ellipsis;
|
||||
overflow:hidden;
|
||||
text-align:center;
|
||||
height:35rem;
|
||||
max-height:35rem;
|
||||
width: 100%;
|
||||
background: var(--color-faded);
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
&.accent {
|
||||
color:var(--color-accent);
|
||||
}
|
||||
}
|
||||
.input {
|
||||
width:100%;
|
||||
height:30rem;
|
||||
border:0;
|
||||
background:transparent;
|
||||
color:var(--color-text-fade);
|
||||
display:block;
|
||||
padding:7rem 5rem;
|
||||
position: relative;
|
||||
display: var(--display-input);
|
||||
|
||||
input {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
padding:7rem 5rem;
|
||||
width: 100%;
|
||||
font: inherit;
|
||||
text-align:center;
|
||||
border:0;
|
||||
background: transparent;
|
||||
color:var(--color-accent);
|
||||
}
|
||||
canvas {
|
||||
width:100%;
|
||||
height:100%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
input + canvas {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
color:var(--color-accent);
|
||||
|
||||
}
|
||||
&[disabled] {
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@import 'widgets/fader';
|
||||
@import 'widgets/knob';
|
||||
|
||||
@import 'widgets/matrices';
|
||||
@import 'widgets/pads';
|
||||
|
||||
@import 'widgets/plots';
|
||||
|
||||
|
||||
@import 'widgets/toggle';
|
||||
@import 'widgets/push';
|
||||
@import 'widgets/switch';
|
||||
|
||||
@import 'widgets/strip';
|
||||
@import 'widgets/panel';
|
||||
257
browser/scss/style.scss
Normal file
257
browser/scss/style.scss
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
@import 'vars';
|
||||
@import 'reset';
|
||||
|
||||
|
||||
@import 'scrollbars';
|
||||
|
||||
@import 'layout';
|
||||
|
||||
@import 'editor';
|
||||
@import 'sidepanel';
|
||||
@import 'widgets';
|
||||
|
||||
|
||||
input:focus::selection{
|
||||
background:var(--color-accent);
|
||||
color:var(--color-text);
|
||||
}
|
||||
input {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
html, body {
|
||||
height:100%;
|
||||
overflow:hidden;
|
||||
position:relative;
|
||||
|
||||
}
|
||||
|
||||
html{
|
||||
// global pixel scaling
|
||||
font-size: calc(var(--pixel-scale) * 1px);
|
||||
|
||||
// prevent android's auto font-resize
|
||||
max-height: 999999px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size:13rem;
|
||||
line-height:16rem;
|
||||
font-family:Droid Sans;
|
||||
color:var(--color-text);
|
||||
white-space:nowrap;
|
||||
opacity:1;
|
||||
cursor: default;
|
||||
}
|
||||
i {
|
||||
font-size: 14rem!important;
|
||||
}
|
||||
|
||||
|
||||
.btn {
|
||||
background: var(--color-raised);
|
||||
display: block;
|
||||
padding:15rem;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
&.small {
|
||||
padding:8rem;
|
||||
padding-right: 15rem;
|
||||
}
|
||||
&.warning {
|
||||
background:firebrick;
|
||||
}
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
&.align-center {
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
.list {
|
||||
flex:1;
|
||||
overflow: auto;
|
||||
background: var(--color-fg);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
|
||||
}
|
||||
.header {
|
||||
padding:20rem;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-grow: 0;
|
||||
background-color: var(--color-faded);
|
||||
color:var(--color-accent);
|
||||
font-size:16rem;
|
||||
line-height: 24rem;
|
||||
}
|
||||
.footer {
|
||||
background: var(--color-raised);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
flex-grow: 0;
|
||||
background: var(--color-faded);
|
||||
border-top:2rem solid var(--color-bg);
|
||||
}
|
||||
a {
|
||||
display: block;
|
||||
padding-right:35rem;
|
||||
overflow: hidden;
|
||||
padding-top:15rem;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
background: none;
|
||||
border-bottom:1rem solid var(--color-bg);
|
||||
&:hover {
|
||||
background:var(--color-raised)
|
||||
}
|
||||
&:last-child {
|
||||
border-bottom:0;
|
||||
}
|
||||
span {
|
||||
position: absolute;
|
||||
right:0rem;
|
||||
top:0rem;
|
||||
padding:15rem;
|
||||
color:var(--color-text-fade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#loading {
|
||||
position: absolute;
|
||||
top:50%;
|
||||
left:50%;
|
||||
margin-top:-15rem;
|
||||
text-align: center;
|
||||
.spinner {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
height:30rem;
|
||||
width:30rem;
|
||||
border-radius: 50%;
|
||||
border:2rem solid var(--color-track);
|
||||
border-top-color:var(--color-accent);
|
||||
animation: spin .5s linear infinite;
|
||||
}
|
||||
#status {
|
||||
margin-top: 10rem;
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {transform: rotate(0deg);}
|
||||
100% {transform: rotate(360deg);}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.popup {
|
||||
position: fixed;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
padding:10%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index:1000000;
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background:var(--color-bg);
|
||||
opacity: .5;
|
||||
}
|
||||
.popup-title {
|
||||
position: relative;
|
||||
padding:15rem;
|
||||
background:var(--color-raised);
|
||||
.closer {
|
||||
position:absolute;
|
||||
right:0rem;
|
||||
top:0;
|
||||
padding:15rem;
|
||||
color:var(--color-text-fade);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.popup-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
background:var(--color-fg);
|
||||
width:auto;
|
||||
max-width:600rem;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border:1rem solid var(--color-track);
|
||||
.popup-content {
|
||||
height:100%;
|
||||
width:100%;
|
||||
padding:10rem;
|
||||
overflow-y:auto;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
373
browser/scss/widgets/_fader.scss
Normal file
373
browser/scss/widgets/_fader.scss
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
.fader-container {
|
||||
--color-custom:var(--color-accent);
|
||||
--color-pips: var(--color-text-fade);
|
||||
--color-gauge: var(--color-custom);
|
||||
--color-knob: var(--color-custom);
|
||||
|
||||
|
||||
|
||||
width:100rem;
|
||||
min-height: 200rem;
|
||||
height:100%;
|
||||
|
||||
&.align-right {
|
||||
|
||||
.fader-wrapper {
|
||||
.fader {
|
||||
margin-left:calc(50% + 10rem);
|
||||
}
|
||||
.meter-container {
|
||||
right:auto;
|
||||
left:-13rem!important;
|
||||
}
|
||||
.pips {
|
||||
margin-left: -20rem;
|
||||
.pip {
|
||||
right:0;
|
||||
left:auto;
|
||||
span {
|
||||
right:3rem;
|
||||
left:auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.compact {
|
||||
.fader-wrapper-outer .fader-wrapper .fader{
|
||||
.meter-container {
|
||||
left:0!important;
|
||||
right: auto!important;
|
||||
}
|
||||
}
|
||||
.has-meter {
|
||||
.input {
|
||||
left:calc(50% + 2rem)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.compact {
|
||||
.fader-wrapper-outer {
|
||||
.input {
|
||||
position: absolute;
|
||||
top:50%;
|
||||
transform: rotate(-90deg);
|
||||
pointer-events: none;
|
||||
width: 100rem;
|
||||
margin-left: -50rem;
|
||||
left:50%;
|
||||
z-index: 3;
|
||||
}
|
||||
.fader-wrapper {
|
||||
padding:1rem 0 0!important;
|
||||
background:var(--color-track);
|
||||
.fader {
|
||||
width:100%;
|
||||
margin: 0;
|
||||
&:before {
|
||||
content:none;
|
||||
}
|
||||
.gauge {
|
||||
opacity: .25;
|
||||
}
|
||||
.knob {
|
||||
&:before, &:after {
|
||||
display:none;
|
||||
}
|
||||
width:100%;
|
||||
height:1rem;
|
||||
background:var(--color-knob);
|
||||
}
|
||||
.pips {
|
||||
display: none;
|
||||
}
|
||||
.meter-container {
|
||||
right:-1rem!important;
|
||||
left: auto!important;
|
||||
width: 4rem;
|
||||
top:-2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.has-meter {
|
||||
.input {
|
||||
left:calc(50% - 2rem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
margin-top:-5rem;
|
||||
}
|
||||
|
||||
.fader-wrapper-outer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex:1;
|
||||
}
|
||||
|
||||
.fader-wrapper {
|
||||
padding:20rem;
|
||||
flex:1;
|
||||
overflow:hidden;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
cursor: -webkit-grab;
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
.fader {
|
||||
width:2rem;
|
||||
position: relative;
|
||||
margin:0 auto;
|
||||
margin-right:calc(50% + 15rem);
|
||||
|
||||
pointer-events: none;
|
||||
flex:1;
|
||||
&:before {
|
||||
content:"";
|
||||
width:100%;
|
||||
height:100%;
|
||||
background:var(--color-track);
|
||||
z-index: 1;
|
||||
display:block;
|
||||
box-shadow: 0 0 0 15rem;
|
||||
color: var(--color-fg);
|
||||
position: absolute;
|
||||
}
|
||||
.gauge {
|
||||
position: absolute;
|
||||
bottom:0!important;
|
||||
top:0!important;
|
||||
width:100%;
|
||||
height:100%;
|
||||
transform-origin: bottom;
|
||||
max-height:100%;
|
||||
max-width:100%;
|
||||
background:var(--color-gauge);
|
||||
z-index: 1;
|
||||
|
||||
}
|
||||
.knob {
|
||||
position: absolute;
|
||||
bottom:0;
|
||||
width:0;
|
||||
height:0;
|
||||
z-index: 2;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
left:-3rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-knob);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-10rem;
|
||||
left:-9rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-knob);
|
||||
opacity: .2;
|
||||
}
|
||||
}
|
||||
.meter-container {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
left:auto;
|
||||
right:-15rem;
|
||||
bottom:0;
|
||||
top:0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
width: 4rem;
|
||||
background: var(--color-bg);
|
||||
height:auto;
|
||||
.meter {
|
||||
margin:0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pips {
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
left:50%;
|
||||
z-index: 0;
|
||||
width: 4rem;
|
||||
margin-left: 17rem;
|
||||
background: linear-gradient(to bottom, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
|
||||
background-size: 100% 5px;
|
||||
background-repeat: repeat-y;
|
||||
|
||||
.pip {
|
||||
height:1px;
|
||||
background: var(--color-pips);
|
||||
color:var(--color-fg);
|
||||
position: absolute;
|
||||
width:8rem;
|
||||
left:0;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4px;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:-4px;
|
||||
background: var(--color-fg);
|
||||
z-index: -1;
|
||||
}
|
||||
span {
|
||||
position: absolute;
|
||||
width:30rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size:10rem;
|
||||
line-height: 12rem;
|
||||
left:3rem;
|
||||
top:-5.5rem;
|
||||
color:var(--color-pips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.no-pip {
|
||||
.pips {
|
||||
display: none!important;
|
||||
}
|
||||
.fader {
|
||||
margin:0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.fader-container.horizontal {
|
||||
min-height: 80rem;
|
||||
height: auto;
|
||||
width:300rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.compact .fader-wrapper-outer {
|
||||
|
||||
.input {
|
||||
transform: none;
|
||||
top:50%;
|
||||
margin-top:-15rem;
|
||||
}
|
||||
.fader-wrapper {
|
||||
display:flex;
|
||||
flex:1;
|
||||
padding:0 1rem 0 0!important;
|
||||
}
|
||||
.fader {
|
||||
height:100%;
|
||||
top:0;
|
||||
.knob {
|
||||
width:1rem;
|
||||
height:100%;
|
||||
margin-bottom:0;
|
||||
bottom:0;
|
||||
}
|
||||
.meter-container {
|
||||
top:0;
|
||||
left:0!important;
|
||||
right:-1px!important;
|
||||
width: auto;
|
||||
height: 4rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.fader-wrapper-outer {
|
||||
position: relative;
|
||||
top:auto;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
.fader-wrapper {
|
||||
padding:20rem 20rem 40rem;
|
||||
display: block;
|
||||
flex:0;
|
||||
flex-shrink: 0;
|
||||
&.no-pip {
|
||||
padding: 20rem;
|
||||
}
|
||||
}
|
||||
.fader {
|
||||
width:100%;
|
||||
left:auto;
|
||||
top:50%;
|
||||
height:2rem;
|
||||
&:before {
|
||||
box-shadow:none;
|
||||
}
|
||||
.gauge {
|
||||
transform-origin: left;
|
||||
}
|
||||
.meter-container {
|
||||
top:-15rem;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:auto;
|
||||
height:1rem;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
width:auto;
|
||||
height: 4rem;
|
||||
}
|
||||
.knob {
|
||||
bottom:1px;
|
||||
}
|
||||
}
|
||||
.pips {
|
||||
top:15rem;left:0;
|
||||
right:0;
|
||||
font-size: 0;
|
||||
height:4rem;
|
||||
width:100%;
|
||||
margin:0;
|
||||
background: linear-gradient(to right, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
|
||||
background-size: 5px 100%;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.pip {
|
||||
width:1px;
|
||||
height:6rem;
|
||||
margin: 0;
|
||||
&:before {
|
||||
top:0;
|
||||
bottom:0;
|
||||
left:-4px;
|
||||
right:-4px;
|
||||
}
|
||||
span {
|
||||
top:15rem;
|
||||
left:-15rem!important;
|
||||
right:auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.compact .has-meter {
|
||||
.input {
|
||||
top:calc(50% + 2rem)
|
||||
}
|
||||
}
|
||||
}
|
||||
202
browser/scss/widgets/_knob.scss
Normal file
202
browser/scss/widgets/_knob.scss
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
.knob-container {
|
||||
--color-custom:var(--color-accent);
|
||||
--color-pips: var(--color-text-fade);
|
||||
--color-gauge: var(--color-custom);
|
||||
--color-knob: var(--color-custom);
|
||||
|
||||
width: 100rem;
|
||||
height: 150rem;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.compact {
|
||||
.pips {
|
||||
display: none;
|
||||
}
|
||||
.input {
|
||||
position: absolute;
|
||||
top:50%;
|
||||
margin-top: -15rem;
|
||||
left:22%;
|
||||
right:22%;
|
||||
width:auto;
|
||||
pointer-events: none;
|
||||
}
|
||||
.knob-wrapper-outer {
|
||||
position: relative;
|
||||
}
|
||||
.knob-wrapper {
|
||||
padding:10% 0!important;
|
||||
}
|
||||
.knob:before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.knob-wrapper-outer {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex:1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
.input {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.knob-wrapper {
|
||||
padding:15rem 0 15rem;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 0;
|
||||
position: relative;
|
||||
|
||||
cursor: -webkit-grab;
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
|
||||
&.no-pip {
|
||||
padding-bottom: 0;
|
||||
.pips {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.knob-mask {
|
||||
width:58%;
|
||||
padding-bottom:58%;
|
||||
flex-shrink: 0;
|
||||
border-radius:100%;
|
||||
pointer-events: none;
|
||||
position: relative;
|
||||
&:before {
|
||||
position:absolute;
|
||||
top:0;left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
border-radius:100%;
|
||||
border:2rem solid var(--color-track);
|
||||
transform: rotate(45deg);
|
||||
z-index:4;
|
||||
}
|
||||
|
||||
&:after {
|
||||
content:"";
|
||||
position:absolute;
|
||||
top:0rem;left:-3rem;
|
||||
right:-3rem;
|
||||
bottom:-2rem;
|
||||
border-radius:100%;
|
||||
border:12rem solid transparent;
|
||||
border-bottom-color: var(--color-fg);
|
||||
z-index:4;
|
||||
}
|
||||
}
|
||||
|
||||
.knob {
|
||||
position:absolute;
|
||||
top:0;left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
pointer-events: none;
|
||||
transform:rotateZ(0deg);
|
||||
backface-visibility: hidden;
|
||||
z-index: 2;
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position:absolute;
|
||||
top:17rem;
|
||||
left:17rem;
|
||||
right:17rem;
|
||||
bottom:17rem;
|
||||
border-radius:100%;
|
||||
background-color:var(--color-raised);
|
||||
// background-image:linear-gradient(135deg,rgba(0,0,0,0), rgba(0,0,0,0) 50%, rgba(0,0,0,0.05) 50%, rgba(0,0,0,0.05));
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position:absolute;
|
||||
top:0;left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
border-radius:100%;
|
||||
border:2rem solid var(--color-track);
|
||||
border-bottom-color: var(--color-gauge);
|
||||
}
|
||||
|
||||
&.d2:after {
|
||||
border-right-color: var(--color-gauge);
|
||||
}
|
||||
&.d3:after {
|
||||
border-top-color: var(--color-gauge);
|
||||
border-right-color: var(--color-gauge);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
.handle {
|
||||
position:absolute;
|
||||
top:0;left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
pointer-events: none;
|
||||
transform:rotateZ(-45deg);
|
||||
backface-visibility: hidden;
|
||||
z-index: 5;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:50%;
|
||||
left:-3rem;
|
||||
margin-top:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-knob);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:50%;
|
||||
margin-top:-10rem;
|
||||
left:-9rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-knob);
|
||||
opacity: .2;
|
||||
}
|
||||
}
|
||||
.pips {
|
||||
width:100%;
|
||||
pointer-events: none;
|
||||
height: 0;
|
||||
}
|
||||
.pip {
|
||||
font-size:11rem;
|
||||
color:var(--color-pips);
|
||||
display:inline-block;
|
||||
&.min {
|
||||
width:50%;
|
||||
text-align:center;
|
||||
}
|
||||
&.max {
|
||||
width:50%;
|
||||
text-align:center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
browser/scss/widgets/_matrices.scss
Normal file
46
browser/scss/widgets/_matrices.scss
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
|
||||
/* Multiple widgets (push|toggle|fader) matrix */
|
||||
.multitoggle-container, .multipush-container, .multifader-container {
|
||||
height:200rem;
|
||||
width:200rem;
|
||||
&.nolabel .matrix {
|
||||
top:0;
|
||||
}
|
||||
}
|
||||
.matrix {
|
||||
flex:1;
|
||||
overflow: auto;
|
||||
background: var(--color-bg);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
margin-right:-1rem;
|
||||
margin-bottom: -1rem;
|
||||
|
||||
> .widget {
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
margin:0!important;
|
||||
.label {
|
||||
background:none;
|
||||
border:0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.multifader-container {
|
||||
.matrix {
|
||||
padding:0!important;
|
||||
align-items:stretch;
|
||||
}
|
||||
.widget {
|
||||
height: auto;
|
||||
}
|
||||
.fader-wrapper {
|
||||
padding:10rem 0 20rem!important;
|
||||
.fader {
|
||||
left:0!important;
|
||||
}
|
||||
}
|
||||
}
|
||||
172
browser/scss/widgets/_pads.scss
Normal file
172
browser/scss/widgets/_pads.scss
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
|
||||
.xy-container, .rgb-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
width:200rem;
|
||||
height:250rem;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
}
|
||||
.xy-wrapper {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.value {
|
||||
width:100%;
|
||||
display:var(--display-input);
|
||||
}
|
||||
.input {
|
||||
width:50%;
|
||||
float:left;
|
||||
height: 30rem;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
.xy {
|
||||
position:relative;
|
||||
width:auto;
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
cursor: -webkit-grab;
|
||||
background:var(--color-faded);
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
.handle {
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
z-index:2;
|
||||
pointer-events: none;
|
||||
backface-visibility: hidden;
|
||||
transform-origin: center;
|
||||
transform:translate3d(0,0,0);
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-custom);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-10rem;
|
||||
right:-10rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-custom);
|
||||
opacity: .2; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.rgb-wrapper {
|
||||
.input, input {
|
||||
width:33.33%;
|
||||
}
|
||||
}
|
||||
|
||||
.rgb {
|
||||
.bg {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background-color: red;
|
||||
opacity: .75;
|
||||
pointer-events: none;
|
||||
&:before, &:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
&:before {
|
||||
background: linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
|
||||
}
|
||||
&:after {
|
||||
background:linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%);
|
||||
}
|
||||
}
|
||||
.handle {
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
background:var(--color-text);
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-10rem;
|
||||
right:-10rem;
|
||||
height:20rem;
|
||||
width:20rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
background:var(--color-text);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hue {
|
||||
width:auto;
|
||||
min-height:30rem;
|
||||
overflow: hidden;
|
||||
cursor: -webkit-grab;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
.bg {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
opacity: 0.5;
|
||||
background:transparent linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
|
||||
pointer-events: none;
|
||||
}
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
.handle {
|
||||
position:absolute;
|
||||
z-index:2;
|
||||
left:0;
|
||||
top:50%;
|
||||
pointer-events: none;
|
||||
transform: translate3d(0,0,0);
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:-4rem;
|
||||
right:-4rem;
|
||||
height:8rem;
|
||||
width:8rem;
|
||||
border:none!important;
|
||||
border-radius: 100%!important;
|
||||
box-shadow: none;
|
||||
background:var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
70
browser/scss/widgets/_panel.scss
Normal file
70
browser/scss/widgets/_panel.scss
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
|
||||
|
||||
.panel-container {
|
||||
width: 200rem;
|
||||
height: 200rem;
|
||||
border:0;
|
||||
|
||||
background: var(--color-faded);
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
border-bottom: 1rem solid var(--color-bg);
|
||||
border-right: 1rem solid var(--color-bg);
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece {
|
||||
border-top: 1rem solid var(--color-bg);
|
||||
}
|
||||
|
||||
&.nolabel .panel {
|
||||
top:0;
|
||||
}
|
||||
|
||||
.panel {
|
||||
overflow: auto;
|
||||
position: absolute;
|
||||
top:35rem;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
|
||||
&.has-tabs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
&.noscroll {
|
||||
overflow: hidden;
|
||||
> .widget {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.navigation {
|
||||
border-top: 0;
|
||||
background: transparent;
|
||||
&:after {
|
||||
background: var(--color-bg);
|
||||
}
|
||||
a.on {
|
||||
border-color: var(--color-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
124
browser/scss/widgets/_plots.scss
Normal file
124
browser/scss/widgets/_plots.scss
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
.led-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
width:100rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.led {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
padding:10rem 0;
|
||||
overflow: hidden;
|
||||
|
||||
div {
|
||||
border-radius: 100%;
|
||||
width:calc(100% - 20rem);
|
||||
padding-bottom:calc(100% - 20rem);
|
||||
margin: 0 auto;
|
||||
background:var(--color-track);
|
||||
position: relative;
|
||||
span {
|
||||
position: absolute;
|
||||
top:0;left:0;right:0;bottom:0;
|
||||
border-radius: 100%;
|
||||
display:block;
|
||||
background-color:var(--color-custom);
|
||||
&:after {
|
||||
content:"";
|
||||
border-radius:100%;
|
||||
position: absolute;
|
||||
top:-1rem;left:-1rem;right:-1rem;bottom:-1rem;
|
||||
display:block;
|
||||
border: 6rem solid var(--color-fg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.plot-container, .visualizer-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
height: 200rem;
|
||||
width: 200rem;
|
||||
.plot {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
position: relative;
|
||||
}
|
||||
canvas {
|
||||
position: absolute;
|
||||
top:0;left:0;
|
||||
width:100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.meter-container {
|
||||
--color-custom:var(--color-accent);
|
||||
--color-gauge: var(--color-custom);
|
||||
|
||||
height: 100rem;
|
||||
.meter {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
position: relative;
|
||||
|
||||
background: var(--color-track);
|
||||
|
||||
.level {
|
||||
width:100%;
|
||||
flex:1;
|
||||
transform-origin: bottom;
|
||||
background:var(--color-custom);
|
||||
// opacity: .5;
|
||||
}
|
||||
&::after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
bottom:0;
|
||||
right:0;
|
||||
background-image: linear-gradient(transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
|
||||
background-size: 100% 2px;
|
||||
background-repeat: repeat;
|
||||
}
|
||||
&.horizontal {
|
||||
&::after {
|
||||
background-image: linear-gradient(to left, transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
|
||||
background-size: 2px 100% ;
|
||||
}
|
||||
.level {
|
||||
transform-origin: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.text-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
.text {
|
||||
flex: 1;
|
||||
height:35rem;
|
||||
padding: 10rem;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--color-faded);
|
||||
color:var(--color-custom);
|
||||
&.vertical {
|
||||
transform: rotate(180deg);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
-webkit-writing-mode:vertical-lr;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
browser/scss/widgets/_push.scss
Normal file
45
browser/scss/widgets/_push.scss
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
.push-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
width:100rem;
|
||||
min-height: 65rem;
|
||||
flex-shrink: 0;
|
||||
padding:0!important;
|
||||
|
||||
background: var(--color-raised);
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
height:auto;
|
||||
max-height: initial;
|
||||
border:0;
|
||||
background: none!important;
|
||||
text-align: center;
|
||||
pointer-events:none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
.push {
|
||||
&.active {
|
||||
background: var(--color-fg);
|
||||
}
|
||||
.light {
|
||||
position: absolute;
|
||||
left:auto;
|
||||
background: var(--color-custom);
|
||||
height:4rem;
|
||||
width:4rem;
|
||||
border-radius: 4rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
80
browser/scss/widgets/_strip.scss
Normal file
80
browser/scss/widgets/_strip.scss
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
|
||||
|
||||
.strip-container {
|
||||
width:100rem;
|
||||
height:100%;
|
||||
overflow: visible;
|
||||
// background: var(--color-bg);
|
||||
border:0;
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
pointer-events: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
> .strip {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
> .widget {
|
||||
width:auto;
|
||||
margin:0;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
&.vertical {
|
||||
> .strip > .widget {
|
||||
max-width: 100%;
|
||||
}
|
||||
&::before {
|
||||
border-right: 1rem solid var(--color-bg);
|
||||
}
|
||||
}
|
||||
&.horizontal {
|
||||
width:100%;
|
||||
height:200rem;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
&::before {
|
||||
border-bottom: 1rem solid var(--color-bg);
|
||||
}
|
||||
|
||||
> .strip {
|
||||
flex-direction: row;
|
||||
flex:1;
|
||||
> .widget {
|
||||
flex-shrink: initial;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
max-height: 100%;
|
||||
height:100%;
|
||||
}
|
||||
}
|
||||
> .label {
|
||||
width:35rem;
|
||||
height:100%;
|
||||
border-bottom:0;
|
||||
border-right:1rem solid var(--color-bg);
|
||||
max-height: initial;
|
||||
span {
|
||||
transform: rotate(180deg);
|
||||
display: block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
-webkit-writing-mode:vertical-lr;
|
||||
text-align: center;
|
||||
height:100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
81
browser/scss/widgets/_switch.scss
Normal file
81
browser/scss/widgets/_switch.scss
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
.switch-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
// height: 100%;
|
||||
width:100rem;
|
||||
flex-shrink: 0;
|
||||
.switch {
|
||||
height:100%;
|
||||
width:100%;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction:column;
|
||||
align-items: stretch;
|
||||
flex:1;
|
||||
&.horizontal {
|
||||
flex-direction:row;
|
||||
.value {
|
||||
padding:28rem 6rem 6rem 6rem;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
border-top:0;
|
||||
border-right:1rem solid var(--color-bg);
|
||||
flex:1;
|
||||
height:auto;
|
||||
&:last-child {
|
||||
border-right:0;
|
||||
}
|
||||
&:before {
|
||||
left:50%;
|
||||
top:8rem;
|
||||
width:8rem;
|
||||
height:8rem;
|
||||
margin-left: -4rem;
|
||||
margin-top:0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.value {
|
||||
background:var(--color-raised);
|
||||
color:var(--color-text);
|
||||
width:100%;
|
||||
height:100%;
|
||||
position: relative;
|
||||
border-top: 1rem solid var(--color-bg);
|
||||
padding:12rem 12rem 12rem 24rem ;
|
||||
white-space: normal;
|
||||
text-align: left;
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
&:first-child {
|
||||
border-top:0;
|
||||
}
|
||||
&:last-child {
|
||||
margin-bottom:0;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
left:8rem;
|
||||
top:50%;
|
||||
width:8rem;
|
||||
height:8rem;
|
||||
margin-top: -4rem;
|
||||
background: var(--color-track);
|
||||
border-radius: 8rem;
|
||||
}
|
||||
&.on:before {
|
||||
background: var(--color-custom);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
56
browser/scss/widgets/_toggle.scss
Normal file
56
browser/scss/widgets/_toggle.scss
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
.toggle-container {
|
||||
--color-custom:var(--color-accent);
|
||||
|
||||
width:100rem;
|
||||
min-height: 65rem;
|
||||
flex-shrink: 0;
|
||||
padding:0!important;
|
||||
background: var(--color-raised);
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top:1rem;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
height:auto;
|
||||
max-height: initial;
|
||||
border:0;
|
||||
background: none!important;
|
||||
text-align: center;
|
||||
pointer-events:none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toggle {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
|
||||
.light {
|
||||
position: absolute;
|
||||
left:2rem;
|
||||
right:2rem;
|
||||
top:2rem;
|
||||
height:2rem;
|
||||
pointer-events: none;
|
||||
background: var(--color-custom);
|
||||
&:after {
|
||||
content:"";
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
background: var(--color-track);
|
||||
}
|
||||
}
|
||||
&.on .light:after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
services:
|
||||
app:
|
||||
build: .
|
||||
volumes:
|
||||
- ./sessions:/sessions
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
test -f "$LOAD" || cp "basesession.json" "$LOAD"
|
||||
|
||||
exec node app/index.js \
|
||||
--port $PORT \
|
||||
--osc-port $OSC_PORT \
|
||||
--send $SEND \
|
||||
--load $LOAD \
|
||||
--read-only=$READ_ONLY
|
||||
3842
examples/audio.js
Normal file
3842
examples/audio.js
Normal file
File diff suppressed because it is too large
Load diff
329
examples/plot.js
Normal file
329
examples/plot.js
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
[
|
||||
{
|
||||
"label": "Plots and ploplots",
|
||||
"widgets": [
|
||||
{
|
||||
"type": "fader",
|
||||
"id": "fader_1",
|
||||
"linkId": "",
|
||||
"label": "auto",
|
||||
"unit": "",
|
||||
"left": "auto",
|
||||
"top": "auto",
|
||||
"width": "auto",
|
||||
"height": 254,
|
||||
"horizontal": false,
|
||||
"css": "",
|
||||
"absolute": false,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScale": false,
|
||||
"precision": 2,
|
||||
"path": "/fader_1",
|
||||
"target": [],
|
||||
"meter": false
|
||||
},
|
||||
{
|
||||
"type": "fader",
|
||||
"id": "fader_2",
|
||||
"linkId": "",
|
||||
"label": "auto",
|
||||
"unit": "",
|
||||
"left": "auto",
|
||||
"top": "auto",
|
||||
"width": "auto",
|
||||
"height": 253,
|
||||
"horizontal": false,
|
||||
"css": "",
|
||||
"absolute": false,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScale": false,
|
||||
"precision": 2,
|
||||
"path": "/fader_2",
|
||||
"target": [],
|
||||
"meter": false
|
||||
},
|
||||
{
|
||||
"type": "fader",
|
||||
"id": "fader_3",
|
||||
"linkId": "",
|
||||
"label": "auto",
|
||||
"unit": "",
|
||||
"left": "auto",
|
||||
"top": "auto",
|
||||
"width": "auto",
|
||||
"height": 253,
|
||||
"horizontal": false,
|
||||
"css": "",
|
||||
"absolute": false,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScale": false,
|
||||
"precision": 2,
|
||||
"path": "/fader_3",
|
||||
"target": [],
|
||||
"meter": false
|
||||
},
|
||||
{
|
||||
"type": "fader",
|
||||
"id": "fader_4",
|
||||
"linkId": "",
|
||||
"label": "auto",
|
||||
"unit": "",
|
||||
"left": "auto",
|
||||
"top": "auto",
|
||||
"width": "auto",
|
||||
"height": 253,
|
||||
"horizontal": false,
|
||||
"css": "",
|
||||
"absolute": false,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScale": false,
|
||||
"precision": 2,
|
||||
"path": "/fader_4",
|
||||
"target": [],
|
||||
"meter": false
|
||||
},
|
||||
{
|
||||
"type": "plot",
|
||||
"id": "plot_1",
|
||||
"label": "plot (faders)",
|
||||
"left": 400,
|
||||
"top": 122,
|
||||
"width": 200,
|
||||
"height": 131,
|
||||
"css": "",
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
"fader_1"
|
||||
],
|
||||
[
|
||||
0.25,
|
||||
"fader_2"
|
||||
],
|
||||
[
|
||||
0.75,
|
||||
"fader_3"
|
||||
],
|
||||
[
|
||||
1,
|
||||
"fader_4"
|
||||
]
|
||||
],
|
||||
"rangeX": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"rangeY": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScaleX": false,
|
||||
"logScaleY": false,
|
||||
"path": "/plot_1"
|
||||
},
|
||||
{
|
||||
"type": "visualizer",
|
||||
"left": 400,
|
||||
"top": 0,
|
||||
"width": "auto",
|
||||
"height": 122,
|
||||
"css": "",
|
||||
"id": "visualizer_(fader_1)",
|
||||
"widgetId": "fader_1",
|
||||
"duration": 1,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScale": false,
|
||||
"label": "visualizer (fader1)",
|
||||
"path": "/visualizer_(fader_1)"
|
||||
},
|
||||
{
|
||||
"type": "rgb",
|
||||
"id": "rgb_1",
|
||||
"linkId": "",
|
||||
"label": "auto",
|
||||
"left": 0,
|
||||
"top": 254,
|
||||
"width": "auto",
|
||||
"height": "auto",
|
||||
"css": "",
|
||||
"absolute": false,
|
||||
"precision": 0,
|
||||
"path": "/rgb_1",
|
||||
"split": false,
|
||||
"target": []
|
||||
},
|
||||
{
|
||||
"type": "plot",
|
||||
"left": 200,
|
||||
"top": 253,
|
||||
"width": 400,
|
||||
"height": 251,
|
||||
"css": "",
|
||||
"points": "rgb_1",
|
||||
"rangeX": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"rangeY": {
|
||||
"min": 0,
|
||||
"max": 255
|
||||
},
|
||||
"logScaleX": false,
|
||||
"logScaleY": false,
|
||||
"id": "plot_2",
|
||||
"label": "plot_2 (rgb)",
|
||||
"path": "/plot_2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Multifader plot !",
|
||||
"widgets": [
|
||||
{
|
||||
"type": "multifader",
|
||||
"id": "multifader_1",
|
||||
"strips": 10,
|
||||
"label": "auto",
|
||||
"unit": "",
|
||||
"left": 0,
|
||||
"top": 0,
|
||||
"width": 557,
|
||||
"height": 228,
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"precision": 2,
|
||||
"path": "/multifader_1",
|
||||
"target": [],
|
||||
"logScale": false,
|
||||
"css": ""
|
||||
},
|
||||
{
|
||||
"type": "plot",
|
||||
"id": "plot_3",
|
||||
"label": "plot (multifader)",
|
||||
"left": 0,
|
||||
"top": 228,
|
||||
"width": 557,
|
||||
"height": 220,
|
||||
"points": "multifader_1",
|
||||
"rangeX": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"rangeY": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScaleX": false,
|
||||
"logScaleY": false,
|
||||
"path": "/plot_3",
|
||||
"css": "z-index:1"
|
||||
},
|
||||
{
|
||||
"type": "multitoggle",
|
||||
"id": "multitoggle_1",
|
||||
"label": "auto",
|
||||
"left": 557,
|
||||
"top": 0,
|
||||
"width": 209,
|
||||
"height": 229,
|
||||
"css": "",
|
||||
"precision": 2,
|
||||
"path": "/multifader_2",
|
||||
"target": [],
|
||||
"matrix": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"on": 1,
|
||||
"off": 0
|
||||
},
|
||||
{
|
||||
"type": "plot",
|
||||
"left": 557,
|
||||
"top": 228,
|
||||
"width": 209,
|
||||
"height": 220,
|
||||
"css": "",
|
||||
"label": "plot (toggles)",
|
||||
"points": "multitoggle_1",
|
||||
"rangeX": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"rangeY": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScaleX": false,
|
||||
"logScaleY": false,
|
||||
"id": "plot_4",
|
||||
"path": "/plot_4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Hacking",
|
||||
"widgets": [
|
||||
{
|
||||
"type": "multifader",
|
||||
"strips": 10,
|
||||
"unit": "",
|
||||
"left": 6,
|
||||
"top": 17,
|
||||
"width": 564,
|
||||
"height": 267,
|
||||
"css": "z-index:8;opacity:0",
|
||||
"range": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"precision": 2,
|
||||
"target": [],
|
||||
"logScale": false,
|
||||
"id": "multifader_2",
|
||||
"label": "auto",
|
||||
"path": "/multifader_2"
|
||||
},
|
||||
{
|
||||
"type": "plot",
|
||||
"left": 16,
|
||||
"top": 41,
|
||||
"width": 541,
|
||||
"height": 220,
|
||||
"points": "multifader_2",
|
||||
"rangeX": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"rangeY": {
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"logScaleX": false,
|
||||
"logScaleY": false,
|
||||
"css": "z-index:1",
|
||||
"label": "There is a transparent multifader above this plot, just touch it... incredible, isn't it ?",
|
||||
"path": "/plot_6",
|
||||
"id": "plot_7"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
1856
examples/widgets.js
Normal file
1856
examples/widgets.js
Normal file
File diff suppressed because it is too large
Load diff
1
index.js
Normal file
1
index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
require(__dirname+'/main/main.js')
|
||||
134
main/callbacks.js
Normal file
134
main/callbacks.js
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
var vm = require('vm')
|
||||
|
||||
module.exports = function(settings,fs,ipc,osc,dialog) {
|
||||
|
||||
return {
|
||||
|
||||
ready: function(data,clientId) {
|
||||
if (settings.read('theme')) ipc.send('applyStyle',settings.read('theme'),clientId)
|
||||
if (settings.read('sessionFile')) this.sessionOpen({path:settings.read('sessionFile')},clientId)
|
||||
var recentSessions = settings.read('recentSessions')
|
||||
ipc.send('sessionList',recentSessions,clientId)
|
||||
},
|
||||
|
||||
sessionBrowse: function(data) {
|
||||
var sessionlist = settings.read('recentSessions'),
|
||||
self = this
|
||||
dialog.showOpenDialog(window,{title:'Load session file',defaultPath:settings.read('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){
|
||||
if (file==undefined) {return}
|
||||
settings.write('sessionPath',file[0].replace(file[0].split('/').pop(),''))
|
||||
self.sessionOpen({path:file[0]})
|
||||
})
|
||||
},
|
||||
|
||||
sessionSave: function(data) {
|
||||
var self = this
|
||||
dialog.showSaveDialog(window,{title:'Save current session',defaultPath:settings.read('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){
|
||||
|
||||
if (file==undefined) {return}
|
||||
settings.write('sessionPath',file.replace(file.split('/').pop(),''))
|
||||
|
||||
if (file.indexOf('.js')==-1){file+='.js'}
|
||||
fs.writeFile(file,data, function (err, data) {
|
||||
if (err) throw err
|
||||
self.sessionAddToHistory(file)
|
||||
console.log('The session was saved in '+file)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
sessionAddToHistory: function(data) {
|
||||
var sessionlist = settings.read('recentSessions')
|
||||
// add session to history
|
||||
sessionlist.unshift(data)
|
||||
// remove doubles from history
|
||||
sessionlist = sessionlist.filter(function(elem, index, self) {
|
||||
return index == self.indexOf(elem)
|
||||
})
|
||||
// save history
|
||||
settings.write('recentSessions',sessionlist)
|
||||
},
|
||||
|
||||
sessionRemoveFromHistory: function(data) {
|
||||
var sessionlist = settings.read('recentSessions')
|
||||
sessionlist.splice(data,1)
|
||||
settings.write('recentSessions',sessionlist)
|
||||
},
|
||||
|
||||
sessionOpen: function(data,clientId) {
|
||||
var file = data.file || (function(){try {return fs.readFileSync(data.path,'utf8')} catch(err) {return false}})(),
|
||||
error = file===false&&data.path?'Session file "' + data.path + '" not found.':false,
|
||||
session
|
||||
|
||||
try {
|
||||
session = vm.runInNewContext(file)
|
||||
} catch(err) {
|
||||
error = err
|
||||
}
|
||||
|
||||
if (!session) error= 'No session object returned'
|
||||
|
||||
if (!error) {
|
||||
if (data.path) this.sessionAddToHistory(data.path)
|
||||
ipc.send('sessionOpen',JSON.stringify(session),clientId)
|
||||
} else {
|
||||
ipc.send('error',{title:'Error: invalid session file',text:'<p>'+error+'</p>'})
|
||||
}
|
||||
},
|
||||
|
||||
sendOsc: function(data) {
|
||||
|
||||
var targets = []
|
||||
|
||||
if (settings.read('syncTargets') && data.sync!==false) Array.prototype.push.apply(targets, settings.read('syncTargets'))
|
||||
if (data.target) Array.prototype.push.apply(targets, data.target)
|
||||
|
||||
|
||||
for (i in targets) {
|
||||
|
||||
var host = targets[i].split(':')[0],
|
||||
port = targets[i].split(':')[1]
|
||||
|
||||
if (port) osc.send(host,port,data.path,data.args,data.precision)
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
stateSave: function(data) {
|
||||
dialog.showSaveDialog(window,{title:'Save current state to preset file',defaultPath:settings.read('presetPath').replace(settings.read('presetPath').split('/').pop(),''),filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){
|
||||
|
||||
if (file==undefined) {return}
|
||||
settings.write('presetPath',file)
|
||||
|
||||
if (file.indexOf('.preset')==-1){file+='.preset'}
|
||||
fs.writeFile(file,data, function (err, data) {
|
||||
if (err) throw err
|
||||
console.log('The current state was saved in '+file)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
stateLoad: function(data,clientId) {
|
||||
dialog.showOpenDialog(window,{title:'Load preset file',defaultPath:settings.read('presetPath').replace(settings.read('presetPath').split('/').pop(),''),filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){
|
||||
|
||||
if (file==undefined) {return}
|
||||
settings.write('presetPath',file[0])
|
||||
|
||||
fs.readFile(file[0],'utf-8', function read(err, data) {
|
||||
if (err) throw err
|
||||
ipc.send('stateLoad',data,clientId)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fullscreen: function(data) {
|
||||
window.setFullScreen(!window.isFullScreen())
|
||||
},
|
||||
|
||||
log: function(data) {
|
||||
console.log(data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
41
main/main.js
Normal file
41
main/main.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
var fs = require('fs'),
|
||||
settings = require('./settings')(fs)
|
||||
|
||||
if (!settings.read('noGui')) {
|
||||
|
||||
var electron = require('electron'),
|
||||
app = electron.app,
|
||||
browserWindow = electron.BrowserWindow,
|
||||
dialog = electron.dialog,
|
||||
ipc = electron.ipcMain
|
||||
|
||||
dialog.showErrorBox = function(title,err) {
|
||||
console.log(title + ': ' + err)
|
||||
}
|
||||
|
||||
app.commandLine.appendSwitch('--enable-touch-events')
|
||||
app.on('window-all-closed', function() {
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('ready',function(){
|
||||
var server = require('./server-electron')(settings,app,ipc,browserWindow),
|
||||
osc = require('./osc')(ipc,settings),
|
||||
callbacks = require('./callbacks')(settings,fs,ipc,osc,dialog)
|
||||
|
||||
|
||||
server.bindCallbacks(callbacks)
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
var server = require('./server-express')(settings),
|
||||
ipc = server.ipc,
|
||||
osc = require('./osc')(ipc,settings),
|
||||
callbacks = require('./callbacks')(settings,fs,ipc,osc,dialog)
|
||||
|
||||
server.bindCallbacks(callbacks)
|
||||
|
||||
}
|
||||
64
main/osc.js
Normal file
64
main/osc.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
var osc = require('node-osc')
|
||||
|
||||
module.exports = function(ipc, settings) {
|
||||
|
||||
var inPort = settings.read('oscInPort'),
|
||||
debug = settings.read('debug')
|
||||
|
||||
if (inPort) {
|
||||
var oscServer = new osc.Server(inPort, '127.0.0.1')
|
||||
|
||||
oscServer.on('message', function (msg, rinfo) {
|
||||
var data = {path:msg.shift(),args:msg}
|
||||
if (data.args.length==1) data.args = data.args[0]
|
||||
ipc.send('receiveOsc',data)
|
||||
if (debug) console.log('OSC received: ',data, 'From : ' + rinfo.address + ':' + rinfo.port)
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
send: function(host,port,path,args,precision) {
|
||||
|
||||
var client = new osc.Client(host, port)
|
||||
|
||||
client._sock.bind({exclusive:false,reuseAddr:true,port:inPort},function(){
|
||||
|
||||
|
||||
var message = new osc.Message(path)
|
||||
|
||||
var numberType = precision==0?'integer':'float'
|
||||
|
||||
if (typeof args=='object' && args!==null) {
|
||||
for (i in args) {
|
||||
var arg = args[i]
|
||||
|
||||
if (typeof arg == 'number' && arg!==null && typeof arg != 'object') {
|
||||
message.append({type:numberType,value:arg})
|
||||
} else if (arg!==null && typeof arg != 'object'){
|
||||
message.append({type:'string',value:String(arg)})
|
||||
} else if (arg!==null && typeof arg == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:arg.type,value:arg.value})
|
||||
}
|
||||
}
|
||||
} else if (args!==null){
|
||||
if (typeof args == 'number') {
|
||||
message.append({type:numberType,value:args})
|
||||
} else if (typeof args == 'object' && arg.type && arg.value!=undefined) {
|
||||
message.append({type:args.type,value:args.value})
|
||||
} else {
|
||||
message.append({type:'string',value:String(args)})
|
||||
}
|
||||
}
|
||||
|
||||
client.send(message, function () {
|
||||
client.kill()
|
||||
})
|
||||
|
||||
if (debug) console.log('OSC sent: ',{path:path,args:message.args}, 'To : ' + host + ':' + port)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
83
main/server-electron.js
Normal file
83
main/server-electron.js
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
var path = require('path')
|
||||
module.exports = function(settings,app,ipc,browserWindow) {
|
||||
|
||||
window = new browserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
icon: path.resolve(__dirname + '/../resources/images/logo.png'),
|
||||
title:settings.read('appName'),
|
||||
backgroundColor:'#1a1d22',
|
||||
autoHideMenuBar:true,
|
||||
// show:false
|
||||
})
|
||||
|
||||
window.loadURL('file://' + __dirname + '/../browser/index.html')
|
||||
|
||||
window.on('closed', function() {
|
||||
window = null
|
||||
})
|
||||
|
||||
window.setMenuBarVisibility(false)
|
||||
|
||||
var Menu = require('electron').Menu
|
||||
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(
|
||||
[
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Restart',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click: function(){
|
||||
window.reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle DevTools',
|
||||
accelerator: 'F12',
|
||||
click: function() { window.toggleDevTools(); }
|
||||
},
|
||||
{
|
||||
label: 'Toggle Fullscreen',
|
||||
accelerator: 'F11',
|
||||
click: function() { window.setFullScreen(!window.isFullScreen()); }
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
))
|
||||
|
||||
// mainProcess > renderProcess ipc shorthand
|
||||
|
||||
ipc.send = function(name,data) {
|
||||
window.webContents.send(name,data)
|
||||
}
|
||||
|
||||
|
||||
// ipc bindings
|
||||
|
||||
var bindCallbacks = function(callbacks) {
|
||||
|
||||
var bindCallback = function(i) {
|
||||
ipc.on(i,function(event,data){
|
||||
callbacks[i](data)
|
||||
})
|
||||
}
|
||||
|
||||
for (i in callbacks) {
|
||||
bindCallback(i)
|
||||
}
|
||||
|
||||
ipc.on('ready',function(){
|
||||
window.show()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
ipc:ipc,
|
||||
bindCallbacks:bindCallbacks
|
||||
}
|
||||
|
||||
}
|
||||
58
main/server-express.js
Normal file
58
main/server-express.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
module.exports = function(settings) {
|
||||
|
||||
// Headless (noGui) mode
|
||||
|
||||
var express = require('express')(),
|
||||
path = require('path'),
|
||||
http = require('http'),
|
||||
server = http.createServer(express),
|
||||
io = require('socket.io')(),
|
||||
ioWildcard = require('socketio-wildcard')(),
|
||||
ipc = {}
|
||||
|
||||
express.get('/', function(req, res){
|
||||
res.sendFile(path.resolve(__dirname + '/../browser/index-headless.html'))
|
||||
})
|
||||
express.get('*', function(req, res){
|
||||
res.sendFile(path.resolve(__dirname + '/../browser' + req.path))
|
||||
})
|
||||
|
||||
|
||||
io.use(ioWildcard)
|
||||
|
||||
|
||||
io.listen(server);
|
||||
|
||||
server.listen(settings.read('noGui'))
|
||||
|
||||
ipc.send = function(name,data,clientId) {
|
||||
if (clientId) {
|
||||
io.to(clientId).emit(name,data)
|
||||
} else {
|
||||
io.emit(name,data)
|
||||
}
|
||||
}
|
||||
|
||||
var bindCallbacks = function(callbacks) {
|
||||
io.on('connection', function(socket) {
|
||||
socket.on('*', function(e){
|
||||
var name = e.data[0],
|
||||
data = e.data[1]
|
||||
if (callbacks[name]) callbacks[name](data,socket.id)
|
||||
if (name=='sendOsc' && data.sync!==false) {
|
||||
// synchronize all other connected clients
|
||||
socket.broadcast.emit('receiveOsc',data)
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
console.log('Headless mode: app available at http://127.0.0.1:'+settings.read('noGui'))
|
||||
|
||||
return {
|
||||
ipc:ipc,
|
||||
bindCallbacks:bindCallbacks
|
||||
}
|
||||
|
||||
}
|
||||
64
main/settings.js
Normal file
64
main/settings.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// This prevents argv parsing to be breaked when the app is packaged (executed without 'electron' prefix)
|
||||
if (process.argv[1]&&process.argv[1].indexOf('-')==0) process.argv.unshift('')
|
||||
|
||||
var baseDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'],
|
||||
configFile = require('path').join(baseDir, '.open-stage-control')
|
||||
|
||||
var argv = require('yargs')
|
||||
.help('help').usage(`\nUsage:\n $0 [options]`).alias('h', 'help')
|
||||
.options({
|
||||
's':{alias:'sync',type:'array',describe:'synchronized hosts (ip:port pairs)'},
|
||||
'l':{alias:'load',type:'string',describe:'session file to load'},
|
||||
'p':{alias:'port',describe:'osc input port (for synchronization)'},
|
||||
'd':{alias:'debug',describe:'log received osc messages in the console'},
|
||||
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
|
||||
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'}
|
||||
})
|
||||
.check(function(a,x){if(a.p==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}})
|
||||
.check(function(a,x){if(a.s==undefined || a.s.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Sync hosts must be ip:port pairs & port must be >= 1024'}})
|
||||
.strict()
|
||||
.argv
|
||||
|
||||
module.exports = function(fs) {
|
||||
var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8'))} catch(err) {return {}}}(),
|
||||
defaultConfig = {
|
||||
presetPath : process.cwd(),
|
||||
sessionPath: process.cwd(),
|
||||
recentSessions: [],
|
||||
|
||||
appName: 'Open Stage Control',
|
||||
syncTargets: argv.s || false,
|
||||
oscInPort: argv.p || 0,
|
||||
debug: argv.d || false,
|
||||
sessionFile: argv.l || false,
|
||||
noGui: argv.n || false,
|
||||
theme: function(){
|
||||
if (!argv.t) return
|
||||
var style = []
|
||||
for (i in argv.t) {
|
||||
try {style.push(fs.readFileSync(__dirname + '/themes/' + argv.t[i] + '.css','utf-8'))}
|
||||
catch(err) {
|
||||
try {style.push(fs.readFileSync(argv.t[i],'utf-8'))}
|
||||
catch(err) {
|
||||
console.log('Theme "' + argv.t[i] + '" not found.')
|
||||
}
|
||||
}
|
||||
}
|
||||
return style
|
||||
}()
|
||||
}
|
||||
return {
|
||||
|
||||
read:function(key){
|
||||
var x = config[key] || defaultConfig[key]
|
||||
return x
|
||||
},
|
||||
write:function(key,value) {
|
||||
config[key] = value
|
||||
fs.writeFile(configFile,JSON.stringify(config,null,4), function (err, data) {
|
||||
if (err) throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
10
main/themes/light.css
Normal file
10
main/themes/light.css
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
:root {
|
||||
--color-text: rgba(0,0,0,0.7);
|
||||
--color-text-fade: rgba(0,0,0,0.5);
|
||||
--color-bg: #aaa;
|
||||
--color-fg: #ddd;
|
||||
--color-raised: #eee;
|
||||
--color-faded: #ccc;
|
||||
--color-track: #aaa;
|
||||
--color-accent: #307aaa;
|
||||
}
|
||||
3
main/themes/noinput.css
Normal file
3
main/themes/noinput.css
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.widget .input {
|
||||
display: none;
|
||||
}
|
||||
9718
package-lock.json
generated
9718
package-lock.json
generated
File diff suppressed because it is too large
Load diff
133
package.json
133
package.json
|
|
@ -1,110 +1,51 @@
|
|||
{
|
||||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.31.2",
|
||||
"description": "A libre desktop OSC bi-directionnal control surface application.",
|
||||
"version": "0.6.2",
|
||||
"main": "index.js",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
"name": "Jean-Emmanuel Doucet / AMMD",
|
||||
"email": "jeannot@ammd.net"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-osc": "2.0.3",
|
||||
"yargs": "5.0.0",
|
||||
"socket.io": "1.4.8",
|
||||
"socket.io-client": "1.4.8",
|
||||
"socketio-wildcard": "0.3.0",
|
||||
"express": "4.14.0",
|
||||
"electron-prebuilt": "1.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "13.1.0",
|
||||
"node-sass": "^3.7.0",
|
||||
"nodemon": "^1.9.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron-installer-debian": "0.3.1",
|
||||
"electron-packager": "8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"build": "electron-packager . open-stage-control --platform=$PLATFORM --arch=$ARCH --out dist/ --icon=resources/images/logo --overwrite --ignore \"(dist|node_modules/electron.*)\"",
|
||||
"deb32": "electron-installer-debian --src dist/open-stage-control-linux-ia32/ --arch i386 --dest dist/open-stage-control-linux-ia32/ --icon resources/images/logo.png",
|
||||
"deb64": "electron-installer-debian --src dist/open-stage-control-linux-x64/ --arch amd64 --dest dist/open-stage-control-linux-x64/ --icon resources/images/logo.png",
|
||||
"debarm": "electron-installer-debian --src dist/open-stage-control-linux-armv7l/ --arch armv7l --dest dist/open-stage-control-linux-armv7l/ --icon resources/images/logo.png",
|
||||
"test": "npm run build",
|
||||
"build-css": "node-sass --include-path browser/scss browser/scss/style.scss browser/css/style.css --output-style compressed",
|
||||
"watch-css": "nodemon --watch browser/scss -e scss -x \"npm run build-css\"",
|
||||
"build-js": "browserify browser/js/browser-headless.js -o browser/js/browser-headless.bundle.js",
|
||||
"watch-js": "nodemon --watch browser/js -e js --ignore browser/js/browser-headless.bundle.js -x \"npm run build-js\""
|
||||
},
|
||||
"keywords": [
|
||||
"osc",
|
||||
"midi",
|
||||
"interface",
|
||||
"multi-touch"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://framagit.org/jean-emmanuel/open-stage-control"
|
||||
"url": "https://github.com/jean-emmanuel/open-stage-control"
|
||||
},
|
||||
"homepage": "http://openstagecontrol.ammd.net/",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@babel/core": "7.18.0",
|
||||
"@babel/preset-env": "7.18.0",
|
||||
"@electron/packager": "18.4.4",
|
||||
"@electron/remote": "2.1.3",
|
||||
"@rollup/plugin-babel": "^6.0.4",
|
||||
"@rollup/plugin-commonjs": "^28.0.6",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"ace-builds": "1.39.0",
|
||||
"ansi-html": "0.0.9",
|
||||
"babelify": "10.0.0",
|
||||
"balanced-match": "2.0.0",
|
||||
"bonjour": "git+https://framagit.org/jean-emmanuel/bonjour.git",
|
||||
"chokidar": "3.5.3",
|
||||
"chroma-js": "2.4.2",
|
||||
"core-js": "3.22.5",
|
||||
"cpr": "3.0.1",
|
||||
"deep-extend": "0.6.0",
|
||||
"electron-localshortcut": "3.2.1",
|
||||
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "1.0.2",
|
||||
"env-paths": "2.2.1",
|
||||
"eslint": "8.16.0",
|
||||
"fastdom": "1.0.10",
|
||||
"file-saver": "2.0.5",
|
||||
"http-auth": "4.1.9",
|
||||
"json5": "2.2.1",
|
||||
"jsondiffpatch": "0.4.1",
|
||||
"keyboardjs": "2.6.4",
|
||||
"minimatch": "5.1.0",
|
||||
"nanohtml": "1.10.0",
|
||||
"nanoid": "3.3.4",
|
||||
"nanomorph": "5.4.3",
|
||||
"node-forge": "1.3.1",
|
||||
"node-mouse": "0.0.2",
|
||||
"nodemon": "2.0.16",
|
||||
"nosleep.js": "0.12.0",
|
||||
"open": "8.4.0",
|
||||
"osc": "2.4.5",
|
||||
"python-shell": "3.0.1",
|
||||
"qrcode": "1.5.1",
|
||||
"replacestream": "4.0.3",
|
||||
"rollup": "4.50.1",
|
||||
"rollup-plugin-copy": "3.5.0",
|
||||
"rollup-plugin-license": "^3.6.0",
|
||||
"rollup-plugin-node-externals": "^8.1.1",
|
||||
"sass": "1.89.2",
|
||||
"scope-css": "1.2.1",
|
||||
"screenfull": "5.2.0",
|
||||
"semver": "7.3.7",
|
||||
"send": "0.18.0",
|
||||
"sortablejs": "1.15.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"stacktrace-js": "2.0.2",
|
||||
"ua-parser-js": "2.0.7",
|
||||
"ws": "8.6.0",
|
||||
"yargs": "17.5.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron": "36.9.5",
|
||||
"electron-installer-debian": "3.1.0",
|
||||
"electron-installer-redhat": "git+https://framagit.org/jean-emmanuel/electron-installer-redhat.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "echo '\\033[36m=> Dependencies installed successfully. Run \"npm run build\" to build the assets.\\033[0m\n'",
|
||||
"start": "electron app/",
|
||||
"build": "npm run build-css && npm run build-js && echo '\\033[36m=> JS and CSS assets built successfully. Run \"npm run package\" to build an executable or \"npm start\" to run the app.\\033[0m\n'",
|
||||
"package": "node scripts/package.js",
|
||||
"package-node": "node scripts/package-node.js",
|
||||
"deb64": "electron-installer-debian --src dist/open-stage-control-linux-x64/ --arch amd64 --dest dist/ --icon resources/images/logo.png",
|
||||
"rpm64": "electron-installer-redhat --src dist/open-stage-control-linux-x64/ --arch x86_64 --dest dist/ --icon resources/images/logo.png",
|
||||
"build-css": "node scripts/build-css.js",
|
||||
"watch-css": "nodemon --watch src/scss -e scss -x \"npm run build-css -- --reload\"",
|
||||
"build-js": "npm run build-launcher-js && npm run build-client-js && npm run build-server-js",
|
||||
"build-client-js": "rollup -c scripts/client.rollup.config.js",
|
||||
"watch-client": "npm run build-client-js -- --watch",
|
||||
"build-server-js": "rollup -c scripts/server.rollup.config.js",
|
||||
"watch-server": "npm run build-server-js -- --watch",
|
||||
"build-launcher-js": "rollup -c scripts/launcher.rollup.config.js",
|
||||
"watch-launcher": "npm run build-launcher-js -- --watch",
|
||||
"build-docs": "rollup -c scripts/docs.rollup.config.js && node src/docs/widgets-reference.js > resources/docs/docs/widgets/properties-reference.md && cd resources && python3 -m mkdocs build",
|
||||
"lint": "eslint src --ext mjs",
|
||||
"test": "npm run lint && npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
"licence": "GPL-3.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# How to build the docs
|
||||
|
||||
```bash
|
||||
# https://squidfunk.github.io/mkdocs-material/getting-started/
|
||||
$ python3 -m pip install mkdocs-material
|
||||
|
||||
$ sudo apt-get install python python-pip # python package manager
|
||||
$ sudo pip install mkdocs # docs site builder
|
||||
$ sudo pip install mkdocs-cinder # theme
|
||||
|
||||
$ mkdocs serve # make docs available on http://127.0.0.1:8000
|
||||
# or
|
||||
$ mkdocs build # build docs in site/
|
||||
$ mkdocs build # build docs static site
|
||||
$ mkdocs gh-deploy --clean # deploy static site on gh-pages branch
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,898 +0,0 @@
|
|||
[
|
||||
[
|
||||
"greeter_text",
|
||||
"Ardour Control"
|
||||
],
|
||||
[
|
||||
"osc_logo",
|
||||
"/assets/favicon.png"
|
||||
],
|
||||
[
|
||||
"strip_type_1",
|
||||
1
|
||||
],
|
||||
[
|
||||
"strip_type_2",
|
||||
2
|
||||
],
|
||||
[
|
||||
"strip_type_3",
|
||||
4
|
||||
],
|
||||
[
|
||||
"strip_type_4",
|
||||
8
|
||||
],
|
||||
[
|
||||
"strip_type_5",
|
||||
16
|
||||
],
|
||||
[
|
||||
"strip_type_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"strip_type_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"strip_type_8",
|
||||
128
|
||||
],
|
||||
[
|
||||
"strip_type_9",
|
||||
0
|
||||
],
|
||||
[
|
||||
"strip_type_10",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trip_type_bitsum",
|
||||
159
|
||||
],
|
||||
[
|
||||
"bank_size",
|
||||
8
|
||||
],
|
||||
[
|
||||
"display_session_name",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_transport",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_monitor",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_trim",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_recbar",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_input",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_pan",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_expand",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_compact_faders",
|
||||
0
|
||||
],
|
||||
[
|
||||
"display_polarity_sel",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_trim_sel",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_recbar_sel",
|
||||
1
|
||||
],
|
||||
[
|
||||
"display_pan_sel",
|
||||
1
|
||||
],
|
||||
[
|
||||
"spacer",
|
||||
-1
|
||||
],
|
||||
[
|
||||
"connect",
|
||||
0
|
||||
],
|
||||
[
|
||||
"loading",
|
||||
"<div class=\"spinner\"></div>"
|
||||
],
|
||||
[
|
||||
"hidden_utils",
|
||||
-1
|
||||
],
|
||||
[
|
||||
"settings_tab",
|
||||
-1
|
||||
],
|
||||
[
|
||||
"sess_name",
|
||||
" "
|
||||
],
|
||||
[
|
||||
"shttl",
|
||||
0
|
||||
],
|
||||
[
|
||||
"zero",
|
||||
0
|
||||
],
|
||||
[
|
||||
"end",
|
||||
0
|
||||
],
|
||||
[
|
||||
"play",
|
||||
0
|
||||
],
|
||||
[
|
||||
"transport_stop",
|
||||
0
|
||||
],
|
||||
[
|
||||
"masterrec",
|
||||
0
|
||||
],
|
||||
[
|
||||
"time",
|
||||
"00:00:00:00"
|
||||
],
|
||||
[
|
||||
"chan_1",
|
||||
1
|
||||
],
|
||||
[
|
||||
"trim_label_1",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_1",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_1",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_1",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_2",
|
||||
2
|
||||
],
|
||||
[
|
||||
"trim_label_2",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_2",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_2",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_2",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_3",
|
||||
3
|
||||
],
|
||||
[
|
||||
"trim_label_3",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_3",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_3",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_3",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_4",
|
||||
4
|
||||
],
|
||||
[
|
||||
"trim_label_4",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_4",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_4",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_4",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_5",
|
||||
5
|
||||
],
|
||||
[
|
||||
"trim_label_5",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_5",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_5",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_5",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_6",
|
||||
6
|
||||
],
|
||||
[
|
||||
"trim_label_6",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"trim_knob_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_6",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_6",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_label",
|
||||
"Master"
|
||||
],
|
||||
[
|
||||
"mastertrim_label",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"mastertrim_input",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mastertrim",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monitor",
|
||||
-200
|
||||
],
|
||||
[
|
||||
"monmute",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mondim",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monmono",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monitor_modal",
|
||||
0
|
||||
],
|
||||
[
|
||||
"Master_meter",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"Master",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_input",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_pan",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mastermute",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solocan",
|
||||
0
|
||||
],
|
||||
[
|
||||
"bank_dn",
|
||||
0
|
||||
],
|
||||
[
|
||||
"bank_up",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mixer_tab",
|
||||
-1
|
||||
],
|
||||
[
|
||||
"sess_name",
|
||||
" "
|
||||
],
|
||||
[
|
||||
"shttl",
|
||||
0
|
||||
],
|
||||
[
|
||||
"zero",
|
||||
0
|
||||
],
|
||||
[
|
||||
"end",
|
||||
0
|
||||
],
|
||||
[
|
||||
"play",
|
||||
0
|
||||
],
|
||||
[
|
||||
"transport_stop",
|
||||
0
|
||||
],
|
||||
[
|
||||
"masterrec",
|
||||
0
|
||||
],
|
||||
[
|
||||
"time",
|
||||
"00:00:00:00"
|
||||
],
|
||||
[
|
||||
"select_name",
|
||||
" sel"
|
||||
],
|
||||
[
|
||||
"select_trim_label",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"select_trim_input",
|
||||
0
|
||||
],
|
||||
[
|
||||
"select_trim_knob",
|
||||
0
|
||||
],
|
||||
[
|
||||
"polarity_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"receives_panel",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sends_panel",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_select",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_select",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_select",
|
||||
0
|
||||
],
|
||||
[
|
||||
"text_1",
|
||||
"Plugins"
|
||||
],
|
||||
[
|
||||
"push_6",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_label",
|
||||
"Master"
|
||||
],
|
||||
[
|
||||
"mastertrim_label",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"mastertrim_input",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mastertrim",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monitor",
|
||||
-200
|
||||
],
|
||||
[
|
||||
"monmute",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mondim",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monmono",
|
||||
0
|
||||
],
|
||||
[
|
||||
"monitor_modal",
|
||||
0
|
||||
],
|
||||
[
|
||||
"Master_meter",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"Master",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_input",
|
||||
0
|
||||
],
|
||||
[
|
||||
"master_pan",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mastermute",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solocan",
|
||||
0
|
||||
],
|
||||
[
|
||||
"bank_dn",
|
||||
0
|
||||
],
|
||||
[
|
||||
"bank_up",
|
||||
0
|
||||
],
|
||||
[
|
||||
"track_tab",
|
||||
-1
|
||||
],
|
||||
[
|
||||
"root",
|
||||
1
|
||||
],
|
||||
[
|
||||
"chan_7",
|
||||
7
|
||||
],
|
||||
[
|
||||
"trim_label_7",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_7",
|
||||
""
|
||||
],
|
||||
[
|
||||
"trim_knob_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_7",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_7",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_7",
|
||||
0
|
||||
],
|
||||
[
|
||||
"chan_8",
|
||||
8
|
||||
],
|
||||
[
|
||||
"trim_label_8",
|
||||
"Trim"
|
||||
],
|
||||
[
|
||||
"trim_input_8",
|
||||
""
|
||||
],
|
||||
[
|
||||
"trim_knob_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"record_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"mon_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"disk_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"meter_8",
|
||||
-193
|
||||
],
|
||||
[
|
||||
"fader_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"fader_input_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"pan_8",
|
||||
0.5
|
||||
],
|
||||
[
|
||||
"mute_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"solo_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"sel_8",
|
||||
0
|
||||
],
|
||||
[
|
||||
"expand_8",
|
||||
0
|
||||
]
|
||||
]
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../../CHANGELOG.md
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
Client options can be set either with the server's `--client-options` option, or per client by adding query parameters to the server's url. One must prepend the url with a question mark (`?`) followed by `parameter=value` pairs separated with ampersands (`&`).
|
||||
|
||||
|
||||
| Option | Value | Default | Description |
|
||||
|----|----|----|----|
|
||||
| hdpi | 1 / 0 | 0 | enable high resolution canvas |
|
||||
| forceHdpi | number | 0 | force canvas scaling (ignore `hdpi`) |
|
||||
| doubleTap | number | 375 | sets the double tap/click time threshold in milliseconds |
|
||||
| zoom | number | 1 | sets the initial zoom |
|
||||
| framerate | number | 60 | limit canvas drawing framerate |
|
||||
| desyncCanvas | number | 0 | set to 1 to enable desynchronized canvas (may improve rendering performances) |
|
||||
| lang | string | *system_default* | use a different language than the default if available (available languages: en, fr, de, pl) |
|
||||
| consoleLength | number | 300 | sets the maximum number of log messages in the client's console |
|
||||
| id | string | *random_id* | client's unique id (use with caution: two clients should never have the same id) |
|
||||
| usePercents | 1 / 0 | 0 | sets the editor's "relative units" option |
|
||||
| noFocus | 1 / 0 | 0 | (built-in client only) prevent the client window from taking focus |
|
||||
| clientSync | 1 / 0 | 1 | set to 0 to prevent the client from syncing with other clients |
|
||||
| altTraversing | 1 / 0 | 0 | set to 1 to enable an alternative traversing behavior for toggle buttons (traversing gestures on toggle buttons will change their values in only one way depending on the first touched button's state) |
|
||||
| virtualKeyboard | 1 / 0 | 0 | (desktop only) set to 1 to enable the virtual keyboard by default |
|
||||
| notifications | 1 / 0 | 1 | set to 0 to hide notifications by default |
|
||||
| title | string | '' | replace window title |
|
||||
| noWarning | 1 / 0 | 0 | set to 0 to disable unsaved session warnings |
|
||||
|
||||
Example:
|
||||
|
||||
`http://server-ip:port?hdpi=1`
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
## License
|
||||
|
||||
Copyleft © Jean-Emmanuel Doucet 2014-2025.
|
||||
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
|
||||
|
||||
## Dependencies
|
||||
|
||||
Open Stage Control relies on several other free softwares listed in [package.json](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/package.json).
|
||||
|
||||
The default theme was based on [Nord](https://www.nordtheme.com/), some UI components were inspired by the text editor formerly known as Atom (now [Pulsar](https://pulsar-edit.dev/)).
|
||||
|
||||
## Contributors
|
||||
|
||||
[Jean-Emmanuel](https://framagit.org/jean-emmanuel), [MartinHN](https://github.com/MartinHN), [Eric Theise](https://github.com/erictheise), [danielappelt](https://github.com/erictheise), [ritschwumm](https://github.com/ritschwumm), [matthijskooijman](https://github.com/matthijskooijman), [WillyKaze](https://github.com/WillyKaze), [stefanboca](https://github.com/stefanboca), [pixelnerve](https://github.com/pixelnerve), [AdamAdamsMusic](https://github.com/AdamAdamsMusic), [wicast](https://github.com/wicast), [kdallafior](https://github.com/kdallafior), [brunetton](https://github.com/brunetton), [cyberic99](https://github.com/cyberic99), [kdejaeger](https://github.com/kdejaeger), [trebmuh](https://github.com/trebmuh), [MagnusReichel](https://github.com/MagnusReichel), [jpcima](https://github.com/jpcima), [t1st3](https://github.com/t1st3")
|
||||
|
||||
## Infrastructure supports
|
||||
|
||||
----
|
||||
|
||||
<a href="https://ammd.net/" class="sp-logo">
|
||||
<img src="/img/sponsors/ammd.png" width="140px"/>
|
||||
</a>
|
||||
|
||||
AMMD hosts this website and made this project possible by funding its first 2 years of development.
|
||||
|
||||
----
|
||||
|
||||
<a href="https://discourse.org/" class="sp-logo">
|
||||
<img src="/img/sponsors/discourse.png" width="140px"/>
|
||||
</a>
|
||||
|
||||
Discourse provides the community forum.
|
||||
|
||||
----
|
||||
|
||||
<a href="https://browserstack.com/" class="sp-logo">
|
||||
<img src="/img/sponsors/browserstack.png" width="140px"/>
|
||||
</a>
|
||||
|
||||
BrowserStack provides remote browsers for debugging.
|
||||
|
|
@ -1,220 +0,0 @@
|
|||
# Custom module
|
||||
|
||||
Using the server's `custom-module` option, users can load a custom javascript module that filters incoming and outgoing OSC / MIDI messages.
|
||||
|
||||
## Writing a custom module
|
||||
|
||||
|
||||
```js
|
||||
|
||||
// Do whatever you want
|
||||
// initialize variables
|
||||
// declare functions
|
||||
// listen to app events
|
||||
// load modules
|
||||
// etc
|
||||
|
||||
module.exports = {
|
||||
|
||||
init: function(){
|
||||
// this will be executed once when the osc server starts after
|
||||
// connections are set up
|
||||
// it is called for the main module only
|
||||
},
|
||||
|
||||
stop: function(){
|
||||
// this will be executed once when the osc server stops
|
||||
// it is called for the main module only
|
||||
},
|
||||
|
||||
reload: function(){
|
||||
// this will be executed after the custom module is reloaded
|
||||
// it is called for the main module only
|
||||
},
|
||||
|
||||
oscInFilter:function(data){
|
||||
// Filter incoming osc messages
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
// do what you want
|
||||
|
||||
// address = string
|
||||
// args = array of {value, type} objects
|
||||
// host = string
|
||||
// port = integer
|
||||
|
||||
// return data if you want the message to be processed
|
||||
return {address, args, host, port}
|
||||
|
||||
},
|
||||
|
||||
oscOutFilter:function(data){
|
||||
// Filter outgoing osc messages
|
||||
|
||||
var {address, args, host, port, clientId} = data
|
||||
|
||||
// same as oscInFilter
|
||||
|
||||
// return data if you want the message to be and sent
|
||||
return {address, args, host, port}
|
||||
},
|
||||
|
||||
unload: function(){
|
||||
// this will be executed before the custom module is reloaded
|
||||
// it is called for all modules, including other loaded modules
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Available globals
|
||||
|
||||
The module is executed in a restricted context, only a few globals are available :
|
||||
|
||||
----
|
||||
|
||||
#### `app`
|
||||
[`Event Emitter`](https://nodejs.org/api/events.html#events_class_eventemitter), useful for monitoring the events sent by the different clients. Event names can be found in [callbacks.js](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/ipc/callbacks.mjs), callbacks are called with 2 arguments: `data` (object) and `client` (object: `{address, id}`)
|
||||
|
||||
----
|
||||
|
||||
#### `receive(host, port, address, ...args, options)`
|
||||
|
||||
Send osc/midi message to connected clients. `host` and `port` can be specified to simulate a specific origin for the message.
|
||||
|
||||
- `host` (optional): `string` ip address, valid hostname or `"midi"`
|
||||
- `port` (optional): `integer` port number or `string` midi device name
|
||||
- `address`: osc address
|
||||
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object` (objects that don't match this format will simply be turned to a JSON string).
|
||||
- `options` (optional): set to `{clientId: id}` to define which client receives the message (where `id` is the client's id as retrieved from `app` events or `oscOutFilter`)
|
||||
|
||||
For convenience, `host` and `port` can be provided both as single string argument joined with a colon.
|
||||
|
||||
----
|
||||
|
||||
#### `send(host, port, address, ...args)`
|
||||
|
||||
Send osc/midi to a target (see `receive()`).
|
||||
|
||||
----
|
||||
|
||||
#### `settings.read(name)`
|
||||
|
||||
Returns specified server option. `name` must be the option's long name without the leading dashes (ie: `"send"`, not `"s"`)
|
||||
|
||||
----
|
||||
|
||||
#### `settings.appAddresses()`
|
||||
|
||||
Returns the server's http addresses.
|
||||
|
||||
----
|
||||
|
||||
#### `loadJSON(path, errorCallback)`
|
||||
|
||||
Loads a json file (path is relative to the custom module location)
|
||||
|
||||
- `path`: `string`, path to file (any extension allowed, but the content must be valid JSON)
|
||||
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `saveJSON(path, data, errorCallback)`
|
||||
|
||||
Saves an object/array to a json file (path is relative to the custom module location)
|
||||
|
||||
- `path`: `string`, path to file (any extension allowed)
|
||||
- `data`: `object`, `array` or any value that can be encoded to JSON
|
||||
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
|
||||
|
||||
----
|
||||
|
||||
#### `require(path)`
|
||||
|
||||
Load another javascript module. Returns the value of `module.exports` defined in this module. If `path` is a relative path, it will be resolved against its parent module's path. See [Managing Big Modules](../managing-big-modules).
|
||||
|
||||
This function is different from node's native `require` function, it's merely a way to split a custom module into separate files.
|
||||
|
||||
----
|
||||
|
||||
#### `nativeRequire(moduleName)`
|
||||
|
||||
This function can be used to load native node modules or locally installed modules (e.g. with npm) if a `node_modules` folder is found in the custom module's location.
|
||||
|
||||
??? "Installing node modules: resources"
|
||||
- https://nodejs.dev/
|
||||
- https://nodejs.dev/learn/an-introduction-to-the-npm-package-manager
|
||||
- https://nodejs.dev/learn/the-package-json-guide
|
||||
|
||||
----
|
||||
|
||||
#### `tcpServer`
|
||||
|
||||
Raw access to the server's [TCP backend](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/osc/tcp.mjs). Can be used to monitor the state of TCP connections:
|
||||
|
||||
```js
|
||||
for (var ip in tcpServer.clients) {
|
||||
tcpServer.clients[ip].port.on('ready', ()=>{
|
||||
console.log(`TCP connection established with ${ip}:${tcpServer.clients[ip].remotePort}`)
|
||||
})
|
||||
tcpServer.clients[ip].port.on('close', ()=>{
|
||||
console.log(`TCP connection lost with ${ip}:${tcpServer.clients[ip].remotePort}`)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### `restartMidiBackend()`
|
||||
|
||||
This function can be used to restart the midi backend (if already running) without restarting the server
|
||||
|
||||
#### Other javascript globals
|
||||
|
||||
- `console`
|
||||
- `setTimeout`
|
||||
- `clearTimeout`
|
||||
- `setInterval`
|
||||
- `clearInterval`
|
||||
- `__dirname`
|
||||
- `__filename`
|
||||
- `process`
|
||||
- `global`
|
||||
|
||||
----
|
||||
|
||||
|
||||
## Autoreload
|
||||
|
||||
Custom modules (including submodules loaded with `require()`) are reloaded automatically when they are modified. Upon reload, timers (`setTimeout` and `setInterval`) and event listeners (added to the `app` object) are reset. After each reload the `module.exports.reload()` function (if any) is called.
|
||||
|
||||
The `global` object persists accross reloads.
|
||||
|
||||
??? "Reloading native modules"
|
||||
|
||||
When using modules loaded with `nativeRequire()`, you may need to tell the custom module how to unload some components to allow reloading using the `module.exports.unload` definition. For example, if a port is bound using the `http` module, you'll need to unbind it otherwise the custom module will fail to bind it again when reloading:
|
||||
|
||||
```js
|
||||
|
||||
var http = nativeRequire('http'),
|
||||
server = http.createServer((req, res)=>{
|
||||
res.writeHead(200)
|
||||
res.end('Hello world')
|
||||
})
|
||||
|
||||
server.listen(5555, 'localhost')
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
unload: function() {
|
||||
|
||||
server.close()
|
||||
// otherwise you'd get "Error: listen EADDRINUSE: address already in use 127.0.0.1:5555"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue