Compare commits
No commits in common. "master" and "v0.2.0" have entirely different histories.
339 changed files with 12171 additions and 52251 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
|
||||
|
|
|
|||
30
.travis.yml
Normal file
30
.travis.yml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "4.1"
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- wine
|
||||
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-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
|
||||
- cd ..
|
||||
- npm run deb32
|
||||
- npm run deb64
|
||||
- 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
|
||||
|
|
@ -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.
|
||||
1778
CHANGELOG.md
1778
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
|
||||
79
README.md
79
README.md
|
|
@ -1,21 +1,76 @@
|
|||
<img src="resources/images/logo.png" alt="Open Stage Control" height="50px"/>
|
||||
[](https://travis-ci.org/jean-emmanuel/Open-Stage-Control)
|
||||
|
||||
Open Stage Control
|
||||
## Open Stage Control
|
||||
|
||||
*Libre and modular OSC / MIDI controller*
|
||||
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.
|
||||
|
||||
### Demo
|
||||
|
||||
You can try the app here http://openstagecontrol.herokuapp.com/
|
||||
|
||||
Please note that :
|
||||
- Chrome 47 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 from 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
|
||||
- light & dark themes !
|
||||
|
||||
----
|
||||
### Getting started
|
||||
|
||||
Docker additions by Rik Berkelder.
|
||||
Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page. If you want to build or run the app from sources, here's how to:
|
||||
- [Build from sources](resources/docs/build-from-sources.md)
|
||||
- [Run from sources](resources/docs/run-from-sources.md)
|
||||
|
||||
mount `/sessions` directory. default session file is created and loaded there.
|
||||
**Command line switches**
|
||||
```
|
||||
Options:
|
||||
-h, --help display help
|
||||
-s, --sync synchronized hosts (ip:port pairs) (all osc messages will also be sent to these)
|
||||
-c, --compile recompile stylesheets (increases startup time), if 'light' is specified, the light theme will be compiled, otherwise, the default dark theme will be compiled.
|
||||
-l, --load session file to load
|
||||
-p, --port osc input port (for synchronization)
|
||||
-n, --nogui disable default gui and makes the app availabe through http on specified port
|
||||
|
||||
---
|
||||
Exemples :
|
||||
|
||||
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.
|
||||
$ open-stage-control -s 127.0.0.1:5555 127.0.0.1:6666 -p 7777
|
||||
|
||||
This will create an app listening on port 7777 for synchronization messages, and sending its widgets state changes to ports 5555 and 6666.
|
||||
|
||||
$ open-stage-control -n 8080 -l path/to/session.js
|
||||
|
||||
This will create a headless app available through http on port 8080. Multiple clients can use the app (with chrome only) simultaneously, their widgets will be synchronized.
|
||||
|
||||
```
|
||||
|
||||
### Advanced usage
|
||||
|
||||
Although the built-in editor might suits most of your needs while creating small control interfaces, you may need to write the session file yourself to create large and maintainable interfaces. The followings docs will help:
|
||||
- [Session reference](resources/docs/session-reference.md)
|
||||
- [Widgets reference](resources/docs/widgets-reference.md)
|
||||
|
||||
### 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]()
|
||||
- [browserify]()
|
||||
- [express]()
|
||||
- [Sass.js](https://github.com/medialize/sass.js/)
|
||||
- [jQuery](http://jquery.com/)
|
||||
- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
|
||||
- [Font Awesome](http://fontawesome.io/)
|
||||
|
||||
Design was heavily inspired by [Atom](https://atom.io/)'s theme 'One Dark'
|
||||
|
|
|
|||
|
|
@ -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
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.
16
browser/index-headless.html
Normal file
16
browser/index-headless.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!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="css/style.css"/>
|
||||
<script src="/js/browser-headless.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="lobby"></div>
|
||||
<div id="container"></div>
|
||||
<div id="sidepanel"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
18
browser/index.html
Normal file
18
browser/index.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!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="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>
|
||||
40
browser/js/app.js
Normal file
40
browser/js/app.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
///////////////////////
|
||||
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_ID_BY_PATH = {}
|
||||
SESSION = []
|
||||
CLIPBOARD = null
|
||||
EDITING = false
|
||||
|
||||
MISC = {
|
||||
iterators: {
|
||||
widget:{},
|
||||
tab:{}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
|
||||
$ = 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')
|
||||
173
browser/js/app/actions.js
Normal file
173
browser/js/app/actions.js
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
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 = module.exports.stateGet()
|
||||
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 = []
|
||||
$.each(WIDGETS,function(i,widget) {
|
||||
var v = widget[widget.length-1].getValue()
|
||||
if (v!=undefined) data.push(i+' '+v)
|
||||
})
|
||||
return data.join('\n')
|
||||
},
|
||||
|
||||
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(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){
|
||||
|
||||
$.each(preset.split('\n'),function(i,d) {
|
||||
var data = d.split(' ')
|
||||
|
||||
setTimeout(function(){
|
||||
if (WIDGETS[data[0]]!=undefined) {
|
||||
WIDGETS[data[0]][WIDGETS[data[0]].length-1].setValue(data[1].split(','),send,true)
|
||||
}
|
||||
},i)
|
||||
})
|
||||
},
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
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).unbind('keydown.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
|
||||
},
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
85
browser/js/app/callbacks.js
Normal file
85
browser/js/app/callbacks.js
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
var init = require('./init'),
|
||||
actions = require('./actions'),
|
||||
utils = require('./utils'),
|
||||
icon = utils.icon
|
||||
|
||||
module.exports = {
|
||||
|
||||
receiveOsc: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
// fetch id
|
||||
var path = data.path
|
||||
var id = WIDGETS_ID_BY_PATH[path]
|
||||
|
||||
// update
|
||||
if (WIDGETS[id]!=undefined) {
|
||||
for (i in WIDGETS[id]){
|
||||
WIDGETS[id][i].setValue(data.args,false,false)
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
stateLoad: function(event,data){
|
||||
var data = data || event
|
||||
actions.stateSet(data,true)
|
||||
actions.stateQuickSave(data)
|
||||
},
|
||||
|
||||
sessionList: function(event,data){
|
||||
var data = data || event
|
||||
$('#lobby').append('\
|
||||
<div class="main">\
|
||||
<div class="header">\
|
||||
Session selection\
|
||||
</div>\
|
||||
<div class="list"></div>\
|
||||
</div>')
|
||||
|
||||
for (i in data) {
|
||||
$('#lobby .list').append('<li><a class="btn load" data-session="'+data[i]+'">'+data[i]+'<span>'+icon('remove')+'</span></a></li>')
|
||||
}
|
||||
$('#lobby .list').append('<a class="btn browse">...</a>')
|
||||
$('#lobby .list').append('<a class="btn new">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('li').hide()
|
||||
})
|
||||
$('#lobby .browse').click(function(e){
|
||||
e.stopPropagation()
|
||||
actions.sessionBrowse()
|
||||
})
|
||||
$('#lobby .new').click(function(e){
|
||||
e.stopPropagation()
|
||||
$('#lobby').remove()
|
||||
setTimeout(function(){
|
||||
init([{}],function(){$('#open-toggle, .enable-editor, .editor-root').click()})
|
||||
},25)
|
||||
})
|
||||
},
|
||||
|
||||
sessionOpen: function(event,data){
|
||||
var data = data || event
|
||||
var session = JSON.parse(data)
|
||||
|
||||
$('#lobby').remove()
|
||||
$('#container').empty().append('<div id="loading"><div class="spinner"></div></div>')
|
||||
setTimeout(function(){
|
||||
init(session,function(){$('#loading').hide()})
|
||||
},25)
|
||||
|
||||
},
|
||||
|
||||
error: function(event,data){
|
||||
var data = data || event
|
||||
|
||||
utils.createPopup(icon('warning')+' '+data.title,data.text)
|
||||
}
|
||||
|
||||
}
|
||||
56
browser/js/app/editor/context-menu.js
Normal file
56
browser/js/app/editor/context-menu.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
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 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('touchstart mousedown',function(e){e.stopPropagation()})
|
||||
menu(e,actions[label],item)
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$(`<div class="item">${label}</div>`).on('mousedown.editor touchstart.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
|
||||
94
browser/js/app/editor/data-workers.js
Normal file
94
browser/js/app/editor/data-workers.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
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)}
|
||||
|
||||
|
||||
var getObjectData = function(obj){
|
||||
var path = []
|
||||
|
||||
do {
|
||||
if (obj[0].classList.contains('widget')) {
|
||||
path.unshift(obj.index())
|
||||
path.unshift('widgets')
|
||||
} else if (obj[0].classList.contains('tab')){
|
||||
path.unshift(obj.index())
|
||||
path.unshift('tabs')
|
||||
} else if (obj[0].getAttribute('id')=='container') {
|
||||
break
|
||||
}
|
||||
|
||||
} while(obj = obj.parent() )
|
||||
|
||||
path.splice(0,1)
|
||||
|
||||
for (var i=0,obj=SESSION, path=path, len=path.length; i<len; i++){
|
||||
obj = obj[path[i]]
|
||||
}
|
||||
|
||||
return obj
|
||||
|
||||
}
|
||||
|
||||
var updateDom = function(container,data) {
|
||||
|
||||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
state = actions.stateGet()
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
||||
$(`a[data-tab="#${container.attr('id')}"]`).html(`<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()
|
||||
|
||||
}
|
||||
|
||||
|
||||
// restore state
|
||||
|
||||
actions.stateSet(state,false)
|
||||
sync()
|
||||
ui.tabs()
|
||||
ui.scrolls()
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
|
||||
// return updated node
|
||||
return newContainer
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateDom:updateDom,
|
||||
getObjectData:getObjectData
|
||||
}
|
||||
290
browser/js/app/editor/edit-objects.js
Normal file
290
browser/js/app/editor/edit-objects.js
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
|
||||
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')
|
||||
|
||||
if (isWidget) {
|
||||
$(container).addClass('editing')
|
||||
} else {
|
||||
$(`a[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],
|
||||
label = $(`<label>${i}</label>`).appendTo(form),
|
||||
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(form)
|
||||
|
||||
} 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(form)
|
||||
|
||||
} else {
|
||||
|
||||
input = $(`<input data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
|
||||
input.on('change',function(){
|
||||
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
|
||||
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):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>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.widget').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
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(form)
|
||||
list.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
// tab list edit
|
||||
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
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(form)
|
||||
list.appendTo(form)
|
||||
}
|
||||
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
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)
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)
|
||||
updateDom(container,data)
|
||||
},
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5
|
||||
})
|
||||
}
|
||||
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
if (data.hasOwnProperty('top')) {
|
||||
container.draggable({
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = ui.helper.position().top + container.parent().scrollTop()
|
||||
data.left = ui.helper.position().left + container.parent().scrollLeft()
|
||||
ui.helper.remove()
|
||||
updateDom(container,data)
|
||||
},
|
||||
handle:'.ui-draggable-handle',
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
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
|
||||
|
||||
$('.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>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
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(form)
|
||||
list.appendTo(form)
|
||||
|
||||
|
||||
$('.editor-container').append(form)
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
editObject:editObject,
|
||||
editSession:editSession
|
||||
}
|
||||
143
browser/js/app/editor/init.js
Normal file
143
browser/js/app/editor/init.js
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
var data = require('./data-workers'),
|
||||
getObjectData = data.getObjectData,
|
||||
updateDom = data.updateDom,
|
||||
edit = require('./edit-objects'),
|
||||
editObject = edit.editObject,
|
||||
editSession = edit.editSession,
|
||||
createPopup = require('../utils').createPopup,
|
||||
widgetOptions = require('../widgets').widgetOptions,
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
||||
var init = function(){
|
||||
|
||||
document.addEventListener("contextmenu", function(e){
|
||||
e.preventDefault()
|
||||
}, false);
|
||||
|
||||
$('body').off('.editor').on('mousedown.editor touchstart.editor',function(e){
|
||||
|
||||
if (!EDITING) return
|
||||
|
||||
$('.context-menu').remove()
|
||||
|
||||
var target = $(e.target).is('.widget, .tab, [data-tab], #container')?
|
||||
$(e.target):
|
||||
$(e.target).closest('.widget, .tab, a[data-tab], #container')
|
||||
|
||||
if (!target.length) return
|
||||
|
||||
var container = target.attr('data-tab')?$(target.attr('data-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.button!=2) return
|
||||
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
menu(e,{
|
||||
'<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'] = function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push(JSON.parse(JSON.stringify(CLIPBOARD)))
|
||||
updateDom(container,data)
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add widget'] = {}
|
||||
var createFunction = function(widgetType,container,data){
|
||||
return function() {
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({type:widgetType})
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
for (widgetType in widgetOptions) {
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][widgetType] = createFunction(widgetType,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.index(),1)
|
||||
} else {
|
||||
parentData.splice(container.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(e,actions,'body')
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = init
|
||||
21
browser/js/app/init.js
Normal file
21
browser/js/app/init.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
var parsetabs = require('./parser').tabs,
|
||||
ui = require('./ui'),
|
||||
sync = require('./widgets').sync,
|
||||
editorDisable = require('./actions').editorDisable
|
||||
|
||||
module.exports = function(session,callback) {
|
||||
|
||||
$('#container').empty()
|
||||
|
||||
parsetabs(session,$('#container'),true)
|
||||
|
||||
ui.init()
|
||||
|
||||
editorDisable()
|
||||
require('./editor/init')()
|
||||
|
||||
sync()
|
||||
|
||||
if (callback) callback()
|
||||
|
||||
}
|
||||
153
browser/js/app/parser.js
Normal file
153
browser/js/app/parser.js
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
createWidget = widgets.createWidget
|
||||
|
||||
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){
|
||||
|
||||
if (main) {
|
||||
// Reset Globals
|
||||
WIDGETS = {}
|
||||
WIDGETS_LINKED = {}
|
||||
WIDGETS_ID_BY_PATH = {}
|
||||
SESSION = data
|
||||
|
||||
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')
|
||||
|
||||
nav.append(navtabs)
|
||||
parent.append(nav).append(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'),
|
||||
on = i==0?'on':''
|
||||
|
||||
tabData.label = label
|
||||
delete tabData.id
|
||||
|
||||
navtabs.append(`<li class="${on}"><a class="${on}" data-tab="#${id}"><span>${label}</span></a></li>`)
|
||||
|
||||
var tabContent = $(`<div class="tab ${on}" id="${id}"></div>`)
|
||||
tabContent.data(tabData)
|
||||
|
||||
|
||||
if (tabData.tabs && tabData.tabs.length) {
|
||||
module.exports.tabs(tabData.tabs,parent=tabContent)
|
||||
} else if (tabData.widgets && tabData.widgets.length) {
|
||||
module.exports.widgets(tabData.widgets,tabContent)
|
||||
}
|
||||
|
||||
content.append(tabContent)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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]
|
||||
}
|
||||
|
||||
widgetData.id = widgetData.id=='auto'?widgetData.type+'_'+getIterator(widgetData.type,'widget'):widgetData.id.replace(' ','_')
|
||||
widgetData.label = widgetData.label=='auto'?widgetData.id:widgetData.label
|
||||
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]}
|
||||
}
|
||||
|
||||
|
||||
// Sort widgets' properties and turn string-numbers to numbers
|
||||
for (k in widgetOptions[widgetData.type]) {
|
||||
if (parseFloat(widgetOptions[widgetData.type])==widgetOptions[widgetData.type]) widgetOptions[widgetData.type]=parseFloat(widgetOptions[widgetData.type])
|
||||
if (parseInt(widgetOptions[widgetData.type])==widgetOptions[widgetData.type]) widgetOptions[widgetData.type]=parseInt(widgetOptions[widgetData.type])
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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 widgetContainer = $(`
|
||||
<div class="widget ${widgetData.type}-container ${styleL.length || styleT.length?'absolute-position':''}" style="${styleW + styleH + styleL + styleT + widgetData.css}">
|
||||
<div class="label"><span>${widgetData.label}</span></div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
|
||||
if (widgetData.label===false) widgetContainer.addClass('nolabel')
|
||||
|
||||
// create widget
|
||||
var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
|
||||
|
||||
widgetContainer.append(widgetInner)
|
||||
|
||||
// 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 path vs widget id for faster cross-app sync
|
||||
WIDGETS_ID_BY_PATH[widgetData.path] = widgetData.id
|
||||
|
||||
parent.append(widgetContainer)
|
||||
}
|
||||
|
||||
// Editor needs to get the container object
|
||||
if (data && data.length==1) return widgetContainer
|
||||
|
||||
}
|
||||
121
browser/js/app/sidepanel.js
Normal file
121
browser/js/app/sidepanel.js
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
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('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(inner)
|
||||
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(){
|
||||
$(`<a id="open-toggle">${icon('navicon')}</a>`).appendTo('#container').click(function(){
|
||||
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open')
|
||||
})
|
||||
|
||||
// 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
|
||||
}
|
||||
79
browser/js/app/ui.js
Normal file
79
browser/js/app/ui.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var sidepanel = require('./sidepanel').init
|
||||
|
||||
// Tabs...
|
||||
var tabs = function() {
|
||||
$('.tablist a').click(function(){
|
||||
|
||||
var id = $(this).data('tab')
|
||||
$(id).siblings('.on').removeClass('on')
|
||||
$(id).addClass('on')
|
||||
$(this).parents('ul').find('.on').removeClass('on')
|
||||
$(this).addClass('on');$(this).parent().addClass('on')
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 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(){
|
||||
if (WEBFRAME) {
|
||||
$('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/Math.abs(e.originalEvent.deltaY)/20,
|
||||
s = d+WEBFRAME.getZoomFactor()
|
||||
WEBFRAME.setZoomFactor(s)
|
||||
|
||||
}
|
||||
})
|
||||
$(document).on('keydown.resetzoom', function(e){
|
||||
if (e.keyCode==96||e.keyCode==48) WEBFRAME.setZoomFactor(1)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('.tab').on('mousewheel.scroll',function(e) {
|
||||
if (!e.ctrlKey) {
|
||||
if ($(this).height()>$(this).get(0).scrollHeight) {
|
||||
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
|
||||
$(this).scrollLeft($(this).scrollLeft()+scroll)
|
||||
e.preventDefault()
|
||||
} else if (e.pageY>window.innerHeight-scrollbarHeight) {
|
||||
$(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY)
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$('.panel').on('mousewheel.scroll',function(e) {
|
||||
if (!e.ctrlKey) {
|
||||
|
||||
var h = $(this).parent().innerHeight()-scrollbarHeight-$(this).parents('.tab').length*5
|
||||
if ($(this).get(0).scrollHeight+scrollbarHeight == $(this).parent().height()) {
|
||||
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
|
||||
$(this).scrollLeft($(this).scrollLeft()+scroll)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
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).unbind('.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>`
|
||||
}
|
||||
|
||||
}
|
||||
79
browser/js/app/widgets.js
Normal file
79
browser/js/app/widgets.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
var strip = require('./widgets/strip'),
|
||||
panel = require('./widgets/panel'),
|
||||
led = require('./widgets/led'),
|
||||
fader = require('./widgets/fader'),
|
||||
knob = require('./widgets/knob'),
|
||||
xy = require('./widgets/xy'),
|
||||
rgb = require('./widgets/rgb'),
|
||||
toggle = require('./widgets/toggle'),
|
||||
swiitch = require('./widgets/switch'),
|
||||
push = require('./widgets/push')
|
||||
|
||||
module.exports.widgetOptions = {
|
||||
strip: strip.options,
|
||||
panel: panel.options,
|
||||
led: led.options,
|
||||
fader: fader.options,
|
||||
knob: knob.options,
|
||||
xy: xy.options,
|
||||
rgb: rgb.options,
|
||||
toggle: toggle.options,
|
||||
switch: swiitch.options,
|
||||
push: push.options
|
||||
}
|
||||
|
||||
module.exports.createWidget = {
|
||||
strip: strip.create,
|
||||
panel: panel.create,
|
||||
led: led.create,
|
||||
fader: fader.create,
|
||||
knob: knob.create,
|
||||
xy: xy.create,
|
||||
rgb: rgb.create,
|
||||
toggle: toggle.create,
|
||||
switch: swiitch.create,
|
||||
push: push.create
|
||||
}
|
||||
|
||||
module.exports.sync = function() {
|
||||
// Widget that share the same id will update each other
|
||||
// without sending any extra osc message
|
||||
$.each(WIDGETS,function(i,widget) {
|
||||
if (widget.length>1) {
|
||||
var closureSync = function(x) {
|
||||
return function() {
|
||||
var v = widget[x].getValue()
|
||||
for (k=0;k<widget.length;k++) {
|
||||
if (x!=k) {
|
||||
if (document.body.contains(widget[k][0].parentNode))
|
||||
widget[k].setValue(v,false,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j in widget) {
|
||||
widget[j].off('sync.id').on('sync.id',closureSync(j))
|
||||
}
|
||||
}
|
||||
})
|
||||
// widgets that share the same linkId will update each other.
|
||||
// Updated widgets will send osc messages normally
|
||||
$.each(WIDGETS_LINKED,function(i,widget) {
|
||||
if (widget.length>1) {
|
||||
var closureSync = function(x) {
|
||||
return function() {
|
||||
var v = widget[x].getValue()
|
||||
for (k=0;k<widget.length;k++) {
|
||||
if (x!=k) {
|
||||
if (document.body.contains(widget[k][0].parentNode))
|
||||
widget[k].setValue(v,true,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j in widget) {
|
||||
widget[j].off('sync.link').on('sync.link',closureSync(j))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
202
browser/js/app/widgets/fader.js
Normal file
202
browser/js/app/widgets/fader.js
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
var utils = require('./utils'),
|
||||
sizeToAngle = utils.sizeToAngle,
|
||||
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',
|
||||
horizontal:false,
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
absolute:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
var widget = $(`
|
||||
<div class="fader-wrapper-outer">
|
||||
<div class="fader-wrapper">
|
||||
<div class="fader">
|
||||
<div class="handle"><span></span></div>
|
||||
<div class="pips"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input"></div>
|
||||
</div>
|
||||
`),
|
||||
handle = widget.find('.handle'),
|
||||
knob = widget.find('span')[0],
|
||||
wrapper = widget.find('.fader-wrapper'),
|
||||
fader = widget.find('.fader'),
|
||||
pips = widget.find('.pips'),
|
||||
input = widget.find('.input').fakeInput(),
|
||||
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
|
||||
dimension = widgetData.horizontal?'width':'height',
|
||||
axe = dimension=='height'?'X':'Y',
|
||||
absolute = widgetData.absolute
|
||||
if (widgetData.horizontal) container.addClass('horizontal')
|
||||
|
||||
handle.size = 0
|
||||
fader.size = dimension=='height'?fader.outerHeight():fader.outerWidth()
|
||||
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
|
||||
|
||||
fader.resize(function(){
|
||||
fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
|
||||
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
|
||||
})
|
||||
|
||||
|
||||
var off = 0
|
||||
|
||||
wrapper.on('draginit',function(e,data){
|
||||
if (absolute || data.ctrlKey || data.shiftKey) {
|
||||
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
|
||||
var r = sizeToAngle(d)
|
||||
handle[0].setAttribute('style','transform:rotate'+axe+'('+ r +'deg)')
|
||||
knob.setAttribute('style','transform:rotate'+axe+'('+ (-r) +'deg)')
|
||||
handle.size = d
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
|
||||
}
|
||||
|
||||
off = handle.size
|
||||
|
||||
})
|
||||
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
var d = (dimension=='height')?-data.deltaY:data.deltaX
|
||||
d = clip(d*100/fader.size+off,[0,100])
|
||||
var r = sizeToAngle(d)
|
||||
|
||||
handle[0].setAttribute('style','transform:rotate'+axe+'('+ r +'deg)')
|
||||
knob.setAttribute('style','transform:rotate'+axe+'('+ (-r) +'deg)')
|
||||
handle.size = d
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
|
||||
})
|
||||
|
||||
widgetData.range = widgetData.range || {'min':0,'max':1}
|
||||
|
||||
var range = {}
|
||||
for (k in widgetData.range) {
|
||||
if (k=='min') {
|
||||
range[0]=widgetData.range[k]
|
||||
} else if (k=='max') {
|
||||
range[100]=widgetData.range[k]
|
||||
} else {
|
||||
range[parseInt(k)]=widgetData.range[k]
|
||||
}
|
||||
}
|
||||
|
||||
var scale = []
|
||||
for (var i=0;i<=100;i++) {scale.push(i)}
|
||||
for (i in scale) {
|
||||
var pip = $('<div class="pip"></div>')
|
||||
if (range[i]!=undefined) {
|
||||
var piptext = Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]
|
||||
pip.addClass('val').append('<span>'+piptext+'</span>')
|
||||
}
|
||||
pips.append(pip)
|
||||
}
|
||||
if (dimension=='height') {
|
||||
pips.append(pips.find('.pip').get().reverse())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
|
||||
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
|
||||
|
||||
|
||||
|
||||
widget.getValue = function(){
|
||||
var h = clip(handle.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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
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]],widgetData.precision)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var r = sizeToAngle(h)
|
||||
|
||||
handle[0].setAttribute('style','transform:rotate'+axe+'('+ r +'deg)')
|
||||
knob.setAttribute('style','transform:rotate'+axe+'('+ (-r) +'deg)')
|
||||
|
||||
handle.size = h
|
||||
|
||||
widget.showValue(v)
|
||||
|
||||
|
||||
if (sync) widget.trigger('sync')
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
|
||||
widget.sendValue = function(v) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:v
|
||||
})
|
||||
}
|
||||
|
||||
widget.showValue = function(v) {
|
||||
input.val(v+unit)
|
||||
}
|
||||
|
||||
input.change(function(){
|
||||
widget.setValue(input.val(),true,true)
|
||||
})
|
||||
|
||||
widget.setValue(rangeVals[0])
|
||||
|
||||
return widget
|
||||
}
|
||||
201
browser/js/app/widgets/knob.js
Normal file
201
browser/js/app/widgets/knob.js
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
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',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
absolute:false,
|
||||
pan:false,
|
||||
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
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 class="round"></div>
|
||||
</div>
|
||||
<div class="pip min"></div>
|
||||
<div class="pip max"></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(),
|
||||
range = widgetData.range || {min:0,max:1},
|
||||
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
|
||||
absolute = widgetData.absolute,
|
||||
pan = widgetData.pan
|
||||
|
||||
|
||||
|
||||
var pipmin = Math.abs(range.min)>=1000?range.min/1000+'k':range.min,
|
||||
pipmax = Math.abs(range.max)>=1000?range.max/1000+'k':range.max
|
||||
|
||||
widget.find('.pip.min').text(pipmin)
|
||||
widget.find('.pip.max').text(pipmax)
|
||||
|
||||
mask.size = Math.floor(wrapper[0].offsetWidth*.58)
|
||||
|
||||
wrapper.resize(function(){
|
||||
var w = Math.floor(wrapper[0].offsetWidth*.58)
|
||||
if (!w || mask.size==w) return
|
||||
mask.size=w
|
||||
mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
|
||||
})
|
||||
|
||||
|
||||
knob.rotation = 0
|
||||
|
||||
var offR = 0,
|
||||
offX = 0,
|
||||
offY = 0
|
||||
wrapper.on('draginit',function(e,data){
|
||||
|
||||
if (absolute || data.ctrlKey || data.shiftKey) {
|
||||
var w = data.target.clientWidth,
|
||||
h = data.target.clientHeight,
|
||||
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
|
||||
|
||||
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
|
||||
handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
|
||||
knob.rotation = r
|
||||
|
||||
|
||||
if (pan && r<135) {mask.removeClass('pan-right').addClass('pan-left')}
|
||||
else if (pan) {mask.removeClass('pan-left').addClass('pan-right')}
|
||||
|
||||
if (r>180) {knob.addClass('d3')}
|
||||
else if (r>90) {knob.removeClass('d3').addClass('d2')}
|
||||
else {knob.removeClass('d3 d2')}
|
||||
|
||||
var v = mapToScale(r,[0,270],[range.min,range.max],widgetData.precision)
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.trigger('sync')
|
||||
widget.showValue(v)
|
||||
|
||||
}
|
||||
|
||||
offR = knob.rotation
|
||||
})
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
var r = clip(-data.deltaY*2+offR,[0,270])
|
||||
|
||||
if (absolute || 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])
|
||||
}
|
||||
|
||||
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
|
||||
handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
|
||||
knob.rotation = r
|
||||
|
||||
if (pan && r<135) {mask.removeClass('pan-right').addClass('pan-left')}
|
||||
else if (pan) {mask.removeClass('pan-left').addClass('pan-right')}
|
||||
|
||||
if (r>180) {knob.addClass('d3')}
|
||||
else if (r>90) {knob.removeClass('d3').addClass('d2')}
|
||||
else {knob.removeClass('d3 d2')}
|
||||
|
||||
var v = mapToScale(r,[0,270],[range.min,range.max],widgetData.precision)
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.trigger('sync')
|
||||
widget.showValue(v)
|
||||
|
||||
})
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
return mapToScale(knob.rotation,[0,270],[range.min,range.max],widgetData.precision)
|
||||
}
|
||||
widget.showValue = function(v) {
|
||||
input.val(v+unit)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:v
|
||||
})
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
var r = mapToScale(v,[range.min,range.max],[0,270],widgetData.precision)
|
||||
knob.rotation = r
|
||||
|
||||
|
||||
|
||||
if (pan && r<135) {mask.removeClass('pan-right').addClass('pan-left')}
|
||||
else if (pan) {mask.removeClass('pan-left').addClass('pan-right')}
|
||||
|
||||
if (r>180) {knob.addClass('d3')}
|
||||
else if (r>90) {knob.removeClass('d3').addClass('d2')}
|
||||
else {knob.removeClass('d3 d2')}
|
||||
|
||||
|
||||
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
|
||||
handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
|
||||
var v = widget.getValue()
|
||||
|
||||
widget.showValue(v)
|
||||
|
||||
if (sync) widget.trigger('sync')
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
input.change(function(){
|
||||
widget.setValue(input.val(),true,true)
|
||||
})
|
||||
|
||||
widget.setValue(range.min)
|
||||
return widget
|
||||
}
|
||||
39
browser/js/app/widgets/led.js
Normal file
39
browser/js/app/widgets/led.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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:'green',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
range:{min:0,max:1},
|
||||
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 || {min:0,max:1}
|
||||
|
||||
if (widgetData.color) led.css('background-color',widgetData.color)
|
||||
|
||||
widget.setValue = function(v){
|
||||
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision))
|
||||
}
|
||||
widget.getValue = function(){return}
|
||||
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:'0',
|
||||
top:'0',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
stretch:false,
|
||||
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.stretch) widget.addClass('stretch')
|
||||
|
||||
if (widgetData.tabs.length) {
|
||||
parsetabs(widgetData.tabs,widget)
|
||||
} else {
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
}
|
||||
widget.getValue = function(){return}
|
||||
widget.setValue = function(){return}
|
||||
return widget
|
||||
}
|
||||
86
browser/js/app/widgets/push.js
Normal file
86
browser/js/app/widgets/push.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
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',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
|
||||
var widget = $(`
|
||||
<div class="push toggle">
|
||||
<div class="light"></div>
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = widget.find('span')
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
widget.setValue(widgetData.on,true,true)
|
||||
$document.on('dragend.push',function(){
|
||||
widget.setValue(widgetData.off,true,true)
|
||||
$document.off('dragend.push')
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.hasClass('on')?widgetData.on:widgetData.off
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
var on = widgetData.on,
|
||||
off= widgetData.off
|
||||
if (v==on) {
|
||||
widget.addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
|
||||
widget.removeClass('ripple')
|
||||
next()
|
||||
})
|
||||
if (send) widget.sendValue(v)
|
||||
} else if (v==off) {
|
||||
widget.removeClass('on')
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
|
||||
if (sync) widget.trigger('sync')
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:v
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
272
browser/js/app/widgets/rgb.js
Normal file
272
browser/js/app/widgets/rgb.js
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
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',
|
||||
|
||||
absolute:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
precision:0,
|
||||
path:'auto',
|
||||
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'})},
|
||||
absolute = widgetData.absolute,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
|
||||
:false
|
||||
|
||||
if (widgetData.height!='auto') widget.addClass('manual-height')
|
||||
|
||||
|
||||
pad.width = pad.innerWidth()
|
||||
pad.height = pad.innerHeight()
|
||||
rgbHandle.height = 0
|
||||
rgbHandle.width = 0
|
||||
hueHandle.width = 0
|
||||
|
||||
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){
|
||||
if (absolute || data.ctrlKey || data.shiftKey) {
|
||||
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()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
widget.trigger('sync')
|
||||
|
||||
}
|
||||
|
||||
rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
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()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
|
||||
})
|
||||
|
||||
|
||||
var hueOff = 0
|
||||
huePad.on('draginit',function(e,data){
|
||||
if (absolute || data.ctrlKey || data.shiftKey) {
|
||||
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}),
|
||||
v = widget.getValue()
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
|
||||
|
||||
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
widget.trigger('sync')
|
||||
|
||||
}
|
||||
|
||||
hueOff = hueHandle.width
|
||||
|
||||
})
|
||||
|
||||
|
||||
huePad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
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}),
|
||||
v = widget.getValue()
|
||||
|
||||
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
|
||||
widget.trigger('sync')
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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],widgetData.precision),
|
||||
h = mapToScale(hsb.b,[0,100],[0,100],widgetData.precision),
|
||||
hueW = mapToScale(hsb.h,[0,360],[0,100],widgetData.precision)
|
||||
|
||||
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
|
||||
|
||||
|
||||
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')
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:v,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.r,
|
||||
args:v[0],
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.g,
|
||||
args:v[1],
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.b,
|
||||
args: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
|
||||
}
|
||||
37
browser/js/app/widgets/strip.js
Normal file
37
browser/js/app/widgets/strip.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
module.exports.options = {
|
||||
type:'strip',
|
||||
id:'auto',
|
||||
|
||||
separator1:'style',
|
||||
|
||||
label:'auto',
|
||||
left:'auto',
|
||||
top:'auto',
|
||||
width:'auto',
|
||||
height:'auto',
|
||||
horizontal:false,
|
||||
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)
|
||||
widget.getValue = function(){return}
|
||||
widget.setValue = function(){return}
|
||||
return widget
|
||||
}
|
||||
81
browser/js/app/widgets/switch.js
Normal file
81
browser/js/app/widgets/switch.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
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,
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
values:{"Value 1":1,"Value 2":2},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
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.on('drag',function(e){e.stopPropagation()})
|
||||
|
||||
widget.on('draginit',function(e,dd){
|
||||
var data = $(dd.target).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')
|
||||
}
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:v
|
||||
})
|
||||
}
|
||||
return widget
|
||||
}
|
||||
84
browser/js/app/widgets/toggle.js
Normal file
84
browser/js/app/widgets/toggle.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
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',
|
||||
css:'',
|
||||
|
||||
separator2:'osc',
|
||||
|
||||
on:1,
|
||||
off:0,
|
||||
precision:2,
|
||||
path:'auto',
|
||||
target:[]
|
||||
}
|
||||
module.exports.create = function(widgetData,container) {
|
||||
|
||||
var widget = $(`
|
||||
<div class="toggle">
|
||||
<div class="light"></div>
|
||||
</div>\
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = widget.find('span')
|
||||
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit.toggle',function(){
|
||||
widget.off('draginit.toggle')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
var newVal = widget.hasClass('on')?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.hasClass('on')?widgetData.on:widgetData.off
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (v==widgetData.on) {
|
||||
widget.addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
|
||||
widget.removeClass('ripple')
|
||||
next()
|
||||
})
|
||||
if (send) widget.sendValue(widgetData.on)
|
||||
} else if (v==widgetData.off) {
|
||||
widget.removeClass('on')
|
||||
if (send) widget.sendValue(widgetData.off)
|
||||
}
|
||||
|
||||
if (sync) widget.trigger('sync')
|
||||
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
if (v===false) return
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:widgetData.path,
|
||||
precision:widgetData.precision,
|
||||
args:v
|
||||
})
|
||||
}
|
||||
widget.setValue()
|
||||
return widget
|
||||
}
|
||||
76
browser/js/app/widgets/utils.js
Normal file
76
browser/js/app/widgets/utils.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
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) {
|
||||
|
||||
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
|
||||
roundFactor = precision!=undefined?Math.pow(10,precision):100
|
||||
|
||||
value = ((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])))
|
||||
|
||||
value = Math.round(value*roundFactor)/roundFactor
|
||||
|
||||
return value
|
||||
|
||||
},
|
||||
|
||||
sizeToAngle: function(size) {
|
||||
return module.exports.clip(Math.acos((size/100))*180/Math.PI,[0,90])
|
||||
},
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
182
browser/js/app/widgets/xy.js
Normal file
182
browser/js/app/widgets/xy.js
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
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',
|
||||
css:'',
|
||||
|
||||
separator2:'behaviour',
|
||||
|
||||
absolute:false,
|
||||
|
||||
separator3:'osc',
|
||||
|
||||
rangeX:{min:0,max:1},
|
||||
rangeY:{min:0,max:1},
|
||||
precision:2,
|
||||
path:'auto',
|
||||
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},
|
||||
absolute = widgetData.absolute,
|
||||
split = widgetData.split?
|
||||
typeof widgetData.split == 'object'?
|
||||
widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
|
||||
:false
|
||||
|
||||
|
||||
if (widgetData.height!='auto') widget.addClass('manual-height')
|
||||
|
||||
pad.width = pad.innerWidth()
|
||||
pad.height = pad.innerHeight()
|
||||
handle.height = 0
|
||||
handle.width = 0
|
||||
|
||||
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
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*handle.width/100}px, -${pad.height*handle.height/100}px,0)`)
|
||||
})
|
||||
|
||||
var off = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data){
|
||||
if (absolute || data.ctrlKey || data.shiftKey) {
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
widget.trigger('sync')
|
||||
|
||||
}
|
||||
|
||||
off = {x:handle.width,y:handle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
|
||||
w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
|
||||
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
var v = widget.getValue()
|
||||
widget.sendValue(v)
|
||||
widget.showValue(v)
|
||||
widget.trigger('sync')
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
widget.getValue = function() {
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision)
|
||||
|
||||
return [x,y]
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (!v || v.length!=2) return
|
||||
|
||||
for (i in [0,1]) {
|
||||
v[i] = clip(v[i],[range[['x','y'][i]].min,range[['x','y'][i]].max])
|
||||
}
|
||||
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],widgetData.precision)
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],widgetData.precision),
|
||||
|
||||
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
|
||||
handle.height = h
|
||||
handle.width = w
|
||||
|
||||
widget.showValue(v)
|
||||
if (sync) widget.trigger('sync')
|
||||
if (send) widget.sendValue(v)
|
||||
}
|
||||
widget.sendValue = function(v) {
|
||||
sendOsc({
|
||||
target:split?false:widgetData.target,
|
||||
path:widgetData.path,
|
||||
args:v,
|
||||
precision:widgetData.precision,
|
||||
})
|
||||
if (split) {
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.x,
|
||||
args:v[0],
|
||||
precision:widgetData.precision,
|
||||
sync:false
|
||||
})
|
||||
sendOsc({
|
||||
target:widgetData.target,
|
||||
path:split.y,
|
||||
args: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
|
||||
}
|
||||
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')
|
||||
6
browser/js/browser.js
Normal file
6
browser/js/browser.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
WEBFRAME = require('web-frame')
|
||||
|
||||
// mainProcess & renderProcess communication engine
|
||||
IPC = require('ipc-renderer')
|
||||
|
||||
require('./app')
|
||||
151
browser/js/jquery/jquery.drag.js
Normal file
151
browser/js/jquery/jquery.drag.js
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// jQuery drag event handler
|
||||
;(function($){
|
||||
$.event.special.drag = {
|
||||
setup: function() {
|
||||
var element = $(this),
|
||||
previousEvent = null,
|
||||
$document = $(document)
|
||||
|
||||
var mousemove = function(e) {
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
if (e.button==2) {
|
||||
e.speedX = e.speedX/10
|
||||
e.speedY = e.speedY/10
|
||||
}
|
||||
e.deltaX = e.speedX + previousEvent.deltaX
|
||||
e.deltaY = e.speedY + previousEvent.deltaY
|
||||
|
||||
|
||||
element.trigger("drag",e)
|
||||
previousEvent = e
|
||||
}
|
||||
var mouseup = function(e) {
|
||||
$document.off("mouseup")
|
||||
$document.off("mousemove")
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
element.trigger("dragend", e)
|
||||
}
|
||||
var touchend = function(e) {
|
||||
e.preventDefault()
|
||||
|
||||
e.pageX = e.originalEvent.changedTouches[0].pageX
|
||||
e.pageY = e.originalEvent.changedTouches[0].pageY
|
||||
e.offsetX = e.pageX-getOffset(e.target).left
|
||||
e.offsetY = e.pageY-getOffset(e.target).top
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
element.trigger("dragend", e)
|
||||
}
|
||||
|
||||
function getOffset(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}
|
||||
}
|
||||
|
||||
element.on("touchstart.drag mousedown.drag", function(e) {
|
||||
e.preventDefault()
|
||||
previousEvent = e
|
||||
|
||||
if (!e.originalEvent.changedTouches) {
|
||||
// mouse
|
||||
$document.on("mousemove", mousemove)
|
||||
$document.on("mouseup", mouseup)
|
||||
} else {
|
||||
// touch
|
||||
e.pageX = e.originalEvent.changedTouches[0].pageX
|
||||
e.pageY = e.originalEvent.changedTouches[0].pageY
|
||||
e.offsetX = e.pageX-getOffset(e.target).left
|
||||
e.offsetY = e.pageY-getOffset(e.target).top
|
||||
}
|
||||
|
||||
e.speedX = 0
|
||||
e.speedY = 0
|
||||
e.deltaX = 0
|
||||
e.deltaY = 0
|
||||
|
||||
element.trigger("draginit", e)
|
||||
})
|
||||
element.on("touchmove.drag", function(e) {
|
||||
e.preventDefault()
|
||||
|
||||
if (e.shiftKey) {
|
||||
// get element under pointer: usefull only for master dragging (when target changes during drag)
|
||||
e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].clientX, e.originalEvent.changedTouches[0].clientY)
|
||||
}
|
||||
|
||||
e.pageX = e.originalEvent.targetTouches[0].pageX
|
||||
e.pageY = e.originalEvent.targetTouches[0].pageY
|
||||
e.speedX = previousEvent?e.pageX - previousEvent.pageX:0
|
||||
e.speedY = previousEvent?e.pageY - previousEvent.pageY:0
|
||||
e.deltaX = previousEvent?e.speedX + previousEvent.deltaX:0
|
||||
e.deltaY = previousEvent?e.speedY + previousEvent.deltaY:0
|
||||
e.offsetX = previousEvent&&!e.shiftKey?previousEvent.offsetX+e.speedX:e.pageX-getOffset(e.target).left
|
||||
e.offsetY = previousEvent&&!e.shiftKey?previousEvent.offsetY+e.speedY:e.pageY-getOffset(e.target).top
|
||||
|
||||
// do now allow two touch points to drag the same element
|
||||
if (e.originalEvent.targetTouches.length > 1) return
|
||||
|
||||
element.trigger("drag",e)
|
||||
previousEvent = e
|
||||
|
||||
})
|
||||
element.on("touchend.drag", touchend)
|
||||
element.on("touchcancel.drag", touchend)
|
||||
|
||||
|
||||
},
|
||||
teardown: function() {
|
||||
var element = $(this)
|
||||
element.off("touchstart.drag")
|
||||
element.off("touchmove.drag")
|
||||
element.off("touchend.drag")
|
||||
element.off("touchcancel.drag")
|
||||
element.off("mousedown.drag")
|
||||
element.off("mouseup.drag")
|
||||
}
|
||||
}
|
||||
|
||||
// MASTER DRAGGING (while shift key pressed)
|
||||
var target
|
||||
$(document).keydown(function (e) {
|
||||
if (e.keyCode == 16) {
|
||||
|
||||
$('body').on('drag',function(ev,dd){
|
||||
dd.target = dd.originalEvent.changedTouches?
|
||||
document.elementFromPoint(dd.originalEvent.changedTouches[0].clientX, dd.originalEvent.changedTouches[0].clientY)
|
||||
:dd.target
|
||||
|
||||
$(dd.target).trigger('draginit',[dd])
|
||||
target = dd.target
|
||||
|
||||
})
|
||||
}
|
||||
});
|
||||
$(document).keyup(function (e) {
|
||||
if (e.keyCode == 16) {
|
||||
$('body').off('drag')
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery)
|
||||
89
browser/js/jquery/jquery.fake-input.js
Normal file
89
browser/js/jquery/jquery.fake-input.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
(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 = $('body').css('color')
|
||||
self.center = settings.align == 'center'
|
||||
self.visible = false
|
||||
|
||||
|
||||
self.attr('tabindex',"0")
|
||||
|
||||
canvas.resize(function(){
|
||||
var width = canvas.width(),
|
||||
height = canvas.height()
|
||||
|
||||
if (height==100 && width==100) return
|
||||
|
||||
if (!self.visible) {
|
||||
self.visible = true
|
||||
canvas.addClass('visible')
|
||||
}
|
||||
|
||||
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 = '13px sans-serif'
|
||||
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('click focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
// $(this).remove()
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('mousedown.fakeInput touchstart.fakeInput')
|
||||
})
|
||||
$(document).on('mousedown.fakeInput touchstart.fakeInput',function(){
|
||||
i.blur()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
return self
|
||||
|
||||
}
|
||||
})(jQuery)
|
||||
5
browser/js/jquery/jquery.min.js
vendored
Normal file
5
browser/js/jquery/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
94
browser/js/jquery/jquery.resize.js
Normal file
94
browser/js/jquery/jquery.resize.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* jquery.reize
|
||||
* 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 )
|
||||
|
||||
// Initialize data store on the element.
|
||||
elem.setAttribute('resize-data-w',elem.offsetWidth)
|
||||
elem.setAttribute('resize-data-h',elem.offsetHeight)
|
||||
|
||||
// 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 resizePollingLoop() {
|
||||
|
||||
// yep, setTimeout, 'cuz requestAnimation doesn't seem to perform that well
|
||||
resizeTimeout = window.setTimeout(function(){
|
||||
// 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,
|
||||
data = {
|
||||
w:elem.getAttribute('resize-data-w'),
|
||||
h:elem.getAttribute('resize-data-h')
|
||||
}
|
||||
|
||||
// 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.setAttribute('resize-data-w',width)
|
||||
elem.setAttribute('resize-data-h',height)
|
||||
$(elem).trigger('resize',[width,height])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Loop.
|
||||
resizePollingLoop()
|
||||
|
||||
}, pollInterval )
|
||||
|
||||
}
|
||||
|
||||
})(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
BIN
browser/js/sass/libsass.js.mem
Normal file
BIN
browser/js/sass/libsass.js.mem
Normal file
Binary file not shown.
807
browser/js/sass/sass.sync.js
Normal file
807
browser/js/sass/sass.sync.js
Normal file
File diff suppressed because one or more lines are too long
1788
browser/scss/style.scss
Normal file
1788
browser/scss/style.scss
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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
1593
examples/widgets.js
Normal file
1593
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')
|
||||
125
main/callbacks.js
Normal file
125
main/callbacks.js
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
var vm = require('vm')
|
||||
|
||||
module.exports = function(settings,fs,ipc,osc,dialog) {
|
||||
|
||||
return {
|
||||
|
||||
ready: function(data,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) {
|
||||
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
|
||||
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 (!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())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
58
main/main.js
Normal file
58
main/main.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
var fs = require('fs'),
|
||||
settings = require('./settings')(fs)
|
||||
|
||||
|
||||
if (settings.read('compileScss')) {
|
||||
var sass = require(__dirname + '/../browser/js/sass/sass.sync.js')
|
||||
var filenames = fs.readdirSync(__dirname + '/../browser/scss/')
|
||||
for (i in filenames) {
|
||||
if (filenames[i].indexOf('.scss')!=-1)
|
||||
var file = __dirname + '/../browser/scss/' + filenames[i]
|
||||
var light = settings.read('lightTheme')?'$theme:\'light\';':'$theme:\'dark\';'
|
||||
var content = fs.readFileSync(file,'utf8')
|
||||
sass.compile(light+content,{style: sass.style.compact,linefeed: ''}, function(result) {
|
||||
fs.writeFileSync(__dirname + '/../browser/css/'+filenames[i].replace('.scss','.css'),result.text,'utf8')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!settings.read('noGui')) {
|
||||
|
||||
var app = require('app'),
|
||||
browserWindow = require('browser-window'),
|
||||
dialog = require('dialog'),
|
||||
ipc = require('ipc-main')
|
||||
|
||||
dialog.showErrorBox = function(title,err) {
|
||||
console.log(title + ': ' + err)
|
||||
}
|
||||
|
||||
app.commandLine.appendSwitch('--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)
|
||||
|
||||
}
|
||||
47
main/osc.js
Normal file
47
main/osc.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
var osc = require('node-osc')
|
||||
|
||||
module.exports = function(ipc, settings) {
|
||||
|
||||
if (settings.read('oscInPort')) {
|
||||
var oscServer = new osc.Server(settings.read('oscInPort'), '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)
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
send: function(host,port,path,args,precision) {
|
||||
|
||||
var client = new osc.Client(host, port)
|
||||
|
||||
var message = new osc.Message(path)
|
||||
|
||||
var numberType = precision==0?'integer':'float'
|
||||
|
||||
if (typeof args=='object') {
|
||||
for (i in args) {
|
||||
var arg = args[i]
|
||||
if (typeof arg == 'number') {
|
||||
message.append({type:numberType,value:arg})
|
||||
} else {
|
||||
message.append({type:'string',value:arg})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (typeof args == 'number') {
|
||||
message.append({type:numberType,value:args})
|
||||
} else {
|
||||
message.append({type:'string',value:args})
|
||||
}
|
||||
}
|
||||
|
||||
client.send(message, function () {
|
||||
client.kill()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
84
main/server-electron.js
Normal file
84
main/server-electron.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
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'),
|
||||
autoHideMenuBar:true,
|
||||
backgroundColor:'#1a1d22',
|
||||
// show:false
|
||||
})
|
||||
|
||||
window.loadURL('file://' + __dirname + '/../browser/index.html')
|
||||
|
||||
window.on('closed', function() {
|
||||
window = null
|
||||
})
|
||||
|
||||
|
||||
var Menu = require('menu')
|
||||
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(
|
||||
[
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Restart',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click: function(){
|
||||
var exec = require('child_process').exec
|
||||
exec(process.argv.join(' '))
|
||||
app.quit()
|
||||
}// function() { window.reload(); }//restartApp
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
62
main/server-express.js
Normal file
62
main/server-express.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
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')(),
|
||||
browserify = require('browserify'),
|
||||
ipc = {}
|
||||
|
||||
express.get('/', function(req, res){
|
||||
res.sendFile(path.resolve(__dirname + '/../browser/index-headless.html'))
|
||||
})
|
||||
express.get('*browser-headless.js', function(req, res){
|
||||
browserify().add(path.resolve(__dirname + '/../browser' + req.path)).bundle().pipe(res);
|
||||
})
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
50
main/settings.js
Normal file
50
main/settings.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// 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)'},
|
||||
'c':{alias:'compile',type:'string',describe:'recompile stylesheets (increases startup time)'},
|
||||
'l':{alias:'load',type:'string',describe:'session file to load'},
|
||||
'p':{alias:'port',describe:'osc input port (for synchronization)'},
|
||||
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
|
||||
})
|
||||
.check(function(a,x){if(a.port==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.sync==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 || false,
|
||||
compileScss: argv.c!==undefined || false,
|
||||
lightTheme: argv.c && argv.c.match(/light/),
|
||||
sessionFile: argv.l || false,
|
||||
noGui: argv.n || false,
|
||||
}
|
||||
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
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
9718
package-lock.json
generated
9718
package-lock.json
generated
File diff suppressed because it is too large
Load diff
148
package.json
148
package.json
|
|
@ -1,110 +1,42 @@
|
|||
{
|
||||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.31.2",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
},
|
||||
"keywords": [
|
||||
"osc",
|
||||
"midi",
|
||||
"interface",
|
||||
"multi-touch"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://framagit.org/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"
|
||||
}
|
||||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "A libre desktop OSC bi-directionnal control surface application.",
|
||||
"version": "0.2.0",
|
||||
"main": "index.js",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet / AMMD",
|
||||
"email": "jeannot@ammd.net"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-osc": "1.2",
|
||||
"yargs":"4.2.0",
|
||||
"socket.io":"1.4.5",
|
||||
"socket.io-client":"1.4.5",
|
||||
"socketio-wildcard":"0.1.1",
|
||||
"browserify":"13.0.0",
|
||||
"express":"4.13.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron-prebuilt": "0.36.9",
|
||||
"electron-packager": "5.2.1",
|
||||
"electron-installer-debian":"*"
|
||||
},
|
||||
"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",
|
||||
"test": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
"osc",
|
||||
"interface",
|
||||
"multi-touch"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jean-emmanuel/Open-Stage-Control"
|
||||
},
|
||||
"licence": "GPL-3.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
# How to build the docs
|
||||
|
||||
```bash
|
||||
# https://squidfunk.github.io/mkdocs-material/getting-started/
|
||||
$ python3 -m pip install mkdocs-material
|
||||
|
||||
|
||||
$ mkdocs serve # make docs available on http://127.0.0.1:8000
|
||||
# or
|
||||
$ mkdocs build # build docs in site/
|
||||
```
|
||||
|
|
@ -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
|
||||
]
|
||||
]
|
||||
27
resources/docs/build-from-sources.md
Normal file
27
resources/docs/build-from-sources.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
## Build from sources
|
||||
|
||||
**Requirements**
|
||||
- [Node.js](https://nodejs.org/)
|
||||
- [npm](https://www.npmjs.com/)
|
||||
|
||||
```
|
||||
$ sudo apt-get install npm # install nodejs & npm
|
||||
$ sudo npm install -g npm # update npm
|
||||
```
|
||||
|
||||
**Build**
|
||||
```
|
||||
$ git clone https://github.com/jean-emmanuel/open-stage-control
|
||||
$ cd open-stage-control
|
||||
$ npm install --save-dev
|
||||
$ export PLATFORM=TARGET_PLATFORM # TARGET_PLATFORM can be linux, win32 (windows) or darwin (os x)
|
||||
$ export ARCH=TARGET_ARCH # TARGET_ARCH can be ia32 or x64
|
||||
$ npm run build
|
||||
|
||||
$ # Do the following if you want a deb package for debian/ubuntu
|
||||
$ npm run deb32
|
||||
$ # or
|
||||
$ npm run deb64
|
||||
```
|
||||
|
||||
This will build the app in `dist/open-stage-control-PLATFORM-ARCH`.
|
||||
|
|
@ -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"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
|
@ -1,471 +0,0 @@
|
|||
## Basic address routing
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (address === '/some_address') {
|
||||
address = '/fader_1'
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
|
||||
},
|
||||
|
||||
oscOutFilter:function(data){
|
||||
|
||||
var {address, args, host, port, clientId} = data
|
||||
|
||||
if (address === '/fader_1') {
|
||||
address = '/some_address'
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Value conversion
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (address === '/some_address') {
|
||||
|
||||
args[0].value = args[0].value * 10
|
||||
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
|
||||
},
|
||||
|
||||
oscOutFilter:function(data){
|
||||
|
||||
var {address, args, host, port, clientId} = data
|
||||
|
||||
if (address === '/some_address') {
|
||||
|
||||
args[0].value = args[0].value / 10
|
||||
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Arguments split / merge
|
||||
|
||||
```js
|
||||
|
||||
var xyValue = [0, 0]
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
// split
|
||||
if (address === '/some_xy_address') {
|
||||
var arg1 = args[0].value,
|
||||
arg2 = args[1].value
|
||||
|
||||
receive('/fader_1', arg1)
|
||||
receive('/fader_2', arg2)
|
||||
|
||||
return // bypass original message
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
|
||||
},
|
||||
|
||||
oscOutFilter:function(data){
|
||||
|
||||
var {address, args, host, port, clientId} = data
|
||||
|
||||
// merge
|
||||
if (address === '/fader_1') {
|
||||
|
||||
xyValue[0] = args[0].value
|
||||
send(host, port, '/some_xy_address', ...xyValue)
|
||||
return // bypass original message
|
||||
|
||||
} else if (address === '/fader_2') {
|
||||
|
||||
xyValue[1] = args[1].value
|
||||
send(host, port, '/some_xy_address', ...xyValue)
|
||||
return // bypass original message
|
||||
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Reply
|
||||
|
||||
```js
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (address === '/knock_knock') {
|
||||
|
||||
send(host, port, '/who_is_there')
|
||||
|
||||
return // bypass original message
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Simulate user input on a single client
|
||||
|
||||
```js
|
||||
|
||||
// keep track of connected clients
|
||||
|
||||
var clients = []
|
||||
|
||||
app.on('open', (data, client)=>{
|
||||
if (!clients.includes(client.id)) clients.push(client.id)
|
||||
})
|
||||
|
||||
app.on('close', (data, client)=>{
|
||||
if (clients.includes(client.id)) clients.splice(clients.indexOf(client.id))
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (address === '/some_osc_address') {
|
||||
|
||||
// simulate user input on the first client in the array
|
||||
|
||||
receive('/SET', 'widget_id', 1, {clientId: clients[0]})
|
||||
|
||||
return // bypass original message
|
||||
}
|
||||
|
||||
return {address, args, host, port}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Auto-save client state
|
||||
|
||||
```js
|
||||
// store state in a variable
|
||||
var state = {}
|
||||
|
||||
// keep track of connected clients
|
||||
var clients = []
|
||||
|
||||
app.on('sessionOpened', (data, client)=>{
|
||||
|
||||
// client connected (and in a session)
|
||||
if (!clients.includes(client.id)) clients.push(client.id)
|
||||
|
||||
// when a client opens a session, send the state
|
||||
// but only if it's the only connected client (otherwise, let the regular sync happen)
|
||||
if (clients.length === 1) {
|
||||
receive('/STATE/SET', state, {clientId: clients[0]})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
app.on('close', (data, client)=>{
|
||||
|
||||
// client disconnected
|
||||
if (clients.includes(client.id)) clients.splice(clients.indexOf(client.id))
|
||||
|
||||
})
|
||||
|
||||
// request 1st client's state every 10 seconds
|
||||
setInterval(()=>{
|
||||
|
||||
if (clients.length > 0) {
|
||||
receive('/STATE/GET', '127.0.0.1:8888', {clientId: clients[0]})
|
||||
}
|
||||
|
||||
}, 10000)
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscOutFilter: function(data) {
|
||||
|
||||
if (data.address === '/STATE/GET') {
|
||||
// update state variable when the client responds
|
||||
state = data.args[0].value
|
||||
|
||||
// bypass the osc message
|
||||
return
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## MIDI routing
|
||||
|
||||
```js
|
||||
var routing = {
|
||||
// midi cc vs widget id
|
||||
60: 'fader_1',
|
||||
61: 'fader_2',
|
||||
// etc
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscInFilter:function(data){
|
||||
// Filter incoming osc messages
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (host === 'midi') {
|
||||
|
||||
// MIDI routing !
|
||||
if (address === '/control') {
|
||||
|
||||
// assign args to variables
|
||||
var [channel, ctrl, value] = args.map(arg=>arg.value)
|
||||
|
||||
// simple conditions
|
||||
if (ctrl === 80) receive('/SET', 'widget_id', value / 127)
|
||||
|
||||
// simple routing table (midi cc vs widget id)
|
||||
if (routing[ctrl]) receive('/SET', routing[ctrl], value / 127)
|
||||
|
||||
// note: /SET simulates a user interaction and makes the widget send its osc message
|
||||
// but it adds some delay (we wait for the UI to respond)
|
||||
// AND it may trigger multiple replies if more than one client are connected.
|
||||
// Alternatively, we could do this:
|
||||
// send('/osc_address', value / 127)
|
||||
// receive('/osc_address', value / 127)
|
||||
// Or, to send /SET to a single client:
|
||||
// receive('/SET', '/osc_address', value / 127, {clientId: ID})
|
||||
|
||||
|
||||
}
|
||||
|
||||
return // bypass original message
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return data if you want the message to be processed
|
||||
return {address, args, host, port}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Read file
|
||||
|
||||
```js
|
||||
|
||||
var fs = nativeRequire('fs')
|
||||
|
||||
module.exports = {
|
||||
|
||||
oscOutFilter:function(data){
|
||||
// Filter outgoing osc messages
|
||||
|
||||
var {address, args, host, port} = data
|
||||
|
||||
if (address === '/file') {
|
||||
|
||||
fs.readFile(args[0].value, 'utf8' , (err, data) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
receive('/html', data)
|
||||
})
|
||||
|
||||
return // bypass original message
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return data if you want the message to be processed
|
||||
return {address, args, host, port}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Display RTSP Stream
|
||||
|
||||
```js
|
||||
// requires ffmpeg installed on the system
|
||||
// and rtsp-ffmpeg installed in the custom module's folder (by running npm install rtsp-ffmpeg)
|
||||
// see https://github.com/agsh/rtsp-ffmpeg#ffmpeg for available options
|
||||
|
||||
var rtsp = nativeRequire('rtsp-ffmpeg')
|
||||
|
||||
var stream = new rtsp.FFMpeg({
|
||||
input: 'rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream',
|
||||
})
|
||||
|
||||
stream.on('data', (data)=>{
|
||||
|
||||
// send frame to image widget with address set to "/stream"
|
||||
receive('/stream', 'data:image/jpeg;base64,' + data.toString('base64'))
|
||||
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
|
||||
unload: ()=>{
|
||||
stream.stop()
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Custom module merger
|
||||
```js
|
||||
var submodules = [
|
||||
require('./custom_modA.js'),
|
||||
require('./custom_modB.js'),
|
||||
// etc
|
||||
]
|
||||
|
||||
|
||||
module.exports = {
|
||||
init: function(){
|
||||
for (var m of submodules) {
|
||||
if (m.init) m.init()
|
||||
}
|
||||
},
|
||||
reload: function(){
|
||||
for (var m of submodules) {
|
||||
if (m.reload) m.reload()
|
||||
}
|
||||
},
|
||||
oscInFilter: function(data){
|
||||
|
||||
for (var m of submodules) {
|
||||
if (m.oscInFilter) data = m.oscInFilter(data)
|
||||
if (!data) return
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
},
|
||||
oscOutFilter: function(data){
|
||||
|
||||
for (var m of submodules) {
|
||||
if (m.oscOutFilter) data = m.oscOutFilter(data)
|
||||
if (!data) return
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Dynamic widget creation
|
||||
```js
|
||||
function create_widgets() {
|
||||
receive('', '', '/EDIT', 'root', {
|
||||
widgets: [{
|
||||
type: 'panel',
|
||||
id: 'my_panel',
|
||||
layout: 'vertical',
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
widgets: [
|
||||
{
|
||||
type: 'text',
|
||||
id: 'notice',
|
||||
value: 'Hello, world!',
|
||||
width: '100%',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
id: 'button',
|
||||
address: '/foo',
|
||||
preArgs: [1],
|
||||
},
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
reload: function(){
|
||||
// Create widgets whenever the custom modules is edited
|
||||
create_widgets()
|
||||
},
|
||||
}
|
||||
|
||||
// Create widgets whenever an existing session is loaded
|
||||
app.on('sessionOpened', ()=>{
|
||||
create_widgets()
|
||||
})
|
||||
|
||||
// And when a new session is created
|
||||
app.on('sessionSetPath', (e)=>{
|
||||
if (e.path === '') {
|
||||
create_widgets()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Simple bridge
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
||||
oscInFilter: function(data) {
|
||||
|
||||
// pass through incoming messages directly to another application
|
||||
send('127.0.0.1', 12345, data.address, ...args)
|
||||
|
||||
return data // let original message reach clients / widgets
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Starting with `v1.6.0`, custom modules can load submodules with the `require()` function.
|
||||
|
||||
**1**. define some variable in `number.js`
|
||||
|
||||
```javascript
|
||||
module.exports = 42
|
||||
```
|
||||
|
||||
**2**. retrieve it in your main module file (`main.js`):
|
||||
|
||||
```javascript
|
||||
var num = require('./number.js')
|
||||
|
||||
module.exports = {
|
||||
init: function(){
|
||||
console.log(num) // 42
|
||||
},
|
||||
oscInFilter: function(data){
|
||||
// etc
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
# CSS Tips
|
||||
|
||||
## Browser inspector
|
||||
|
||||
|
||||
Hit ++f12++ to open the developers tools panel. The html/css inspector helps retrieving the class names needed to style specific parts of the widgets: hit ++ctrl+shift+c++ or click on the inspect icon () and click on a element in the interface to reveal its html code.
|
||||
|
||||
|
||||
## Inline syntax
|
||||
|
||||
For simple use cases, the `css` property can be written as a HTML inline styles (without any CSS selector). CSS rules will apply to the widget element.
|
||||
|
||||
```css
|
||||
opacity: 0.5; /* make the widget transparent */
|
||||
font-size: 120%; /* increase font-size */
|
||||
```
|
||||
|
||||
|
||||
## Selector syntax
|
||||
|
||||
CSS selectors can be used to apply styles to specific elements:
|
||||
|
||||
```css
|
||||
:host {
|
||||
/* style for the widget element
|
||||
& { } also works (deprecated)
|
||||
*/
|
||||
}
|
||||
|
||||
label {
|
||||
/* style for the label elements */
|
||||
}
|
||||
|
||||
> label {
|
||||
/* style for the direct child label element */
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
!!! info ""
|
||||
Mixing Inline and Selector syntaxes doesn't work, once you use selectors, you have to use the `:host` selector to target the widget element.
|
||||
|
||||
## Extra css classes: `class`
|
||||
|
||||
This non-standard css property can be used to add custom css classes to the widget element: `class: my-custom-class;`
|
||||
Multiple classes can be added (one per `class` statement). Custom classes are always added to the widget's root element, css selectors are ignored.
|
||||
|
||||
!!! info ""
|
||||
Using class names that are already used in the app can be hazardous. In order to avoid that, custom class names should be prefixed with something uncommon and preferably cool, such as `xxx-myclass` or `crispy-seitan-myclass`.
|
||||
|
||||
## Layering: `z-index`
|
||||
|
||||
Z-Axis ordering can be set using the `z-index` rule. Widgets positioned at absolute coordinates (when `top` or `left` is different from `auto`) have `z-index:10;` by default.
|
||||
|
||||
## Responsive sizing
|
||||
|
||||
In most cases, using `vertical`, `horizontal` or `grid` layouts as well as using percentages in `height` and `width` will do. CSS `calc()` function can help in some cases (set the corresponding property to `auto` to avoid conflicts):
|
||||
|
||||
```css
|
||||
:host {
|
||||
|
||||
width: calc(100% - 100rem);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Media queries can also be used:
|
||||
|
||||
```css
|
||||
@media screen and (min-width: 768px) {
|
||||
|
||||
:host {
|
||||
|
||||
/* style the widget if the screen is bigger than 768px */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Size units
|
||||
|
||||
- use `rem` instead of `px` (`px` values will not scale when zooming), except for media queries
|
||||
- use `%` for font-size
|
||||
|
||||
|
||||
## CSS variables
|
||||
|
||||
[CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) declared in the [default theme](https://github.com/jean-emmanuel/open-stage-control/blob/master/src/scss/themes/default.scss) can be overridden.
|
||||
|
||||
Widgets also rely on CSS variables for the style properties (colors, padding, etc). These are documented in the widgets' `css` property description.
|
||||
|
||||
# Loading images
|
||||
|
||||
Image urls are resolved in this order:
|
||||
- in the session's directory
|
||||
- in theme's directory
|
||||
- in the server's `remote-root` directory if the option is set
|
||||
- as absolute paths
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
## Built-in themes
|
||||
|
||||
Themes can be loaded with the `--theme` option. Multiple themes can be combined. Built-in themes can be loaded using their name, custom theme files can be loaded using their path.
|
||||
|
||||
Available themes (full color scheme):
|
||||
|
||||
- `nord`: arctic color palette (https://www.nordtheme.com/)
|
||||
- `orange`: grey and orange theme
|
||||
|
||||
## Creating a custom theme
|
||||
|
||||
Creating a custom theme is as simple as writing a tiny css file that will override the default css variables defined in [default.scss](https://github.com/jean-emmanuel/open-stage-control/blob/master/src/scss/themes/default.scss) :
|
||||
|
||||
```css
|
||||
:root {
|
||||
--color-accent: red;
|
||||
}
|
||||
```
|
||||
|
||||
This will change the default accent color to red. Variables can also be overridden for a specific subset of elements, for example :
|
||||
|
||||
```css
|
||||
.panel-container {
|
||||
--color-accent: blue;
|
||||
}
|
||||
```
|
||||
|
||||
This will change the default accent color to blue for all elements in panel widgets.
|
||||
|
||||
## Autoreload
|
||||
|
||||
Theme files are reloaded automatically when they are modified.
|
||||
|
||||
## SCSS
|
||||
|
||||
If you want to use the [SCSS](https://sass-lang.com/documentation/syntax) syntax to write your theme, follow the [Running from sources](../../getting-started/running-from-sources) instructions, create a `.scss` file in `src/scss/themes/` and run `npm run watch-css`. The theme will be watched and compiled automatically to a css file located in `app/assets/themes/` (css files in this directory can be selected from the theme option by their name, without .css suffix).
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
Welcome to Open Stage Control documentation. Along these pages you'll learn how to setup OSC on your system and everything you need to start building your own control interface.
|
||||
|
||||
## Overview
|
||||
|
||||
Open Stage Control consists of 3 modules: the server, the launcher and the client.
|
||||
|
||||
The **server** is the core of the software, it is responsible for sending and receiving all osc/midi messages, and act as a web server that serves the clients web application. It is written in Javascript and runs with Electron, a cross-platform framework based on Chromium. By default, the server always opens a client window when it starts but it can be run in *headless* mode, without any window.
|
||||
|
||||
The **launcher** provides a simple way to configure and start the server. It appears whenever the server is not launched from a terminal or without being configured.
|
||||
|
||||
The **client** is the web application made available by the server when it starts. Any compatible browser that connects to the server by browsing to its address will create a new client instance and be able to open and modify sessions.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
The **server** can run on all [platforms supported by Electron](https://www.electronjs.org/docs/tutorial/support#supported-platforms). Systems that can run [Node.js](https://nodejs.org/en/) may also be able to run it in headless mode (see [Running with Node](./running-with-node.md)).
|
||||
|
||||
The **client** is compatible with the following browsers:
|
||||
|
||||
- Firefox: version `75` and higher
|
||||
- Chromium / Chrome: version `75` and higher
|
||||
|
||||
iOS devices must be of version `11` or higher.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
=== "Linux 64bit"
|
||||
|
||||
**Ubuntu / Debian**
|
||||
|
||||
- [Download](/download) `open-stage-control-VERSION-amd64.deb`
|
||||
- Install it by running this as root in a terminal:
|
||||
```bash
|
||||
dpkg -i path/to/open-stage-control-VERSION-ARCH.deb
|
||||
```
|
||||
|
||||
**Other linux distributions**
|
||||
|
||||
- [Download](/download) `open-stage-control-VERSION-linux-x64.zip`
|
||||
- Extract it in the location of your choice
|
||||
- The file inside it named `open-stage-control` is the app's main executable
|
||||
|
||||
=== "Mac 64bit"
|
||||
|
||||
- [Download](/download) `open-stage-control-VERSION-osx-x64.zip`
|
||||
- Extract it in the location of your choice
|
||||
- Drag `open-stage-control.app` in your `Application` folder
|
||||
|
||||
|
||||
=== "Mac Silicon (arm)"
|
||||
|
||||
- [Download](/download) `open-stage-control-VERSION-osx-arm.zip`
|
||||
- Extract it in the location of your choice
|
||||
- Drag `open-stage-control.app` in your `Application` folder
|
||||
|
||||
See [https://disable-gatekeeper.github.io/](https://disable-gatekeeper.github.io/) to workaround the "damaged and can't be opened" error.
|
||||
|
||||
=== "Windows 64bit"
|
||||
|
||||
- [Download](/download) `open-stage-control-VERSION-win32-x64.zip`
|
||||
- Extract it in the location of your choice
|
||||
- The file inside it named `open-stage-control.exe` is the app's main executable
|
||||
|
||||
=== "Other systems"
|
||||
|
||||
- Install [Node.js](https://nodejs.org/en/download/package-manager/)
|
||||
- Download `open-stage-control-VERSION-node.zip`
|
||||
- Extract it in the location of your choice
|
||||
- In a terminal, run `node /path/to/open-stage-control-VERSION-node --help`
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
Running the app from the sources slightly differs from using prebuilt binaries: we'll build and launch the app with npm (node package manager).
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Node.js](https://nodejs.org/en/#download)
|
||||
- [git](https://git-scm.com/downloads)
|
||||
|
||||
|
||||
## Run from sources
|
||||
|
||||
|
||||
**Download**
|
||||
|
||||
```bash
|
||||
git clone https://framagit.org/jean-emmanuel/open-stage-control.git
|
||||
cd open-stage-control/
|
||||
# uncomment next line if you want the latest release
|
||||
# instead of the current development version
|
||||
# git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
!!! tip "Raspberry systems"
|
||||
Run one of these instead of `npm install` (you can get the system's `arch` by running `uname -m` in a terminal)
|
||||
```
|
||||
npm install --arch=arm64
|
||||
npm install --arch=armv7l
|
||||
```
|
||||
|
||||
|
||||
!!! info "Updating from sources"
|
||||
```bash
|
||||
git pull
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
**Run**
|
||||
|
||||
```bash
|
||||
npm start [ -- options]
|
||||
```
|
||||
|
||||
!!! info ""
|
||||
A double hyphen (`--`) is used here to tell npm that the options are to be passed to the app.
|
||||
|
||||
|
||||
!!! warning "MIDI support"
|
||||
When running from sources, MIDI support won't be enabled unless the [MIDI configuration procedure](../../midi/midi-configuration/) for "other systems" is followed.
|
||||
|
||||
## Build documentation
|
||||
|
||||
In order to make the local documentation available through the server's `--docs` option and the launcher's `Documentation` menu action, an extra step is needed.
|
||||
|
||||
|
||||
```bash
|
||||
# install docs website theme
|
||||
python3 -m pip install mkdocs-material
|
||||
# build docs website
|
||||
npm run build-docs
|
||||
```
|
||||
|
||||
## Package from sources
|
||||
|
||||
Follow the "Run from sources" instructions, then:
|
||||
|
||||
```bash
|
||||
|
||||
# TARGET_PLATFORM can be linux, win32 (windows) or darwin (os x)
|
||||
export PLATFORM=TARGET_PLATFORM
|
||||
# TARGET_ARCH can be ia32, x64, armv7l or arm64
|
||||
export ARCH=TARGET_ARCH
|
||||
|
||||
|
||||
npm run package
|
||||
|
||||
|
||||
# The node-only package can be built with
|
||||
npm run package-node
|
||||
|
||||
```
|
||||
|
||||
This will build the app in `dist/open-stage-control-PLATFORM-ARCH`.
|
||||
|
||||
!!! info ""
|
||||
Building the app for windows from a linux system requires wine to be installed.
|
||||
|
||||
|
||||
## Debian / Ubuntu and RPM installers
|
||||
|
||||
=== "Debian / Ubuntu"
|
||||
|
||||
```
|
||||
npm run deb64
|
||||
```
|
||||
|
||||
=== "RPM"
|
||||
|
||||
```
|
||||
npm run rpm
|
||||
```
|
||||
|
||||
|
||||
## Build script on Mac Silicon
|
||||
|
||||
This user-contributed script can be used to build open stage control on recent Macs:
|
||||
|
||||
https://github.com/rewgs/osc-as
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
## Lite headless mode
|
||||
|
||||
It's possible to run the server in headless mode with the nodejs engine embedded in Electron, this reduces memory / cpu usage significantly.
|
||||
|
||||
```
|
||||
ELECTRON_RUN_AS_NODE=1 open-stage-control path/to/open-stage-control/resources/app/ [options]
|
||||
```
|
||||
|
||||
|
||||
## Running with node
|
||||
|
||||
If Electron does not run on your platform, it is possible to run the server in headless mode using [Node.js](https://nodejs.org/en/download/package-manager/).
|
||||
|
||||
|
||||
1. Install [Node.js](https://nodejs.org/en/download/package-manager/)
|
||||
2. Download `open-stage-control-[version]-node.zip` package and extract it
|
||||
3. Run `node /path/to/open-stage-control [options]`
|
||||
|
||||
|
||||
!!! info
|
||||
When running from sources or with regular binaries (packaged with electron), the command slightly differs:
|
||||
|
||||
- electron package: `node /path/to/open-stage-control/resources/app [options]`
|
||||
- from sources: `node /path/to/open-stage-control/app [options]`
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
The **server** can be configured with many options, either from a terminal or with the help of the **launcher**.
|
||||
|
||||
## Options
|
||||
|
||||
!!! quote ""
|
||||
#### `send`
|
||||
|
||||
Defines the default osc/midi targets. These will be added to the widget's individual targets. Targets must be separated by a space and formatted as follows:
|
||||
|
||||
- `ip_address:port`
|
||||
- `host_name:port`
|
||||
- `midi:device_name`
|
||||
|
||||
!!! quote ""
|
||||
#### `load`
|
||||
|
||||
Path to a session file (.json). All clients connecting the server will load it.
|
||||
|
||||
!!! quote ""
|
||||
#### `state`
|
||||
|
||||
Path to a state file (.state). All clients connecting the server will load it.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `custom-module`
|
||||
|
||||
Path to a custom module file (.js).
|
||||
|
||||
**WARNING:** custom module can access the file system, use at your own risk.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `port`
|
||||
|
||||
HTTP port for the server (default: `8080`).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `osc-port`
|
||||
|
||||
OSC (UDP) input port (default: `port`).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `tcp-port`
|
||||
|
||||
OSC (TCP) input port.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `tcp-targets`
|
||||
|
||||
TCP servers to connect to. When sending osc messages, if the target matches one of these, TCP protocol will be used instead of UDP. Targets must be separated by a space and formatted as follows:
|
||||
|
||||
- `ip_address:port`
|
||||
- `host_name:port`
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `midi`
|
||||
|
||||
MIDI options separated by spaces, MIDI support must be enabled, see [MIDI configuration](../midi/midi-configuration.md).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `debug`
|
||||
|
||||
Print sent and received messages in the console. This may impact performance and should not be enabled in production.
|
||||
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `no-gui`
|
||||
|
||||
Disable built-in client window.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `fullscreen`
|
||||
|
||||
Start the built-in client window in fullscreen.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `theme`
|
||||
|
||||
Theme names or paths. See [Themes](../customization/themes.md).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `client-options`
|
||||
|
||||
Default [client options](../client-options.md), separated by spaces.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `disable-vsync`
|
||||
|
||||
Disable built-in client window's vertical synchronization.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `force-gpu`
|
||||
|
||||
Disable built-in client window's gpu blacklist (may improve rendering performance in some cases).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `read-only`
|
||||
|
||||
Disable session editing, and file saving.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `remote-saving`
|
||||
|
||||
Disable file saving for hosts that don't match the regular expression.
|
||||
|
||||
Sessions are saved and opened on the server's filesystem. It is possible to limit this feature to specific client with a regular expression. For example, `"127.0.0.1|192.168.0.10"` disables remote saving except for clients with ip addresses `127.0.0.1` (the server's local address) and `192.168.0.10`.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `remote-root`
|
||||
|
||||
Set file browsing root folder. Prevent writing files outside of this folder.
|
||||
|
||||
!!! quote ""
|
||||
#### `authentication`
|
||||
|
||||
Restrict access to `user:password` (remote clients will be prompted for these credentials).
|
||||
|
||||
!!! quote ""
|
||||
#### `instance-name`
|
||||
|
||||
Server's name on zeroconf/bonjour network. Incremented automatically if not available.
|
||||
|
||||
!!! quote ""
|
||||
#### `use-ssl`
|
||||
|
||||
Use HTTPS protocol instead of HTTP (a self-signed certificate will be created)
|
||||
|
||||
|
||||
|
||||
## Command-line options
|
||||
|
||||
The following options can only be set from a terminal.
|
||||
|
||||
!!! quote ""
|
||||
#### `disable-gpu`
|
||||
|
||||
Disable hardware acceleration for the launcher window and the built-in client window.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `inspect`
|
||||
|
||||
Enable node inspector.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `cache-dir`
|
||||
|
||||
Override default cache directory (contains browser cache and localStorage data).
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `config-file`
|
||||
|
||||
Override default config file location (contains session history and launcher config). Defaults to `cache-dir/config.json`.
|
||||
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `client-position`
|
||||
|
||||
Define the built-in client window position, must be a pair of integers separated by a comma (`x,y`).
|
||||
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `client-size`
|
||||
|
||||
Define the built-in client window size, must be a pair of integers separated by a comma (`width,height`).
|
||||
|
||||
!!! quote ""
|
||||
#### `no-qrcode`
|
||||
|
||||
Disable qrcode when the server starts.
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `help`
|
||||
|
||||
Show help.
|
||||
|
||||
!!! quote ""
|
||||
#### `docs`
|
||||
|
||||
Serve documentation website locally and open it with the system's default browser
|
||||
|
||||
|
||||
!!! quote ""
|
||||
#### `version`
|
||||
|
||||
Show version number.
|
||||
|
||||
|
||||
## Running in a terminal
|
||||
|
||||
Options name must be prepended with a double dash (`--`) in a terminal.
|
||||
|
||||
!!! example "Example"
|
||||
```
|
||||
open-stage-control --no-gui --load path/to/your/session.json --theme path/to/your/theme.css
|
||||
```
|
||||
|
||||
Launches the server in headless mode, and makes all clients load provided session and theme automatically.
|
||||
|
||||
|
||||
## Running in a terminal on Windows
|
||||
|
||||
Windows users launching the app from a terminal need to add a double dash (`--`) and a space before their options:
|
||||
|
||||
```bash
|
||||
open-stage-control.exe -- --port 5555 [...]
|
||||
|
||||
# when running from sources
|
||||
npm start -- -- [options]
|
||||
```
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
## Installation
|
||||
|
||||
|
||||
=== "Linux / Windows / OSX"
|
||||
|
||||
Open Stage Control comes bundled with built-in MIDI support if you're using the official package for Linux, OSX or Windows.
|
||||
|
||||
|
||||
=== "Other systems / Node"
|
||||
|
||||
Enabling MIDI support on other systems or when building Open Stage Control from sources requires additional softwares to be installed on the server's system:
|
||||
|
||||
- [python 3](https://www.python.org/downloads/)
|
||||
- python package [python-rtmidi](https://spotlightkid.github.io/python-rtmidi/installation.html#from-pypi)
|
||||
|
||||
|
||||
??? example "Linux"
|
||||
|
||||
Install `python3-rtmidi` from your distribution's package repository, or if it's not available:
|
||||
|
||||
- Install `python3` and `python3-pip` from your distribution's package repository
|
||||
- Run this command in a terminal
|
||||
```bash
|
||||
python3 -m pip install python-rtmidi --upgrade
|
||||
```
|
||||
|
||||
??? example "Mac"
|
||||
|
||||
- Download and install [Python 3 for Mac OS](https://www.python.org/downloads/mac-osx/)
|
||||
- Open a terminal
|
||||
- Install `pip` (package installer for python) by executing these commands
|
||||
```
|
||||
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
```
|
||||
- Install `python-rtmidi` by executing this command
|
||||
```bash
|
||||
python -m pip install python-rtmidi --upgrade
|
||||
```
|
||||
|
||||
??? example "Windows"
|
||||
|
||||
- Download and install [Python 3 for Windows](https://www.python.org/downloads/windows/)
|
||||
- **make sure to check the option** "Add Python 3.x to PATH"
|
||||
- Open a terminal (++win+r++)
|
||||
- Install `pip` (package installer for python) by executing these commands
|
||||
```
|
||||
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
||||
python get-pip.py
|
||||
```
|
||||
- Install `python-rtmidi` by executing this command
|
||||
```bash
|
||||
python -m pip install python-rtmidi --upgrade
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The server's `midi` option accepts the following parameters, separated by spaces.
|
||||
|
||||
!!! warning ""
|
||||
If an option contains space characters, it must be quoted.
|
||||
|
||||
**`list`**
|
||||
|
||||
Print the available MIDI ports to the console when the server starts. This action is also available in the launcher's menu.
|
||||
|
||||
**`device_name:input,output`**
|
||||
|
||||
Create a virtual MIDI device that will translate OSC messages to MIDI messages
|
||||
|
||||
- `device_name` is an arbitrary identifier that can be used as a target by widgets (see [Widget setup](#widget-setup)). It doesn't have to match any device's real name.
|
||||
- `input` / `output` can be port numbers or strings (as reported by the `list` action). If a string is specified, the first port whose name contains the string will be used (comparison is case-insensitive).
|
||||
|
||||
**`sysex`**
|
||||
|
||||
Enable parsing of system exclusive messages (disabled by default).
|
||||
|
||||
**`mtc`**
|
||||
|
||||
Enable parsing of midi time code messages (disabled by default).
|
||||
|
||||
**`rpn`**
|
||||
|
||||
Enable sending and receiving [RPN/NRPN](https://en.wikipedia.org/wiki/NRPN) controls on as single `/rpn` / `/nrpn` messages instead of 3 or 4 control changes that constitute them.
|
||||
|
||||
|
||||
**`active_sensing`**
|
||||
|
||||
Enable parsing of midi active sensing messages (disabled by default). Active sensing messages will be received as sysex.
|
||||
|
||||
**`pc_offset`**
|
||||
|
||||
Send program changes with a `-1` offset to match some software/hardware implementations
|
||||
|
||||
**`note_off_velocity`**
|
||||
|
||||
Use `/note_on` for noteOn messages and `/note_off` for noteOff messages instead of the defaut `/note` and velocity 0 for note off.
|
||||
|
||||
**`auto_note_off`**
|
||||
|
||||
Prevent converting outgoing noteOn messages with velocity 0 to noteOff messages.
|
||||
|
||||
|
||||
**`device_name:virtual`** (*Linux / Mac only*): creates a virtual midi device with one input port and one output port
|
||||
|
||||
|
||||
**`jack`** (*Linux only*): use JACK MIDI instead of ALSA. `python-rtmidi` must be compiled with [jack support](https://spotlightkid.github.io/python-rtmidi/installation.html#linux) for this to work.
|
||||
|
||||
|
||||
**`path=/path/to/python`**
|
||||
|
||||
*Only use this if you know what you are doing. This option should not be set when using the official Linux / Windows / OSX packages.*
|
||||
|
||||
Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`).
|
||||
|
||||
|
||||
## Widget setup
|
||||
|
||||
In order to send MIDI messages, a widget must have at least one `target` formatted as follows:
|
||||
|
||||
`midi:device_name` (where `device_name` is one of the declared midi devices)
|
||||
|
||||
Its `address` and `preArgs` properties must be set according to Open Stage Control's [midi messages](../midi-messages) specification.
|
||||
|
||||
!!! warning
|
||||
Messages received from a MIDI port only affect widgets that send to this port.
|
||||
|
||||
## Debug
|
||||
|
||||
Enabling the server's `debug` options will print some extra information (sent/received midi messages, midi setup information, etc)
|
||||
|
||||
## Example configuration
|
||||
|
||||
Setting the server's `midi` option as follows:
|
||||
|
||||
```
|
||||
sysex synth:1,2 daw:3,3
|
||||
```
|
||||
|
||||
- enables sysex support (sysex messages will not be ignored)
|
||||
- creates a midi device "synth" connected with input 1 and output 2
|
||||
- creates a midi device "daw" connected with input 3 and output 3
|
||||
|
||||
If a widget has its `target` set to `midi:synth`, it will receive MIDI from port 1 and send MIDI to port 2.
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
!!! info ""
|
||||
Define static argument values using the [`preArgs`](/docs/widgets/properties-reference/#preArgs) option in order to complete the respective MIDI message.
|
||||
|
||||
----
|
||||
|
||||
#### `/note channel note velocity`
|
||||
|
||||
NoteOn event or noteOff if velocity equals `0`. Incoming noteOff events will be received as `/note` with velocity 0 if `note_off_velocity` is not set during [setup](../midi-configuration).
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `note`: integer between 0 and 127
|
||||
- `velocity`: integer between 0 and 127
|
||||
|
||||
!!! example "Example"
|
||||
|
||||
A push button might be configured as follows in order to send a MIDI note whose velocity is defined by the button's on/off value:
|
||||
|
||||
- `address`: `/note`
|
||||
- `preArgs`: `[1, 60]` (for MIDI channel 1, and note 60 / C4)
|
||||
- `on`: `100` (for noteOn velocity of 100 on button push)
|
||||
- `off`: `0` (to send a noteOff on button release)
|
||||
- `target`: `midi:device_name` (where device_name is one of the declared midi devices defined during [setup](../midi-configuration))
|
||||
|
||||
----
|
||||
|
||||
#### `/note_off channel note velocity`
|
||||
|
||||
NoteOff event with any velocity. Incoming noteOff events will be received as `/note_off` if `note_off_velocity` is set during [setup](../midi-configuration).
|
||||
|
||||
----
|
||||
|
||||
#### `/control channel cc value`
|
||||
|
||||
Control change event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `cc`: integer between 0 and 127
|
||||
- `value`: integer between 0 and 127
|
||||
|
||||
!!! example "Example"
|
||||
|
||||
A fader might be configured as follows in order to send a MIDI control message (a volume control in this example):
|
||||
|
||||
- `address`: `/control`
|
||||
- `pre-args`: `[1, 7]` (MIDI channel 1, control number 7 generally used as volume control)
|
||||
- `range`: `{"min": 0, "max": 127}` (MIDI values are encoded in this range)
|
||||
- `target`: `midi:device_name`
|
||||
|
||||
----
|
||||
|
||||
#### `/program channel program`
|
||||
|
||||
Program change event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `program`: integer between 0 and 127*
|
||||
|
||||
!!! info
|
||||
\* Some devices / softwares display the `program` value between 1 and 128, thus interpreting `program change 0` as `program change 1` and so on. Add the `pc_offset` parameter to the server's `midi` option to make Open Stage Control behave this way.
|
||||
|
||||
----
|
||||
|
||||
#### `/pitch channel pitch`
|
||||
|
||||
PitchWheel event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `pitch`: integer between 0 and 16383
|
||||
|
||||
----
|
||||
|
||||
#### `/sysex msg`
|
||||
|
||||
System exclusive message.
|
||||
|
||||
- `msg`: hexadecimal sysex data string of the form `f0 ... f7`.
|
||||
|
||||
Instead of a single hexadecimal string, arguments can be separated and defined either as hexadecimal bytes or as integers. When received, system messages are always formatted as a single hexadecimal string.
|
||||
|
||||
----
|
||||
|
||||
#### `/mtc timecode`
|
||||
|
||||
MIDI time code message.
|
||||
|
||||
- `timecode`: `hh:mm:ss:ff` string.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/channel_pressure channel pressure`
|
||||
|
||||
Channel pressure event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `pressure`: integer between 0 and 127
|
||||
|
||||
----
|
||||
|
||||
|
||||
#### `/key_pressure channel note pressure`
|
||||
|
||||
Polyphonic key pressure event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `note`: integer between 0 and 127
|
||||
- `pressure`: integer between 0 and 127
|
||||
|
||||
----
|
||||
|
||||
|
||||
#### `/rpn channel rpn value`
|
||||
|
||||
Registered Parameter Number event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `rpn`: integer between 0 and 16383
|
||||
- `value`: integer between 0 and 16383
|
||||
|
||||
----
|
||||
|
||||
#### `/nrpn channel nrpn value`
|
||||
|
||||
Non-Registered Parameter Number event.
|
||||
|
||||
- `channel`: integer between 1 and 16
|
||||
- `nrpn`: integer between 0 and 16383
|
||||
- `value`: integer between 0 and 16383
|
||||
|
||||
----
|
||||
|
|
@ -1,237 +0,0 @@
|
|||
# Remote control
|
||||
|
||||
When osc messages are received, the default behavior is to update the value of all widgets that match the address and preArgs. Additionally, Open Stage Control clients respond to some general osc commands.
|
||||
|
||||
!!! note "Multi-client setup"
|
||||
These commands are interpreted by each client connected to the server so there might be more than one reply. Using a custom module is the only way to send a message to a single client.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT id properties options`
|
||||
|
||||
|
||||
Apply a set of options to an existing widget by replacing the old ones with the new ones. This ignores the widget's `lock` property. If sent by a custom module using `receive()`, this command will not be prevented by the server's `read-only` option.
|
||||
|
||||
- `id`: `string`, widget's `id`
|
||||
- `properties`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge
|
||||
- example: `{"label":"New Label", "color":"red"}`
|
||||
- `options` (optional): `string`, [JSON5](https://github.com/json5/json5) stringified object defining extra option flags:
|
||||
- `noWarning`: set to `true` to prevent further warning when exiting.
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT/MERGE id properties options`
|
||||
|
||||
Apply a set of options to an existing widget by merging them to the widget's options.
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT/UNDO`
|
||||
|
||||
Undo editing action
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT/REDO`
|
||||
|
||||
Redo editing action
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT/GET target id`
|
||||
|
||||
Sends back a widget's data (JSON stringified object), including its children, to specified target.
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
- `id`: `string`, widget's `id`
|
||||
|
||||
Replies `/EDIT/GET id data`
|
||||
|
||||
- `id`: `string`
|
||||
- `data`: `string`
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/EDIT/GET target address preArg1 preArg2 ...`
|
||||
|
||||
Sends back a widget's data (JSON stringified object), including its children, to specified target.
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
|
||||
Replies `/EDIT/GET address preArg1 preArg2 ... data`
|
||||
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
- `data`: `string`
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/GET target id`
|
||||
|
||||
Sends back a widget's value to specified target.
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
- `id`: `string`, widget's `id`
|
||||
|
||||
Replies `/GET id value`
|
||||
|
||||
- `id`: `string`
|
||||
- `value`: `*`
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/GET target address preArg1 preArg2 ...`
|
||||
|
||||
Sends back a widget's value to specified target.
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
|
||||
Replies `/GET address preArg1 preArg2 ... value`
|
||||
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
- `value`: `*`
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/GET/#`
|
||||
|
||||
Same as `/GET` but uses the widget's address instead of `/GET` to reply.
|
||||
|
||||
----
|
||||
|
||||
#### `/NOTIFY icon message`
|
||||
|
||||
Sends a notification message to the client.
|
||||
|
||||
- `icon`: icon for the notification, for example : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)
|
||||
- `message`: message content
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/LOG message`
|
||||
|
||||
Print message in the client's console.
|
||||
|
||||
----
|
||||
|
||||
#### `/SET id value`
|
||||
|
||||
Set a widget's value as if it was interacted with from the interface. This is likely to make it send its value.
|
||||
|
||||
- `id`: `string`, widget's `id`
|
||||
- `value`: `*`, widget's new value
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/SET address preArg1 preArg2 ... value`
|
||||
|
||||
Set a widget's value as if it was interacted with from the interface. This is likely to make it send its value.
|
||||
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
- `value`: `*`, widget's new value
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/GET target`
|
||||
|
||||
Sends back the app's state to specified target
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/SET state send`
|
||||
|
||||
Set widgets' state
|
||||
|
||||
- `state`: `string`, json stringified object (`"widget_id": value` pairs)
|
||||
- `send` (optional): `boolean`, set to `false` to prevent widgets from sending their values when the state is applied
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/STORE`
|
||||
|
||||
Save the state of all widgets in the temporary slot.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/RECALL`
|
||||
|
||||
Reload saved state from the temporary slot.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/SEND`
|
||||
|
||||
Make all widgets send their current value.
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/OPEN path.state`
|
||||
|
||||
Open state file `path.state`.
|
||||
|
||||
----
|
||||
|
||||
#### `/STATE/SAVE path.state`
|
||||
|
||||
Save state session to `path.state`.
|
||||
|
||||
----
|
||||
|
||||
#### `/SESSION/CREATE`
|
||||
|
||||
Create a new empty session. Unsaved changes will be lost.
|
||||
|
||||
----
|
||||
#### `/SESSION/OPEN path.json`
|
||||
|
||||
Open session file `path.json`.
|
||||
|
||||
----
|
||||
|
||||
#### `/SESSION/SAVE path.json`
|
||||
|
||||
Save current session to `path.json`. If `path.json` is omitted, current session's path is used.
|
||||
|
||||
----
|
||||
|
||||
#### `/TABS tab_id1 tab_id2 ...`
|
||||
|
||||
Open the tabs designated by the id parameters.
|
||||
|
||||
----
|
||||
|
||||
#### `/SCRIPT code`
|
||||
|
||||
Run code as if it where executed by a script widget.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `/RELOAD`
|
||||
|
||||
Reload page in the browser.
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
# Change a widget property with an osc message
|
||||
|
||||
By default, widgets only expose their value to incoming messages, but there are multiple ways to allow changing any widget property using osc messages as well. In this tutorial we'll explore the different possibilities for exposing the `visible` property of a widget to incoming messages, but it applies to any other property.
|
||||
|
||||
## 1. Using a variable widget
|
||||
|
||||
Create a variable widget and set up its `address` (and `preArgs` if needed) so that it receives the messages you want to use, and then in your other widget's `visible` property, use the [inheritance syntax](../widgets/advanced-syntaxes.md#inheritance-idproperty) to retrieve the variable's value:
|
||||
|
||||
|
||||
=== "Inheritance syntax"
|
||||
```
|
||||
@{variable_id}
|
||||
```
|
||||
=== "Inheritance syntax + Javascript"
|
||||
```js
|
||||
JS{
|
||||
// bonus, in case you don't want to use the variable's value as-is
|
||||
if (@{variable_id} > 0.5) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now the variable's value will determine the visibility of the widget. The `visible` property expects a boolean value (`true` for visible, `false` for invisible) but any [truthy](https://developer.mozilla.org/en-US/docs/Glossary/truthy) / [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) will do (e.g. `1` for visible, `0` for invisible is a sensible choice).
|
||||
|
||||
## 2. Using the OSC listener syntax
|
||||
|
||||
The [OSC listener syntax](../widgets/advanced-syntaxes.md#osc-listeners-oscaddress-default-usepreargs) might be a more straightforward solution for simple use cases. Writing this in a widget's `visible` property:
|
||||
|
||||
|
||||
=== "Relative address"
|
||||
```
|
||||
OSC{show}
|
||||
```
|
||||
|
||||
will listen for messages on address `/widget_address/show` and return the last received value.
|
||||
|
||||
|
||||
If we write this instead:
|
||||
|
||||
=== "Absolute address"
|
||||
```
|
||||
OSC{/show}
|
||||
```
|
||||
|
||||
the address will be `/show` and won't be prefixed with the widget's address as before.
|
||||
|
||||
|
||||
It is often needed to specify the initial state of the listener (before it receives any message), this is done via the second argument of the listener syntax:
|
||||
|
||||
|
||||
=== "Default value (true)"
|
||||
```
|
||||
OSC{show, true}
|
||||
```
|
||||
=== "Default value (truthy)"
|
||||
```
|
||||
OSC{show, 1}
|
||||
```
|
||||
=== "Default value (false)"
|
||||
```
|
||||
OSC{show, false}
|
||||
```
|
||||
=== "Default value (falsy)"
|
||||
```
|
||||
OSC{show, 0}
|
||||
```
|
||||
|
||||
If the widget has any preArgs set, the osc listener will inherit them by default, this means that for a message to change the listener's value it will not only have to match its address but also the widget's `preArgs`, this can be prevented using the third argument of the listener syntax:
|
||||
|
||||
=== "Ignore preArgs"
|
||||
```
|
||||
OSC{show, 1, false}
|
||||
```
|
||||
|
||||
|
||||
## 3. Using custom variables
|
||||
|
||||
The [custom variable syntax](../widgets/advanced-syntaxes.md#custom-variables-varvariablename-default) connects regular properties and scripting properties (`onCreate`, `onValue`, etc), writing this in the `visible` property:
|
||||
|
||||
```
|
||||
VAR{show}
|
||||
```
|
||||
|
||||
will create a custom variable named `show` scoped to the widget (custom variables do not use a global namespace and multiple widgets may use the same names for their custom variables without conflict). This custom variable can be read and set from any widget scripting property using the [`getVar()` / `setVar()`](../widgets/scripting.md#getvarid-name) functions.
|
||||
|
||||
For instance, we could use a variable widget as osc receiver like in the first example of this tutorial and use it's `onValue` script to change the custom variable's value (instead of using the inheritance syntax):
|
||||
|
||||
```js
|
||||
// variable widget onValue
|
||||
// simply pass received value to the custom variable
|
||||
setVar('widget_id', 'show', value)
|
||||
```
|
||||
|
||||
|
||||
The custom variable's initial state can be specified:
|
||||
|
||||
```
|
||||
VAR{show, 1}
|
||||
```
|
||||
|
||||
## 4. Using /EDIT commands
|
||||
|
||||
The [`/EDIT`](../remote-control.md) remote control command can be used to modify any widget property in the session, for instance:
|
||||
|
||||
```
|
||||
/EDIT widget_id '{visible: false}'
|
||||
```
|
||||
|
||||
Will hide the widget with id `widget_id`. Note that this is different from the 3 techniques described above in that it actually modifies the session and changes the property value in a destructive way (the property is rewritten, not just its state). When quitting the session after using it a warning indicating the session has unsaved changes will be shown, this can be prevented by appending a extra argument to the message:
|
||||
|
||||
```
|
||||
/EDIT widget_id '{visible: false}' '{noWarning: true}'
|
||||
```
|
||||
|
||||
Note that the arguments after `widget_id` are sent as strings ([JSON5](https://github.com/json5/json5)-encoded objects), this is because sending plain javascript object over osc is not possible.
|
||||
|
||||
## Bonus: custom module
|
||||
|
||||
Any of these techniques can be used in conjunction with a [custom module](../custom-module/custom-module.md). Using the `receive()` function allows simulating incoming osc messages and can be used to trigger property changes:
|
||||
|
||||
=== "Variable widget"
|
||||
```js
|
||||
var visible = true
|
||||
receive('/variable_id', visible)
|
||||
// or if variable widgets has preArgs
|
||||
receive('/variable_id', preArg1, preArg2, visible)
|
||||
```
|
||||
=== "OSC listener"
|
||||
```js
|
||||
var visible = true
|
||||
receive('/widget_address/show', visible)
|
||||
// or if listener has preArgs
|
||||
receive('/widget_address/show', preArg1, preArg2, visible)
|
||||
```
|
||||
=== "Custom variable"
|
||||
```js
|
||||
var visible = true
|
||||
receive('/SCRIPT', `setVar('widget_id', 'show', ${visible})`)
|
||||
```
|
||||
=== "/EDIT command"
|
||||
```js
|
||||
var visible = true
|
||||
// what's really cool here is that you don't need to stringify objects arguments
|
||||
// receive() will take care of that for you
|
||||
receive('/EDIT', 'widget_id', {visible: visible}}, {noWarning: true})
|
||||
```
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
# First Steps with Open Stage Control
|
||||
|
||||
*Contributed by H. James Harkins, Feb. 2023*
|
||||
|
||||
Let's walk through the basic steps to build a simple interface in Open Stage Control, send information to another app, and deploy the interface to remote (even mobile) devices.
|
||||
|
||||
Before beginning, you should already have installed Open Stage Control -- see the [Introduction](../getting-started/introduction.md).
|
||||
|
||||
Also: This document provides sample patches for SuperCollider, Pure Data and Max/MSP, to receive control data from the Open Stage Control interface. If you do not have any of these tools, I suggest to install [Pure Data](https://puredata.info/downloads/pure-data) because it has the smallest footprint.
|
||||
|
||||
## The Launcher
|
||||
|
||||
Use your system's application launcher, open the Open Stage Control app. Here, you can configure options for the interface server.
|
||||
|
||||
For now, go to the first box ("send") and type in `127.0.0.1:57120`. This will tell the server to send Open Sound Control messages to the same machine where the server is running, on port 57120.
|
||||
|
||||
NOTE: For your own applications, you can use any port that is not in use. For this example, I chose 57120 because it is SuperCollider's default UDP port (and I set the Pure Data and Max patches to use the same port, to simplify.)
|
||||
|
||||
You don't need to set any other options at this time.
|
||||
|
||||
### Addresses and ports
|
||||
|
||||
Many users approaching Open Sound Control for the first time get confused about ports. You need to be aware of the FROM and TO addresses. The "send" field in the Launcher should reference the address TO which messages should be sent. In this demo, we are assuming that Open Stage Control and the target app are running on the same machine. So the TO address is localhost: `127.0.0.1`. The "send" box should use the port *on which the target app is receiving messages*. This is typically under control of the target app: 1/ SuperCollider opens 57120 by default; 2/ Pd's [netreceive] object, and Max's [udpreceive], both require the TO port as an argument. So the TO port is your choice, as long as they match.
|
||||
|
||||
Open Stage Control sends messages FROM the IP address of the machine where Open Stage Control is running, and from port 8080 (or localhost = `127.0.0.1` if on the same machine). Thus, if the receiving app will filter incoming messages based on address, the filtering address should be the FROM address, port 8080. The target app can also update Open Stage Control's display by sending messages back to exactly this address. So you will see later, in the demo patches, that messages are sent to `127.0.0.1:8080` so that the user's interaction with the target app appears in Open Stage Control as well.
|
||||
|
||||
## Starting the server
|
||||
|
||||
Click the "play" button near the top left of the window. You should see status messages in the launcher window such as:
|
||||
|
||||
```
|
||||
(INFO) Server started, app available at
|
||||
http://127.0.0.1:8080
|
||||
http://your.ip.ad.dress:8080
|
||||
```
|
||||
|
||||
And a new, mostly empty, window will open. This new, larger window is the *client*.
|
||||
|
||||
## The client
|
||||
|
||||
The client allows you to edit and perform your interface.
|
||||
|
||||
The interface design is called a *session*. To create a new session, go to the "three-dots" menu at the top left, and choose Session > New session.
|
||||
|
||||
Two new panels are displayed: a project browser, and an object inspector (to set properties). The empty space in the middle is the editor, where you will build the interface.
|
||||
|
||||
Let's start with a toggle button. Right-click in the empty editor panel in the middle, and navigate to Add widget > Basics > button. For this demo, we don't need to change anything else: the button defaults to toggle behavior, and the display text is not important for now (although you can change it in the inspector, if you want).
|
||||
|
||||
And let's add one more control, to the right of this: Right-click, Add widget > Sliders > fader.
|
||||
|
||||

|
||||
|
||||
When a widget is selected, you can move it by dragging the top-left handle, and resize it by dragging the bottom-right handle. Let's use these handles to position the fader to the right of the button, and stretch it to be horizontal instead of vertical.
|
||||
|
||||

|
||||
|
||||
Notice, however, that the fader's value handle is still vertical. To fix this, look in the Inspector at the right, expand "Fader style," and check the "horizontal" checkbox.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
By the way: I suggest to keep the widgets closer to the top left, so that they are still visible on a phone screen (later).
|
||||
|
||||
When designing an interface for production, you would change other object properties as well. In particular, the Open Sound Control addresses `/button_1` and `/fader_1` are not very descriptive. You would probably want to assign different command paths, in the "osc" tab. As this is just an introduction, we won't do that now.
|
||||
|
||||
## Receiving the data
|
||||
|
||||
At this time, the interface can already be used: three-dots menu > Editor > "Enabled" (click to disable the editor). (The controls will respond also when the editor is enabled, but you have to click an extra time to select the widget before changing its value.)
|
||||
|
||||
To see the effect, launch one of the following apps and open the given patch. The Open Stage Control button should open and close the envelope, and the fader should control frequency. The patches also send control data from their own GUIs back to Open Stage Control, so all of the controls should be synced in both directions.
|
||||
|
||||
NOTE: In Pure Data and Max, the default slider/fader range is 0-127, integers. Open Stage Control uses the range 0.0 - 1.0 by default. If you just create a slider and connect it, you won't see much action. In the example patches, the slider's properties have been modified to take a 0.0 - 1.0 floating-point range, matching the data from Open Stage Control.
|
||||
|
||||
NOTE: Because all of the patches bind to the same UDP port, you can open only one at a time. You could, if you like, change the port number in one patch, and add that port by specifying multiple "send" targets in the Launcher, e.g. `127.0.0.1:57120 127.0.0.1:7374`.
|
||||
|
||||
NOTE: These patches are provided as a courtesy to get you started more quickly. Maintaining, extending or developing them is outside the scope of the Open Stage Control community.
|
||||
|
||||
!!! Example "Choose your app"
|
||||
|
||||
=== "Pure Data"
|
||||
|
||||
Copy the code below, and save it into a text file `osc-first-steps.pd`. Then open it in Pure Data.
|
||||
|
||||
```
|
||||
#N canvas 436 127 562 502 12;
|
||||
#X obj 86 51 loadbang;
|
||||
#X msg 86 76 \; pd dsp 1;
|
||||
#X obj 253 51 netreceive -u -b 57120;
|
||||
#X obj 253 76 oscparse;
|
||||
#X obj 253 101 list trim;
|
||||
#X obj 253 126 route fader_1 button_1;
|
||||
#X msg 253 190 4 \$1;
|
||||
#X obj 253 215 pow;
|
||||
#X obj 253 240 * 200;
|
||||
#X obj 253 265 lop~ 3;
|
||||
#X msg 328 265 \$1 100;
|
||||
#X obj 328 304 line~;
|
||||
#X obj 279 356 *~;
|
||||
#X obj 279 381 *~ 0.1;
|
||||
#X obj 266 424 dac~;
|
||||
#X text 38 139 Open Stage Control \; "First Steps" tutorial \; hjh
|
||||
2023;
|
||||
#X obj 253 304 osc~ 200;
|
||||
#X obj 328 159 tgl 15 0 empty empty empty 17 7 0 10 #fcfcfc #000000
|
||||
#000000 0 1;
|
||||
#X obj 256 159 hsl 60 15 0 1 0 0 empty empty empty -2 -8 0 10 #fcfcfc
|
||||
#000000 #000000 0 1;
|
||||
#X obj 70 251 unpack f s;
|
||||
#X obj 70 325 oscformat;
|
||||
#X msg 137 283 set \$1;
|
||||
#X obj 70 424 netsend -u -b;
|
||||
#X obj 93 356 loadbang;
|
||||
#X msg 93 381 connect 127.0.0.1 8080;
|
||||
#X obj 70 226 r sendback;
|
||||
#X msg 379 200 \; sendback \$1 button_1;
|
||||
#X msg 379 233 \; sendback \$1 fader_1;
|
||||
#X connect 0 0 1 0;
|
||||
#X connect 2 0 3 0;
|
||||
#X connect 3 0 4 0;
|
||||
#X connect 4 0 5 0;
|
||||
#X connect 5 0 18 0;
|
||||
#X connect 5 1 17 0;
|
||||
#X connect 6 0 7 0;
|
||||
#X connect 7 0 8 0;
|
||||
#X connect 8 0 9 0;
|
||||
#X connect 9 0 16 0;
|
||||
#X connect 10 0 11 0;
|
||||
#X connect 11 0 12 1;
|
||||
#X connect 12 0 13 0;
|
||||
#X connect 13 0 14 0;
|
||||
#X connect 13 0 14 1;
|
||||
#X connect 16 0 12 0;
|
||||
#X connect 17 0 10 0;
|
||||
#X connect 17 0 26 0;
|
||||
#X connect 18 0 6 0;
|
||||
#X connect 18 0 27 0;
|
||||
#X connect 19 0 20 0;
|
||||
#X connect 19 1 21 0;
|
||||
#X connect 20 0 22 0;
|
||||
#X connect 21 0 20 0;
|
||||
#X connect 23 0 24 0;
|
||||
#X connect 24 0 22 0;
|
||||
#X connect 25 0 19 0;
|
||||
```
|
||||
|
||||
=== "Max/MSP"
|
||||
|
||||
Copy the text below. In Max, choose File > New from clipboard.
|
||||
|
||||
```
|
||||
----------begin_max5_patcher----------
|
||||
949.3oc0XkraaCCD8rCP9GHDxo.GWRJpEWzaEnW6gdrInfVlwgoxjBRTYEMe
|
||||
6khTx0HgVlwP1MFAwBZnjl2algyBe9zSFELS9.qJ.7YvOAiF8rVxHirFIi5D
|
||||
LJXI8grbZk4ACVxppnKXAiaWTwdPYV3SWSmyJ+EBbFZ0h74lkjyt8BDdkzBp
|
||||
J6FtXwuJYYJq1wwjIvw.LJt4RRh4F7DH3ptWRTujKxYJCJvqIUVq5Di5Dako
|
||||
drfY+7AAfqLK8mSOo4p9x3AfwypUJoXiTNtWFSBaHIJB1bIM5iDiEr603+sD
|
||||
tddQESLGfvZGj9ODHElBc5s8f5gnTqEHdKbG4l6vcleYxkKYB0aI32KXBvOT
|
||||
ZuM3qRgpTlCtL3a7xJkVJqn5x.fpVIK4zbvEfat8F.FhCW8cx4BVlrVX9XgN
|
||||
LK3DerKv0BLHoGNyRUNWuC1k6DG0GtsHEAM9wXCGvvsC6qykTkF3E0pdnC5e
|
||||
JtjtjozoXXB5rbSbNruv+t0p3OYjhlr6lFkbwhblSSCoOSCBkLIZksAS5988
|
||||
4R2Qa.uIP7pgeWxWt3BPVNO62.kDXABfVOmKcZe5MuOJzj3iDEYLSsUAfGtX
|
||||
d1SyoYu3D3vdi4mNIQiXhcKKIp622W5a3fmh97W.57xNSIOsO9jfab.gSmZH
|
||||
xfW+shuPPy2G0jN2oyCk5AYiwFZNs4liCx1TfwMeS7HKTaAWBb27t3sQ3wff
|
||||
YTwh8RuVmgzIQc2pQrGTGaqQEAOFZyJ6wr7M3lIauNbqWd3o5+ivZz14KNM7
|
||||
XNpNxcPMzCh21gX3wPL845p5vItnZpGL0NVHYvGRxzB5dwyR1vLgIdzHc693
|
||||
ihQBKj26hl9LufceaX3GNm5l3ZoVULvpy4X03+tL.djn11rKJhrECPnaCP3l
|
||||
8yia+e+bD.Zdv32w.QIHryjWgdTjxFBfR1sQ+eOw31uroFyqOpKC7ZV3UVhJ
|
||||
YcYV2Wr6vq.qgw4rJEWPUboX8mx9Pa1l6s9Zl21C88JTIKaFeu+wJ7GBDefP
|
||||
7dDAwGVadpWpCNX5KwG8EMXpyqHpzAScdE8fiFT8g1p9HCl9B8gejCbBgjMr
|
||||
aDcvxGfh2iPn4DL7HnB9w.Bn8TZQjeIplNXwdHuxTYfEZXTneY9SFNFR7lgC
|
||||
jBQdovgK+AB5kBcWMssCJZQwcrxp1WwpKcSi2JMg1ois2yE16ssnETxti28J
|
||||
1SpNfVp6IToaHrtz.wfGha6VNXoTuQQTy61t1v1FUa5KUP0SaUPs7xz+5omn
|
||||
ef+B9C+QQC
|
||||
-----------end_max5_patcher-----------
|
||||
```
|
||||
|
||||
=== "SuperCollider"
|
||||
|
||||
Copy/paste the code below into a new code document. Run the entire block to start. It will clean up when you close the GUI window.
|
||||
|
||||
```
|
||||
// OSC response part
|
||||
(
|
||||
var addr = NetAddr("127.0.0.1", 8080); // FROM address
|
||||
var freqRange = ControlSpec(200.0, 800.0, \exp);
|
||||
var button, slider;
|
||||
|
||||
OSCdef(\button, { |msg|
|
||||
defer { button.value = msg[1] };
|
||||
if(x.notNil) { x.set(\gate, msg[1]) };
|
||||
}, '/button_1', addr);
|
||||
|
||||
OSCdef(\slider, { |msg|
|
||||
defer { slider.value = msg[1] };
|
||||
if(x.notNil) { x.set(\freq, freqRange.map(msg[1])) };
|
||||
}, '/fader_1', addr);
|
||||
|
||||
w = Window("Open Stage Control", Rect(800, 200, 400, 100)).front;
|
||||
w.layout = HLayout(
|
||||
button = Button(),
|
||||
slider = Slider().orientation_(\horizontal)
|
||||
);
|
||||
w.alwaysOnTop = true; // may not take effect in all window managers
|
||||
|
||||
button.states = [["off"], ["playing", Color.black, Color(0.7, 1, 0.7)]];
|
||||
button.action = { |view|
|
||||
if(x.notNil) { x.set(\gate, view.value) };
|
||||
addr.sendMsg('/button_1', view.value);
|
||||
};
|
||||
|
||||
slider.action = { |view|
|
||||
if(x.notNil) { x.set(\freq, freqRange.map(view.value)) };
|
||||
addr.sendMsg('/fader_1', view.value);
|
||||
};
|
||||
|
||||
w.onClose = {
|
||||
if(x.notNil) { x.free };
|
||||
OSCdef(\button).free;
|
||||
OSCdef(\slider).free;
|
||||
};
|
||||
|
||||
// audio part
|
||||
// if this fails (if you have an issue with audio devices),
|
||||
// you won't hear anything but the onscreen GUIs
|
||||
// will reflect changes from Open Stage Control
|
||||
s.waitForBoot {
|
||||
x = { |freq = 200, amp = 0.1, gate = 0|
|
||||
var eg = EnvGen.kr(Env.asr(0.1, 1, 0.1), gate);
|
||||
(SinOsc.ar(Lag.kr(freq, 0.1)) * amp * eg).dup
|
||||
}.play;
|
||||
};
|
||||
)
|
||||
```
|
||||
|
||||
## Deploying the interface
|
||||
|
||||
The whole point of Open Stage Control is to make the interface available on other devices, especially mobile devices.
|
||||
|
||||
The interface will not be visible to other clients, however, until you save it to disk: three-dots menu > Session > Save, and give the file a name such as `open-stage-demo` (you don't need to type the `.json` extension).
|
||||
|
||||
Now -- remember those status messages in the launcher window? On another device (computer, phone or tablet), go to the `http://192.168.xxx.yyy:8080` address. The device should be on the same (W)LAN. (If there is another remote address, it may or may not work, depending on your network.) Supported browsers are Firefox v. 75 and higher, or Chromium/Chrome v. 60 and higher.
|
||||
|
||||
This should open an empty client window, similar to the one you saw before.
|
||||
|
||||
From here, you can open the session that you just saved: three-dots menu *in the webpage* > Session > Open Recent (yes, this is synced from the server!). This should display the controls created in that session, and the controls should function the same as in the other client window.
|
||||
|
||||
And that is... it! Basic usage is as simple as that.
|
||||
|
||||
For convenience, if there is a session you know that you will use often, and you don't want to load it in the webpage by hand every time, you can choose the file under "load" in the initial Launcher window. This is also useful for public deployments with audience participation, where you don't want audience members to have to load manually.
|
||||
|
||||
When not using Open Stage Control, you can also stop the server from the launcher window (stop button, top-left).
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.1 KiB |
|
|
@ -1,96 +0,0 @@
|
|||

|
||||
|
||||
## 1. Menu
|
||||
|
||||
- Session
|
||||
- New session: create a new empty session and enable the editor
|
||||
- Open: browse session files on the server
|
||||
- Open recent: open a recent session on the server
|
||||
- Save / Save as: save session file on the server
|
||||
- Fragment mode: when enabled, the session will be saved as a fragment file (only the root's first child will be saved)
|
||||
- Save backup: save a copy of current session with a incremented suffix appended to the file name
|
||||
- Import: import a session file from the client's filesystem
|
||||
- Export: export a session file to the client's filesystem
|
||||
- State
|
||||
- Store: save all widgets' state to a persistent slot (stored in the client's cache)
|
||||
- Recall: apply state storer in the persistent slot (updated widgets may send messages)
|
||||
- Send All: make all widgets send their current value
|
||||
- Open: browse state files on the server
|
||||
- Save / Save as: save state file on the server
|
||||
- Import: import a state file from the client's filesystem
|
||||
- Export: export a state file to the client's filesystem
|
||||
- Editor
|
||||
- Enable: toggle editor's state
|
||||
- Grid: toggle grid
|
||||
- Project tree: toggle project tree's visibility
|
||||
- Inspector: toggle inspector's visibility
|
||||
- Relative units (%): when enabled, newly created widgets will have their position and size set in percents.
|
||||
- Console
|
||||
- Enable: toggle console's state
|
||||
- Clear console: remove logged messages from the console
|
||||
- Virtual keyboard: (desktop only) toggle virtual keyboard (displayed only when a text input is in focus, except for code editors in the inspector)
|
||||
- Fullscreen: toggle fullscreen
|
||||
- Notifications: toggle visibility of notifications
|
||||
- Prevent sleep (mobile only): attempt to prevent device from going to sleep when idle
|
||||
|
||||
## 2. Sidepanels
|
||||
|
||||
The sidepanels are only visible when the editor is active, they can be resized and/or hidden. Both are described in the [editor](./editor.md) section.
|
||||
|
||||
## 3. Session
|
||||
|
||||
It is the main component, it contains all the widgets and takes all the available space when the sidepanels are closed.
|
||||
|
||||
## 4. Notifications
|
||||
|
||||
Notifications appear in the lower right corner, they are usually used to convey server status information and can be dismissed with a single click.
|
||||
|
||||
## 5. Modals
|
||||
|
||||

|
||||
|
||||
Modals are virtual popup windows that may contain various content: file browser, color picker, error, widgets...
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
=== "Linux"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++ctrl+"Mousewheel"++ | change global zoom (pixel scaling) |
|
||||
| ++ctrl+0++ | reset global zoom |
|
||||
| ++ctrl+e++ | enable/disable editor |
|
||||
| ++ctrl+k++ | show/hide console |
|
||||
| ++ctrl+l++ | clear console |
|
||||
| ++ctrl+s++ | save session |
|
||||
| ++ctrl+shift+s++ | save session as... |
|
||||
| ++ctrl+o++ | open a session file |
|
||||
| ++ctrl+w++ | close client |
|
||||
|
||||
=== "Windows"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++ctrl+"Mousewheel"++ | change global zoom (pixel scaling) |
|
||||
| ++ctrl+0++ | reset global zoom |
|
||||
| ++ctrl+e++ | enable/disable editor |
|
||||
| ++ctrl+k++ | show/hide console |
|
||||
| ++ctrl+l++ | clear console |
|
||||
| ++ctrl+s++ | save session |
|
||||
| ++ctrl+shift+s++ | save session as... |
|
||||
| ++ctrl+o++ | open a session file |
|
||||
| ++alt+f4++ | close client |
|
||||
|
||||
=== "Mac"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++cmd+"Mousewheel"++ | change global zoom (pixel scaling) |
|
||||
| ++cmd+0++ | reset zoom |
|
||||
| ++cmd+e++ | enable/disable editor |
|
||||
| ++cmd+k++ | show/hide console |
|
||||
| ++cmd+l++ | clear console |
|
||||
| ++cmd+s++ | save session |
|
||||
| ++cmd+shift+s++ | save session as... |
|
||||
| ++cmd+o++ | open a session file |
|
||||
| ++cmd+w++ | close client |
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
## Widget selection
|
||||
|
||||
Clicking on a widget, on a tab label or on an item in the project tree selects the widgets for editing:
|
||||
|
||||
- All its editable properties are shown in the inspector panel
|
||||
- The corresponding item in the project tree is highlighted
|
||||
- A selection outline is drawn around the widget
|
||||
- Dragging / Resizing handles are added to the widget
|
||||
|
||||

|
||||
|
||||
To interact with a widget directly without selecting it, either use the middle mouse button or hold ++shift+win++ (++shift+cmd++ on Mac).
|
||||
|
||||
## Menu
|
||||
|
||||
Right clicking on a widget displays a menu with the following actions
|
||||
|
||||
- `Show in tree`: show widget in project tree (hidden when clicking in the project tree)
|
||||
- `Position`:
|
||||
- `Send to back`: Send selected widget to back (first of siblings)
|
||||
- `Send farther`: Send selected widget farther
|
||||
- `Bring closer`: Bring selected widget closer
|
||||
- `Bring to front`: Bring selected widget to front (last of siblings)
|
||||
- `Copy`: copy widget's data
|
||||
- `Cut`: copy widget's data and delete selected widget
|
||||
- `Paste`: paste copied widget in selected container
|
||||
- `Paste`: paste the widget as is
|
||||
- `ID + 1` : increments the id of the copied widget (and all its children) before pasting
|
||||
- `Clone` : create a clone widget targetting the copied widget
|
||||
- `Add widget`: create a new widget in selected container
|
||||
- `Add tab`: create a new tab in selected container
|
||||
- `Export`: export as fragment file
|
||||
- `Delete`: delete selected tab or widget
|
||||
|
||||
|
||||
## Inspector
|
||||
|
||||
Selected widget's properties are displayed and can be modified in the inspector. The [properties reference](../widgets/properties-reference.md) lists the available properties for each widget type.
|
||||
|
||||
- Property fields are all multiline (press `shift + enter` for new line).
|
||||
- Properties are written in JSON, with some flexibility brought by the [JSON5](https://github.com/json5/json5) format. For example, double quotes around object keys are not mandatory.
|
||||
- Clicking on a property name spawns a help modal window
|
||||
- Properties are divided into multiple categories that can be toggled with a click. ++alt+"Click"++ on a category closes the other categories before toggling selected category.
|
||||
|
||||
Some properties (for example `onValue`) have a special code editor with syntax highlighting and many keyboard shortcuts (available by clicking on the "Help" button). In these properties, pressing `enter` will not submit pending changes but instead insert a new line at the cursor position (as you would expect in a regular editor). To submit pending changes, press ++ctrl+enter++ (or ++cmd+enter== on Mac) or click outside the editor.
|
||||
|
||||
Widgets can be locked for edition by enabling their `lock` property. When locked, a widget can't be modified by the editor but it remains possible to delete it or to move it from a container to another in the project tree.
|
||||
|
||||
## Project tree
|
||||
|
||||
The project tree displays the whole widget structure of the session. Widgets can be reordered or moved to another container with drag-and-drop.
|
||||
|
||||
The "Filter" input allows filtering displayed widgets by their `id`. It's also possible to only display a single type of widget by typing `type:fader` for example.
|
||||
|
||||
Invisible widgets are displayed with a lower opacity and their name in italic. Locked widgets are displayed with a lock icon after their name.
|
||||
|
||||
## Widget resizing / dragging
|
||||
|
||||
Selected widget can be resized using its south, south-east and east handles. It can be dragged with its north-west handle (holding ++alt++ extends this handle to the widget's size to ease dragging). If the widget's position/size was written in percents, the editor will try to keep using percents.
|
||||
|
||||
When the grid is enabled, widget resizing / dragging snaps to a 10 pixel wide grid.
|
||||
|
||||
## Multi-widgets editing
|
||||
|
||||
Multiple widgets can be edited at once.
|
||||
|
||||
- The inspector will only display properties that are shared by all selected widgets
|
||||
- Selection can only contain sibling widgets (same direct parent)
|
||||
- Context-menu actions and properties changes apply to all selected widgets
|
||||
- Resizing / Dragging will affect all selected widgets, relatively the selection's size and position
|
||||
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
=== "Linux / Windows"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++ctrl+g++ | Toggle grid. |
|
||||
| ++ctrl+t++ | Toggle session tree. |
|
||||
| ++ctrl+i++ | Toggle inspector. |
|
||||
| ++"Click"++ | Widget selection. |
|
||||
| ++ctrl+"Click"++ | Multi-widget selection. Widgets can be toggled from selection by clicking on them individually.|
|
||||
| ++shift+"Click"+"Drag"++ | Draw a selection rectangle and attempt to select widgets in it. If ++ctrl++ is pressed too, current selection is kept and will be merged with the new one if possible. |
|
||||
| ++ctrl+z++ | Undo |
|
||||
| ++ctrl+y++ <br/>++ctrl+shift+z++ | Redo |
|
||||
| ++delete++ | Delete selected widgets |
|
||||
| ++ctrl+c++ | Copy selected widgets |
|
||||
| ++ctrl+x++ | Cut selected widgets |
|
||||
| ++ctrl+v++ | Paste clipboard in selected widget |
|
||||
| ++ctrl+shift+v++ | Paste and increment id |
|
||||
| ++ctrl+d++ | Duplicate selected widget |
|
||||
| ++ctrl+shift+d++ | Duplicate selected widget and increment id |
|
||||
| ++alt+c+"Drag"++ | Paste selection to position |
|
||||
| ++alt+c+shift+"Drag"++ | Paste selection to dragged position and increment id |
|
||||
| ++ctrl+up++ <br/>++ctrl+down++ <br/>++ctrl+left++ <br/>++ctrl+right++ | Move selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
| ++alt+up++ <br/>++alt+down++ <br/>++alt+left++ <br/>++alt+right++ | Resize selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
| ++ctrl+a++ | Select current widget's siblings and itself |
|
||||
| ++ctrl+shift+a++ | Cancel current widget selection |
|
||||
| ++up++ | Select current widget's previous sibling |
|
||||
| ++down++ | Select current widget's next sibling |
|
||||
| ++left++ | Select current widget's parent |
|
||||
| ++right++ | Select current widget's first child |
|
||||
| ++t++ | Show selected widget(s) in the project tree |
|
||||
| ++y++ | Show selected widget(s) in the session |
|
||||
| ++ctrl+f++ | Focus search input in project tree |
|
||||
| ++"Home"++ | Send selected widget to back |
|
||||
| ++"Page Up"++ | Send selected widget farther |
|
||||
| ++"Page Down"++ | Bring selected widget closer |
|
||||
| ++"End"++ | Bring selected widget to front |
|
||||
| ++"F2"++ | Bring "label" property input into view if selected widget has one |
|
||||
| ++h++ | Hide selection area and widget resize / drag handles while pressed |
|
||||
| ++alt+"Mousewheel"++ | change editor zoom |
|
||||
| ++ctrl+0++ | reset zoom |
|
||||
|
||||
|
||||
=== "Mac"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++cmd+g++ | Toggle grid. |
|
||||
| ++cmd+t++ | Toggle session tree. |
|
||||
| ++cmd+i++ | Toggle inspector. |
|
||||
| ++"Click"++ | Widget selection. |
|
||||
| ++cmd+"Click"++ | Multi-widget selection. Widgets can be toggled from selection by clicking on them individually.|
|
||||
| ++shift+"Click"+"Drag"++ | Draw a selection rectangle and attempt to select widgets in it. If ++cmd++ is pressed too, current selection is kept and will be merged with the new one if possible. |
|
||||
| ++cmd+z++ | Undo |
|
||||
| ++cmd+y++ <br/>++cmd+shift+z++ | Redo |
|
||||
| ++backspace++ | Delete selected widgets |
|
||||
| ++cmd+c++ | Copy selected widgets |
|
||||
| ++cmd+x++ | Cut selected widgets |
|
||||
| ++cmd+v++ | Paste clipboard in selected widget |
|
||||
| ++cmd+shift+v++ | Paste and increment id |
|
||||
| ++cmd+d++ | Duplicate selected widget |
|
||||
| ++cmd+shift+d++ | Duplicate selected widget and increment id |
|
||||
| ++alt+c+"Drag"++ | Paste selection to position |
|
||||
| ++alt+c+shift+"Drag"++ | Paste selection to dragged position and increment id |
|
||||
| ++cmd+up++ <br/>++cmd+down++ <br/>++cmd+left++ <br/>++cmd+right++ | Move selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
| ++alt+up++ <br/>++alt+down++ <br/>++alt+left++ <br/>++alt+right++ | Resize selected widgets (1 grid unit, hold ++shift++ for 5 grid units) |
|
||||
| ++cmd+a++ | Select current widget's siblings and itself |
|
||||
| ++cmd+shift+a++ | Cancel current widget selection |
|
||||
| ++up++ | Select current widget's previous sibling |
|
||||
| ++down++ | Select current widget's next sibling |
|
||||
| ++left++ | Select current widget's parent |
|
||||
| ++right++ | Select current widget's first child |
|
||||
| ++t++ | Show selected widget in the project tree |
|
||||
| ++y++ | Show selected widget(s) in the session |
|
||||
| ++cmd+f++ | Focus search input in project tree |
|
||||
| ++"Home"++ | Send selected widget to back |
|
||||
| ++"Page Up"++ | Send selected widget farther |
|
||||
| ++"Page Down"++ | Bring selected widget closer |
|
||||
| ++"End"++ | Bring selected widget to front |
|
||||
| ++"F2"++ | Bring "label" property input into view if selected widget has one |
|
||||
| ++h++ | Hide selection area and widget resize / drag handles while pressed |
|
||||
| ++alt+"Mousewheel"++ | change editor zoom |
|
||||
| ++cmd+0++ | reset zoom |
|
||||
|
|
@ -1,81 +0,0 @@
|
|||

|
||||
|
||||
## 1. Menu
|
||||
|
||||
- Start: start the server (hidden when started)
|
||||
- Stop: stop the server (hidden when stopped)
|
||||
- New window: open a new client window (hidden when stopped)
|
||||
- Load: load server configuration from file
|
||||
- Save / Save as: save server configuration to file
|
||||
- MIDI
|
||||
- List devices: list available MIDI devices in the console
|
||||
- Restart backend: restart midi backend without restarting the server
|
||||
- Console:
|
||||
- Clear: clear console
|
||||
- Autoscroll: enable/disable console autoscroll
|
||||
- Check for update at startup: enable/disable this feature
|
||||
- Launcher
|
||||
- Autostart: start the server automatically when launcher is started
|
||||
- Always on top: pin the launcher window above other the windows
|
||||
- Use tray: enable tray icon and menu
|
||||
- Start minimized: starts the launcher minimized (or hidden in tray)
|
||||
|
||||
The "play/stop" icon can be used to start and stop the server without opening the menu.
|
||||
|
||||
## 2. Configuration form
|
||||
|
||||
Each server option is displayed here. When clicking on an option's label, a short help will be printed in the console. When an option is not correctly set, its label will turn to orange and an error message will be printed in the console.
|
||||
|
||||
## 3. Console
|
||||
|
||||
The console displays various information, runtime errors and server debug messages.
|
||||
|
||||
## Tray icon
|
||||
|
||||
If `Use tray` is set, the launcher comes with a system tray icon that keeps the launcher alive when closed if there is at least one client window opened or if the server is running. Its context menu can be used to toggle the launcher's visibility and access some of the launcher's menu actions.
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
=== "Linux"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++f5++ | start server |
|
||||
| ++f6++ | stop server |
|
||||
| ++ctrl+n++ | open new client window |
|
||||
| ++ctrl+o++ | load settings |
|
||||
| ++ctrl+s++ | save settings |
|
||||
| ++ctrl+shift+s++ | save settings as... |
|
||||
| ++ctrl+m++ | list midi devices |
|
||||
| ++ctrl+l++ | clear console |
|
||||
| ++ctrl+w++ | close window |
|
||||
|
||||
|
||||
=== "Windows"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++f5++ | start server |
|
||||
| ++f6++ | stop server |
|
||||
| ++ctrl+n++ | open new client window |
|
||||
| ++ctrl+o++ | load settings |
|
||||
| ++ctrl+s++ | save settings |
|
||||
| ++ctrl+shift+s++ | save settings as... |
|
||||
| ++ctrl+m++ | list midi devices |
|
||||
| ++ctrl+l++ | clear console |
|
||||
| ++alt+f4++ | close window |
|
||||
|
||||
=== "Mac"
|
||||
|
||||
| Shortcut | Description |
|
||||
|---|---|
|
||||
| ++f5++ | start server |
|
||||
| ++f6++ | stop server |
|
||||
| ++cmd+n++ | open new client window |
|
||||
| ++cmd+o++ | load settings |
|
||||
| ++cmd+s++ | save settings |
|
||||
| ++cmd+shift+s++ | save settings as... |
|
||||
| ++cmd+m++ | list midi devices |
|
||||
| ++cmd+l++ | clear console |
|
||||
| ++cmd+w++ | close window |
|
||||
| ++cmd+q++ | quit app |
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
# Advanced syntaxes
|
||||
|
||||
Advanced syntaxes are special blocks of code that can be written in the widgets properties to customize the widgets and how they behave. These blocks end up replaced with the value they hold before the widgets evaluate the properties they're in.
|
||||
|
||||
|
||||
## Inheritance: `@{id.property}`
|
||||
|
||||
The inheritance syntax returns either a widget's value or one of its properties. When using this syntax, value or property changes will be applied automatically.
|
||||
|
||||
- `id`: target widget's `id`. A widget can fetch its own properties or its direct parent's by using the keywords `this` or `parent` instead of `id`. When `this` or `parent` can be used, using the target widget's `id` instead won't work.
|
||||
- `property`: target widget's property name. If omitted (along with the dot), the widget's value will be returned (`@{widgetId}` is the same as `@{widgetId.value}`). `value` always resolves to the target widget's current value, not its `value` property.
|
||||
|
||||
|
||||
!!! note "Unique identifier"
|
||||
Each widget has a unique random identifier that can be retrieved with the property name `uuid` (e.g. `@{this.uuid}`, `@{parent.uuid}`).
|
||||
|
||||
#### Dynamic properties
|
||||
|
||||
Some properties, when changed, trigger a complete widget recreation that ends any ongoing user interaction. Also, updating these properties continuously (e.g. when linked to a slider's dynamic value) can be very cpu expensive.
|
||||
|
||||
Some properties have much cheaper update routines and can be considered as `dynamic`, as in performance safe. These properties are marked in the documentation with a <i class="fas fa-bolt" title="dynamic"></i>.
|
||||
|
||||
|
||||
#### Circular references cases
|
||||
|
||||
- container widgets can inherit their children's properties only to define `dynamic` properties
|
||||
- widgets can inherit their own `value`<i class="dynamic-prop-icon" title="dynamic"></i> property only to define `dynamic` properties
|
||||
|
||||
#### Object properties
|
||||
|
||||
If the retrieved property is an object (`{}`), a subset can be retrieved directly by appending a dot and a key (array index or object key) : `@{parent.variables.key}`
|
||||
|
||||
|
||||
#### Nesting
|
||||
|
||||
The inheritance syntax supports 1-level nesting for defining the target widget's id dynamically : `@{fader_@{toggle_1}}`
|
||||
|
||||
|
||||
## OSC listeners: `OSC{address, default, usePreArgs}`
|
||||
|
||||
The OSC listener syntax returns the value received on specified address (or the `default` value if none has been received yet).
|
||||
|
||||
- `address`: osc address to listen to; if the leading slash (`/`) is omitted, the address will be prefixed with the widget's `address` property
|
||||
- `default` (optional): default value returned before any message is received. Must be a primitive value, not an object or an array.
|
||||
- `usePreArgs` (optional): by default, osc listeners inherit the widget's `preArgs` (these must be matched for the osc messages to be processed). Set to `false` bypass them.
|
||||
|
||||
Options can contain `@{}` blocks.
|
||||
|
||||
!!! note "Receiving MIDI"
|
||||
Midi messages will be processed only if the receiver's widget includes the emitting MIDI device in its targets.
|
||||
|
||||
??? example "Array/Object default value"
|
||||
```js
|
||||
JS{
|
||||
return OSC{address} || {
|
||||
"key a": 1,
|
||||
"key b": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Custom variables: `VAR{variableName, default}`
|
||||
|
||||
This syntax creates a custom variable in the widget that can be read and modified from any widget's script property (see [scripting](./scripting.md#getvarid-name)). Changes made to this variable using `setVar()` in scripts will be applied automatically where `VAR{}` is used.`
|
||||
|
||||
## File imports: `IMPORT{file_name}`
|
||||
|
||||
This allows loading the content of an external file in a property. If used in a `JS{}` of `#{}` block, it will be seen as a string variable containing the raw content of the file. Changes made to the file be applied automatically.
|
||||
|
||||
File paths are resolved in this order:
|
||||
|
||||
- in the session's directory
|
||||
- in theme's directory
|
||||
- in the server's `remote-root` directory if the option is set
|
||||
- as absolute paths
|
||||
|
||||
!!! warning
|
||||
[Fragments](../fragments/) and session files already loaded with fragment widgets should not be imported using this syntax.
|
||||
|
||||
## Javascript: `JS{ <code> }`
|
||||
|
||||
This syntax allows defining a property using [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript). The code will be compiled as a function and executed in a restricted context.
|
||||
|
||||
- if no `return` statement is found, the formula will return an empty string
|
||||
- javascript [strict mode](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Strict_mode) is always enabled
|
||||
- `setTimeout` and `setInterval` functions are not available
|
||||
|
||||
A property *cannot* contain multiple `JS{}` blocks
|
||||
|
||||
#### Available variables
|
||||
|
||||
- `console`: javascript console
|
||||
- `locals`: object for storing/reading arbitrary values. Changing its properties *does not* trigger any synchronisation even if the value is used somewhere else.
|
||||
- `globals`: same as `locals` but shared between all widgets, contains a few useful variables:
|
||||
- `screen`: client screen informations (`{width, height, orientation}`)
|
||||
- `env`: client options (ie: url query options),
|
||||
- `ip`: client's ip address,
|
||||
- `url`: server url,
|
||||
- `platform`: operating system as seen by the client
|
||||
- `session`: session file path
|
||||
- `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)
|
||||
|
||||
Parsing errors can be read in the console (++ctrl+k++).
|
||||
|
||||
!!! warning
|
||||
Modifying values in `locals` or `globals` **does not** trigger anything if they are used somewhere else.
|
||||
|
||||
#### Using in advanced syntaxes
|
||||
|
||||
In this context, `@{}`, `VAR{}` and `OSC{}` syntaxes are seen as variables. When they change, the whole block will be evaluated again.
|
||||
|
||||
!!! danger "Do not mutate"
|
||||
When these syntaxes return objects or arrays, mutating said objects will affect the underlying variables in memory and may lead to unexpected behavior.
|
||||
|
||||
The `@{}` syntax, when used for anything else than the widget's value, will always return a copy of the property and is not affected by this.
|
||||
|
||||
## Javascript: `#{ <code> }`
|
||||
|
||||
This is a shorthand for the `JS{}` syntax, the only difference being that `<code>` is automatically prepended with a `return` statement.
|
||||
|
||||
A property *can* contain multiple `#{}` blocks.
|
||||
|
||||
!!! note "Compilation order"
|
||||
`#{}` blocks are compiled after `JS{}` blocks
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
# Canvas widget
|
||||
|
||||
The canvas widget allows creating custom widgets with user-defined drawings and touch reactions.
|
||||
|
||||
It has dedicated scripting properties (`onTouch`, `onDraw` and `onResize`) that work like the `onValue` property : they are used to defined scripts that will be executed when specific events occurs.
|
||||
|
||||
This widget requires a good understanding of the javascript [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) and of the javascript programming language in general.
|
||||
|
||||
## Canvas properties
|
||||
|
||||
### `valueLength`
|
||||
|
||||
This property must be set to the number of values held by the widget : 1 for a simple slider, 2 for an XY pad, etc. Attempts to set the widget's value with a different number of values will be ignored.
|
||||
|
||||
```js
|
||||
set("this", 1) // works if valueLength == 1
|
||||
set("this", [1, 2]) // works if valueLength == 2
|
||||
```
|
||||
|
||||
### `autoClear`
|
||||
|
||||
This is a convenience option that clears the canvas context and calls [`beginPath`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/beginPath) before each drawing. When this property is set to `false`, the canvas must be cleared manually.
|
||||
|
||||
### `continuous`
|
||||
|
||||
If this property is enabled, the widget will be redrawn at a fixed rate even if not interacted with (see [`onDraw`](#onDraw)).
|
||||
|
||||
|
||||
### `onTouch`
|
||||
|
||||
This script is executed when the widget is touched, when it is released, and during the movement of the pointer while the widget is touched.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
- `height`: canvas height in pixels
|
||||
- `event`: object containing the following:
|
||||
- `type`: `"start"`, `"move"` or `"stop"`
|
||||
- `target`: id of the widget under the pointer, `"this"` if it's the canvas widget itself, `null` if no widget is under the pointer
|
||||
- `targetName`: name attribute of the html element under the pointer
|
||||
- `targetTagName`: tag name of the html element under the pointer
|
||||
- `offsetX`, `offsetY`: touch coordinates in pixels, relative to the html element under the pointer
|
||||
- `movementX`, `movementY`: movement of the pointer in pixels since the last event
|
||||
- `pageX`, `pageY`: touch coordinates in pixels, relative to the page
|
||||
- `pointerId`: unique identifier used to differentiate fingers in multitouch situation
|
||||
- `altKey`, `ctrlKey`, `shiftKey`: keyboard modifier states
|
||||
- `force`: amount of pressure applied to the touch surface between `0` and `1` (see [Touch.force](https://developer.mozilla.org/en-US/docs/Web/API/Touch/force)). Equals `0` if the API is not supported or if no pressure information is found.
|
||||
- `radiusX`, `radiusY`, `rotationAngle`: see [Touch.rotationAngle](https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle)
|
||||
- (iOS only) `altitudeAngle`, `azimuthAngle`: see [Touch.altitudeAngle](https://w3c.github.io/touch-events/#dom-touch-altitudeangle)
|
||||
- (iOS only) `touchType`: "direct" or "stylus"
|
||||
|
||||
|
||||
!!! note "Extra html elements"
|
||||
Elements added using the `html` property can be touched as well, `event.targetName` can be used to determine which element is touched.
|
||||
|
||||
|
||||
### `onDraw`
|
||||
|
||||
This script is executed when the widget should be redrawn, which is when it's touched and when it receives a value.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
- `height`: canvas height in pixels
|
||||
- `ctx`: [canvas rendering context](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D) of the widget
|
||||
- `cssVars`: object containing the computed value of some of the widget's style properties such as `colorWidget`, `alphaFill`, `padding`, etc
|
||||
|
||||
In this script, all osc messages emissions are prevented and changing the value of a widget won't trigger widget synchronisation / scripts / advanced syntaxes updates.
|
||||
|
||||
### `onResize`
|
||||
|
||||
This script is executed when the widget has resized, before it is redrawn.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
- `height`: canvas height in pixels
|
||||
- `cssVars`: object containing the computed value of some of the widget's style properties such as `colorWidget`, `alphaFill`, `padding`, etc
|
||||
|
||||
## Example: XY pad
|
||||
|
||||
Let's create a simple xy pad, with a value made of two numbers between 0 and 1. We set `valueLength` to `2` to make sure the widget only accepts incoming messages with two values (x and y).
|
||||
|
||||
First, we use the `onTouch` property to store the touch coordinates in the `locals` object. We also call `set()` to store these in the widget's value (this way, the widget can send messages and sync with other widgets).
|
||||
|
||||
```js
|
||||
// onTouch
|
||||
|
||||
// store normalized coordinates
|
||||
if (event.type == "start") {
|
||||
locals.x = event.offsetX / width
|
||||
locals.y = event.offsetY / height
|
||||
} else {
|
||||
// when the pointer is moving, increment coordinates
|
||||
// because offsetX and offsetY may not be relevant
|
||||
// if the pointer hovers a different widgets
|
||||
locals.x += event.movementX / width
|
||||
locals.y += event.movementY / height
|
||||
}
|
||||
|
||||
// update widget value and send
|
||||
set("this", [locals.x, locals.y])
|
||||
```
|
||||
|
||||
Then, we use the `onDraw` property to draw a circle at the touch coordinates.
|
||||
|
||||
```js
|
||||
// onDraw
|
||||
|
||||
// draw circle at touch coordinates
|
||||
ctx.arc(value[0] * width, value[1] * height, 6, 0, Math.PI * 2)
|
||||
// use colorFill property as stroke color
|
||||
ctx.strokeStyle = cssVars.colorFill
|
||||
// draw stroke
|
||||
ctx.stroke()
|
||||
```
|
||||
|
||||
Finally, we use the `onValue` property to apply limits to the values.
|
||||
|
||||
```js
|
||||
// onValue
|
||||
|
||||
// apply limits
|
||||
var x = Math.max(0, Math.min(1, value[0])),
|
||||
y = Math.max(0, Math.min(1, value[1]))
|
||||
|
||||
// re-update widget value without retriggering script or sending message
|
||||
set("this", [x, y], {sync: false, send: false})
|
||||
|
||||
// the widget will automatically send its value if
|
||||
// this script was triggered by a user interaction
|
||||
// no need to call send() here but we could, for example
|
||||
// if we want to split the value in to multiple messages
|
||||
```
|
||||
|
||||
## Example: multi slider
|
||||
|
||||
Let's build a row of 20-sliders with a single widget. We first set `valueLength` to... 20 !
|
||||
|
||||
```js
|
||||
// onTouch
|
||||
|
||||
// store normalized coordinates
|
||||
if (event.type == "start") {
|
||||
locals.x = event.offsetX / width
|
||||
locals.y = event.offsetY / height
|
||||
} else {
|
||||
// when the pointer is moving, increment coordinates
|
||||
// because offsetX and offsetY may not be relevant
|
||||
// if the pointer hovers a different widgets
|
||||
locals.x += event.movementX / width
|
||||
locals.y += event.movementY / height
|
||||
}
|
||||
|
||||
|
||||
// which slider are we touching ?
|
||||
var n = parseInt(locals.x * value.length)
|
||||
n = Math.max(0, Math.min(n, value.length-1))
|
||||
|
||||
// update value at slider's index
|
||||
// 1 - locals.y because y axis is from top to bottom in js canvas
|
||||
value[n] = 1 - locals.y
|
||||
|
||||
// update widget value and send
|
||||
set("this", value)
|
||||
```
|
||||
|
||||
```js
|
||||
// onDraw
|
||||
|
||||
ctx.fillStyle = cssVars.colorFill
|
||||
ctx.globalAlpha = cssVars.alphaFillOn
|
||||
|
||||
var sliderWidth = width / value.length - 1
|
||||
for (var i in value){
|
||||
ctx.beginPath()
|
||||
ctx.rect(i * width / value.length, height, sliderWidth, - value[i] * height)
|
||||
ctx.fill()
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// onValue
|
||||
|
||||
// apply limits
|
||||
for (var i in value) {
|
||||
value[i] = Math.max(0, Math.min(1, value[i]))
|
||||
}
|
||||
|
||||
// re-update widget value without retriggering script or sending message
|
||||
set("this", value, {sync: false, send: false})
|
||||
```
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# Fragments
|
||||
|
||||
Fragments allow breaking sessions into multiple files and reusable components made of multiple widgets.
|
||||
|
||||
## Fragment files
|
||||
|
||||
|
||||
When right-clicking on a widget in the editor mode, it is possible to export it as a fragment file.
|
||||
|
||||
Fragment files have the same extension as session files (`.json`) and can be opened like regular sessions. When doing so, keep in mind that only the first child of the root widget will be saved. It is possible to save a fragment file as a session file (and vice versa) by toggling the `Fragment mode` in the main menu.
|
||||
|
||||
|
||||
## Fragment widgets
|
||||
|
||||
Fragment widgets work like clone widget except their source widget are loaded from fragment files or session files. When the sources files are modified, the fragment widgets are updated automatically.
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
## Interaction
|
||||
|
||||
These are interaction events widgets are likely to respond to:
|
||||
|
||||
| Mouse | Touch | Description |
|
||||
|---|---|---|
|
||||
| Mousedown | Tap | Handled at pressing time, not releasing. |
|
||||
| Click | Click | Handled at release time. |
|
||||
| Double Click | Double Tap | Some widgets handle double click / double tap events. |
|
||||
| Drag | Drag | The widgets respond to mouse and touch drag gestures with a 1:1 precision ratio. |
|
||||
|
||||
|
||||
Widgets sensibility can be tuned with the `sensibility` property. Single-touch widgets (i.e. all widgets except `mutlixy` and `range`) also accept an alternate interaction event for fine control.
|
||||
|
||||
| Mouse | Touch | Description |
|
||||
|---|---|---|
|
||||
| `Ctrl` + Drag | / | Holding the `Ctrl` key while dragging with the mouse increases the gesture's precision by 10.|
|
||||
| / | Two-fingers drag | Using two fingers on a single-touch target increases the gesture's precision by 10. |
|
||||
|
||||
|
||||
## Sending messages
|
||||
|
||||
When interacted with, widgets with at least one target (including the server's defaults) send osc messages of the following form:
|
||||
|
||||
```
|
||||
/address ...preArgs ...value
|
||||
```
|
||||
|
||||
If they have MIDI targets, the server will try to convert the osc messages into a MIDI messages (see [MIDI messages](../midi/midi-messages.md)).
|
||||
|
||||
|
||||
## Receiving messages
|
||||
|
||||
When an osc message is received, it updates every widgets that meets the following conditions
|
||||
|
||||
- same `address`
|
||||
- same `preArgs` (no distinction between integers and round floats )
|
||||
|
||||
The remaining arguments after `preArgs` are passed to the widget.
|
||||
|
||||
|
||||
When a MIDI message is received, it's converted into an osc message (see [MIDI messages](../midi/midi-messages.md)) and follows the same rules, except that only the widgets that include the emitting MIDI device in their targets will be able to receive it.
|
||||
|
||||
|
||||
## Widget synchronization
|
||||
|
||||
Within a single client's scope, there are multiple ways to synchronize widgets:
|
||||
|
||||
- If they share the same `id`: in this case, the synchronized widget doesn't send any osc/midi message. This case is mostly used for widget cloning.
|
||||
- If they share a `linkId`: in this case, the synchronized widget sends its osc/midi message normally.
|
||||
- If their `value` properties depend on each other using the [advanced syntaxes](./advanced-syntaxes.md)
|
||||
- Using [scripting](./scripting.md)
|
||||
|
||||
## Client synchronization
|
||||
|
||||
From a client to another, widgets are automatically synchronized if they share the following properties:
|
||||
|
||||
- `address`
|
||||
- `preArgs`
|
||||
- `targets`
|
||||
|
||||
Client synchronization can be disabled globally with the `clientSync` [client option](../client-options.md). Widgets with `bypass` set to `true` will not send synchronization messages to other clients.
|
||||
|
|
@ -1,437 +0,0 @@
|
|||
# Scripting
|
||||
|
||||
Widgets can run [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) scripts upon specific events. These scripts are written in special properties under the scripting category.
|
||||
|
||||
!!! warning "Advanced syntaxes"
|
||||
Most [advanced syntaxes](../advanced-syntaxes/) should be avoided as much as possible in scripting properties:
|
||||
|
||||
- `@{}`: use `get()` and `getProp()` instead
|
||||
- `OSC{}`: use `get()` instead (using another widget as receiver)
|
||||
- `VAR{}`: use `getVar()`instead
|
||||
- `JS{}` and `#{}` are useless (scripting properties are already interpreted as javascript code) unless you want to generate code procedurally
|
||||
|
||||
The editor will always fail to recognize these syntaxes as they don't comply with the javacript language specification, even if the resulting code is valid.
|
||||
|
||||
## Events
|
||||
|
||||
### `onCreate`
|
||||
|
||||
This script is called when the widget is created. If the widget has children, it will be executed after the children are created.
|
||||
|
||||
!!! warning "Modifying parent container"
|
||||
Modifying a non-dynamic property on a parent container from this script **will not work**.
|
||||
|
||||
The following variables are available in this context:
|
||||
|
||||
- `value`: widget's value
|
||||
|
||||
### `onValue`
|
||||
|
||||
This script is called when the widget's value updates and when it receives a value.
|
||||
|
||||
The following variables are available in this context:
|
||||
|
||||
- `id` (`string`): id of the widget that's responsible for the value update
|
||||
- `value`: widget's value
|
||||
- `touch`: see [Touch state](#touch-state)
|
||||
|
||||
??? infos "Keyboard & Matrix"
|
||||
In keyboards and matrices, `id` is the id of the child widget that triggered the event, and `value` is an array containing the children's values.
|
||||
The touched widget's value can be retrieved with:
|
||||
```javascript
|
||||
value[getIndex(id)]
|
||||
```
|
||||
|
||||
??? infos "Touch state (deprecated)"
|
||||
|
||||
*This feature is deprecated, use `onTouch` instead*
|
||||
|
||||
When some widgets are touched or released, a special value event can be caught to trigger custom actions.
|
||||
|
||||
If the variable `touch` is not `undefined`, this means it holds the widget's current touch state:
|
||||
|
||||
- `0/1` for the widget's touch state (`fader`, `knob` and `xy`, `range` and `multixy`)
|
||||
- `[i, 0/1]` if the widget is multi touch (`range` and `multixy`). In this case `i` is the touched handle's index, starting with `0`.
|
||||
|
||||
```js
|
||||
if (touch !== undefined) {
|
||||
// send multi touch state
|
||||
if (touch.length) send('/touch_address', touch[0], touch[1])
|
||||
// send global touch state
|
||||
else send('/touch_address', touch)
|
||||
} else {
|
||||
// do something with the value ?
|
||||
}
|
||||
```
|
||||
|
||||
To avoid unwanted script executions, touch state events will only be caught if the script contains the word `touch` and if `onTouch` is empty.
|
||||
|
||||
|
||||
### `onTouch`
|
||||
|
||||
This script is executed when the widget is touched, and when it is released.
|
||||
|
||||
This script has access to the same variables and functions as the `script` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `event`: object containing the following:
|
||||
- `type`: `"start"` or `"stop"`
|
||||
- `handle`: `undefined` if the event concerns the widget, `integer` if it concerns one of it's handles (`multixy` and `range` widgets only)
|
||||
|
||||
[Canvas](../canvas/) and containers expose more informations in their `onTouch` script.
|
||||
|
||||
??? infos "Containers onTouch"
|
||||
|
||||
Containers (root, panel, etc) can monitor touch events happening inside them, it works like with [Canvas](../canvas/#ontouch), with a few differences:
|
||||
|
||||
- `event.firstTarget` will return the id of the first touched widget
|
||||
- setting `event.preventDefault` to `true` will prevent the event from reaching widgets in the container ('start' and 'move' events only)
|
||||
- setting `event.allowScroll` to `true` will allow touch scrolling where it would normally be prevented ('start' event only)
|
||||
- setting `event.inertia` will affect 'move' events (works like widget `sensitivity` in reverse (1 = normal, 10 = slow move))
|
||||
- `width` and `height` are undefined
|
||||
|
||||
Containers with `traversing` enabled change how touch events are emitted:
|
||||
|
||||
- a new 'stop' event is emitted whenever the pointer exits a touchable widget while pressed.
|
||||
- a new 'start' event is emitted whenever the pointer enters a touchable widget while pressed.
|
||||
|
||||
|
||||
### `onDraw`
|
||||
|
||||
See [canvas](../canvas/).
|
||||
|
||||
### `onKeyboard`
|
||||
|
||||
*Script widget only*
|
||||
|
||||
This script is executed when the key(s) defined in the widget's `keyBinding` property are pressed.
|
||||
|
||||
|
||||
The following variables are available in this context:
|
||||
|
||||
|
||||
- `type` (`string`): `keydown` or `keyup`
|
||||
- `key` (`string`): key name,
|
||||
- `code` (`number`): key code
|
||||
- `ctrl` (`boolean)`: `true` if ctrl key is pressed
|
||||
- `shift` (`boolean`): `true` if shift key is pressed
|
||||
- `alt` (`boolean`): `true` if alt key is pressed
|
||||
- `meta` (`boolean`): `true` if meta key is pressed
|
||||
|
||||
|
||||
### `onPreload`
|
||||
|
||||
This script is specific to the root widget, it's called before any other widget is created and can be used to create global variables / functions accessible in other scripts.
|
||||
|
||||
In this script, all osc messages emissions are prevented and changing the value of a widget won't trigger widget synchronisation / scripts / advanced syntaxes updates.
|
||||
|
||||
## Available variables
|
||||
|
||||
The following variables and functions are accessible in this context.
|
||||
|
||||
|
||||
- `console`: javascript console
|
||||
- `locals`: object for storing/reading arbitrary values. Changing its properties *does not* trigger any synchronisation even if the value is used somewhere else.
|
||||
- `globals`: same as `locals` but shared between all widgets, contains a few useful variables:
|
||||
- `screen`: client screen informations (`{width, height, orientation}`)
|
||||
- `env`: client options (ie: url query options),
|
||||
- `ip`: client's ip address,
|
||||
- `url`: server url,
|
||||
- `platform`: operating system as seen by the client
|
||||
- `session`: session file path
|
||||
- `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)
|
||||
- `Image`: javascript's [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) constructor
|
||||
|
||||
|
||||
!!! note "this"
|
||||
Unlike in most javascript contexts, the special keyword `this` doesn't point to an object but instead returns the string `"this"`.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `get(id)`
|
||||
- `id`: widget `id` as a string.
|
||||
|
||||
Returns the value of the first matching widget. If the returned value is an object, a copy is returned to allow safe mutation.
|
||||
|
||||
----
|
||||
|
||||
#### `set(id, value, options)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget. `id` may contains wildcards ('\*').
|
||||
- `value`: new value for the widget.
|
||||
- `options` (optional): `object`, accepts the following items:
|
||||
- `sync: false`: prevents widgets from triggering synchronization and scripts
|
||||
- `script: false`: prevents scripts but not synchronization
|
||||
- `send: false`: prevents widgets from sending osc messages
|
||||
- `external: true`: simulates a value coming from an osc/midi message (implies `send: false` automatically)
|
||||
|
||||
Sets the value of the first matching widget. If `ìd` contains wildcards, affects all matching widgets **except** the emitting widget.
|
||||
|
||||
If the event that triggered the script's execution was initiated by a user interaction, this will make the widget send its value as well (unless `options` is set to `{send: false}`).
|
||||
|
||||
----
|
||||
|
||||
#### `getVar(id, name)`
|
||||
- `id`: widget `id` as a string.
|
||||
- `name`: variable name as a string.
|
||||
|
||||
Returns the value of a widget's custom variable. If the returned value is an object, a copy is returned to allow safe mutation.
|
||||
|
||||
----
|
||||
|
||||
#### `setVar(id, name, value)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget. `id` may contains wildcards ('\*').
|
||||
- `name`: variable name as a string.
|
||||
- `value`: new value for the variable.
|
||||
|
||||
Sets the value of a widget's custom variable (see [advanced syntaxes](./advanced-syntaxes.md##ustom-variables-varvariablename-default)). If `ìd` contains wildcards, affects all matching widgets.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `send(target, address, ...args)`
|
||||
- `target` (optional): `"ip:port"` or `"midi:device_name"` string. If omitted, the widget's target (or the server's defaults) will be used.
|
||||
- `address`: osc address, must start with a `/`
|
||||
- `args`: values or `{type: "OSC_TYPE_LETTER", value: VALUE}` objects
|
||||
|
||||
Sends an osc message.
|
||||
|
||||
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.
|
||||
|
||||
This function ignores the widget's `bypass` and `ignoreDefaults` properties.
|
||||
|
||||
??? infos "Examples"
|
||||
```javascript
|
||||
send('127.0.0.1:4444', '/address', 1)
|
||||
send('127.0.0.1:4444', '/address', 1, 2)
|
||||
send('/address', 1) // uses the widget's target
|
||||
send('/address', {type: 'i', value: 1}) // sends 1 as an integer
|
||||
```
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `getProp(id, name)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `name`: property name.
|
||||
|
||||
Returns the property called `"name"` of the first matching widget. If the returned value is an object, a copy is returned to allow safe mutation.
|
||||
|
||||
----
|
||||
|
||||
#### `getIndex(id)`
|
||||
- `id` (optional): widget `id` as a string. Defaults to `"this"`.
|
||||
|
||||
Returns the widget's index in its container.
|
||||
|
||||
----
|
||||
|
||||
#### `updateProp(id, name)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `name`: property name.
|
||||
|
||||
Forces a widget to check if one of its properties has changed and update itself if needed.
|
||||
|
||||
----
|
||||
|
||||
#### `updateCanvas(id)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget.
|
||||
|
||||
Forces a canvas widget redraw.
|
||||
|
||||
----
|
||||
|
||||
#### `httpGet(url, callback)`
|
||||
|
||||
- `url`: url of the resource to fetch (local url only)
|
||||
- `callback`: function executed when/if the http request succeeds, with the response text as argument
|
||||
|
||||
----
|
||||
|
||||
#### `stateGet(id)`
|
||||
- `id`: widget `id` as a string, or array of `id` strings. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
|
||||
Returns a state object (`id:value`) for matching widget and all their children.
|
||||
|
||||
----
|
||||
|
||||
#### `stateSet(state, options)`
|
||||
|
||||
Loads a state object. If the event that triggered the script's execution was initiated by a user interaction, this will make the updated widgets send their value as well.
|
||||
|
||||
- `options` (optional): `object`, accepts the following items:
|
||||
- `send: false`: prevents widgets from sending osc messages
|
||||
|
||||
----
|
||||
|
||||
#### `storage`
|
||||
|
||||
Global [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) instance, allows storing data that persists upon refresh/relaunch.
|
||||
|
||||
----
|
||||
|
||||
#### `setTimeout(id, callback, delay)` / `setInterval(id, callback, delay)`
|
||||
|
||||
These work like almost their native equivalent, with an extra (optional) `id` argument.
|
||||
|
||||
- `id` (optional): unique identifier, if omitted, defaults to `undefined`. If a timeout with the same id is already running, it is cleared before the new one is created (even if `undefined`). `id`s are scoped to the widget's context: two timeouts with the same `id` in two different widgets can run concurrently
|
||||
- `callback`: function to be executed
|
||||
- `delay`: delay before execution is ms
|
||||
|
||||
Reference:
|
||||
|
||||
- https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
|
||||
- https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
|
||||
|
||||
|
||||
Usage note:
|
||||
|
||||
If no concurrent timeout / interval is needed, calling `setTimeout`, `setInterval`, `clearTimeout` and `clearInterval` with no `ìd` argument will do.
|
||||
|
||||
-----
|
||||
|
||||
#### `clearTimeout(id)` / `clearInterval(id)`
|
||||
|
||||
Clears timeout with matching `id`.
|
||||
|
||||
Reference:
|
||||
|
||||
- https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearTimeout
|
||||
- https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearInterval
|
||||
|
||||
----
|
||||
|
||||
#### `setFocus(id)`
|
||||
|
||||
- `id` (optional): widget `id` as a string
|
||||
|
||||
Gives focus to a widget (ie input widget). If `id` is omitted or falsy, currently focused element will be unfocused.
|
||||
|
||||
*Built-in client only*: tells the operating system to give the focus to the client window
|
||||
|
||||
----
|
||||
|
||||
#### `unfocus()`
|
||||
|
||||
*Built-in client only*: tells the operating system to give the focus to the window that was focused before.
|
||||
|
||||
----
|
||||
|
||||
#### `setFocusable(focusable)`
|
||||
|
||||
- `focusable`: `0` or `1`
|
||||
|
||||
*Built-in client only*: define whether the client window can be focused or not. Text inputs cannot be interacted with when the window is not focusable.
|
||||
|
||||
----
|
||||
|
||||
#### `getScroll(id)`
|
||||
- `id`: widget `id` as a string.
|
||||
|
||||
Returns the scroll position of a container as a `[x, y]` array.
|
||||
|
||||
----
|
||||
|
||||
#### `setScroll(id, x, y)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `x`: horizontal scroll, `undefined` to use current value
|
||||
- `y`: vertical scroll, `undefined` to use current value
|
||||
|
||||
Sets the scroll state of a container.
|
||||
|
||||
----
|
||||
|
||||
#### `scrollIntoView(id, option)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `option`: `alignToTop` or `options` argument as defined in https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
||||
|
||||
Scroll containers to make widget(s) visible.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `toolbar(id)`
|
||||
- `id` menu entry id (string)
|
||||
|
||||
Triggers toobar action if currently available (ie accessible from the menu). `id` can be one of the following:
|
||||
|
||||
- `session-new`,`session-open`, `session-save`, `session-save-as`, `session-fragment`, `session-backup`, `session-import`, `session-export`
|
||||
- `state-store`, `state-recall`, `state-send`, `state-open`, `state-save`, `state-save-as`, `state-import`, `state-export`
|
||||
- `editor-enabled`, `editor-grid`, `editor-tree`, `editor-inspector`, `editor-percents`
|
||||
- `console-enabled`, `console-clear`
|
||||
- `fullscreen`, `notifictions`, `prevent-sleep`, `virtual-keyboard`
|
||||
|
||||
Some actions will only be triggered if initiated with a physical user interaction, check the console for errors if it doesn't work as expected.
|
||||
|
||||
|
||||
=== "Legacy syntax: `toolbar(i1, i2, ...)`"
|
||||
|
||||
- `iX`: menu entry index
|
||||
|
||||
Triggers toolbar action at specified index.
|
||||
|
||||
!!! example "Examples"
|
||||
|
||||
- `toolbar(0, 0)` -> Open a new session
|
||||
- `toolbar(4)` -> Toggle full screen
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `getToolbar(id)`
|
||||
- `id` menu entry id (string)
|
||||
|
||||
Returns `true` if the toolbar entry exists and is currently activated.
|
||||
|
||||
#### `openUrl(url)`
|
||||
- `url`: http(s) url
|
||||
|
||||
*Built-in client only*: opens url with the system's default browser
|
||||
*External client only*: opens url in a new tab
|
||||
|
||||
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.
|
||||
|
||||
----
|
||||
|
||||
#### `runAs(id, callback)`
|
||||
- `id`: widget `id` as a string.
|
||||
- `callback`: function to be executed
|
||||
|
||||
Run `callback` function as if executed by another that widget matches specified id. This will not change the value of any local variable but `"this"` and `"parent"` arguments (accepted by functions such as `set()`) will be interpreted differently. Timeouts and intervals will be created and cleared in the target widget's scope.
|
||||
|
||||
----
|
||||
|
||||
#### `reload(keepState)`
|
||||
- `keepState` (optional): `true` by default, set to false to discard the client's state.
|
||||
|
||||
Reload the client application. Cannot be called from the `onCreate` property.
|
||||
|
||||
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.
|
||||
|
||||
|
||||
----
|
||||
|
||||
#### `getNavigator()`
|
||||
|
||||
Returns the instance of [Navigator](https://developer.mozilla.org/en-US/docs/Web/API/Navigator).
|
||||
|
||||
----
|
||||
|
||||
#### `browseFile(options, callback)`
|
||||
|
||||
Opens the server file browser and pass selected file to a callback function (does not create nor read files by itself).
|
||||
|
||||
- `options`: object with the following keys:
|
||||
- `extension`: allowed extension (default: "*")
|
||||
- `directory`: starting directory for browser (default: user's home)
|
||||
- `allowDir`: allow choosing a directory instead of a file (default: false)
|
||||
- `mode`: "save" or "open"
|
||||
- `callback`: function called with 1 argument (file path)
|
||||
|
||||
#### `uploadFile(options, callback)`
|
||||
|
||||
Opens the client file upload prompt and pass the raw content of selected file to a callback function.
|
||||
|
||||
- `options`: object with the following keys:
|
||||
- `types`: equivalent of HTML attribute [`accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept)
|
||||
- `callback`: function called with 1 argument (file content)
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
# Download the latest release
|
||||
|
||||
!!! tip ""
|
||||
[*Click here*](/docs/getting-started/introduction/#installation) to read the installation guide.
|
||||
|
||||
<a href="https://framagit.org/jean-emmanuel/open-stage-control/-/releases/v{{config.latest_release}}">
|
||||
Open Stage Control v{{config.latest_release}}
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="/packages/open-stage-control-{{config.latest_release}}-1.x86_64.rpm"><i class="fa fa-download"></i>GNU/Linux RPM (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_amd64.deb"><i class="fa fa-download"></i>GNU/Linux Debian (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_linux-x64.zip"><i class="fa fa-download"></i>GNU/Linux (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_node.zip"><i class="fa fa-download"></i>Node.js</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_osx-x64.zip"><i class="fa fa-download"></i>MacOS x64</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_osx-arm64.zip"><i class="fa fa-download"></i>MacOS arm64</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_win32-x64.zip"><i class="fa fa-download"></i>Windows (64-bit)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<style>
|
||||
html {
|
||||
overflow-y: scroll
|
||||
}
|
||||
.md-sidebar--secondary {
|
||||
display: none;
|
||||
}
|
||||
@media screen and (min-width: 76.25em) {
|
||||
.md-sidebar--primary {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.md-content {
|
||||
margin: 0;
|
||||
}
|
||||
.md-content__inner {
|
||||
margin-left: .8rem;
|
||||
margin-right: .6rem;
|
||||
}
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
li i {
|
||||
margin-right: 10px
|
||||
}
|
||||
.download-size {
|
||||
color: var(--md-typeset-color);
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<a
|
||||
href="/docs/changelog/"
|
||||
class="md-button md-button-small"
|
||||
>
|
||||
Read the Changelog
|
||||
</a>
|
||||
<a
|
||||
href="https://www.patreon.com/openstagecontrol?fan_landing=true"
|
||||
class="md-button md-button-small patreon-icon"
|
||||
>
|
||||
Support on Patreon
|
||||
</a></div>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
document.addEventListener('DOMContentLoaded', ()=>{
|
||||
|
||||
if (window.location.hash && window.location.href.includes('properties-reference')) {
|
||||
// show target in tabs/details
|
||||
document.querySelectorAll('[id='+window.location.hash.split("#")[1]+']').forEach(function(item){
|
||||
var tab = item.closest('.tabbed-block'),
|
||||
container= item.closest('.tabbed-set'),
|
||||
details = item.closest('details'),
|
||||
index = 0
|
||||
while (tab.previousElementSibling) {
|
||||
index++
|
||||
tab = tab.previousElementSibling
|
||||
}
|
||||
console.log(index)
|
||||
container.querySelectorAll('.tabbed-labels label:nth-child('+(index+1)+')').forEach(function(item,i){
|
||||
item.click()
|
||||
})
|
||||
|
||||
if (item) {
|
||||
item.scrollIntoView()
|
||||
document.documentElement.scrollTop -= 70
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
:root {
|
||||
--osc-background-color: rgb(21,26,36);
|
||||
--osc-accent-color: #448aff;
|
||||
}
|
||||
|
||||
html {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.md-header, .md-nav__title[for=__drawer] {
|
||||
background-color: var(--osc-background-color)!important;
|
||||
}
|
||||
|
||||
@media screen and (min-width:1220px) {
|
||||
.md-nav__title[for=__drawer] {
|
||||
background-color: transparent!important;
|
||||
}
|
||||
}
|
||||
|
||||
.md-header-nav__title {
|
||||
padding-top: 1px;
|
||||
padding-left: 0!important
|
||||
}
|
||||
|
||||
.md-source__facts {
|
||||
display: none;
|
||||
}
|
||||
|
||||
td:first-child {
|
||||
white-space: pre!important;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
.force-full-table + .md-typeset__scrollwrap .md-typeset__table {
|
||||
width:100%;
|
||||
}
|
||||
.force-full-table + .md-typeset__scrollwrap .md-typeset__table table {
|
||||
display: table!important;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
|
||||
.accordion {
|
||||
margin: 1.5625em 0;
|
||||
padding: .6rem;
|
||||
overflow: hidden;
|
||||
font-size: .64rem;
|
||||
page-break-inside: avoid;
|
||||
border-left: .2rem solid var(--osc-accent-color);
|
||||
border-radius: .1rem;
|
||||
box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,.05), 0 0 0.05rem rgba(0,0,0,.1);
|
||||
}
|
||||
.accordion h6 {
|
||||
cursor: pointer;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.accordion > :last-child {
|
||||
display: none;
|
||||
}
|
||||
.accordion .md-typeset__table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.accordion.show > :last-child {
|
||||
display: block;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.accordionlink > .headerlink {
|
||||
opacity: 1!important;
|
||||
visibility: visible!important;
|
||||
text-decoration: none;
|
||||
color: inherit!important;
|
||||
display: block;
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
.accordion-description {
|
||||
opacity: 0.8;
|
||||
}
|
||||
.accordion.show .accordion-description {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
table .thead2 {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
white-space: nowrap;
|
||||
}
|
||||
table .thead2 h6 {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
details.api h4 {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
details.api summary {
|
||||
padding-left: 0.6rem;
|
||||
}
|
||||
details.api summary:before {
|
||||
display: none!important;
|
||||
}
|
||||
|
||||
details summary div {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
i[title="dynamic"] {
|
||||
color: var(--osc-accent-color);
|
||||
}
|
||||
|
||||
|
||||
.patreon-icon {
|
||||
margin-top: 2em!important;
|
||||
color: black!important;
|
||||
display: block;
|
||||
background-image: url('data:image/svg+xml;charset=UTF-8,<svg fill="black" viewBox="0 0 569 546" xmlns="http://www.w3.org/2000/svg"><g><circle cx="362.589996" cy="204.589996" data-fill="1" id="Oval" r="204.589996"></circle><rect data-fill="2" height="545.799988" id="Rectangle" width="100" x="0" y="0"></rect></g></svg>');
|
||||
background-size: 20px 30px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 20px center;
|
||||
padding-left: 3em!important;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
../fonts
|
||||
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