Compare commits

..

No commits in common. "master" and "v1.8.2" have entirely different histories.

316 changed files with 9813 additions and 29081 deletions

13
.babelrc Normal file
View file

@ -0,0 +1,13 @@
{
"presets": [
["@babel/env", {
"targets": {
"ios": "10.3",
"chrome": "60"
},
"useBuiltIns": "usage",
"corejs": 3
}]
],
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

View file

@ -1,3 +0,0 @@
node_modules
app
sessions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
jquery.*.js

View file

@ -1,18 +1,24 @@
{
"parser": "babel-eslint",
"env": {
"es2021": true,
"es6": true,
"browser": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"no-prototype-builtins": "off",
"no-console": "off",
"no-undef": "off",
"no-useless-escape": "off",
"no-self-assign": "off",
"no-fallthrough": "off",
"no-empty": [
"error",
{
@ -46,12 +52,14 @@
],
"quotes": [
"error",
"single",
{ "allowTemplateLiterals": true }
"single"
],
"semi": [
"error",
"never"
]
},
"globals": {
"module": true
}
}

View file

@ -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}}

21
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View file

@ -0,0 +1,21 @@
---
name: Bug report
about: Report a bug in Open Stage Control
title: '[Bug] '
---
<!--
Please provide as much contextual informations as possible:
- Open Stage Control version (or commit if built from sources)
- Operating system
- Open Stage Control options
- Client type (built-in or external chromium/chrome browser) and version
- Session file (can be uploaded after adding the .txt extension)
- Custom module
- Server logs (from the terminal or the launcher's console)
- Client logs (hit F12 in chromium/chrome to open the console)
- Screenshot
-->

5
.github/ISSUE_TEMPLATE/feature.md vendored Normal file
View file

@ -0,0 +1,5 @@
---
name: Feature request
about: Suggest an idea for Open Stage Control
title: '[Feature] '
---

5
.github/SUPPORT.md vendored Normal file
View file

@ -0,0 +1,5 @@
## How do I get help ?
- If you found a bug, open a bug report
- If you have a suggestion, open a feature request
- If you have a question or want to share your experience with other users, please use the dedicated forum at https://openstagecontrol.discourse.group/

32
.gitignore vendored
View file

@ -1,17 +1,15 @@
# 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/
node_modules
dist
app/LICENSE
app/assets/fonts/*
app/assets/*.css*
app/assets/*.png
app/client/*.js*
app/launcher/*.js*
app/server/*
app/docs/*
!app/docs/.htaccess
!app/server/.keep
app/package.json
package-lock.json
*.pyc

46
.travis.yml Normal file
View file

@ -0,0 +1,46 @@
anHsudo: required
dist: bionic
language: node_js
node_js:
- "12"
before_install:
- sudo dpkg --add-architecture i386
- sudo apt-get update -qq
- sudo apt-get install -qq wine-stable fakeroot xvfb python3.8 python3-pip python3-setuptools
- sudo python3 -m pip install mkdocs-material
install: npm install
before_deploy:
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_glob: true
file: dist/packages/*
skip_cleanup: true
on:
tags: true
before_deploy:
- export VERSION=$(sed -nE 's/^\s*"version":\ "(.*?)",$/\1/p' package.json)
- npm run build-docs
- npm run package -- --all
- npm run package-node
- cd $TRAVIS_BUILD_DIR/dist/open-stage-control-linux-x64/resources/app/server/
- wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-linux && chmod +x osc-midi-linux
- cd $TRAVIS_BUILD_DIR/dist/open-stage-control-win32-x64/resources/app/server/
- wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-windows.exe && chmod +x osc-midi-windows.exe
- cd $TRAVIS_BUILD_DIR/dist/open-stage-control-darwin-x64/open-stage-control.app/Contents/Resources/app/server
- wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-osx && chmod +x osc-midi-osx
- cd $TRAVIS_BUILD_DIR
- npm run deb64
- cd dist
- mkdir packages
- mv open-stage-control-linux-x64/*.deb packages/open-stage-control-${VERSION}-amd64.deb
- mv open-stage-control-node open-stage-control-${VERSION}-node
- mv open-stage-control-win32-x64 open-stage-control-${VERSION}-win32-x64
- mv open-stage-control-linux-x64 open-stage-control-${VERSION}-linux-x64
- zip -q -r --symlinks packages/open-stage-control-${VERSION}-osx.zip open-stage-control-darwin-x64/open-stage-control.app
- zip -q -r packages/open-stage-control-${VERSION}-node.zip open-stage-control-${VERSION}-node
- zip -q -r packages/open-stage-control-${VERSION}-win32-x64.zip open-stage-control-${VERSION}-win32-x64
- zip -q -r packages/open-stage-control-${VERSION}-linux-x64.zip open-stage-control-${VERSION}-linux-x64
- ls packages
- cd ..

View file

@ -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.

File diff suppressed because it is too large Load diff

View file

@ -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
View file

@ -0,0 +1 @@
web: node app/ -n -p $PORT --remote-saving 127.0.0.1 $OPTIONS

View file

@ -4,18 +4,9 @@ Open Stage Control
*Libre and modular OSC / MIDI controller*
- Website: https://openstagecontrol.ammd.net/
- Forum: https://openstagecontrol.discourse.group/
- IRC: Libera.chat #openstagecontrol
https://openstagecontrol.ammd.net/
----
Docker additions by Rik Berkelder.
mount `/sessions` directory. default session file is created and loaded there.
---
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.
Copyleft © Jean-Emmanuel Doucet @ [AMMD](http://ammd.net) 2014-2020.
This program is a free software released under the [GNU/GPL3](ttps://github.com/jean-emmanuel/open-stage-control/blob/master/LICENSE) license.

2
app/assets/themes/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
app/client/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

1
app/docs/.htaccess Normal file
View file

@ -0,0 +1 @@
ErrorDocument 404 /404.html

1
app/index.js Normal file
View file

@ -0,0 +1 @@
require('./server/open-stage-control-server')

2
app/launcher/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

0
app/server/.keep Normal file
View file

View file

@ -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": []
}
}

View file

@ -1,8 +0,0 @@
services:
app:
build: .
volumes:
- ./sessions:/sessions
ports:
- 8080:8080

View file

@ -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

9718
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
"name": "open-stage-control",
"productName": "Open Stage Control",
"description": "Libre and modular OSC / MIDI controller",
"version": "1.31.2",
"version": "1.8.2",
"author": {
"name": "Jean-Emmanuel Doucet",
"email": "jean-emmanuel@ammd.net"
@ -15,96 +15,95 @@
],
"repository": {
"type": "git",
"url": "https://framagit.org/jean-emmanuel/open-stage-control"
"url": "https://github.com/jean-emmanuel/open-stage-control"
},
"homepage": "http://openstagecontrol.ammd.net/",
"license": "GPL-3.0",
"dependencies": {
"@babel/core": "7.18.0",
"@babel/preset-env": "7.18.0",
"@electron/packager": "18.4.4",
"@electron/remote": "2.1.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"ace-builds": "1.39.0",
"ansi-html": "0.0.9",
"@babel/core": "7.12.8",
"@babel/plugin-proposal-object-rest-spread": "7.12.1",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.12.7",
"ansi-html": "0.0.7",
"babel-eslint": "10.1.0",
"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",
"bonjour": "github:jean-emmanuel/bonjour",
"browserify": "17.0.0",
"chokidar": "3.4.3",
"chroma-js": "2.1.0",
"core-js": "3.7.0",
"cpr": "3.0.1",
"deep-extend": "0.6.0",
"electron": "7.1.11",
"electron-installer-debian": "3.1.0",
"electron-localshortcut": "3.2.1",
"electron-packager": "15.1.0",
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "1.0.2",
"env-paths": "2.2.1",
"eslint": "8.16.0",
"fastdom": "1.0.10",
"env-paths": "2.2.0",
"eslint": "7.14.0",
"exorcist": "1.0.1",
"file-saver": "2.0.5",
"http-auth": "4.1.9",
"json5": "2.2.1",
"gyronorm": "2.0.6",
"http-auth": "4.1.2",
"json5": "2.1.3",
"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",
"licensify": "3.1.3",
"loop-protect": "github:jean-emmanuel/loop-protect#v1.0.1",
"minimatch": "3.0.4",
"nanohtml": "1.9.1",
"nanoid": "3.1.18",
"nanomorph": "5.4.2",
"node-forge": "0.10.0",
"node-sass": "5.0.0",
"nodemon": "2.0.6",
"nosleep.js": "0.11.0",
"open": "7.3.0",
"osc": "2.4.1",
"python-shell": "2.0.3",
"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",
"sanitize-html": "2.1.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",
"screenfull": "5.0.2",
"semver": "7.3.2",
"send": "0.17.1",
"sortablejs": "1.10.2",
"source-map-support": "0.5.19",
"stacktrace-js": "2.0.2",
"ua-parser-js": "2.0.7",
"ws": "8.6.0",
"yargs": "17.5.1"
"through": "2.3.8",
"uglifyify": "5.0.2",
"webworkify": "1.5.0",
"ws": "7.4.0",
"yargs": "16.1.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"
"electron": "7.1.11",
"electron-installer-debian": "3.1.0"
},
"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'",
"build": "npm run build-css && npm run build-js && node scripts/copy-assets.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",
"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",
"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",
"build-client-js": "node scripts/build-client.js",
"build-launcher-js": "node scripts/build-launcher.js",
"build-server-js": "node scripts/build-server.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"
"watch-browser": "npm run build-client-js -- --watch",
"watch-css": "nodemon --watch src/scss -e scss -x \"npm run build-css -- --reload\"",
"watch-server": "nodemon --watch src/server/ -e js -x \"npm run build-server-js\"",
"watch-launcher": "nodemon --watch src/launcher/ -e js -x \"npm run build-launcher-js\"",
"build-docs": "node scripts/build-widgets-reference.js > resources/docs/docs/widgets/properties-reference.md && cd resources && python3 -m mkdocs build",
"test": "eslint src && npm run build && node tests/test.js"
},
"engines": {
"node": ">=16"
"node": ">=10"
},
"devDependencies": {
"watchify": "3.11.1"
}
}

View file

@ -1 +0,0 @@
../../../CHANGELOG.md

View file

@ -5,21 +5,13 @@ Client options can be set either with the server's `--client-options` option, or
|----|----|----|----|
| 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 |
| doubletab | 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) |
| lang | string | *system_default* | use a different language than the default if available (available languages: en, fr) |
| 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:

View file

@ -1,17 +1,19 @@
## 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.
Copyleft © Jean-Emmanuel Doucet @ [AMMD](http://ammd.net) 2014-2020.
This program is a free software released under the [GNU/GPL3](https://github.com/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).
Open Stage Control relies on several other free softwares:
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/)).
https://github.com/jean-emmanuel/open-stage-control/network/dependencies
The default theme is based on [Nord](https://www.nordtheme.com/), some UI components are inspired by the [Atom](https://atom.io/) text editor.
## 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")
https://github.com/jean-emmanuel/open-stage-control/graphs/contributors
## Infrastructure supports
@ -37,4 +39,4 @@ Discourse provides the community forum.
<img src="/img/sponsors/browserstack.png" width="140px"/>
</a>
BrowserStack provides remote browsers for debugging.
BrowserStack provides remote browsers for debbuging.

View file

@ -10,26 +10,13 @@ Using the server's `custom-module` option, users can load a custom javascript mo
// 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
// this will be executed once when the osc server starts
},
oscInFilter:function(data){
@ -61,8 +48,7 @@ module.exports = {
},
unload: function(){
// this will be executed before the custom module is reloaded
// it is called for all modules, including other loaded modules
// this will be executed when the custom module is reloaded
},
}
@ -76,7 +62,7 @@ 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}`)
[`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://github.com/jean-emmanuel/open-stage-control/blob/master/src/server/callbacks.js), callbacks are called with 2 arguments: `data` (object) and `client` (object: `{address, id}`)
----
@ -87,16 +73,14 @@ Send osc/midi message to connected clients. `host` and `port` can be specified t
- `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.
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object`
- `options` (optional): set to `{clientId: id}` to define which client receives the message (where `id` is the client's id as retreived from `app` events or `oscOutFilter`)
----
#### `send(host, port, address, ...args)`
Send osc/midi to a target (see `receive()`).
Send osc/midi to a target.
----
@ -112,24 +96,16 @@ Returns the server's http addresses.
----
#### `loadJSON(path, errorCallback)`
#### `loadJSON(path)`
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)`
#### `saveJSON(path, object)`
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)`
@ -151,26 +127,6 @@ This function can be used to load native node modules or locally installed modul
----
#### `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`
@ -180,17 +136,13 @@ This function can be used to restart the midi backend (if already running) witho
- `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.
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.
??? "Reloading native modules"

View file

@ -178,65 +178,6 @@ module.exports = {
}
```
## 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
@ -333,139 +274,3 @@ module.exports = {
}
```
## 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
}
}
```

View file

@ -3,7 +3,7 @@
## 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 (![x](/img/inspect.png)) and click on a element in the interface to reveal its html code.
Hit ++f12++ to open the developers tools panel. The html/css inspector helps retreiving the class names needed to style specific parts of the widgets: hit ++ctrl+shift+c++ or click on the inspect icon (![x](/img/inspect.png)) and click on a element in the interface to reveal its html code.
## Inline syntax
@ -11,7 +11,7 @@ Hit ++f12++ to open the developers tools panel. The html/css inspector helps ret
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 */
opacity: 0.5; /* make the widget's transparent */
font-size: 120%; /* increase font-size */
```
@ -27,12 +27,12 @@ CSS selectors can be used to apply styles to specific elements:
*/
}
label {
/* style for the label elements */
.label {
/* style for the .label elements */
}
> label {
/* style for the direct child label element */
> .label {
/* style for the direct child .label element */
}
```
@ -50,7 +50,7 @@ Multiple classes can be added (one per `class` statement). Custom classes are al
## 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.
Z-Axis ordering can be set using the `z-index` rule. Absolutely positionned widgets (when `top` or `left` is different from `auto`) have `z-index:10;` by default.
## Responsive sizing
@ -87,14 +87,6 @@ Media queries can also be used:
## 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.
[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 overriden.
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

View file

@ -33,4 +33,4 @@ 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).
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/browser/scss/themes/` and run `npm run watch-css`. The theme will be watched and compiled automatically to a css file located in `app/browser/themes/` (css files in this directory can be selected from the theme option by their name, without .css suffix).

View file

@ -1,8 +1,11 @@
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.
!!! info "Still using v0 ?"
The documentation for this version is available [here](https://v0.openstagecontrol.ammd.net).
## Overview
Open Stage Control consists of 3 modules: the server, the launcher and the client.
Open Stage Control consists in 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.
@ -17,15 +20,15 @@ The **server** can run on all [platforms supported by Electron](https://www.elec
The **client** is compatible with the following browsers:
- Firefox: version `75` and higher
- Chromium / Chrome: version `75` and higher
- Firefox: version `75`
- Chromium / Chrome: version `60`
iOS devices must be of version `11` or higher.
iOS devices must be of version `10.3` or higher.
## Installation
=== "Linux 64bit"
??? example "Linux 64bit"
**Ubuntu / Debian**
@ -41,28 +44,19 @@ iOS devices must be of version `11` or higher.
- Extract it in the location of your choice
- The file inside it named `open-stage-control` is the app's main executable
=== "Mac 64bit"
??? example "Mac 64bit"
- [Download](/download) `open-stage-control-VERSION-osx-x64.zip`
- [Download](/download) `open-stage-control-VERSION-osx.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"
??? example "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"
??? example "Other systems"
- Install [Node.js](https://nodejs.org/en/download/package-manager/)
- Download `open-stage-control-VERSION-node.zip`

View file

@ -12,7 +12,7 @@ Running the app from the sources slightly differs from using prebuilt binaries:
**Download**
```bash
git clone https://framagit.org/jean-emmanuel/open-stage-control.git
git clone https://github.com/jean-emmanuel/open-stage-control
cd open-stage-control/
# uncomment next line if you want the latest release
# instead of the current development version
@ -22,9 +22,8 @@ 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)
Run this instead of `npm install` if the architecture is `armv7l`
```
npm install --arch=arm64
npm install --arch=armv7l
```
@ -45,10 +44,6 @@ 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.
@ -87,23 +82,8 @@ This will build the app in `dist/open-stage-control-PLATFORM-ARCH`.
Building the app for windows from a linux system requires wine to be installed.
## Debian / Ubuntu and RPM installers
## Debian/Ubuntu installer
=== "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
```
npm run deb64
```

View file

@ -66,7 +66,7 @@ The **server** can be configured with many options, either from a terminal or wi
!!! quote ""
#### `debug`
Print sent and received messages in the console. This may impact performance and should not be enabled in production.
Print sent and receiced messages in the console. This may impact performances and should not be enabled in production.
@ -170,25 +170,6 @@ The following options can only be set from a terminal.
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`
@ -197,7 +178,7 @@ The following options can only be set from a terminal.
!!! quote ""
#### `docs`
Serve documentation website locally and open it with the system's default browser
Serve documentation website locally and open it with the system\'s default browser
!!! quote ""

View file

@ -3,10 +3,10 @@
=== "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.
Since version `1.7.0`, Open Stage Control comes bundled with built-in MIDI support if you're using the 64bit package for Linux, OSX or Windows.
=== "Other systems / Node"
=== "Other systems"
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:
@ -16,10 +16,8 @@
??? 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
- Install `python-rtmidi` from a terminal by executing this command
```bash
python3 -m pip install python-rtmidi --upgrade
```
@ -58,7 +56,7 @@
The server's `midi` option accepts the following parameters, separated by spaces.
!!! warning ""
If an option contains space characters, it must be quoted.
If an option contains space characters, it must be enquoted.
**`list`**
@ -66,7 +64,7 @@ Print the available MIDI ports to the console when the server starts. This actio
**`device_name:input,output`**
Create a virtual MIDI device that will translate OSC messages to MIDI messages
Create a virtual MIDI device that will translate OSC messsages 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).
@ -79,27 +77,10 @@ Enable parsing of system exclusive messages (disabled by default).
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
@ -109,9 +90,7 @@ Prevent converting outgoing noteOn messages with velocity 0 to noteOff messages.
**`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`).
Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`). *Only use this if you know what you are doing.*
## Widget setup
@ -127,7 +106,7 @@ Its `address` and `preArgs` properties must be set according to Open Stage Contr
## Debug
Enabling the server's `debug` options will print some extra information (sent/received midi messages, midi setup information, etc)
Enabling the server's `debug` options will print some extra informations (sent/received midi messages, midi setup informations, etc)
## Example configuration

View file

@ -5,7 +5,7 @@
#### `/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).
NoteOn event or noteOff if velocity equals `0`.
- `channel`: integer between 1 and 16
- `note`: integer between 0 and 127
@ -23,12 +23,6 @@ NoteOn event or noteOff if velocity equals `0`. Incoming noteOff events will be
----
#### `/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.
@ -107,24 +101,3 @@ Polyphonic key pressure event.
- `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
----

View file

@ -1,6 +1,6 @@
# 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.
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 responds 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.
@ -11,7 +11,8 @@ When osc messages are received, the default behavior is to update the value of a
#### `/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.
Apply a set of options to an existing widget by replacing the old ones with the new ones.
- `id`: `string`, widget's `id`
- `properties`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge
@ -19,6 +20,10 @@ Apply a set of options to an existing widget by replacing the old ones with the
- `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.
!!! danger "Warning"
Editing widgets is cpu expensive; for small and recurrent changes, consider using [osc listeners](./widgets/advanced-syntaxes.md) instead.
----
#### `/EDIT/MERGE id properties options`
@ -112,20 +117,10 @@ Same as `/GET` but uses the widget's address instead of `/GET` to reply.
----
#### `/NOTIFY icon message`
#### `/NOTIFY 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`
@ -159,12 +154,11 @@ Sends back the app's state to specified target
----
#### `/STATE/SET state send`
#### `/STATE/SET state`
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
@ -181,13 +175,6 @@ Save the state of all widgets in the temporary slot.
Reload saved state from the temporary slot.
----
#### `/STATE/SEND`
Make all widgets send their current value.
----
#### `/STATE/OPEN path.state`
@ -198,15 +185,10 @@ Open state file `path.state`.
#### `/STATE/SAVE path.state`
Save state session to `path.state`.
Save state session to `path.state`. If `path.state` is omitted, current session's path is used.
----
#### `/SESSION/CREATE`
Create a new empty session. Unsaved changes will be lost.
----
#### `/SESSION/OPEN path.json`
Open session file `path.json`.
@ -216,22 +198,3 @@ 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.

View file

@ -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})
```

View file

@ -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.
![](./first-steps/two-widgets.png)
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.
![](./first-steps/resized-fader.png)
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.
![](./first-steps/fader-style.png)
![](./first-steps/horizontal-fader.png)
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

View file

@ -7,8 +7,6 @@
- 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
@ -20,7 +18,7 @@
- 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
- Enable: togggle editor's state
- Grid: toggle grid
- Project tree: toggle project tree's visibility
- Inspector: toggle inspector's visibility
@ -28,14 +26,12 @@
- 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.
The sidepanels are only visible when the editor is active, they can be resized and/or hidden. Both are describe in the [editor](./editor.md) section.
## 3. Session
@ -43,7 +39,7 @@ It is the main component, it contains all the widgets and takes all the availabl
## 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.
Notifications appear in the lower right corner, they are usually used to convey server status informations.
## 5. Modals
@ -53,43 +49,21 @@ Modals are virtual popup windows that may contain various content: file browser,
## Keyboard shortcuts
=== "Linux"
=== "Linux / 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 |
| ++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 |

View file

@ -1,6 +1,6 @@
## Widget selection
Clicking on a widget, on a tab label or on an item in the project tree selects the widgets for editing:
Clicking on a widget, on a tab label or on an item in the project tree selects the widgets for edition:
- All its editable properties are shown in the inspector panel
- The corresponding item in the project tree is highlighted
@ -9,7 +9,6 @@ Clicking on a widget, on a tab label or on an item in the project tree selects t
![](../../img/screenshots/editor.png)
To interact with a widget directly without selecting it, either use the middle mouse button or hold ++shift+win++ (++shift+cmd++ on Mac).
## Menu
@ -29,7 +28,6 @@ Right clicking on a widget displays a menu with the following actions
- `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
@ -38,21 +36,13 @@ Right clicking on a widget displays a menu with the following actions
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.
- Properties are written in JSON, with some flexibility brought by the [JSON5](https://github.com/json5/json5) format. For example, doubles 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.
The project tree displays the whole widget structure of the session. Widgets can be reordered within a container with drag-and-drop.
## Widget resizing / dragging
@ -81,7 +71,7 @@ Multiple widgets can be edited at once.
| ++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. |
| ++shift+"Click"+"Drag"++ | Draw a selection rectangle and attempt to select widgets in it (starts by selecting the widget under the cursor). 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 |
@ -89,29 +79,19 @@ Multiple widgets can be edited at once.
| ++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) |
| ++up++ <br/>++down++ <br/>++left++ <br/>++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 |
| ++ctrl+up++ | Select current widget's parent |
| ++ctrl+down++ | Select current widget's first child |
| ++ctrl+right++ | Select current widget's next sibling |
| ++ctrl+left++ | Select current widget's previous sibling |
| ++t++ | Show selected widget in the 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 |
=== "Mac"
@ -123,7 +103,7 @@ Multiple widgets can be edited at once.
| ++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. |
| ++shift+"Click"+"Drag"++ | Draw a selection rectangle and attempt to select widgets in it (starts by selecting the widget under the cursor). 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 |
@ -131,26 +111,16 @@ Multiple widgets can be edited at once.
| ++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) |
| ++up++ <br/>++down++ <br/>++left++ <br/>++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 |
| ++cmd+up++ | Select current widget's parent |
| ++cmd+down++ | Select current widget's first child |
| ++cmd+right++ | Select current widget's next sibling |
| ++cmd+left++ | Select current widget's previous sibling |
| ++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 |
| ++Home++ | Send selected widget to back |
| ++Page Up++ | Send selected widget farther |
| ++Page Down++ | Bring selected widget closer |
| ++End++ | Bring selected widget to front |

View file

@ -5,77 +5,36 @@
- 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
- Load: load server configration 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
- List MIDI devices: list available MIDI devices in the console
- Console:
- Clear: clear console
- Autoscroll: enable/disable console autoscroll
- Autoscrell: 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
## 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.
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, it's 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.
The console diplays various informations, runtime errors and server debug messages.
## Keyboard shortcuts
=== "Linux"
=== "Linux / 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 |
| ++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 |

View file

@ -1,6 +1,6 @@
# 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.
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' evualate the properties they're in.
## Inheritance: `@{id.property}`
@ -8,11 +8,11 @@ Advanced syntaxes are special blocks of code that can be written in the widgets
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.
- `property`: target widget's property name. If ommitted (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}`).
!!! note "Unique indentifier"
Each widget has a unique random identifier that can be retreived with the property name `uuid` (e.g. `@{this.uuid}`, `@{parent.uuid}`).
#### Dynamic properties
@ -28,7 +28,7 @@ Some properties have much cheaper update routines and can be considered as `dyna
#### 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}`
If the retreived property is an object (`{}`), a subset can be retreived directly by appending a dot and a key (array index or object key) : `@{parent.variables.key}`
#### Nesting
@ -46,79 +46,50 @@ The OSC listener syntax returns the value received on specified address (or the
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{
JS{{
return OSC{address} || {
"key a": 1,
"key b": 2
"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.`
## Javascript: `JS{{ <code> }}`
## 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.
This syntax allows writing formulas in [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
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}`)
- `screen`: client screen dimensions (`{width, height}`)
- `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)
In this context, `@{} / OSC{}` are seen as variables. When they change, the whole block will be evaluated again.
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.
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
`#{}` blocks are compiled after `JS{{}}` blocks

View file

@ -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})
```

View file

@ -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.

View file

@ -58,5 +58,3 @@ From a client to another, widgets are automatically synchronized if they share t
- `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.

View file

@ -0,0 +1,793 @@
<!-- This file is generated automatically from the widget class declarations. See scripts/build-widget-reference.js -->
## Common
??? api "<div id="generic_properties">Generic properties<a class="headerlink" href="#generic_properties" title="Permanent link">#</a></div>"
Properties shared by all widgets
=== "widget"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="type">type<a class="headerlink" href="#type" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Widget type |
| <h6 id="id">id<a class="headerlink" href="#id" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Widgets sharing the same `id` will act as clones and update each other's value(s) without sending extra osc messages. |
| <h6 id="visible">visible<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#visible" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the widget. |
| <h6 id="interaction">interaction<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#interaction" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable pointer interactions. |
=== "geometry"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="left">left<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#left" title="Permanent link">#</a></h6> | `number`&vert;<br/>`string` | <code>"auto"</code> | When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).<br/><br/>Otherwise, the widget will be absolutely positioned |
| <h6 id="top">top<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#top" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"auto"</code> | When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).<br/><br/>Otherwise, the widget will be absolutely positioned |
| <h6 id="width">width<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#width" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"auto"</code> | Widget width |
| <h6 id="height">height<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#height" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"auto"</code> | Widget height |
| <h6 id="expand">expand<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#expand" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>"false"</code> | If parent's layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically. |
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="colorText">colorText<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#colorText" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Text color. Set to "auto" to inherit from parent widget. |
| <h6 id="colorWidget">colorWidget<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#colorWidget" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Widget's default accent color. Set to "auto" to inherit from parent widget. |
| <h6 id="colorStroke">colorStroke<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#colorStroke" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Stroke color. Set to "auto" to use `colorWidget`. |
| <h6 id="colorFill">colorFill<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#colorFill" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Fill color. Set to "auto" to use `colorWidget`. |
| <h6 id="alphaStroke">alphaStroke<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#alphaStroke" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Stroke color opacity. |
| <h6 id="alphaFillOff">alphaFillOff<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#alphaFillOff" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Fill color opacity (off). |
| <h6 id="alphaFillOn">alphaFillOn<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#alphaFillOn" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Fill color opacity (on). |
| <h6 id="lineWidth">lineWidth<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#lineWidth" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Stroke width. |
| <h6 id="padding">padding<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#padding" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Inner spacing. |
| <h6 id="html">html<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#html" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Custom html content to be inserted in the widget (before the widget's content).<br/><br/>The code is automatically wrapped in &lt;div class="html">&lt;/div><br/><br/>Allowed HTML tags:<br/><br/>&nbsp;&nbsp;h1-6, blockquote, p, a, ul, ol, nl, li,<br/><br/>&nbsp;&nbsp;b, i, strong, em, strike, code, hr, br, div,<br/><br/>&nbsp;&nbsp;table, thead, img, caption, tbody, tr, th, td, pre<br/><br/>Allowed attributes:<br/><br/>&nbsp;&nbsp;&lt;*>: class, style, title<br/><br/>&nbsp;&nbsp;&lt;img>: src, width, height |
| <h6 id="css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke` |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#value" title="Permanent link">#</a></h6> | `*` | <code>""</code> | Define the widget's value depending on other widget's values / properties using the advanced property syntax |
| <h6 id="default">default<a class="headerlink" href="#default" title="Permanent link">#</a></h6> | `*` | <code>""</code> | If set, the widget will be initialized with this value when the session is loaded. |
| <h6 id="linkId">linkId<a class="headerlink" href="#linkId" title="Permanent link">#</a></h6> | `string`&vert;<br/>`array` | <code>""</code> | Widgets sharing the same `linkId` update each other's value(s) AND send their respective osc messages.<br/><br/>When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)<br/><br/>When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending) |
| <h6 id="script">script<a class="headerlink" href="#script" title="Permanent link">#</a></h6> | `script` | <code>""</code> | Script executed whenever the widget's value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>. |
=== "osc"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="address">address<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#address" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | OSC address for sending / receiving messages, it must start with a slash (`/`)<br/><br/>By default ("auto"), the widget's id is used: `/widget_id` |
| <h6 id="preArgs">preArgs<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#preArgs" title="Permanent link">#</a></h6> | `*`&vert;<br/>`array` | <code>""</code> | A value or array of values that will be prepended to the OSC messages. |
| <h6 id="typeTags">typeTags<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#typeTags" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Defines the osc argument types, one letter per argument (including preArgs)<br/>- If empty, the types are infered automatically from the values (with numbers casted to floats by default)<br/>- If there are more arguments than type letters, the last type is used for the extra arguments<br/><br/>See <a href="http://opensoundcontrol.org/spec-1_0">http://opensoundcontrol.org/spec-1_0</a> for existing typetags |
| <h6 id="decimals">decimals<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#decimals" title="Permanent link">#</a></h6> | `integer` | <code>2</code> | Defines the number of decimals to send. |
| <h6 id="target">target<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#target" title="Permanent link">#</a></h6> | `string`&vert;<br/>`array`&vert;<br/>`null` | <code>""</code> | This defines the targets of the widget's OSC messages<br/>- A `string` or `array` of strings formatted as follow: `ip:port` or `["ip:portA", "ip:portB"]`<br/>- If midi is enabled, targets can be `midi:device_name`<br/>- If no target is set, messages can still be sent if the server has default targets |
| <h6 id="ignoreDefaults">ignoreDefaults<a class="headerlink" href="#ignoreDefaults" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to ignore the server's default targets |
| <h6 id="bypass">bypass<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#bypass" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to prevent the widget from sending any osc message |
## Basics
??? api "<div id="button">button<a class="headerlink" href="#button" title="Permanent link">#</a></div>"
On / off button.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="button_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#button_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--color-text-on`: `colorTextOn` |
| <h6 id="button_colorTextOn">colorTextOn<a class="headerlink" href="#button_colorTextOn" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Defines the widget's text color when active. |
| <h6 id="button_label">label<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#button_label" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Set to `false` to hide completely<br/>- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)<br/>- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` |
| <h6 id="button_vertical">vertical<a class="headerlink" href="#button_vertical" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display the text vertically |
| <h6 id="button_wrap">wrap<a class="headerlink" href="#button_wrap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to wrap long lines automatically. |
=== "button"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="button_on">on<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#button_on" title="Permanent link">#</a></h6> | `*` | <code>1</code> | Set to `null` to send send no argument in the osc message |
| <h6 id="button_off">off<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#button_off" title="Permanent link">#</a></h6> | `*` | <code>0</code> | Set to `null` to send send no argument in the osc message. Must be different from `on`. |
| <h6 id="button_mode">mode<a class="headerlink" href="#button_mode" title="Permanent link">#</a></h6> | `string` | <code>"toggle"</code> | Interraction mode:<br/>- `toggle` (classic on/off switch)<br/>- `push` (press & release)<br/>- `tap` (no release)<br/><br/>Choices: `toggle`, `push`, `tap` |
| <h6 id="button_doubleTap">doubleTap<a class="headerlink" href="#button_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the button require a double tap to be pushed instead of a single tap |
??? api "<div id="switch">switch<a class="headerlink" href="#switch" title="Permanent link">#</a></div>"
Value selector button.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="switch_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#switch_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--color-text-on`: `colorTextOn` |
| <h6 id="switch_colorTextOn">colorTextOn<a class="headerlink" href="#switch_colorTextOn" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Defines the widget's text color when active. |
| <h6 id="switch_layout">layout<a class="headerlink" href="#switch_layout" title="Permanent link">#</a></h6> | `string` | <code>"vertical"</code> | Defines how items should be laid out<br/><br/>Choices: `vertical`, `horizontal`, `grid` |
| <h6 id="switch_gridTemplate">gridTemplate<a class="headerlink" href="#switch_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
=== "switch"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="switch_values">values<a class="headerlink" href="#switch_values" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>\{<br/>&nbsp;"Value 1": 1,<br/>&nbsp;"Value 2": 2<br/>}</code> | `Array` of possible values to switch between : `[1,2,3]`<br/><br/>`Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept |
| <h6 id="switch_mode">mode<a class="headerlink" href="#switch_mode" title="Permanent link">#</a></h6> | `string` | <code>"tap"</code> | Interraction mode:<br/>- `tap`: activates when the pointer is down but prevents further scrolling<br/>- `slide`: same as `tap` but allows sliding between values<br/>- `click`: activates upon click only and allows further scrolling<br/><br/>Choices: `tap`, `slide`, `click` |
??? api "<div id="dropdown">dropdown<a class="headerlink" href="#dropdown" title="Permanent link">#</a></div>"
Native dropdown menu.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="dropdown_label">label<a class="headerlink" href="#dropdown_label" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Displayed text (defaults to current value). Keywords `%key` and `%value` will be replaced by the widget's selected key/value. |
| <h6 id="dropdown_icon">icon<a class="headerlink" href="#dropdown_icon" title="Permanent link">#</a></h6> | `boolean` | <code>"true"</code> | Set to `false` to hide the dropdown icon |
| <h6 id="dropdown_align">align<a class="headerlink" href="#dropdown_align" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `left` or `right` to change text alignment (otherwise center)<br/><br/>Choices: `center`, `left`, `right` |
=== "dropdown"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="dropdown_values">values<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#dropdown_values" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>\{<br/>&nbsp;"Value 1": 1,<br/>&nbsp;"Value 2": 2<br/>}</code> | `Array` of possible values to switch between : `[1,2,3]`<br/><br/>`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept |
??? api "<div id="menu">menu<a class="headerlink" href="#menu" title="Permanent link">#</a></div>"
Drag and drop menu with a circular or grid layout.
=== "geometry"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="menu_size">size<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#menu_size" title="Permanent link">#</a></h6> | `number`&vert;<br/>`array` | <code>200</code> | - If `layout` is `circular`: diameter (in px)<br/>- Else: square size or `[width, height]` array |
| <h6 id="menu_ignoreTabs">ignoreTabs<a class="headerlink" href="#menu_ignoreTabs" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to allow the menu overflowing its tab ancestors. |
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="menu_label">label<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#menu_label" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Displayed text (defaults to current value). Keywords `%key` and `%value` will be replaced by the widget's selected key/value. |
| <h6 id="menu_icon">icon<a class="headerlink" href="#menu_icon" title="Permanent link">#</a></h6> | `boolean` | <code>"true"</code> | Set to `false` to hide the dropdown icon |
| <h6 id="menu_textAlign">textAlign<a class="headerlink" href="#menu_textAlign" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `left` or `right` to change text alignment (otherwise center)<br/><br/>Choices: `center`, `left`, `right` |
| <h6 id="menu_menuAlignV">menuAlignV<a class="headerlink" href="#menu_menuAlignV" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `top` or `bottom` to change menu alignment (otherwise center)<br/><br/>Choices: `center`, `top`, `bottom` |
| <h6 id="menu_menuAlignH">menuAlignH<a class="headerlink" href="#menu_menuAlignH" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `left` or `right` to change menu alignment (otherwise center)<br/><br/>Choices: `center`, `left`, `right` |
| <h6 id="menu_layout">layout<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#menu_layout" title="Permanent link">#</a></h6> | `string` | <code>"circular"</code> | Defines whether the menu's layout should be rendered in a circle or in a box<br/><br/>Choices: `circular`, `horizontal`, `vertical`, `grid` |
| <h6 id="menu_gridTemplate">gridTemplate<a class="headerlink" href="#menu_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
=== "menu"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="menu_toggle">toggle<a class="headerlink" href="#menu_toggle" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the menu stay opened after mouse/touch release |
| <h6 id="menu_doubleTap">doubleTap<a class="headerlink" href="#menu_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the menu require a double tap to be opened instead of a single tap |
| <h6 id="menu_values">values<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#menu_values" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>[<br/>&nbsp;1,<br/>&nbsp;2,<br/>&nbsp;3<br/>]</code> | `Array` of possible values to switch between : `[1,2,3]`<br/><br/>`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept |
| <h6 id="menu_weights">weights<a class="headerlink" href="#menu_weights" title="Permanent link">#</a></h6> | `array` | <code>""</code> | `Array` of `number` defining the weights of each value in `values`<br/><br/>Ignored when `mode` is `grid` |
??? api "<div id="input">input<a class="headerlink" href="#input" title="Permanent link">#</a></div>"
Text input.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="input_align">align<a class="headerlink" href="#input_align" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `left` or `right` to change text alignment (otherwise center)<br/><br/>Choices: `center`, `left`, `right` |
| <h6 id="input_unit">unit<a class="headerlink" href="#input_unit" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Unit will be appended to the displayed widget's value (it doesn't affect osc messages) |
=== "input"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="input_asYouType">asYouType<a class="headerlink" href="#input_asYouType" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the input send its value at each keystroke |
| <h6 id="input_validation">validation<a class="headerlink" href="#input_validation" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Regular expression: if the submitted value doesn't match the regular expression, it will be reset to the last valid value.<br/><br/>If leading and trailing slashes are omitted, they will be added automatically and the flag will be set to "gm"<br/><br/>Examples:<br/>- `^[0-9]*$` accepts digits only, any number of them<br/>- `/^[a-zs]{0,10}$/i` accept between 0 and 10 alphabetic characters and spaces (case insensitive) |
??? api "<div id="file">file<a class="headerlink" href="#file" title="Permanent link">#</a></div>"
File/Folder selector (server-side).
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="file_align">align<a class="headerlink" href="#file_align" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Set to `left` or `right` to change text alignment (otherwise center)<br/><br/>Choices: `center`, `left`, `right` |
| <h6 id="file_hidePath">hidePath<a class="headerlink" href="#file_hidePath" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to only display the filename (the whole path will still be used as value) |
=== "file"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="file_directory">directory<a class="headerlink" href="#file_directory" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Default browsing directory |
| <h6 id="file_extension">extension<a class="headerlink" href="#file_extension" title="Permanent link">#</a></h6> | `string` | <code>"*"</code> | Only display files with this extension |
| <h6 id="file_allowDir">allowDir<a class="headerlink" href="#file_allowDir" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Allow selecting a folder (by pressing "open" when no file is selected) |
## Containers
??? api "<div id="panel">panel<a class="headerlink" href="#panel" title="Permanent link">#</a></div>"
Widgets or Tabs container.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="panel_colorBg">colorBg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#panel_colorBg" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Panel background color. Set to "auto" to inherit from parent widget. |
| <h6 id="panel_layout">layout<a class="headerlink" href="#panel_layout" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Defines how children are laid out.<br/><br/>Choices: `default`, `vertical`, `horizontal`, `grid` |
| <h6 id="panel_justify">justify<a class="headerlink" href="#panel_justify" title="Permanent link">#</a></h6> | `string` | <code>"start"</code> | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.<br/><br/>Choices: `start`, `end`, `center`, `space-around`, `space-between` |
| <h6 id="panel_gridTemplate">gridTemplate<a class="headerlink" href="#panel_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
| <h6 id="panel_contain">contain<a class="headerlink" href="#panel_contain" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. |
| <h6 id="panel_scroll">scroll<a class="headerlink" href="#panel_scroll" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable scrollbars |
| <h6 id="panel_innerPadding">innerPadding<a class="headerlink" href="#panel_innerPadding" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. |
| <h6 id="panel_verticalTabs">verticalTabs<a class="headerlink" href="#panel_verticalTabs" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display for vertical tab layout |
=== "panel"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="panel_variables">variables<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#panel_variables" title="Permanent link">#</a></h6> | `*` | <code>"@\{parent.variables}"</code> | Defines one or more arbitrary variables that can be inherited by children widgets |
| <h6 id="panel_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#panel_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="panel_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#panel_value" title="Permanent link">#</a></h6> | `integer` | <code>""</code> | Defines currently selected tab in the widget<br/><br/>A tab can be opened only by setting its parent's value |
=== "children"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="panel_widgets">widgets<a class="headerlink" href="#panel_widgets" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. |
| <h6 id="panel_tabs">tabs<a class="headerlink" href="#panel_tabs" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously |
??? api "<div id="modal">modal<a class="headerlink" href="#modal" title="Permanent link">#</a></div>"
A toggle button that opens a popup panel. Cannot contain tabs directly.
=== "geometry"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="modal_popupWidth">popupWidth<a class="headerlink" href="#modal_popupWidth" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"80%"</code> | Modal popup's size |
| <h6 id="modal_popupHeight">popupHeight<a class="headerlink" href="#modal_popupHeight" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"80%"</code> | Modal popup's size |
| <h6 id="modal_popupLeft">popupLeft<a class="headerlink" href="#modal_popupLeft" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"auto"</code> | Modal popup's position |
| <h6 id="modal_popupTop">popupTop<a class="headerlink" href="#modal_popupTop" title="Permanent link">#</a></h6> | `number`&vert;<br/>`percentage` | <code>"auto"</code> | Modal popup's position |
| <h6 id="modal_relative">relative<a class="headerlink" href="#modal_relative" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the modal's position relative to the button's position. |
| <h6 id="modal_ignoreTabs">ignoreTabs<a class="headerlink" href="#modal_ignoreTabs" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to allow the modal overflowing its tab ancestors. |
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="modal_colorBg">colorBg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_colorBg" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Panel background color. Set to "auto" to inherit from parent widget. |
| <h6 id="modal_layout">layout<a class="headerlink" href="#modal_layout" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Defines how children are laid out.<br/><br/>Choices: `default`, `vertical`, `horizontal`, `grid` |
| <h6 id="modal_justify">justify<a class="headerlink" href="#modal_justify" title="Permanent link">#</a></h6> | `string` | <code>"start"</code> | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.<br/><br/>Choices: `start`, `end`, `center`, `space-around`, `space-between` |
| <h6 id="modal_gridTemplate">gridTemplate<a class="headerlink" href="#modal_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
| <h6 id="modal_contain">contain<a class="headerlink" href="#modal_contain" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. |
| <h6 id="modal_scroll">scroll<a class="headerlink" href="#modal_scroll" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable scrollbars |
| <h6 id="modal_innerPadding">innerPadding<a class="headerlink" href="#modal_innerPadding" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. |
| <h6 id="modal_label">label<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_label" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Set to `false` to hide completely<br/>- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)<br/>- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` |
| <h6 id="modal_popupLabel">popupLabel<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_popupLabel" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Alternative label for the modal popup |
| <h6 id="modal_popupPadding">popupPadding<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_popupPadding" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Modal's inner spacing. |
=== "modal"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="modal_variables">variables<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_variables" title="Permanent link">#</a></h6> | `*` | <code>"@\{parent.variables}"</code> | Defines one or more arbitrary variables that can be inherited by children widgets |
| <h6 id="modal_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget |
| <h6 id="modal_doubleTap">doubleTap<a class="headerlink" href="#modal_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the modal require a double tap to open instead of a single tap |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="modal_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#modal_value" title="Permanent link">#</a></h6> | `integer` | <code>""</code> | Defines the modal's state:`0` for closed, `1` for opened |
=== "children"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="modal_widgets">widgets<a class="headerlink" href="#modal_widgets" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. |
| <h6 id="modal_tabs">tabs<a class="headerlink" href="#modal_tabs" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously |
??? api "<div id="clone">clone<a class="headerlink" href="#clone" title="Permanent link">#</a></div>"
Widget replication with overridable properties.
=== "clone"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="clone_widgetId">widgetId<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#clone_widgetId" title="Permanent link">#</a></h6> | `string` | <code>""</code> | `id` of the widget to clone |
| <h6 id="clone_props">props<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#clone_props" title="Permanent link">#</a></h6> | `object` | <code>\{}</code> | Cloned widget's properties to override |
??? api "<div id="matrix">matrix<a class="headerlink" href="#matrix" title="Permanent link">#</a></div>"
Generic matrix for creating rows/columns of widgets.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="matrix_colorBg">colorBg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#matrix_colorBg" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Panel background color. Set to "auto" to inherit from parent widget. |
| <h6 id="matrix_layout">layout<a class="headerlink" href="#matrix_layout" title="Permanent link">#</a></h6> | `string` | <code>"horizontal"</code> | Defines how children are laid out.<br/><br/>Choices: `horizontal`, `vertical`, `grid` |
| <h6 id="matrix_justify">justify<a class="headerlink" href="#matrix_justify" title="Permanent link">#</a></h6> | `string` | <code>"start"</code> | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.<br/><br/>Choices: `start`, `end`, `center`, `space-around`, `space-between` |
| <h6 id="matrix_gridTemplate">gridTemplate<a class="headerlink" href="#matrix_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
| <h6 id="matrix_contain">contain<a class="headerlink" href="#matrix_contain" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. |
| <h6 id="matrix_scroll">scroll<a class="headerlink" href="#matrix_scroll" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable scrollbars |
| <h6 id="matrix_innerPadding">innerPadding<a class="headerlink" href="#matrix_innerPadding" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. |
=== "matrix"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="matrix_variables">variables<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#matrix_variables" title="Permanent link">#</a></h6> | `*` | <code>"@\{parent.variables}"</code> | Defines one or more arbitrary variables that can be inherited by children widgets |
| <h6 id="matrix_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#matrix_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget |
| <h6 id="matrix_widgetType">widgetType<a class="headerlink" href="#matrix_widgetType" title="Permanent link">#</a></h6> | `string` | <code>"button"</code> | Defines the type of the widgets in the matrix |
| <h6 id="matrix_quantity">quantity<a class="headerlink" href="#matrix_quantity" title="Permanent link">#</a></h6> | `number` | <code>4</code> | Defines the number of widgets in the matrix |
| <h6 id="matrix_start">start<a class="headerlink" href="#matrix_start" title="Permanent link">#</a></h6> | `integer` | <code>0</code> | First widget's index |
| <h6 id="matrix_props">props<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#matrix_props" title="Permanent link">#</a></h6> | `object` | <code>\{}</code> | Defines a set of property to override the widgets' defaults.<br/><br/>JS{{}} and #{} blocks in this field are resolved with an extra variable representing each widget's index: `$` (e.g. `#{$}`)<br/><br/>Advanced syntax blocks (@{}, OSC{}, JS{{}} and #{}) are resolved at the matrix' scope (ie @{this.variables} returns the matrix' variables property, not its parent's)<br/><br/>Note: by default, the widgets inherit from the matrix' `id` and osc properties (`id` and `address` are appended with `/$`) |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="matrix_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#matrix_value" title="Permanent link">#</a></h6> | `integer` | <code>""</code> | Defines currently selected tab in the widget<br/><br/>A tab can be opened only by setting its parent's value |
=== "children"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="matrix_widgets">widgets<a class="headerlink" href="#matrix_widgets" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. |
| <h6 id="matrix_tabs">tabs<a class="headerlink" href="#matrix_tabs" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously |
??? api "<div id="keyboard">keyboard<a class="headerlink" href="#keyboard" title="Permanent link">#</a></div>"
Piano keyboard.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="keyboard_colorWhite">colorWhite<a class="headerlink" href="#keyboard_colorWhite" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | White keys color. |
| <h6 id="keyboard_colorBlack">colorBlack<a class="headerlink" href="#keyboard_colorBlack" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Black keys color. |
=== "keyboard"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="keyboard_keys">keys<a class="headerlink" href="#keyboard_keys" title="Permanent link">#</a></h6> | `number` | <code>25</code> | Defines the number keys |
| <h6 id="keyboard_start">start<a class="headerlink" href="#keyboard_start" title="Permanent link">#</a></h6> | `number` | <code>48</code> | MIDI note number to start with (default is C4)<br/><br/>Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]` |
| <h6 id="keyboard_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable traversing gestures |
| <h6 id="keyboard_on">on<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_on" title="Permanent link">#</a></h6> | `*` | <code>1</code> | Set to `null` to send send no argument in the osc message |
| <h6 id="keyboard_off">off<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_off" title="Permanent link">#</a></h6> | `*` | <code>0</code> | Set to `null` to send send no argument in the osc message |
| <h6 id="keyboard_velocity">velocity<a class="headerlink" href="#keyboard_velocity" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to map the touch coordinates between `off` (top) and `on` (bottom). Requires `on` and `off` to be numbers |
| <h6 id="keyboard_mode">mode<a class="headerlink" href="#keyboard_mode" title="Permanent link">#</a></h6> | `string` | <code>"push"</code> | Interraction mode:<br/>- `push` (press & release)<br/>- `toggle` (on/off switches)<br/>- `tap` (no release)<br/><br/>Choices: `push`, `toggle`, `tap` |
??? api "<div id="patchbay">patchbay<a class="headerlink" href="#patchbay" title="Permanent link">#</a></div>"
Connect inputs to outputs.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="patchbay_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#patchbay_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | The inputs/ouputs width can be adjusted by using the `.nodes` selector:<br/><br/>`.nodes { width: 25% }` |
=== "patchbay"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="patchbay_inputs">inputs<a class="headerlink" href="#patchbay_inputs" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>[<br/>&nbsp;"input_1",<br/>&nbsp;"input_2"<br/>]</code> | - `Array` of input names : `['input_1', 'input_2']`<br/>- `Object` of `"label_1": "input_1"` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept<br/><br/><br/><br/>Patchbay inputs can be connected to one or more outputs and will send messages of the following form when they are connected/disconnected: <br/><br/>`/patchbay_address input_x output_x output_y etc`<br/><br/>If no output is connected to the input, the message will be `/patchbay_address input_x`<br/><br/>The inputs values can be consumed with the property inheritance syntax: `@{patchbay_id/input_1}` returns an array of output names connected to `input_1` |
| <h6 id="patchbay_outputs">outputs<a class="headerlink" href="#patchbay_outputs" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>[<br/>&nbsp;"output_1",<br/>&nbsp;"output_2"<br/>]</code> | List of output values the inputs can connect to (see `inputs`). |
??? api "<div id="root">root<a class="headerlink" href="#root" title="Permanent link">#</a></div>"
Main (unique) container
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="root_colorBg">colorBg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#root_colorBg" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Panel background color. Set to "auto" to inherit from parent widget. |
| <h6 id="root_layout">layout<a class="headerlink" href="#root_layout" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Defines how children are laid out.<br/><br/>Choices: `default`, `vertical`, `horizontal`, `grid` |
| <h6 id="root_justify">justify<a class="headerlink" href="#root_justify" title="Permanent link">#</a></h6> | `string` | <code>"start"</code> | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.<br/><br/>Choices: `start`, `end`, `center`, `space-around`, `space-between` |
| <h6 id="root_gridTemplate">gridTemplate<a class="headerlink" href="#root_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
| <h6 id="root_contain">contain<a class="headerlink" href="#root_contain" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. |
| <h6 id="root_scroll">scroll<a class="headerlink" href="#root_scroll" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable scrollbars |
| <h6 id="root_innerPadding">innerPadding<a class="headerlink" href="#root_innerPadding" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. |
| <h6 id="root_verticalTabs">verticalTabs<a class="headerlink" href="#root_verticalTabs" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display for vertical tab layout |
=== "root"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="root_variables">variables<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#root_variables" title="Permanent link">#</a></h6> | `*` | <code>"@\{parent.variables}"</code> | Defines one or more arbitrary variables that can be inherited by children widgets |
| <h6 id="root_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#root_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="root_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#root_value" title="Permanent link">#</a></h6> | `integer` | <code>""</code> | Defines currently selected tab in the widget<br/><br/>A tab can be opened only by setting its parent's value |
=== "children"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="root_widgets">widgets<a class="headerlink" href="#root_widgets" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. |
| <h6 id="root_tabs">tabs<a class="headerlink" href="#root_tabs" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously |
??? api "<div id="tab">tab<a class="headerlink" href="#tab" title="Permanent link">#</a></div>"
Tabbed panel widget
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="tab_colorBg">colorBg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#tab_colorBg" title="Permanent link">#</a></h6> | `string` | <code>"auto"</code> | Panel background color. Set to "auto" to inherit from parent widget. |
| <h6 id="tab_layout">layout<a class="headerlink" href="#tab_layout" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Defines how children are laid out.<br/><br/>Choices: `default`, `vertical`, `horizontal`, `grid` |
| <h6 id="tab_justify">justify<a class="headerlink" href="#tab_justify" title="Permanent link">#</a></h6> | `string` | <code>"start"</code> | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.<br/><br/>Choices: `start`, `end`, `center`, `space-around`, `space-between` |
| <h6 id="tab_gridTemplate">gridTemplate<a class="headerlink" href="#tab_gridTemplate" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number` | <code>""</code> | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. |
| <h6 id="tab_contain">contain<a class="headerlink" href="#tab_contain" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. |
| <h6 id="tab_scroll">scroll<a class="headerlink" href="#tab_scroll" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable scrollbars |
| <h6 id="tab_innerPadding">innerPadding<a class="headerlink" href="#tab_innerPadding" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. |
| <h6 id="tab_verticalTabs">verticalTabs<a class="headerlink" href="#tab_verticalTabs" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display for vertical tab layout |
| <h6 id="tab_label">label<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#tab_label" title="Permanent link">#</a></h6> | `string`&vert;<br/>`boolean` | <code>"auto"</code> | Set to `false` to hide completely<br/>- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)<br/>- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` |
=== "tab"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="tab_variables">variables<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#tab_variables" title="Permanent link">#</a></h6> | `*` | <code>"@\{parent.variables}"</code> | Defines one or more arbitrary variables that can be inherited by children widgets |
| <h6 id="tab_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#tab_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="tab_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#tab_value" title="Permanent link">#</a></h6> | `integer` | <code>""</code> | Defines currently selected tab in the widget<br/><br/>A tab can be opened only by setting its parent's value |
=== "children"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="tab_widgets">widgets<a class="headerlink" href="#tab_widgets" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. |
| <h6 id="tab_tabs">tabs<a class="headerlink" href="#tab_tabs" title="Permanent link">#</a></h6> | `array` | <code>[]</code> | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously |
## Frames
??? api "<div id="frame">frame<a class="headerlink" href="#frame" title="Permanent link">#</a></div>"
Embed a page in a frame (local network only).
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="frame_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#frame_value" title="Permanent link">#</a></h6> | `string` | <code>""</code> | External web page URL. |
??? api "<div id="svg">svg<a class="headerlink" href="#svg" title="Permanent link">#</a></div>"
Svg parser.
=== "svg"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="svg_svg">svg<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#svg_svg" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Svg xml definition (will be wrapped in a `< svg />` element) |
??? api "<div id="html">html<a class="headerlink" href="#html" title="Permanent link">#</a></div>"
Simple HTML parser.
??? api "<div id="image">image<a class="headerlink" href="#image" title="Permanent link">#</a></div>"
Load a image (url or base64-encoded).
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="image_size">size<a class="headerlink" href="#image_size" title="Permanent link">#</a></h6> | `string` | <code>"cover"</code> | CSS background-size |
| <h6 id="image_position">position<a class="headerlink" href="#image_position" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | CSS background-position |
| <h6 id="image_repeat">repeat<a class="headerlink" href="#image_repeat" title="Permanent link">#</a></h6> | `string` | <code>"no-repeat"</code> | CSS background-repeat |
=== "image"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="image_cache">cache<a class="headerlink" href="#image_cache" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to false to disable image caching (forces file reload when updating or editing the widget).<br/><br/>When true, sending `reload` to the widget reloads its image without changing its value |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="image_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#image_value" title="Permanent link">#</a></h6> | `string` | <code>""</code> | - File `url` or `path` (relative to the session file location by default, falling back to absolute path)<br/>- Base64 encoded image : `data:image/...` |
## Graphs
??? api "<div id="plot">plot<a class="headerlink" href="#plot" title="Permanent link">#</a></div>"
XY coordinates plot.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="plot_dots">dots<a class="headerlink" href="#plot_dots" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Draw dots on the line |
| <h6 id="plot_bars">bars<a class="headerlink" href="#plot_bars" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing) |
| <h6 id="plot_pips">pips<a class="headerlink" href="#plot_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the scale |
=== "plot"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="plot_filters">filters<a class="headerlink" href="#plot_filters" title="Permanent link">#</a></h6> | `array` | <code>""</code> | Each item must be an object with the following properties<br/>- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")<br/>- `freq`: number (filter's resonant frequency, default: 1000)<br/>- `q`: number (Q factor, default: 1)<br/>- `gain`: number (default: 0)<br/>- `on`: boolean (default: true)<br/><br/>See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode |
| <h6 id="plot_pips">pips<a class="headerlink" href="#plot_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to false to hide the scale |
| <h6 id="plot_rangeX">rangeX<a class="headerlink" href="#plot_rangeX" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 20,<br/>&nbsp;"max": 22000<br/>}</code> | Defines the min and max values for the x axis (in Hz, logarithmic scale) |
| <h6 id="plot_rangeY">rangeY<a class="headerlink" href="#plot_rangeY" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": -6,<br/>&nbsp;"max": 6<br/>}</code> | Defines the min and max values for the y axis (in dB) |
| <h6 id="plot_origin">origin<a class="headerlink" href="#plot_origin" title="Permanent link">#</a></h6> | `number`&vert;<br/>`boolean` | <code>"auto"</code> | Defines the y axis origin. Set to `false` to disable it |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="plot_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#plot_value" title="Permanent link">#</a></h6> | `array`&vert;<br/>`string` | <code>""</code> | - `Array` of `y` values<br/>- `Array` of `[x, y]` `array` values<br/>- `String` `array`<br/>- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points' coordinates |
??? api "<div id="eq">eq<a class="headerlink" href="#eq" title="Permanent link">#</a></div>"
Draws logarithmic frequency response from an array of filter objects.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="eq_dots">dots<a class="headerlink" href="#eq_dots" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Draw dots on the line |
| <h6 id="eq_bars">bars<a class="headerlink" href="#eq_bars" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing) |
| <h6 id="eq_pips">pips<a class="headerlink" href="#eq_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the scale |
=== "eq"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="eq_filters">filters<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#eq_filters" title="Permanent link">#</a></h6> | `array` | <code>""</code> | Each item must be an object with the following properties<br/>- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")<br/>- `freq`: number (filter's resonant frequency, default: 1000)<br/>- `q`: number (Q factor, default: 1)<br/>- `gain`: number (default: 0)<br/>- `on`: boolean (default: true)<br/><br/>See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode |
| <h6 id="eq_pips">pips<a class="headerlink" href="#eq_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to false to hide the scale |
| <h6 id="eq_rangeX">rangeX<a class="headerlink" href="#eq_rangeX" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 20,<br/>&nbsp;"max": 22000<br/>}</code> | Defines the min and max values for the x axis (in Hz, logarithmic scale) |
| <h6 id="eq_rangeY">rangeY<a class="headerlink" href="#eq_rangeY" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": -6,<br/>&nbsp;"max": 6<br/>}</code> | Defines the min and max values for the y axis (in dB) |
| <h6 id="eq_origin">origin<a class="headerlink" href="#eq_origin" title="Permanent link">#</a></h6> | `number`&vert;<br/>`boolean` | <code>"auto"</code> | Defines the y axis origin. Set to `false` to disable it |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="eq_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#eq_value" title="Permanent link">#</a></h6> | `array`&vert;<br/>`string` | <code>""</code> | - `Array` of `y` values<br/>- `Array` of `[x, y]` `array` values<br/>- `String` `array`<br/>- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points' coordinates |
??? api "<div id="visualizer">visualizer<a class="headerlink" href="#visualizer" title="Permanent link">#</a></div>"
Display its value over time.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="visualizer_dots">dots<a class="headerlink" href="#visualizer_dots" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Draw dots on the line |
| <h6 id="visualizer_bars">bars<a class="headerlink" href="#visualizer_bars" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing) |
| <h6 id="visualizer_pips">pips<a class="headerlink" href="#visualizer_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the scale |
=== "visualizer"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="visualizer_filters">filters<a class="headerlink" href="#visualizer_filters" title="Permanent link">#</a></h6> | `array` | <code>""</code> | Each item must be an object with the following properties<br/>- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")<br/>- `freq`: number (filter's resonant frequency, default: 1000)<br/>- `q`: number (Q factor, default: 1)<br/>- `gain`: number (default: 0)<br/>- `on`: boolean (default: true)<br/><br/>See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode |
| <h6 id="visualizer_pips">pips<a class="headerlink" href="#visualizer_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to false to hide the scale |
| <h6 id="visualizer_rangeX">rangeX<a class="headerlink" href="#visualizer_rangeX" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 20,<br/>&nbsp;"max": 22000<br/>}</code> | Defines the min and max values for the x axis (in Hz, logarithmic scale) |
| <h6 id="visualizer_rangeY">rangeY<a class="headerlink" href="#visualizer_rangeY" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the min and max values for the y axis |
| <h6 id="visualizer_origin">origin<a class="headerlink" href="#visualizer_origin" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Defines the y axis origin. Set to `false` to disable it |
| <h6 id="visualizer_duration">duration<a class="headerlink" href="#visualizer_duration" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines visualization duration in seconds |
| <h6 id="visualizer_framerate">framerate<a class="headerlink" href="#visualizer_framerate" title="Permanent link">#</a></h6> | `number` | <code>30</code> | Defines visualization framerate |
| <h6 id="visualizer_logScaleY">logScaleY<a class="headerlink" href="#visualizer_logScaleY" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm's base. |
| <h6 id="visualizer_freeze">freeze<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#visualizer_freeze" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to freeze current view and ignore incoming values |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="visualizer_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#visualizer_value" title="Permanent link">#</a></h6> | `array`&vert;<br/>`string` | <code>""</code> | - `Array` of `y` values<br/>- `Array` of `[x, y]` `array` values<br/>- `String` `array`<br/>- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points' coordinates |
## Indicators
??? api "<div id="led">led<a class="headerlink" href="#led" title="Permanent link">#</a></div>"
Intensity display.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="led_borderRadius">borderRadius<a class="headerlink" href="#led_borderRadius" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Css border-radius property. |
=== "led"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="led_mode">mode<a class="headerlink" href="#led_mode" title="Permanent link">#</a></h6> | `string` | <code>"intensity"</code> | Defines how value is interpreted (see `value`)<br/><br/>Choices: `intensity`, `color` |
| <h6 id="led_range">range<a class="headerlink" href="#led_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Value range |
| <h6 id="led_alphaRange">alphaRange<a class="headerlink" href="#led_alphaRange" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Alpha range (if `mode` is `color`) |
| <h6 id="led_logScale">logScale<a class="headerlink" href="#led_logScale" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | If `mode` is `intensity`, set to `true` to use logarithmic scale. |
=== "value"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="led_value">value<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#led_value" title="Permanent link">#</a></h6> | `number`&vert;<br/>`array`&vert;<br/>`string` | <code>""</code> | If `mode` is `intensity`:<br/>- `Number`: `intensity` between `range.min` and `range.max`<br/><br/>If `mode` is `color`:<br/>- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)<br/>- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)<br/>- `String`: CSS color |
??? api "<div id="text">text<a class="headerlink" href="#text" title="Permanent link">#</a></div>"
Display text.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="text_vertical">vertical<a class="headerlink" href="#text_vertical" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display the text vertically |
| <h6 id="text_wrap">wrap<a class="headerlink" href="#text_wrap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to wrap long lines automatically. |
| <h6 id="text_align">align<a class="headerlink" href="#text_align" title="Permanent link">#</a></h6> | `string` | <code>"center"</code> | Css text-align property.<br/><br/>Choices: `center`, `left`, `right` |
## Pads
??? api "<div id="xy">xy<a class="headerlink" href="#xy" title="Permanent link">#</a></div>"
Two-dimensional slider.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="xy_pointSize">pointSize<a class="headerlink" href="#xy_pointSize" title="Permanent link">#</a></h6> | `integer` | <code>20</code> | Defines the points' size |
| <h6 id="xy_ephemeral">ephemeral<a class="headerlink" href="#xy_ephemeral" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the point will be drawn only while touched. |
| <h6 id="xy_pips">pips<a class="headerlink" href="#xy_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the scale |
=== "xy"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="xy_snap">snap<a class="headerlink" href="#xy_snap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | By default, the points are dragged from their initial position.<br/><br/>If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates |
| <h6 id="xy_spring">spring<a class="headerlink" href="#xy_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its default value when released |
| <h6 id="xy_rangeX">rangeX<a class="headerlink" href="#xy_rangeX" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the min and max values for the x axis |
| <h6 id="xy_rangeY">rangeY<a class="headerlink" href="#xy_rangeY" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the min and max values for the y axis |
| <h6 id="xy_logScaleX">logScaleX<a class="headerlink" href="#xy_logScaleX" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. |
| <h6 id="xy_logScaleY">logScaleY<a class="headerlink" href="#xy_logScaleY" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. |
| <h6 id="xy_doubleTap">doubleTap<a class="headerlink" href="#xy_doubleTap" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`string` | <code>false</code> | Set to `true` to make the fader reset to its default value when receiving a double tap.<br/><br/>Can also be an osc address, which case the widget will just send an osc message: `/<doubleTap> <preArgs>` |
| <h6 id="xy_sensitivity">sensitivity<a class="headerlink" href="#xy_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the pad's sensitivity when `snap` is `false` |
??? api "<div id="rgb">rgb<a class="headerlink" href="#rgb" title="Permanent link">#</a></div>"
Color picker with optional alpha slider.
=== "rgb"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="rgb_snap">snap<a class="headerlink" href="#rgb_snap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | By default, the points are dragged from their initial position.<br/><br/>If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates |
| <h6 id="rgb_spring">spring<a class="headerlink" href="#rgb_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its default value when released |
| <h6 id="rgb_range">range<a class="headerlink" href="#rgb_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 255<br/>}</code> | Defines the widget's output scale. |
| <h6 id="rgb_alpha">alpha<a class="headerlink" href="#rgb_alpha" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to enable alpha channel |
| <h6 id="rgb_rangeAlpha">rangeAlpha<a class="headerlink" href="#rgb_rangeAlpha" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the widget's output scale for the alpha channel. |
??? api "<div id="multixy">multixy<a class="headerlink" href="#multixy" title="Permanent link">#</a></div>"
Multi-point XY pad.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="multixy_pointSize">pointSize<a class="headerlink" href="#multixy_pointSize" title="Permanent link">#</a></h6> | `integer` | <code>20</code> | Defines the points' size |
| <h6 id="multixy_ephemeral">ephemeral<a class="headerlink" href="#multixy_ephemeral" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the points will be drawn only chile touched. |
| <h6 id="multixy_pips">pips<a class="headerlink" href="#multixy_pips" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to hide the scale |
=== "multixy"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="multixy_points">points<a class="headerlink" href="#multixy_points" title="Permanent link">#</a></h6> | `integer`&vert;<br/>`array` | <code>2</code> | Defines the number of points on the pad<br/><br/>Can be an array of strings that will be used as labels for the points (ex: `['A', 'B']`) |
| <h6 id="multixy_snap">snap<a class="headerlink" href="#multixy_snap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | By default, the points are dragged from their initial position.<br/><br/>If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates |
| <h6 id="multixy_spring">spring<a class="headerlink" href="#multixy_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its default value when released |
| <h6 id="multixy_rangeX">rangeX<a class="headerlink" href="#multixy_rangeX" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the min and max values for the x axis |
| <h6 id="multixy_rangeY">rangeY<a class="headerlink" href="#multixy_rangeY" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the min and max values for the y axis |
| <h6 id="multixy_logScaleX">logScaleX<a class="headerlink" href="#multixy_logScaleX" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. |
| <h6 id="multixy_logScaleY">logScaleY<a class="headerlink" href="#multixy_logScaleY" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. |
| <h6 id="multixy_sensitivity">sensitivity<a class="headerlink" href="#multixy_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the pad's sensitivity when `snap` is `false` |
## Sliders
??? api "<div id="fader">fader<a class="headerlink" href="#fader" title="Permanent link">#</a></div>"
Vertical / horizontal slider.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="fader_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#fader_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--alpha-pips`: `alphaPips`<br/>- `--alpha-pips-text`: `alphaPipsText`<br/>- `--knob-size`: `knobSize` |
| <h6 id="fader_design">design<a class="headerlink" href="#fader_design" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Design style<br/><br/>Choices: `default`, `round`, `compact` |
| <h6 id="fader_knobSize">knobSize<a class="headerlink" href="#fader_knobSize" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Fader knob size |
| <h6 id="fader_horizontal">horizontal<a class="headerlink" href="#fader_horizontal" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display the fader horizontally |
| <h6 id="fader_pips">pips<a class="headerlink" href="#fader_pips" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to show range breakpoints (ignored if `design` is `compact`) |
| <h6 id="fader_dashed">dashed<a class="headerlink" href="#fader_dashed" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`array` | <code>false</code> | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` |
| <h6 id="fader_gradient">gradient<a class="headerlink" href="#fader_gradient" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>[]</code> | When set, the meter's gauge will be filled with a linear color gradient<br/>- each item must be a CSS color string.<br/>- as an `object`: each key must be a number between 0 and 1<br/>- each item must be a CSS color string.<br/><br/>Examples: `['blue', 'red']`, {'0': 'blue', '0.9': 'blue', '1': 'red'} |
=== "fader"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="fader_snap">snap<a class="headerlink" href="#fader_snap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | By default, dragging the widget will modify it's value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position |
| <h6 id="fader_spring">spring<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#fader_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its `default` value when released |
| <h6 id="fader_doubleTap">doubleTap<a class="headerlink" href="#fader_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the fader reset to its `default` value when receiving a double tap.<br/><br/>Can also be an osc address, in which case the widget will just send an osc message (`/<doubleTap> <preArgs>`) |
| <h6 id="fader_range">range<a class="headerlink" href="#fader_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the breakpoints of the fader's scale:<br/>- keys can be percentages and/or `min` / `max`<br/>- values can be `number` or `object` if a custom label is needed<br/><br/>Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) |
| <h6 id="fader_logScale">logScale<a class="headerlink" href="#fader_logScale" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. |
| <h6 id="fader_sensitivity">sensitivity<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#fader_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the fader's sensitivity when `snap` is `false` |
| <h6 id="fader_steps">steps<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#fader_steps" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number`&vert;<br/>`array` | <code>""</code> | Restricts the widget's value:<br/>- `auto`: use values defined in `range`<br/>- `number`: define a number of evenly spaced steps<br/>- `array`: use arbitrary values |
| <h6 id="fader_origin">origin<a class="headerlink" href="#fader_origin" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Defines the starting point's value of the fader's gauge |
??? api "<div id="knob">knob<a class="headerlink" href="#knob" title="Permanent link">#</a></div>"
Rotative knob slider.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="knob_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#knob_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--alpha-pips`: `alphaPips`<br/>- `--alpha-pips-text`: `alphaPipsText` |
| <h6 id="knob_design">design<a class="headerlink" href="#knob_design" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Design style<br/><br/>Note: "solid" design uses "colorStroke" for the central knob color.<br/><br/>Choices: `default`, `solid`, `line` |
| <h6 id="knob_pips">pips<a class="headerlink" href="#knob_pips" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to show the scale's breakpoints |
| <h6 id="knob_dashed">dashed<a class="headerlink" href="#knob_dashed" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`array` | <code>false</code> | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` |
| <h6 id="knob_angle">angle<a class="headerlink" href="#knob_angle" title="Permanent link">#</a></h6> | `number` | <code>270</code> | Defines the angle's width of the knob, in degrees |
=== "knob"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="knob_mode">mode<a class="headerlink" href="#knob_mode" title="Permanent link">#</a></h6> | `string` | <code>"vertical"</code> | - `circular`: relative move in circular motion<br/>- `snap`: snap to touch position and move in vertical motion<br/>- `vertical`: relative move in vertical motion<br/><br/>Choices: `vertical`, `circular`, `snap` |
| <h6 id="knob_spring">spring<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#knob_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its `default` value when released |
| <h6 id="knob_doubleTap">doubleTap<a class="headerlink" href="#knob_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the knob reset to its `default` value when receiving a double tap.<br/><br/>Can also be an osc address, in which case the widget will just send an osc message (`/<doubleTap> <preArgs>`) |
| <h6 id="knob_range">range<a class="headerlink" href="#knob_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the breakpoints of the fader's scale:<br/>- keys can be percentages and/or `min` / `max`<br/>- values can be `number` or `object` if a custom label is needed<br/><br/>Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) |
| <h6 id="knob_logScale">logScale<a class="headerlink" href="#knob_logScale" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. |
| <h6 id="knob_sensitivity">sensitivity<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#knob_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the knob's sensitivity when `mode` is not `snap` |
| <h6 id="knob_steps">steps<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#knob_steps" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number`&vert;<br/>`array` | <code>""</code> | Restricts the widget's value:<br/>- `auto`: use values defined in `range`<br/>- `number`: define a number of evenly spaced steps<br/>- `array`: use arbitrary values |
| <h6 id="knob_origin">origin<a class="headerlink" href="#knob_origin" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Defines the starting point's value of the knob's gauge |
??? api "<div id="encoder">encoder<a class="headerlink" href="#encoder" title="Permanent link">#</a></div>"
A knob that sends a relative direction infomation instead of an absolute value.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="encoder_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#encoder_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--alpha-pips`: `alphaPips`<br/>- `--alpha-pips-text`: `alphaPipsText` |
=== "encoder"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="encoder_mode">mode<a class="headerlink" href="#encoder_mode" title="Permanent link">#</a></h6> | `string` | <code>"circular"</code> | - `circular`: relative move in circular motion<br/>- `snap`: snap to touch position and move in vertical motion<br/>- `vertical`: relative move in vertical motion<br/><br/>Choices: `circular`, `snap`, `vertical` |
| <h6 id="encoder_spring">spring<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#encoder_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its `default` value when released |
| <h6 id="encoder_doubleTap">doubleTap<a class="headerlink" href="#encoder_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the fader reset to its `default` value when receiving a double tap.<br/><br/>Can also be an osc address, in which case the widget will just send an osc message (`/<doubleTap> <preArgs>`) |
| <h6 id="encoder_range">range<a class="headerlink" href="#encoder_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the breakpoints of the fader's scale:<br/>- keys can be percentages and/or `min` / `max`<br/>- values can be `number` or `object` if a custom label is needed<br/><br/>Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) |
| <h6 id="encoder_logScale">logScale<a class="headerlink" href="#encoder_logScale" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. |
| <h6 id="encoder_sensitivity">sensitivity<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#encoder_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | When set between 0 and 1, reduces the encoder's verbosity |
| <h6 id="encoder_ticks">ticks<a class="headerlink" href="#encoder_ticks" title="Permanent link">#</a></h6> | `number` | <code>""</code> | Defines the granularity / verbosity of the encoder (number of step for a 360° arc) |
| <h6 id="encoder_back">back<a class="headerlink" href="#encoder_back" title="Permanent link">#</a></h6> | `*` | <code>-1</code> | Defines which value is sent when rotating the encoder anticlockwise |
| <h6 id="encoder_forth">forth<a class="headerlink" href="#encoder_forth" title="Permanent link">#</a></h6> | `*` | <code>1</code> | Defines which value is sent when rotating the encoder clockwise |
| <h6 id="encoder_release">release<a class="headerlink" href="#encoder_release" title="Permanent link">#</a></h6> | `number` | <code>""</code> | Defines which value is sent when releasing the encoder:<br/>- Set to `null` to send send no argument in the osc message<br/>- Can be an `object` if the type needs to be specified |
??? api "<div id="range">range<a class="headerlink" href="#range" title="Permanent link">#</a></div>"
A fader with two heads for setting a range.
=== "style"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="range_css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#range_css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke`<br/>- `--alpha-pips`: `alphaPips`<br/>- `--alpha-pips-text`: `alphaPipsText`<br/>- `--knob-size`: `knobSize` |
| <h6 id="range_design">design<a class="headerlink" href="#range_design" title="Permanent link">#</a></h6> | `string` | <code>"default"</code> | Design style<br/><br/>Choices: `default`, `round`, `compact` |
| <h6 id="range_knobSize">knobSize<a class="headerlink" href="#range_knobSize" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Fader knob size |
| <h6 id="range_horizontal">horizontal<a class="headerlink" href="#range_horizontal" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to display the fader horizontally |
| <h6 id="range_pips">pips<a class="headerlink" href="#range_pips" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to show range breakpoints (ignored if `design` is `compact`) |
| <h6 id="range_dashed">dashed<a class="headerlink" href="#range_dashed" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`array` | <code>false</code> | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` |
| <h6 id="range_gradient">gradient<a class="headerlink" href="#range_gradient" title="Permanent link">#</a></h6> | `array`&vert;<br/>`object` | <code>[]</code> | When set, the meter's gauge will be filled with a linear color gradient<br/>- each item must be a CSS color string.<br/>- as an `object`: each key must be a number between 0 and 1<br/>- each item must be a CSS color string.<br/><br/>Examples: `['blue', 'red']`, {'0': 'blue', '0.9': 'blue', '1': 'red'} |
=== "range"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="range_snap">snap<a class="headerlink" href="#range_snap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | By default, dragging the widget will modify it's value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position |
| <h6 id="range_spring">spring<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#range_spring" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | When set to `true`, the widget will go back to its `default` value when released |
| <h6 id="range_doubleTap">doubleTap<a class="headerlink" href="#range_doubleTap" title="Permanent link">#</a></h6> | `boolean` | <code>false</code> | Set to `true` to make the fader reset to its `default` value when receiving a double tap.<br/><br/>Can also be an osc address, in which case the widget will just send an osc message (`/<doubleTap> <preArgs>`) |
| <h6 id="range_range">range<a class="headerlink" href="#range_range" title="Permanent link">#</a></h6> | `object` | <code>\{<br/>&nbsp;"min": 0,<br/>&nbsp;"max": 1<br/>}</code> | Defines the breakpoints of the fader's scale:<br/>- keys can be percentages and/or `min` / `max`<br/>- values can be `number` or `object` if a custom label is needed<br/><br/>Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) |
| <h6 id="range_logScale">logScale<a class="headerlink" href="#range_logScale" title="Permanent link">#</a></h6> | `boolean`&vert;<br/>`number` | <code>false</code> | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. |
| <h6 id="range_sensitivity">sensitivity<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#range_sensitivity" title="Permanent link">#</a></h6> | `number` | <code>1</code> | Defines the fader's sensitivity when `snap` is `false` |
| <h6 id="range_steps">steps<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#range_steps" title="Permanent link">#</a></h6> | `string`&vert;<br/>`number`&vert;<br/>`array` | <code>""</code> | Restricts the widget's value:<br/>- `auto`: use values defined in `range`<br/>- `number`: define a number of evenly spaced steps<br/>- `array`: use arbitrary values |
## Scripts
??? api "<div id="script">script<a class="headerlink" href="#script" title="Permanent link">#</a></div>"
Evaluates a script each time it receives a value.
=== "script"
| property | type |default | description |
| --- | --- | --- | --- |
| <h6 id="script_event">event<a class="headerlink" href="#script_event" title="Permanent link">#</a></h6> | `string` | <code>"value"</code> | Define which events trigger the script's execution.<br/><br/>Choices: `value`, `keyboard` |
| <h6 id="script_script">script<a class="headerlink" href="#script_script" title="Permanent link">#</a></h6> | `script` | <code>""</code> | Script executed whenever the widget's receives the defined event. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>. |
| <h6 id="script_keyBinding">keyBinding<a class="headerlink" href="#script_keyBinding" title="Permanent link">#</a></h6> | `string`&vert;<br/>`array` | <code>""</code> | Key combo `string` or `array` of strings (see <a href="https://github.com/RobertWHurst/KeyboardJS">KeyboardJS</a> documentation) |
| <h6 id="script_keyRepeat">keyRepeat<a class="headerlink" href="#script_keyRepeat" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to prevent keydown repeats when holding the key combo pressed |
| <h6 id="script_keyType">keyType<a class="headerlink" href="#script_keyType" title="Permanent link">#</a></h6> | `string` | <code>"keydown"</code> | Determines which key event trigger the script's execution<br/><br/>Choices: `keydown`, `keyup`, `both` |
??? api "<div id="variable">variable<a class="headerlink" href="#variable" title="Permanent link">#</a></div>"
Receives / stores a value, to be used in scripts (using the get function) or in properties (using the @{} syntax).

View file

@ -1,37 +1,19 @@
# 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.
The `script` property allows widgets to run [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) code when their value update.
!!! warning "Advanced syntaxes"
Most [advanced syntaxes](../advanced-syntaxes/) should be avoided as much as possible in scripting properties:
!!! info "It's slightly different from the [javascript property syntax ](../advanced-syntaxes/#javascript-js-code)"
- `@{}`: 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
- no `JS{{}}` wrapper, just the code
- `@{}`, `OSC{}`, `JS{{}}` and `#{}` blocks are replaced with their literal value before the script's compilation, therefore **it is recommended to avoid these syntaxes** and use `getProp()` and `get()` instead.
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.
## Event-dependent variables
## Events
Depending on what triggered the script's execution, a few variables are available to help determine the execution conditions.
### `onCreate`
**Event: value**
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
- `id` (`string`): id of the widget that's reponsible for the value update
- `value`: widget's value
- `touch`: see [Touch state](#touch-state)
@ -42,73 +24,7 @@ The following variables are available in this context:
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:
**Event: keyboard** (script widget only)
- `type` (`string`): `keydown` or `keyup`
- `key` (`string`): key name,
@ -118,41 +34,38 @@ The following variables are available in this context:
- `alt` (`boolean`): `true` if alt key is pressed
- `meta` (`boolean`): `true` if meta key is pressed
## Touch state
### `onPreload`
When some widgets are touched or released, a special event can be catched to trigger custom actions.
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.
If the variable `touch` is not `undefined`, this means it holds the widget's current touch state:
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.
- `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 catched if the script contains the word `touch`.
## 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"`.
Besides the variables available in the [javascript property syntax ](./advanced-syntaxes.md#available-variables) and the ones listed above, the following variables and functions are accessible in this context.
----
#### `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.
Returns the value of the first matching widget.
----
@ -160,54 +73,25 @@ Returns the value of the first matching widget. If the returned value is an obje
- `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)
- `sync: false` (prevents widgets from triggering synchronization and scripts)
- `send: false` (prevents widgets from sending osc messages)
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.
- `target` (optional): `"ip:port"` or `"midi:device_name"` string. If omitted, the widget's target will be used.
- `address`: osc address, must start with a `/`
- `args`: values or `{type: "OSC_TYPE_LETTER", value: VALUE}` objects
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object`
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
```
This function ignores the widget's `bypass` property.
----
@ -215,7 +99,7 @@ This function ignores the widget's `bypass` and `ignoreDefaults` properties.
- `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.
Returns the property called `"name"` of the first matching widget.
----
@ -234,13 +118,6 @@ Forces a widget to check if one of its properties has changed and update itself
----
#### `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)
@ -255,13 +132,10 @@ Returns a state object (`id:value`) for matching widget and all their children.
----
#### `stateSet(state, options)`
#### `stateSet(state)`
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`
@ -272,9 +146,9 @@ Global [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/lo
#### `setTimeout(id, callback, delay)` / `setInterval(id, callback, delay)`
These work like almost their native equivalent, with an extra (optional) `id` argument.
These work like 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
- `id` (optional): unique identifier. If a timeout with the same id is already running, it is cleared before the new one is created. If omitted, defaults to `undefined`. One can use `Math.random()` or `Date.now()` to force new id at each execution, though this might cause performance issues. `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
@ -283,16 +157,11 @@ 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`.
Clear timeout with matching `id`.
Reference:
@ -301,34 +170,16 @@ Reference:
----
#### `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.
Returns the scroll state of a container as a `[x, y]` array.
----
@ -341,97 +192,14 @@ 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
#### `toolbar(i1, i2, ...)`
- `iX`: menu entry index
Scroll containers to make widget(s) visible.
Trigger toolbar action at specified index.
----
#### `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"
!!! example "Examples"
- `toolbar(0, 0)` -> Open a new session
- `toolbar(4)` -> Toggle full screen
- `toolbar(3)` -> 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)
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)

View file

@ -3,20 +3,56 @@
!!! 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>
<a href="https://github.com/jean-emmanuel/open-stage-control/releases/latest"> Open Stage Control <span id="osc-version"span></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>
<div id="osc-assets">Loading assets...</div>
</ul>
??? abstract "Changelog"
<div class="highlight"><pre><code id="osc-changelog">Loading changelog...</code></pre></div>
<script>
var oReq = new XMLHttpRequest();
oReq.addEventListener('load', reqListener);
oReq.open('GET', 'https://api.github.com/repos/jean-emmanuel/open-stage-control/releases/latest')
oReq.send()
function text(id, str) {
var el = typeof id === 'string' ? document.getElementById(id) : id
el.textContent = str
}
function reqListener () {
var data = JSON.parse(this.responseText)
var date = new Date(data.published_at)
text('osc-version', data.tag_name + ' (' + date.toLocaleDateString() + ')')
var list = document.createElement('ul')
for (var i in data.assets) {
var item = document.createElement('li'),
link = document.createElement('a')
link.textContent = data.assets[i].name + ' (' + (data.assets[i].size / 1024 / 1024).toFixed(1) + 'M)'
link.href = data.assets[i].browser_download_url
item.appendChild(link)
list.appendChild(item)
}
var assets = document.getElementById('osc-assets')
assets.innerHTML = ''
assets.appendChild(list)
text('osc-changelog', data.body)
}
</script>
<style>
@ -38,28 +74,4 @@ html {
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>

View file

@ -3,19 +3,9 @@ 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()
})
var tab = item.closest('.tabbed-content'),
details = item.closest('details')
if (tab) tab.previousSibling.click()
if (item) {
item.scrollIntoView()
document.documentElement.scrollTop -= 70

View file

@ -102,10 +102,6 @@ details.api summary:before {
display: none!important;
}
details summary div {
display: inline-block;
}
i[title="dynamic"] {
color: var(--osc-accent-color);
}

Binary file not shown.

View file

@ -1,20 +1,14 @@
/*!
* Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
* Font Awesome Free 5.0.8 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/
:root, :host {
--fa-font-solid: normal 900 1em/1 "FontAwesome"; }
@font-face {
font-family: 'FontAwesome';
font-family: FontAwesome;
font-style: normal;
font-weight: 900;
font-display: block;
src: url("./fa-solid-900.woff2") format("woff2"); }
src: url("./fa-solid-900.woff2") format("woff2")}
.fa,
.fas,
.fa-solid {
font-family: 'FontAwesome';
.fas {
font-family: FontAwesome;
font-weight: 900; }

File diff suppressed because one or more lines are too long

View file

@ -2,14 +2,14 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 700;
src: url('./Roboto-Bold.woff2') format('woff2');
src: url('Roboto-Bold.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url('./Roboto-Medium.woff2') format('woff2');
src: url('Roboto-Medium.woff2') format('woff2');
}
@ -17,19 +17,19 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url('./Roboto-Regular.woff2') format('woff2');
src: url('Roboto-Regular.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 100;
src: url('./Roboto-Light.woff2') format('woff2');
src: url('Roboto-Light.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 500;
src: url('./roboto-mono.woff') format('woff');
src: url('roboto-mono.woff') format('woff');
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,11 +1,10 @@
site_name: Open Stage Control
repo_name: open-stage-control
repo_url: https://framagit.org/jean-emmanuel/open-stage-control
repo_url: https://github.com/jean-emmanuel/open-stage-control
edit_uri: tree/master/resources/docs/
copyright: "Copyleft © Jean-Emmanuel Doucet @ <a href='http://ammd.net'>AMMD</a> (<a href='https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE'>GNU/GPLv3</a>)"
copyright: "Copyleft © Jean-Emmanuel Doucet @ <a href='http://ammd.net'>AMMD</a> (<a href='https://github.com/jean-emmanuel/open-stage-control/blob/master/LICENSE'>GNU/GPLv3</a>)"
site_description: "Libre and modular OSC / MIDI controller"
site_dir: '../app/docs/'
latest_release: 1.31.2
theme:
name: 'material'
@ -36,9 +35,6 @@ nav:
- docs/getting-started/server-configuration.md
- docs/getting-started/running-from-sources.md
- docs/getting-started/running-with-node.md
- Tutorials:
- docs/tutorials/first-steps.md
- docs/tutorials/change-property-with-osc.md
- User interface:
- docs/user-interface/launcher.md
- docs/user-interface/client.md
@ -48,8 +44,6 @@ nav:
- docs/widgets/properties-reference.md
- docs/widgets/advanced-syntaxes.md
- docs/widgets/scripting.md
- docs/widgets/fragments.md
- docs/widgets/canvas.md
- MIDI:
- MIDI configuration: docs/midi/midi-configuration.md
- MIDI messages: docs/midi/midi-messages.md
@ -63,7 +57,9 @@ nav:
- Client options: docs/client-options.md
- Remote control: docs/remote-control.md
- Credits: docs/credits.md
- Changelog: docs/changelog.md
- Bug Tracker:
- 'Bug Tracker': 'https://github.com/jean-emmanuel/open-stage-control/issues'
- Community:
- 'Community forums': 'https://openstagecontrol.discourse.group'
@ -91,10 +87,5 @@ markdown_extensions:
custom_checkbox: true
- pymdownx.tilde
- pymdownx.keys
- pymdownx.tabbed:
alternate_style: true
- pymdownx.tabbed
- pymdownx.details
plugins:
- macros

View file

@ -178,6 +178,13 @@
>
Get started
</a>
<div>
<a
href="https://www.patreon.com/openstagecontrol?fan_landing=true"
class="md-button md-button-small patreon-icon"
>
Support on Patreon
</a></div>
</div>
</div>
</div>

98
scripts/build-client.js Normal file
View file

@ -0,0 +1,98 @@
var build = require('./build'),
path = require('path'),
babelify = require('babelify'),
nanohtml = require('nanohtml'),
watch = process.argv.includes('--watch'),
through = require('through'),
minimatch = require('minimatch').Minimatch
var ignores = ['**/*.min.js', '**/jquery.ui.js', 'gyronorm.complete.min.js'],
transformWrapper = function(transform){
return function(file, opts){
if (ignores.some(pattern => minimatch(pattern).match(file))) {
return through()
} else {
return transform(file, opts)
}
}
}
var transforms = [
[transformWrapper(nanohtml)],
[transformWrapper(babelify)]
]
console.warn('\033[36m=> Building compressed client scripts...\033[0m')
transforms.push([transformWrapper(require('uglifyify')), {global: true, safari10: true}])
var bundle = build({
input: '../src/client/index.js',
output: '../app/client/open-stage-control-client.js',
options: {
debug: true,
insertGlobals: false,
noParse: ['**/*.min.js', '**/jquery.ui.js'],
cache: {},
packageCache: {},
},
plugins: watch ? [require('watchify')] : [],
transforms: transforms,
ignore: [
'postcss' // only needed by sanitize-html if <style> is allowed; somehow fails at object spread syntax transpilation
]
})
if (watch) {
var ansiHTML = require('ansi-html'),
WS = require('../node_modules/ws')
function send(msg, data){
var ipc = new WS('ws://127.0.0.1:8080/dev')
ipc.on('error', ()=>{})
ipc.on('open', ()=>{
ipc.send(JSON.stringify([msg, data]))
ipc.close()
})
}
bundle.b.on('update', hotBundle)
bundle.b.on('log', function(msg) {console.warn('\x1b[36m%s\x1b[0m', msg)})
function hotBundle() {
var output = bundle()
output.on('end', (err)=> {
console.log('Build successful reloading...')
send('reload')
})
output.on('error', (err)=> {
console.error(err.stack)
send('errorPopup',
'<div class="error-stack">' +
ansiHTML(
err.stack
.replace(/^ at .*/gm, '') // remove useless stack
.replace(new RegExp(path.resolve(__dirname + '/..'), 'g'),'.') // shorten file path
.trim()
.replace('\n','\n\n') // add 1 new line after 1st line
) +
'</div>'
)
})
}
hotBundle()
} else {
bundle()
}

View file

@ -1,19 +1,16 @@
var sass = require('sass'),
var sass = require('node-sass'),
path = require('path'),
fs = require('fs')
var indir = path.resolve(__dirname + '/../src/scss/'),
outdir= path.resolve(__dirname + '/../app/assets/')
fs.mkdirSync(outdir + '/themes/', {recursive: true})
fs.readdirSync(indir + '/themes/').forEach(file => {
if (file.includes('.scss') && file !== 'default.scss') {
let result = sass.renderSync({
file: indir + '/themes/' + file,
outputStyle: 'compressed',
silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api']
outputStyle: 'compressed'
})
fs.writeFileSync(outdir + '/themes/' + file.split('/').pop().replace('scss', 'css'), result.css)
@ -25,8 +22,7 @@ var result = sass.renderSync({
file: indir + '/index.scss',
outFile: outdir + '/open-stage-control.css',
outputStyle: 'compressed',
sourceMap: true,
silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api']
sourceMap: true
})
fs.writeFileSync(outdir + '/open-stage-control.css', result.css)
@ -37,7 +33,7 @@ if (process.argv.includes('--reload')) {
var WS = require('../node_modules/ws')
var ipc = new WS('ws://127.0.0.1:8080/dev/')
var ipc = new WS('ws://127.0.0.1:8080/dev')
ipc.on('error', ()=>{})
ipc.on('open', ()=>{

16
scripts/build-launcher.js Normal file
View file

@ -0,0 +1,16 @@
var build = require('./build')
build({
input: '../src/launcher/index.js',
output: '../app/launcher/open-stage-control-launcher.js',
options: {
debug: true,
ignoreMissing: false,
detectGlobals: false,
bare: true,
noParse: ['**/mathjs/dist/math.min.js']
},
exclude: [
'electron',
]
})()

21
scripts/build-midi-bin.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# buid python midi addon for linux and windows
cd src/python
pyinstaller midi.py --onefile
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux:python3
mv dist/linux/midi midi-linux-x64
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux:python3-32bit
mv dist/linux/midi midi-linux-ia32
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows:python3
mv dist/windows/midi.exe midi-windows-x64.exe
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows:python3-32bit
mv dist/windows/midi.exe midi-windows-ia32.exe
rm -rf __pycache__ build midi.spec dist

27
scripts/build-server.js Normal file
View file

@ -0,0 +1,27 @@
var build = require('./build'),
babelify = require('babelify')
build({
input: '../src/server/index.js',
output: '../app/server/open-stage-control-server.js',
options: {
commonDir: false,
ignoreMissing: true,
debug: true,
builtins: false,
commondir: false,
insertGlobalVars: {
__filename: true,
__dirname: true,
process: true,
electron: true,
global: true
},
browserField: false,
},
ignore: 'serialport',
exclude: [
'electron',
'./fsevents.node' // osx binary module, to be copied as is
]
})()

View file

@ -1,9 +1,9 @@
import './client-shim.mjs'
import baseClass from '../client/widgets/common/widget.mjs'
import * as widgets from '../client/widgets/index.mjs'
require('./client-shim')
// Here we go
var base = baseClass.defaults(),
var widgets = require('../src/client/widgets'),
baseClass = require('../src/client/widgets/common/widget'),
base = baseClass.defaults(),
doc = ['<!-- This file is generated automatically from the widget class declarations. See scripts/build-widget-reference.js -->']
@ -17,24 +17,24 @@ doc.push(`
`
)
for (let categoryName in base) {
for (var categoryName in base) {
doc.push(`\n
=== "${categoryName}"
=== "${categoryName}"
| property | type |default | description |
| --- | --- | --- | --- |`
| property | type |default | description |
| --- | --- | --- | --- |`
)
let notEmpty = false
var notEmpty = false
for (let propName in base[categoryName]) {
for (var propName in base[categoryName]) {
let prop = base[categoryName][propName],
var prop = base[categoryName][propName],
permalink = propName
if (propName === '_props' || propName[0] === '_') continue
if (propName === '_props' || propName[0] === '_') continue
let help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || '',
var help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || '',
dynamic = baseClass.dynamicProps.includes(propName) ? '<sup><i class="fas fa-bolt" title="dynamic"></i></sup>' : ''
if (prop.choices) {
@ -75,24 +75,24 @@ for (var k in widgets.categories) {
)
for (let categoryName in defaults) {
for (var categoryName in defaults) {
doc.push(`\n
=== "${categoryName == 'class_specific' ? type : categoryName}"
| property | type |default | description |
| --- | --- | --- | --- |`
)
let notEmpty = false
var notEmpty = false
for (let propName in defaults[categoryName]) {
for (var propName in defaults[categoryName]) {
let prop = defaults[categoryName][propName],
var prop = defaults[categoryName][propName],
permalink = type + '_' + propName
if (propName === '_props' || propName[0] === '_' || JSON.stringify(prop) == JSON.stringify((base[categoryName]||{})[propName])) continue
if (propName === '_props' || propName[0] === '_' || JSON.stringify(prop) == JSON.stringify((base[categoryName]||{})[propName])) continue
let help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || '',
var help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || '',
dynamic = widgets.widgets[type].dynamicProps.includes(propName) ? '<sup><i class="fas fa-bolt" title="dynamic"></i></sup>' : ''
if (prop.choices) {

49
scripts/build.js Normal file
View file

@ -0,0 +1,49 @@
var browserify = require('browserify'),
exorcist = require('exorcist'),
licensify = require('licensify'),
fs = require('fs'),
path = require('path')
module.exports = (opt) => {
var {input, output, options, ignore, exclude, transforms, plugins} = opt,
inputPath = path.resolve(__dirname + '/' + input),
outputPath = path.resolve(__dirname + '/' + output),
b
if (!plugins) plugins = []
if (!plugins.includes(licensify)) plugins.push(licensify)
b = browserify(inputPath, options)
if (ignore) b.ignore(ignore)
if (exclude) b.exclude(exclude)
for (var plugin of plugins) {
b.plugin(plugin)
}
if (transforms) {
for (var transform of transforms) {
var [t, opts] = transform
b.transform(t, opts)
}
}
function bundle() {
var output = b.bundle()
var toWrite = output.pipe(exorcist(outputPath + '.map'))
toWrite.pipe(fs.createWriteStream(outputPath))
return output
}
bundle.b = b
return bundle
}

View file

@ -1,12 +1,10 @@
// Dirty browser window shim
import * as DOM from '../client/dom.mjs'
// eslint-disable-next-line no-global-assign
document = {
createElement: x=>({
ownerDocument: document,
addEventListener: ()=>{},
style: {setProperty: ()=>{}},
style: {},
contentWindow: {},
nodeName: '',
childNodes: [],
setAttribute: ()=>{},
@ -14,16 +12,14 @@ document = {
lastChild: {},
toString: ()=>' ',
removeChild: ()=>{},
getPropertyValue: ()=>{},
contentWindow: {
document: {
open: ()=>{},
close: ()=>{},
write: ()=>{},
}
},
}
}),
getElementById: ()=>document.createElement(),
createTextNode: x=>({
nodeValue: '',
nodeName: '',
@ -49,44 +45,41 @@ document = {
appendChild: ()=>{},
addEventListener: ()=>{}
},
location: {search: ''},
location: {},
documentElement: {
appendChild: ()=>{},
removeChild: ()=>{}
}
}
document.documentElement = document.createElement()
// eslint-disable-next-line no-global-assign
window = {
screen: {width: 800, height: 600},
addEventListener: ()=>{},
location: {search: ''},
Image: Function,
location: {},
document: document,
navigator: {
platform:'',
userAgent: ''
},
NodeList: Array,
WebSocket: Object,
localStorage: {
getItem(){return null}
},
sessionStorage: {
}, sessionStorage: {
getItem(){return null},
setItem(){},
},
getComputedStyle: ()=>document.createElement(),
MutationObserver: class MutationObserver{},
ELECTRON_NOGPU: false,
CANVAS_FRAMERATE: 1,
LANG: 'en',
ENV: {id: ''},
IP: '',
DOM
}
if (!global.navigator) {
// defined as getter since node 22
window.navigator = {
platform:'',
userAgent: ''
}
setItem(){},
},
}
Object.assign(global, window)
console.debug = ()=>{}
// Required globals
DOM = require('../src/client/dom')
DOM.get = x=>[{addEventListener:()=>{}}]
DOM.init()
ELECTRON_NOGPU = false
CANVAS_FRAMERATE = 1
LANG = 'en'
ENV = {id: ''}
IP = ''

View file

@ -1,40 +0,0 @@
var ansiHTML = require('ansi-html'),
WS = require('../node_modules/ws'),
path = require('path')
function send(msg, data){
var ipc = new WS('ws://127.0.0.1:8080/dev/')
ipc.on('error', ()=>{})
ipc.on('open', ()=>{
ipc.send(JSON.stringify([msg, data]))
ipc.close()
})
}
module.exports = function watchChangePlugin() {
var reloadClient = false
return {
buildEnd(error) {
if (error) {
var msg = `<div class="error-stack">
${error.message.replace(path.resolve(__dirname + '/..'),'')} at line ${error.loc.line}\n${error.frame}
</div>`
send('errorPopup', msg.trim())
reloadClient = false
} else {
reloadClient = true
}
},
writeBundle() {
if (reloadClient) {
send('reload')
}
}
}
}

View file

@ -1,98 +0,0 @@
var commonjs = require('@rollup/plugin-commonjs'),
nodeResolve = require('@rollup/plugin-node-resolve'),
json = require('@rollup/plugin-json'),
babel = require('@rollup/plugin-babel'),
terser = require('@rollup/plugin-terser'),
copy = require('rollup-plugin-copy'),
license = require('rollup-plugin-license'),
watchChange = require('./client.plugin-watch'),
package = require('../package.json'),
path = require('path'),
watch = process.argv.includes('--watch')
module.exports = {
input: 'src/client/index.mjs',
output: [
{
dir: 'app/client/',
chunkFileNames: `[name].js`,
entryFileNames: `[name].js`,
format: 'es',
sourcemap: true,
sourcemapExcludeSources: true
},
],
treeshake: false,
watch: {
clearScreen: false
},
plugins: [
json(),
nodeResolve({
browser: true
}),
commonjs(),
watch ? {} : babel({
babelHelpers: 'bundled',
babelrc: false,
exclude: [
/node_modules\/core-js/,
/node_modules\/ace-builds/
],
presets: [[
'@babel/preset-env',
{
targets: {
ios: '11',
chrome: '70'
},
useBuiltIns: 'usage',
corejs: 3,
modules:false
}
]]
}),
watch ? {} : terser({
sourceMap: true,
keep_classnames: true,
keep_fnames: true,
output: {
comments: false,
},
}),
{
name: 'remove-node-modules-from-source-map',
enforce: 'post',
transform(code, id) {
if (id.includes('node_modules')) {
return { code, map: { mappings: '' } }
}
}
},
watch ? {} :license({
thirdParty: {
includeSelf: true,
output: 'app/client/LICENSES',
},
}),
watch ? {} : copy({
targets: [
{src: 'resources/images/logo_nobadge.png', dest: 'app/assets/', rename: 'favicon.png'},
{src: 'resources/images/logo.png', dest: 'app/assets/'},
{src: 'resources/images/logo_tray.png', dest: 'app/assets/'},
{src: 'resources/images/logo_tray@x2.png', dest: 'app/assets/'},
{src: 'resources/images/logo_16x16.png', dest: 'app/assets/'},
{src: 'resources/fonts/*', dest: 'app/assets/fonts/'},
{src: 'node_modules/ace-builds/src-min/worker-css.js', dest: 'app/client/ace/'},
{src: 'node_modules/ace-builds/src-min/worker-html.js', dest: 'app/client/ace/'},
{src: 'node_modules/ace-builds/src-min/worker-javascript.js', dest: 'app/client/ace/'},
{src: 'node_modules/ace-builds/src-min/ace.js', dest: 'app/client/ace/'},
{src: 'src/html/client.html', dest: 'app/client/', rename: 'index.html', transform: (contents)=>{
return contents.toString().replace(/\$\{([^\}]+)\}/g, (m, p1)=>{return package[p1]})
}},
]
}),
watchChange()
]
};

56
scripts/copy-assets.js Normal file
View file

@ -0,0 +1,56 @@
var cpr = require('cpr'),
fs = require('fs'),
path = require('path'),
files = [
['../resources/images/logo_nobadge.png', '../app/assets/favicon.png'],
['../resources/images/logo.png', '../app/assets/logo.png'],
['../LICENSE', '../app/LICENSE'],
['../src/python/', '../app/server/python/'],
['../resources/fonts/', '../app/assets/fonts/'],
['../src/html/launcher.html', '../app/launcher/index.html'],
['../node_modules/fsevents/fsevents.node', '../app/server/fsevents.node'],
]
for (var i in files) {
cpr(...files[i].map(f => path.resolve(__dirname + '/' + f)), {
overwrite: true
})
}
var packageJson = require('../package.json'),
appJson = {},
copiedProps = [
"name",
"productName",
"description",
"version",
"author",
"repository",
"homepage",
"license",
"yargs",
"engines"
]
for (var k of copiedProps) {
appJson[k] = packageJson[k]
}
appJson.main = appJson.bin = "index.js"
appJson.scripts = {
"start": "electron index.js",
"start-node": "node index.js"
}
appJson.optionalDependencies = {
electron: packageJson.optionalDependencies.electron
}
fs.writeFileSync(path.resolve(__dirname + '/../app/package.json'), JSON.stringify(appJson, null, ' '))
var clientHtml = fs.readFileSync(path.resolve(__dirname + '/../src/html/client.html'))
.toString()
.replace(/\$\{version\}/g, appJson.version)
fs.writeFileSync(path.resolve(__dirname + '/../app/client/index.html'), clientHtml)

View file

@ -1,45 +0,0 @@
#!/bin/bash
# clean
rm -rf dist app
# buid
npm run build
npm run build-docs
npm run package -- --all
PLATFORM=darwin ARCH=arm64 npm run package
npm run package-node
# get current version
VERSION=$(sed -nE 's/^\s*"version":\ "(.*?)",$/\1/p' package.json)
cd dist
# fetch & copy midi bins
mkdir tmp && cd tmp
cp ../../bin/osc-midi-* ./
chmod +x *
touch .expect-midi-bin
cp {.expect-midi-bin,osc-midi-linux} ../open-stage-control-linux-x64/resources/app/server/python/
cp {.expect-midi-bin,osc-midi-windows.exe} ../open-stage-control-win32-x64/resources/app/server/python/
cp {.expect-midi-bin,osc-midi-osx} ../open-stage-control-darwin-x64/open-stage-control.app/Contents/Resources/app/server/python/
cp {.expect-midi-bin,osc-midi-osx} ../open-stage-control-darwin-arm64/open-stage-control.app/Contents/Resources/app/server/python/
cd ..
rm -rf tmp
# make packages
mkdir packages
npm run deb64
npm run rpm64
mv *.{deb,rpm} packages/
mv open-stage-control-node open-stage-control_${VERSION}_node
mv open-stage-control-win32-x64 open-stage-control_${VERSION}_win32-x64
mv open-stage-control-linux-x64 open-stage-control_${VERSION}_linux-x64
echo "Creating zip packages..."
zip -q -r --symlinks packages/open-stage-control_${VERSION}_osx-x64.zip open-stage-control-darwin-x64/open-stage-control.app
zip -q -r --symlinks packages/open-stage-control_${VERSION}_osx-arm64.zip open-stage-control-darwin-arm64/open-stage-control.app
zip -q -r packages/open-stage-control_${VERSION}_node.zip open-stage-control_${VERSION}_node
zip -q -r packages/open-stage-control_${VERSION}_win32-x64.zip open-stage-control_${VERSION}_win32-x64
zip -q -r packages/open-stage-control_${VERSION}_linux-x64.zip open-stage-control_${VERSION}_linux-x64

View file

@ -1,25 +0,0 @@
var commonjs = require('@rollup/plugin-commonjs'),
nodeResolve = require('@rollup/plugin-node-resolve'),
json = require('@rollup/plugin-json')
module.exports = {
input: 'src/docs/widgets-reference.mjs',
output: [
{
file: 'src/docs/widgets-reference.js',
inlineDynamicImports: true,
format: 'commonjs',
sourcemap: false,
strict: false,
indent: false,
name: '_'
},
],
plugins: [
json(),
nodeResolve({
browser: true
}),
commonjs()
]
};

View file

@ -1,48 +0,0 @@
var commonjs = require('@rollup/plugin-commonjs'),
nodeResolve = require('@rollup/plugin-node-resolve'),
json = require('@rollup/plugin-json'),
babel = require('@rollup/plugin-babel'),
terser = require('@rollup/plugin-terser'),
copy = require('rollup-plugin-copy'),
license = require('rollup-plugin-license'),
package = require('../package.json'),
path = require('path')
module.exports = {
input: 'src/launcher/index.mjs',
output: [
{
dir: 'app/launcher/',
chunkFileNames: `[name].js`,
format: 'commonjs',
sourcemap: true,
sourcemapExcludeSources: true,
strict: false
},
],
treeshake: false,
external: ['electron'],
watch: {
clearScreen: false
},
plugins: [
json(),
commonjs({
ignoreGlobal: true,
ignoreDynamicRequires: true
}),
nodeResolve(),
terser(),
license({
thirdParty: {
includeSelf: true,
output: 'app/launcher/LICENSES',
},
}),
copy({
targets: [
{src: 'src/html/launcher.html', dest: 'app/launcher/', rename: 'index.html'},
]
})
]
};

View file

@ -1,4 +1,8 @@
var cpr = require('cpr'),
var browserify = require('browserify'),
exorcist = require('exorcist'),
licensify = require('licensify'),
fs = require('fs'),
cpr = require('cpr'),
path = require('path'),
files = ['../app', '../dist/open-stage-control-node']

View file

@ -1,4 +1,4 @@
const packager = require('@electron/packager'),
const packager = require('electron-packager'),
path = require('path'),
appData = require('../app/package.json'),
safeFFMPEG = require('electron-packager-plugin-non-proprietary-codecs-ffmpeg').default,
@ -12,7 +12,7 @@ packager({
name: appData.name,
platform: all ? ['linux', 'win32', 'darwin'] : process.env.PLATFORM,
arch: process.env.ARCH || 'x64',
electronVersion: process.env.ELECTRON_VERSION || require('../package.json').optionalDependencies.electron,
electronVersion: process.env.ARCH === 'armv7l' ? '1.7.11' : require('../package.json').optionalDependencies.electron,
overwrite: true,
out: path.resolve(__dirname + '/../dist'),
icon: path.resolve(__dirname + '/../resources/images/logo'),

View file

@ -1,65 +0,0 @@
var commonjs = require('@rollup/plugin-commonjs'),
nodeResolve = require('@rollup/plugin-node-resolve'),
json = require('@rollup/plugin-json'),
babel = require('@rollup/plugin-babel'),
terser = require('@rollup/plugin-terser'),
copy = require('rollup-plugin-copy'),
license = require('rollup-plugin-license'),
package = require('../package.json'),
path = require('path')
module.exports = {
input: {
'node/index': 'src/server/node/index.mjs',
'electron/index': 'src/server/electron/index.mjs'
},
output: [
{
dir: 'app/server/',
chunkFileNames: `[name].js`,
format: 'commonjs',
sourcemap: true,
sourcemapExcludeSources: true,
strict: false
},
],
treeshake: false,
external: ['electron', '@serialport'],
watch: {
clearScreen: false
},
plugins: [
json(),
commonjs({
ignoreGlobal: true,
ignoreDynamicRequires: true
}),
nodeResolve({
preferBuiltins: true
}),
license({
thirdParty: {
includeSelf: true,
output: 'app/server/LICENSES',
},
}),
terser({
sourceMap: true,
keep_classnames: true,
keep_fnames: true,
output: {
comments: false,
},
}),
copy({
targets: [
{src: 'src/index.js', dest: 'app/'},
{src: 'src/server/index.js', dest: 'app/server/'},
{src: 'src/server/python/*.py', dest: 'app/server/python/'},
{src: 'node_modules/fsevents/fsevents.node', dest: 'app/server/'},
{src: 'LICENSE', dest: 'app/'},
{src: 'package.json', dest: 'app/'},
]
})
]
};

59
src/client/backup.js Normal file
View file

@ -0,0 +1,59 @@
var cache = require('./managers/cache'),
localBackup = cache.get('backup', false)
module.exports = {
exists: localBackup !== null,
save: ()=>{
var session = require('./managers/session/'),
state = require('./managers/state'),
editor = require('./editor/')
if (session.session) {
cache.set('backup', {
session: session.session.data,
sessionPath: session.sessionPath,
state: state.get(),
history: editor.history,
historyState: editor.historyState,
editorEnabled: editor.enabled
}, false)
}
},
load: ()=>{
var session = require('./managers/session/'),
state = require('./managers/state'),
editor = require('./editor/'),
ipc = require('./ipc/')
if (localBackup) {
var data = localBackup
cache.remove('backup', false)
session.load(data.session, ()=>{
state.set(data.state, false)
editor.clearHistory()
editor.history = data.history
editor.historyState = data.historyState
if (data.editorEnabled) editor.enable()
ipc.send('sessionSetPath', {path: data.sessionPath})
session.setSessionPath(data.sessionPath)
})
}
}
}

View file

@ -1,62 +0,0 @@
import cache from './managers/cache.mjs'
var session, state, editor, ipc
;(async()=>{
session = (await import('./managers/session/index.mjs')).default
state = (await import('./managers/state.mjs')).default
editor = (await import('./editor/index.mjs')).default
ipc = (await import('./ipc/index.mjs')).default
})()
var localBackup = cache.get('backup', false)
export const exists = localBackup !== null
export function save() {
if (session.session) {
cache.set('backup', {
session: session.session.data,
saveMode: session.saveMode,
sessionPath: session.sessionPath,
fragments: session.fragments,
state: state.get(),
history: editor.history,
historyState: editor.historyState,
editorEnabled: editor.enabled,
}, false)
}
}
export function load() {
if (localBackup) {
var data = localBackup
cache.remove('backup', false)
for (let k in data.fragments) {
session.setFragment({path: k, fileContent: data.fragments[k]})
}
session.load(data.session, ()=>{
session.setSaveMode(data.saveMode)
state.set(data.state, false)
editor.clearHistory()
editor.history = data.history
editor.historyState = data.historyState
if (data.editorEnabled) editor.enable()
ipc.send('sessionSetPath', {path: data.sessionPath})
session.setSessionPath(data.sessionPath)
})
}
}

107
src/client/dom.js Normal file
View file

@ -0,0 +1,107 @@
var readyCallbacks = [],
initState = false
module.exports = {
init: function() {
for (var i in readyCallbacks) {
readyCallbacks[i]()
}
initState = true
},
ready: function(callback) {
if (initState) {
callback()
} else {
readyCallbacks.push(callback)
}
},
dispatchEvent: function(element, name, data) {
var event = new CustomEvent(name, {
detail: data,
bubbles: true,
cancelable: true
})
element.dispatchEvent(event)
},
addEventListener: function(element, events, listener, capture) {
var eventsAsObject = typeof events == 'string' ? events.split(' ') : events
for (var i in eventsAsObject) {
element.addEventListener(eventsAsObject[i], listener, capture)
}
},
get: function(a, b) {
var context = b ? a : document,
selector = b || a,
nodes
if (selector.indexOf('>') === 0) selector = ':scope ' + selector
if (selector.indexOf(' ') === -1 && selector.indexOf(',') === -1) {
if (selector.indexOf('#') === 0 && context === document) {
nodes = [document.getElementById(selector.substr(1, selector.length - 1))]
} else if (selector.indexOf('.') === 0) {
nodes = context.getElementsByClassName(selector.substr(1, selector.length - 1))
}
}
if (!nodes) nodes = context.querySelectorAll(selector)
return [...nodes]
},
each: function(context, selector, callback) {
var nodes = module.exports.get(context, selector)
nodes.forEach(callback)
return nodes
},
index: function(element) {
var parent = element.parentNode
return parent ? Array.prototype.indexOf.call(parent.children, element) : -1
},
offset: function(element, container) {
var offsetLeft = 0,
offsetTop = 0
if (element) {
do {
if (!isNaN(element.offsetLeft)) {
offsetLeft += element.offsetLeft - element.scrollLeft
}
if (!isNaN(element.offsetTop)) {
offsetTop += element.offsetTop - element.scrollTop
}
} while ((element = element.offsetParent) && element !== container)
}
return {
left: offsetLeft,
top: offsetTop
}
}
}

View file

@ -1,82 +0,0 @@
export function dispatchEvent(element, name, data) {
var event = new CustomEvent(name, {
detail: data,
bubbles: true,
cancelable: true
})
element.dispatchEvent(event)
}
export function addEventListener(element, events, listener, capture) {
var eventsAsObject = typeof events == 'string' ? events.split(' ') : events
for (var i in eventsAsObject) {
element.addEventListener(eventsAsObject[i], listener, capture)
}
}
export function get(a, b) {
var context = b ? a : document,
selector = b || a,
nodes
if (selector.indexOf('>') === 0) selector = ':scope ' + selector
if (selector.indexOf(' ') === -1 && selector.indexOf(',') === -1 && selector.indexOf('[') === -1) {
if (selector.indexOf('#') === 0 && context === document) {
nodes = [document.getElementById(selector.substr(1, selector.length - 1))]
} else if (selector.lastIndexOf('.') === 0) {
nodes = context.getElementsByClassName(selector.substr(1, selector.length - 1))
}
}
if (!nodes) nodes = context.querySelectorAll(selector)
return [...nodes]
}
export function each(context, selector, callback) {
var nodes = get(context, selector)
nodes.forEach(callback)
return nodes
}
export function index(element) {
var parent = element.parentNode
return parent ? Array.prototype.indexOf.call(parent.children, element) : -1
}
export function offset(element, container) {
var offsetLeft = 0,
offsetTop = 0
if (element) {
do {
if (!isNaN(element.offsetLeft)) {
offsetLeft += element.offsetLeft - element.scrollLeft
}
if (!isNaN(element.offsetTop)) {
offsetTop += element.offsetTop - element.scrollTop
}
} while ((element = element.offsetParent) && element !== container)
}
return {
left: offsetLeft,
top: offsetTop
}
}

View file

@ -1,29 +1,18 @@
import {updateWidget} from './data-workers.mjs'
import {categories} from '../widgets/index.mjs'
import widgetManager from '../managers/widgets.mjs'
import {icon} from '../ui/utils.mjs'
import editor from './index.mjs'
import locales from '../locales/index.mjs'
import ContextMenu from '../ui/context-menu.mjs'
import {GRIDWIDTH, PXSCALE} from '../globals.mjs'
var {updateWidget} = require('./data-workers'),
{categories} = require('../widgets/'),
widgetManager = require('../managers/widgets'),
{icon} = require('../ui/utils'),
editor = require('./'),
locales = require('../locales'),
ContextMenu = require('../ui/context-menu'),
contextMenu = new ContextMenu()
var sessionManager
;(async()=>{
sessionManager = (await import('../managers/session/index.mjs')).default
})()
var contextMenu = new ContextMenu()
var multiSelectKey = (navigator.platform || '').match('Mac') ? 'metaKey' : 'ctrlKey'
var handleClick = function(event) {
if (
!editor.enabled ||
event.detail.button === 1 ||
(event.detail.metaKey && event.detail.shiftKey)
) return
if (!editor.enabled) return
if (!event.detail[multiSelectKey] && event.type !== 'fast-right-click' && (
event.target.classList.contains('no-widget-select') ||
@ -35,10 +24,6 @@ var handleClick = function(event) {
if (!targetWidget) return
while (targetWidget.meta.not_editable && targetWidget.parent) {
targetWidget = targetWidget.parent
}
// if the widget is not already selected
if (!targetWidget.container.classList.contains('editing') || event.detail.ctrlKey || event.detail.shiftKey) {
// add a flag to the original event to prevent draginit
@ -48,34 +33,9 @@ var handleClick = function(event) {
}
if (editor.inspector.focusedInput) {
editor.inspector.onChange()
editor.inspector.focusedInput = null
if (!document.body.contains(eventData.target)) return
}
if (event.type !== 'fast-right-click') {
if (targetWidget.getProp('type') === 'tab') {
targetWidget.parent.setValue(targetWidget.parent.children.indexOf(targetWidget), {sync: true, send: true})
}
if (
event.target.tagName === 'LI' && // Project tree
event.detail.shiftKey &&
editor.selectedWidgets.length > 0 &&
targetWidget.parent === editor.selectedWidgets[0].parent
) {
var siblings = targetWidget.parent.children,
from = siblings.indexOf(editor.selectedWidgets[0]),
to = siblings.indexOf(targetWidget),
range = siblings.slice(Math.min(from, to), Math.max(from, to) + 1).filter(w=>!editor.selectedWidgets.includes(w))
targetWidget = editor.selectedWidgets.concat(range)
}
if (editor.inspector.focusedInput) editor.inspector.onChange()
editor.select(targetWidget, {multi: event.detail[multiSelectKey]})
}
// right-click menu
@ -98,34 +58,20 @@ var handleClick = function(event) {
if (parent !== widgetManager) {
if (event.target.tagName !== 'LI') { // not Project tree
if (event.target.tagName !== 'LI') {
actions.push({
label: icon('project-diagram') + ' ' + locales('editor_show_in_tree'),
action: ()=>{
editor.widgetTree.showWidget(editor.selectedWidgets[0])
editor.widgetTree.blinkSelected()
},
shortcut: 't'
})
} else {
actions.push({
label: icon('eye') + ' ' + locales('editor_show_in_session'),
action: ()=>{
for (let w of editor.selectedWidgets) {
editor.widgetTree.showWidgetInSession(w)
}
},
shortcut: 'y'
separator: true
})
}
actions.push({
separator: true
})
actions.push({
label: icon('copy') + ' ' + locales('editor_copy'),
action: editor.copyWidget.bind(editor),
@ -191,7 +137,7 @@ var handleClick = function(event) {
}
if (parent !== widgetManager && editor.selectedWidgets.length === 1 && editor.selectedWidgets[0].parent.children.length > 1) {
if (parent !== widgetManager && editor.selectedWidgets[0].parent.children.length > 1) {
actions.push({
separator: true
})
@ -201,28 +147,28 @@ var handleClick = function(event) {
{
label: locales('editor_back'),
action: ()=>{
editor.handleKeydown('home')
editor.handleKeyboard('home')
},
shortcut: 'Home'
},
{
label: locales('editor_farther'),
action: ()=>{
editor.handleKeydown('pageup')
editor.handleKeyboard('pageup')
},
shortcut: 'Page Up'
},
{
label: locales('editor_closer'),
action: ()=>{
editor.handleKeydown('pagedown')
editor.handleKeyboard('pagedown')
},
shortcut: 'Page Down'
},
{
label: locales('editor_front'),
action: ()=>{
editor.handleKeydown('end')
editor.handleKeyboard('end')
},
shortcut: 'End'
}
@ -266,15 +212,11 @@ var handleClick = function(event) {
data[0].widgets.push(newData)
var indexes = {addedIndexes: [data[0].widgets.length -1]}
updateWidget(editor.selectedWidgets[0], indexes)
editor.pushHistory(indexes)
var newWidget = editor.selectedWidgets[0].children[editor.selectedWidgets[0].children.length - 1]
editor.select([newWidget])
if (!editor.widgetTree.parent.minimized) editor.widgetTree.showWidget(newWidget)
}
})
@ -287,11 +229,9 @@ var handleClick = function(event) {
}
if (data.length == 1 && widget.childrenType !== undefined) {
if (actions.length) actions.push({
separator: true
})
}
if (actions.length) actions.push({
separator: true
})
if (data.length == 1 && widget.childrenType !== 'tab') {
actions.push({
@ -309,17 +249,9 @@ var handleClick = function(event) {
data[0].tabs.push({})
var indexes = {addedIndexes: [data[0].tabs.length -1]}
updateWidget(editor.selectedWidgets[0], indexes)
editor.pushHistory(indexes)
var newWidget = editor.selectedWidgets[0].children[editor.selectedWidgets[0].children.length - 1]
editor.select([newWidget])
if (!editor.widgetTree.parent.minimized) editor.widgetTree.showWidget(newWidget)
newWidget.parent.setValue(newWidget.parent.children.indexOf(newWidget))
}
})
@ -328,20 +260,6 @@ var handleClick = function(event) {
}
if (parent !== widgetManager && data.length === 1) {
actions.push({
separator: true
})
actions.push({
label: icon('file-download') + ' ' + locales('editor_fragment_export'),
action: ()=>{
sessionManager.saveFragment(editor.selectedWidgets[0].props)
}
})
}
if (parent !== widgetManager) {
actions.push({

View file

@ -1,28 +1,29 @@
import widgetManager from '../managers/widgets.mjs'
import stateManager from '../managers/state.mjs'
import parser from '../parser.mjs'
import * as resize from '../events/resize.mjs'
var widgetManager = require('../managers/widgets'),
resize = require('../events/resize'),
stateManager = require('../managers/state'),
parser = require('../parser'),
Panel, Matrix,
editor,
scrollState = {}
var Panel, Matrix, editor
;(async()=>{
Panel = (await import('../widgets/containers/panel.mjs')).default
Matrix = (await import('../widgets/containers/matrix.mjs')).default
editor = (await import('./index.mjs')).default
})()
var scrollState = {}
setTimeout(()=>{
editor = require('./')
Panel = require('../widgets/containers/panel')
Matrix = require('../widgets/containers/matrix')
})
function updateWidget(widget, options={}) {
if (options.editedProps) {
if (options.changedProps) {
// alternate routine for small edits
var propNames = options.editedProps
var propNames = options.changedProps
if (
// if non dynamic props have changed, skip this and use rebuild routine
!propNames.some(n => !widget.isDynamicProp(n))
) {
var edited = widget.updateProps(options.editedProps, null, {fromEditor: true}) || widget
var edited = widget.updateProps(options.changedProps, null, {fromEditor: true}) || widget
editor.widgetTree.updateTree(editor.selectedWidgets)
@ -76,7 +77,7 @@ function updateWidget(widget, options={}) {
// save state
if (stateManager.queueCounter === 0) {
scrollState = {} // scrollable modals don't store their scroll state in their value
scrollState = {}
}
stateManager.incrementQueue()
for (let w of removedWidgets) {
@ -88,8 +89,8 @@ function updateWidget(widget, options={}) {
stateManager.pushValueState(id, value)
if (valueProp !== '' && valueProp !== undefined) stateManager.pushValueOldProp(id, valueProp)
}
if (w.getProp('scroll') && w.getProp('type') === 'modal') {
var s = w.getScroll()
if (widgetManager.scrollingWidgets.indexOf(w.hash) > -1 && w.scroll) {
var s = w.scroll()
if (s[0] !== 0 || s[1] !== 0) {
scrollState[w.getProp('id')] = s
}
@ -106,13 +107,12 @@ function updateWidget(widget, options={}) {
parentNode: widget.parentNode,
reCreateOptions: options.reCreateOptions,
locals: widget.parsersLocalScope,
variables: widget.variables,
hash: widget.hash,
children: children,
index: index,
meta: widget.meta
index: index
})
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
if (newWidget.getProp('type') === 'tab') newWidget.parent.trigger('tab-created', {widget: widget})
@ -141,7 +141,7 @@ function updateWidget(widget, options={}) {
if (stateManager.queueCounter === 0) {
for (let id in scrollState) {
for (let w of widgetManager.getWidgetById(id)) {
if (w.getProp('scroll')) w.setScroll(scrollState[id][0], scrollState[id][1])
if (w.scroll) w.scroll(scrollState[id])
}
}
}
@ -177,19 +177,17 @@ var incrementWidget = function(data, root){
return data
}
var id = String(data.id),
address = String(data.address)
var id = data.id,
address = data.address
if (id && address == '/' + id) {
data.address = 'auto'
} else if (!address.match(/^(auto|\/control|\/note|\/program|\/sysex|\/mtc|\/key_pressure|\/channel_pressure|\/pitch)$/)) {
var addressref = widgetManager.createAddressRef(null, data.preArgs,address)
} else if (!address.match(/^auto|\/control|\/note|\/program|\/sysex|\/key_pressure|\/channel_pressure|\/pitch/) !== 'auto') {
var addressref
while (fakeStore.address.indexOf(address) != -1 || widgetManager.getWidgetByAddress(addressref).length) {
address = address.replace(/([0-9]*)$/,function(m){
var n = parseInt(m)+1
n = isNaN(n)?1:n
@ -235,7 +233,7 @@ var incrementWidget = function(data, root){
}
export {
updateWidget,
incrementWidget
module.exports = {
updateWidget:updateWidget,
incrementWidget:incrementWidget
}

32
src/client/editor/diff.js Normal file
View file

@ -0,0 +1,32 @@
module.exports = {
diff: require('jsondiffpatch'),
diffToWidget: function(widget, diff) {
// traverse a diff patch and the associated widget
// to return the first node (widget and sub-patch) with actual changes
var children = diff.tabs || diff.widgets
if (children) {
var childrenKeys = Object.keys(children),
deletedChildren = childrenKeys.filter(x => typeof x === 'string' && x.match(/_[0-9]+/)),
changedChildren = childrenKeys.filter(x => !isNaN(x))
}
if (
!children ||
Array.isArray(children) || // 'tabs' or 'widgets' property created
deletedChildren.length || // 'tabs' or 'widgets' property created
changedChildren.length !== 1 || // children reordered (or same property edited in multiple widgets, but case ignored)
Array.isArray(children[changedChildren[0]]) // child item created
) {
return [widget, diff]
}
return module.exports.diffToWidget(widget.children[changedChildren[0]], children[changedChildren[0]])
}
}

View file

@ -1,29 +0,0 @@
import diff from 'jsondiffpatch'
export {diff}
export function diffToWidget(widget, diff) {
// traverse a diff patch and the associated widget
// to return the first node (widget and sub-patch) with actual changes
var children = diff.tabs || diff.widgets
if (children) {
var childrenKeys = Object.keys(children),
deletedChildren = childrenKeys.filter(x => typeof x === 'string' && x.match(/_[0-9]+/)),
changedChildren = childrenKeys.filter(x => !isNaN(x))
}
if (
!children ||
Array.isArray(children) || // 'tabs' or 'widgets' property created
deletedChildren.length || // 'tabs' or 'widgets' property created
changedChildren.length !== 1 || // children reordered (or same property edited in multiple widgets, but case ignored)
Array.isArray(children[changedChildren[0]]) // child item created
) {
return [widget, diff]
}
return diffToWidget(widget.children[changedChildren[0]], children[changedChildren[0]])
}

View file

@ -1,48 +1,38 @@
import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
import {updateWidget, incrementWidget} from './data-workers.mjs'
import {diff, diffToWidget} from './diff.mjs'
import widgetManager from '../managers/widgets.mjs'
import {deepCopy} from '../utils.mjs'
import {defaults, widgets} from '../widgets/index.mjs'
import UiSelectArea from '../ui/ui-selectarea.mjs'
import UiInspector from '../ui/ui-inspector.mjs'
import UiTree from '../ui/ui-tree.mjs'
import UiDragResize from '../ui/ui-dragresize.mjs'
import uiConsole from '../ui/ui-console.mjs'
import notifications from '../ui/notifications.mjs'
import locales from '../locales/index.mjs'
import {leftUiSidePanel, rightUiSidePanel} from '../ui/index.mjs'
import ipc from '../ipc/index.mjs'
import {DOM, GRIDWIDTH, GRIDWIDTH_CSS, ENV, PXSCALE, setGRIDWIDTH, READ_ONLY} from '../globals.mjs'
import zoom from '../ui/zoom.mjs'
var {updateWidget, incrementWidget} = require('./data-workers'),
keyboardJS = require('keyboardjs/dist/keyboard.min.js'),
{diff, diffToWidget} = require('./diff'),
widgetManager = require('../managers/widgets'),
{deepCopy} = require('../utils'),
{defaults} = require('../widgets/'),
macOs = (navigator.platform || '').match('Mac'),
UiSelectArea = require('../ui/ui-selectarea'),
UiInspector = require('../ui/ui-inspector'),
UiTree = require('../ui/ui-tree'),
UiDragResize = require('../ui/ui-dragresize'),
uiConsole = require('../ui/ui-console'),
notifications = require('../ui/notifications'),
locales = require('../locales'),
{leftUiSidePanel, rightUiSidePanel} = require('../ui/'),
ipc = require('../ipc'),
sessionManager
var sessionManager
;(async()=>{
sessionManager = (await import('../managers/session/index.mjs')).default
await import('./context-menu.mjs')
})()
setTimeout(()=>{
sessionManager = require('../managers/session/')
})
const macOs = (navigator.platform || '').match('Mac')
const HISTORY_SIZE = 50
class Editor {
constructor() {
zoom.editor = this
this.inspector = new UiInspector({selector: '#osc-inspector'})
this.inspector.on('update', (event)=>{
var {propName, value, preventHistory} = event,
var {propName, value} = event,
newWidgets = [],
error = false
if (this.selectedWidgets.some(w=>w.getProp('lock')) && propName !== 'lock') {
this.select(this.selectedWidgets)
return
}
for (var w of this.selectedWidgets) {
let previousValue = w.props[propName]
@ -55,12 +45,12 @@ class Editor {
try {
newWidgets.push(updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
} catch (e) {
w.props[propName] = previousValue
updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
if (uiConsole.minimized) notifications.add({
class: 'error',
@ -69,7 +59,7 @@ class Editor {
})
console.error(
`Error while setting ${propName} to: ${JSON.stringify(value)}.\n` +
'It\'s probably a bug, please open a new bug ticket with the following informations at' +
'It\'s probably a bug, please open a new bug ticket with the followigin informations at' +
'https://github.com/jean-emmanuel/open-stage-control/issues'
)
throw e
@ -80,7 +70,7 @@ class Editor {
if (error) return
if (!preventHistory) this.pushHistory()
this.pushHistory()
if (newWidgets.length > 1) this.select(newWidgets)
@ -90,43 +80,24 @@ class Editor {
this.widgetTree = new UiTree({selector: '#osc-tree', parent: leftUiSidePanel})
this.widgetTree.on('sorted', (event)=>{
var {oldIndex, newIndex, from, to} = event,
propName = from.childrenType + 's',
container
var {widget, oldIndex, newIndex} = event,
propName = widget.props.tabs && widget.props.tabs.length ? 'tabs' : 'widgets'
if (from === to) {
if (widget.props[propName].length < 2) return
if (to.props[propName].length < 2) return
widget.props[propName].splice(newIndex, 0, widget.props[propName].splice(oldIndex, 1)[0])
to.props[propName].splice(newIndex, 0, to.props[propName].splice(oldIndex, 1)[0])
var indices = [newIndex, oldIndex]
if (Math.abs(oldIndex - newIndex) > 1) {
for (var i = Math.min(newIndex, oldIndex) + 1; i < Math.max(newIndex, oldIndex); i++) {
indices.push(i)
}
var indices = [newIndex, oldIndex]
if (Math.abs(oldIndex - newIndex) > 1) {
for (var i = Math.min(newIndex, oldIndex) + 1; i < Math.max(newIndex, oldIndex); i++) {
indices.push(i)
}
container = updateWidget(to, {removedIndexes: indices, addedIndexes: indices, preventSelect: true})
this.pushHistory({removedIndexes: indices, addedIndexes: indices})
this.select(container.children[newIndex])
} else {
to.props[propName].splice(newIndex, 0, from.props[propName][oldIndex])
from.props[propName].splice(oldIndex, 1)
updateWidget(from, {removedIndexes: [oldIndex], preventSelect: true})
container = updateWidget(to, {addedIndexes: [newIndex], preventSelect: true})
this.pushHistory()
this.select(container.children[newIndex])
}
if (!event.ignoreTree) this.widgetTree.showWidget(container.children[newIndex])
var container = updateWidget(widget, {removedIndexes: indices, addedIndexes: indices, preventSelect: true})
this.pushHistory({removedIndexes: indices, addedIndexes: indices})
this.select(container.children[newIndex])
})
@ -138,14 +109,9 @@ class Editor {
this.widgetDragResize.on('move', (e)=>{
var left = Math.round(e.left / GRIDWIDTH) * GRIDWIDTH,
top = Math.round(e.top / GRIDWIDTH) * GRIDWIDTH
if (e.copying) {
this.duplicateWidget(left, top, e.shiftKey)
} else {
var dX = left - e.initLeft,
dY = top - e.initTop
this.moveWidget(dX, dY)
}
var dX = left - e.initLeft,
dY = top - e.initTop
this.moveWidget(dX, dY)
})
this.widgetDragResize.on('drag-resize', (e)=>{
var width = Math.round(e.width / GRIDWIDTH) * GRIDWIDTH,
@ -158,14 +124,13 @@ class Editor {
this.selectedWidgets = []
this.clipboard = null
this.tmpClipboard = null
this.idClipboard = null
ipc.on('clipboard', (data)=>{
this.clipboard = data.clipboard
this.idClipboard = data.idClipboard
})
this.usePercents = !!ENV.usepercents
this.usePercents = false
this.enabled = false
this.grid = true
@ -193,8 +158,6 @@ class Editor {
'mod + x',
'mod + v',
'mod + shift + v',
'mod + d',
'mod + shift + d',
macOs ? 'backspace' : 'delete',
'alt + up',
'alt + down',
@ -214,75 +177,35 @@ class Editor {
'pagedown',
'home',
'end',
't',
'y',
'f2',
'h',
'mod + f'
't'
]
for (let c of combos) {
keyboardJS.bind(c, (e)=>{
e.catchedByEditor = true
this.handleKeydown(c, e)
}, (e)=>{
e.catchedByEditor = true
this.handleKeyup(c, e)
this.handleKeyboard(c, e)
})
}
})
this.selectarea = new UiSelectArea('[data-widget]:not(.not-editable)', (elements, e)=>{
this.selectarea = new UiSelectArea('[data-widget]:not(.not-editable)', (elements)=>{
var widgets = elements.map(e => widgetManager.getWidgetByElement(e, ':not(.not-editable)')).filter(e => e)
elements = elements.map(e => widgetManager.getWidgetByElement(e, ':not(.not-editable)')).filter(e => e)
if (e.ctrlKey) {
// only add siblings to current selection
for (var i in widgets) {
this.select(widgets[i], {multi:true, fromLasso:true, lassoEnd: i == widgets.length - 1})
}
} else {
// select the largest group of siblings in area
var groups = {}
for (var w of widgets) {
var g = w.parent.hash
if (!g) continue
if (!groups[g]) groups[g] = []
if (!groups[g].includes(w)) groups[g].push(w)
}
groups = Object.values(groups)
// if the event started from a container widget (but not in the project tree)
// remove groups that are more than one level away from that container
if (e.target.tagName !== 'LI' && this.selectedWidgets[0].childrenType !== undefined) {
groups = groups.filter(g=>g[0].parent === this.selectedWidgets[0] || g[0].parent === this.selectedWidgets[0].parent)
}
var lengths = groups.map(g=>g.length),
selection = groups[lengths.lastIndexOf(Math.max(...lengths))]
if (selection) this.select(selection)
for (var i in elements) {
this.select(elements[i], {multi:true, fromLasso:true, lassoEnd: i == elements.length - 1})
}
})
}
handleKeydown(combo, e){
handleKeyboard(combo, e){
if (
this.inspector.helpModalOpened ||
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT|OSC-CONSOLE/)
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/)
) return
if (e) e.preventDefault()
@ -314,14 +237,6 @@ class Editor {
this.pasteWidget(this.mousePosition.x, this.mousePosition.y, true)
break
case 'mod + d':
this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, false)
break
case 'mod + shift + d':
this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, true)
break
case 'backspace':
case 'delete':
this.deleteWidget()
@ -331,7 +246,7 @@ class Editor {
case 'alt + down':
case 'alt + right':
case 'alt + left':
if (!this.selectedWidgets.length || this.selectedWidgets[0].parent === widgetManager) return
if (!this.selectedWidgets.length) return
if (this.selectedWidgets[0].props.height === undefined && e.key.match(/Arrow(Up|Down)/)) return
if (this.selectedWidgets[0].props.width === undefined && e.key.match(/Arrow(Left|Right)/)) return
@ -348,10 +263,10 @@ class Editor {
break
case 'mod + up':
case 'mod + down':
case 'mod + right':
case 'mod + left':
case 'up':
case 'down':
case 'right':
case 'left':
if (!this.selectedWidgets.length) return
if (this.selectedWidgets[0].props.top === undefined && e.key.match(/Arrow(Up|Down)/)) return
@ -386,26 +301,33 @@ class Editor {
}
break
case 'up':
case 'down':
case 'right':
case 'left':
case 'mod + up':
case 'mod + down':
case 'mod + right':
case 'mod + left':
if (!this.selectedWidgets.length) return
var curWidget = this.selectedWidgets[0],
toSelect = null
if (e.key === 'ArrowLeft' && curWidget.parent !== widgetManager) {
if (e.key === 'ArrowUp' && curWidget.parent !== widgetManager) {
toSelect = curWidget.parent
} else if (e.key === 'ArrowRight') {
} else if (e.key === 'ArrowDown') {
if (curWidget.children[0] && !curWidget.children[0].meta.not_editable) {
toSelect = curWidget.children[0]
let toSelectList = [...curWidget.children]
if (toSelectList && toSelectList.length) {
toSelectList.sort((a,b) => a.container.offsetLeft>b.container.offsetLeft)
toSelect = toSelectList[0]
if (toSelect.container.classList.contains('not-editable')) {
toSelect = null
}
}
} else if((e.key == 'ArrowUp') || (e.key == 'ArrowDown')){
}
else if((e.key == 'ArrowLeft') || (e.key == 'ArrowRight')){
if (curWidget.parent === widgetManager) return
@ -415,7 +337,7 @@ class Editor {
toSelectList.sort((a,b) => a.container.offsetLeft > b.container.offsetLeft)
var idx = toSelectList.indexOf(curWidget)
if (idx >= 0) {
var nextIdx = (idx + (e.key === 'ArrowUp' ? -1 : 1 ) + toSelectList.length) % toSelectList.length
var nextIdx = (idx + (e.key === 'ArrowLeft' ? -1 : 1 ) + toSelectList.length) % toSelectList.length
toSelect = toSelectList[nextIdx]
}
}
@ -431,7 +353,7 @@ class Editor {
case 'pageup':
case 'home':
case 'end':
if (this.selectedWidgets.length !== 1 || this.selectedWidgets[0].parent.children.length <= 1) return
if (!this.selectedWidgets.length || this.selectedWidgets[0].parent.children.length <= 1) return
var curWidget2 = this.selectedWidgets[0],
index = curWidget2.parent.children.indexOf(curWidget2),
@ -445,11 +367,9 @@ class Editor {
if (index !== newIndex) {
this.widgetTree.trigger('sorted', {
from: curWidget2.parent,
to: curWidget2.parent,
widget: curWidget2.parent,
oldIndex: index,
newIndex: newIndex,
ignoreTree: true
newIndex: newIndex
})
}
break
@ -457,75 +377,21 @@ class Editor {
case 't':
if (!this.selectedWidgets.length) return
this.widgetTree.showWidget(editor.selectedWidgets[0])
this.widgetTree.blinkSelected()
break
case 'y':
if (!this.selectedWidgets.length) return
for (let w of editor.selectedWidgets) {
this.widgetTree.showWidgetInSession(w)
}
this.widgetTree.showWidget(editor.selectedWidgets[0])
break
case 'f2':
if (!this.selectedWidgets.length) return
if (this.selectedWidgets[0].props.label === undefined && this.selectedWidgets[0].props.html === undefined) return
if (!this.inspector.expandedCategories.includes('style')) {
var header = DOM.get(this.inspector.container, '.category-header[data-name="style"]')[0]
if (header) {
header.parentNode.classList.add('expanded')
this.inspector.expandedCategories.push('style')
}
}
var labelProp = this.selectedWidgets[0].props.label === undefined ? 'html' : 'label'
var input = DOM.get(this.inspector.container, `textarea[name="${labelProp}"]`)[0]
if (input) {
if (input._ace_input) {
input._ace_input.focus()
} else {
input.focus()
input.setSelectionRange(0, input.value.length)
input.scrollIntoView({block: 'center'})
}
}
break
case 'h':
document.body.classList.add('editor-hide-selection')
break
case 'mod + f':
if (this.widgetTree.parent.minimized) this.widgetTree.parent.restore()
this.widgetTree.filter.focus()
break
}
}
handleKeyup(combo, e){
if (
this.inspector.helpModalOpened ||
(e && e.target && e.target.tagName && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/))
) return
if (e) e.preventDefault()
switch (combo) {
case 'h':
document.body.classList.remove('editor-hide-selection')
break
}
}
toggleGrid() {
this.grid = !this.grid
setGRIDWIDTH(this.grid ? GRIDWIDTH_CSS : 1)
GRIDWIDTH = this.grid ? 10 : 1
document.body.style.setProperty('--grid-width', GRIDWIDTH)
document.documentElement.style.setProperty('--grid-width', GRIDWIDTH)
document.body.classList.toggle('no-grid', GRIDWIDTH == 1)
}
@ -537,19 +403,13 @@ class Editor {
this.enabled = true
document.body.classList.add('editor-enabled')
document.body.classList.remove('editor-disabled')
this.widgetTree.updateTree(this.selectedWidgets)
leftUiSidePanel.enable()
rightUiSidePanel.enable()
// keyboardJS hack: prevent releaseAllKeys when switching context
var locale = keyboardJS._locale
keyboardJS._locale = null
keyboardJS.setContext('editing')
keyboardJS._locale = locale
this.oscContainer.addEventListener('mousemove', this.mouveMoveHandler)
this.oscContainer.addEventListener('mouseleave', this.mouveLeaveHandler)
@ -560,17 +420,13 @@ class Editor {
disable() {
this.unselect()
this.selectedWidgets = []
document.body.classList.add('editor-disabled')
document.body.classList.remove('editor-enabled')
// keyboardJS hack: prevent releaseAllKeys when switching context
var locale = keyboardJS._locale
keyboardJS._locale = null
keyboardJS.setContext('global')
keyboardJS._locale = locale
this.oscContainer.removeEventListener('mousemove', this.mouveMoveHandler)
this.oscContainer.removeEventListener('mouseleave', this.mouveLeaveHandler)
@ -635,16 +491,6 @@ class Editor {
}
if (this.selectedWidgets.length) {
var parent = this.selectedWidgets[0].parent
while (parent !== widgetManager) {
if (parent.getProp('lock')) {
this.selectedWidgets = [parent]
}
parent = parent.parent
}
}
if (options.fromLasso && !options.lassoEnd) return
this.unselect()
@ -672,9 +518,6 @@ class Editor {
}
this.widgetTree.select(this.selectedWidgets)
this.widgetDragResize.create(this.selectedWidgets)
if (!this.widgetTree.parent.minimized) {
this.widgetTree.showWidget(editor.selectedWidgets[editor.selectedWidgets.length-1])
}
}
@ -691,7 +534,7 @@ class Editor {
}
copyWidget(tmp) {
copyWidget() {
if (!this.selectedWidgets.length) return
if (this.selectedWidgets[0].getProp('type') === 'root') return
@ -706,19 +549,6 @@ class Editor {
}
duplicateWidget(x, y, increment) {
if (!this.selectedWidgets.length) return
if (this.selectedWidgets[0].getProp('type') === 'root') return
this.tmpClipboard = deepCopy(this.selectedWidgets.map((w)=>w.props))
var index = Math.max(...this.selectedWidgets.map(w=>w.parent.children.indexOf(w)))
this.select(this.selectedWidgets[0].parent)
this.pasteWidget(x, y, increment, index + 1, true)
this.select(this.selectedWidgets[0].children[index + 1])
}
cutWidget() {
this.copyWidget()
@ -726,21 +556,16 @@ class Editor {
}
pasteWidget(x, y, increment, index, tmp) {
if (!this.selectedWidgets.length) return
var clipboard = tmp ? this.tmpClipboard : this.clipboard
if (clipboard === null) return
pasteWidget(x, y, increment) {
if (!this.selectedWidgets.length || this.clipboard === null) return
if (
this.selectedWidgets[0].childrenType === undefined ||
clipboard[0].type === 'tab' && this.selectedWidgets[0].childrenType === 'widget' ||
clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
this.clipboard[0].type === 'tab' && this.selectedWidgets[0].childrenType === 'widget' ||
this.clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
) return
var pastedData = deepCopy(clipboard),
var pastedData = deepCopy(this.clipboard),
minTop = Infinity,
minLeft = Infinity
@ -776,27 +601,18 @@ class Editor {
for (let i in pastedData) {
if (!String(pastedData[i].left).match(/\{/)) {
if (pastedData[i]._pleft) {
pastedData[i].left = ((pastedData[i]._aleft - minLeft + x) * 100 / this.selectedWidgets[0].widget.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
pastedData[i].left += - minLeft + x
}
if (pastedData[i]._pleft) {
pastedData[i].left = ((pastedData[i]._aleft - minLeft + x) * 100 / this.selectedWidgets[0].widget.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
pastedData[i].left += - minLeft + x
}
if (!String(pastedData[i].top).match(/\{/)) {
if (pastedData[i]._ptop) {
pastedData[i].top = ((pastedData[i]._atop - minTop + y) * 100 / this.selectedWidgets[0].widget.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
pastedData[i].top += - minTop + y
}
if (pastedData[i]._ptop) {
pastedData[i].top = ((pastedData[i]._atop - minTop + y) * 100 / this.selectedWidgets[0].widget.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
pastedData[i].top += - minTop + y
}
}
}
@ -804,27 +620,20 @@ class Editor {
// paste data
var store = clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
var store = this.clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store] || []
this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store].concat(pastedData)
var indexes = {addedIndexes: []},
start = index || this.selectedWidgets[0].props[store].length
this.selectedWidgets[0].props[store].splice(start, 0, ...pastedData)
var indexes = {addedIndexes: []}
for (let i = 0; i < pastedData.length; i++) {
indexes.addedIndexes.push(start + pastedData.length - 1 - i )
indexes.addedIndexes.push(this.selectedWidgets[0].props[store].length - 1 - i )
}
if (index)indexes.reuseChildren=false
updateWidget(this.selectedWidgets[0], indexes)
this.pushHistory(indexes)
if (!leftUiSidePanel.minimized) this.widgetTree.showWidget(this.selectedWidgets[0].children[0])
}
pasteWidgetAsClone(x, y) {
@ -864,12 +673,8 @@ class Editor {
var indexes = {addedIndexes: [this.selectedWidgets[0].props.widgets.length -1]}
updateWidget(this.selectedWidgets[0], indexes)
this.pushHistory(indexes)
if (!leftUiSidePanel.minimized) this.widgetTree.showWidget(this.selectedWidgets[0].children[0])
}
@ -905,92 +710,51 @@ class Editor {
}
/* Utility function to retrieve the first sizable node */
getWidgetParentContainer(widget) {
while (widget.parent instanceof widgets.folder) {
widget = widget.parent
}
return widget.container.parentNode
}
resizeWidget(deltaW, deltaH) {
resizeWidget(deltaW, deltaH, ui) {
if (!this.selectedWidgets.length) return
if (this.selectedWidgets.some(w=>w.getProp('lock'))) {
this.createSelectionBlock()
return
}
var newWidgets = [],
area = this.widgetDragResize,
editedProps = []
var newWidgets = []
for (var i = 0; i < this.selectedWidgets.length; i++) {
let w = this.selectedWidgets[i],
nW, nH, nL, nT
nW, nH
nW = w.container.offsetWidth + deltaW * w.container.offsetWidth / area.initWidth
nH = w.container.offsetHeight + deltaH * w.container.offsetHeight / area.initHeight
if (i === 0 && ui) {
nW = ui.originalSize.width + deltaW
nH = ui.originalSize.height + deltaH
if (this.selectedWidgets.length > 1) {
nL = w.container.offsetLeft + deltaW * (w.container.offsetLeft - area.initLeft) / area.initWidth
nT = w.container.offsetTop + deltaH * (w.container.offsetTop - area.initTop) / area.initHeight
} else {
nW = w.container.offsetWidth + deltaW
nH = w.container.offsetHeight + deltaH
}
if (deltaW !== 0 && w.props.width !== undefined && w.parent.getProp('layout') !== 'vertical') {
if (w.props.width !== undefined && w.parent.getProp('layout') !== 'vertical') {
var newWidth = Math.max(nW, GRIDWIDTH) / PXSCALE
if (typeof w.props.width === 'string' && w.props.width.indexOf('%') > -1) {
w.props.width = (100 * PXSCALE * newWidth / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.width = (100 * PXSCALE * newWidth / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.width = newWidth
}
editedProps.push('width')
if (this.selectedWidgets.length > 1) {
var newLeft = Math.max(nL, GRIDWIDTH) / PXSCALE
if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else if (w.props.left !== 'auto'){
w.props.left = newLeft
}
editedProps.push('left')
}
}
if (deltaH !== 0 && w.props.height !== undefined && w.parent.getProp('layout') !== 'horizontal') {
if (w.props.height !== undefined && w.parent.getProp('layout') !== 'horizontal') {
var newHeight = Math.max(nH, GRIDWIDTH) / PXSCALE
if (typeof w.props.height === 'string' && w.props.height.indexOf('%') > -1) {
w.props.height = (100 * PXSCALE * newHeight / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.height = (100 * PXSCALE * newHeight / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.height = newHeight
}
editedProps.push('height')
if (this.selectedWidgets.length > 1) {
var newTop = Math.max(nT, GRIDWIDTH) / PXSCALE
if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) {
w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else if (w.props.top !== 'auto'){
w.props.top = newTop
}
editedProps.push('top')
}
}
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {editedProps: editedProps, preventSelect: this.selectedWidgets.length > 1}))
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {changedProps: ['width', 'height'], preventSelect: this.selectedWidgets.length > 1}))
}
this.pushHistory()
// if (newWidgets.length > 1) this.select(newWidgets, {preventSelect: this.selectedWidgets.length > 1})
this.createSelectionBlock()
if (newWidgets.length > 1) this.select(newWidgets, {preventSelect: this.selectedWidgets.length > 1})
}
@ -998,36 +762,30 @@ class Editor {
if (!this.selectedWidgets.length) return
if (this.selectedWidgets.some(w=>w.getProp('lock'))) {
this.createSelectionBlock()
return
}
var newWidgets = []
for (var w of this.selectedWidgets) {
var newTop = Math.max(parseInt(w.container.offsetTop) / PXSCALE + deltaY, 0)
if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) {
w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.top = (100 * PXSCALE * newTop / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.top = newTop
}
var newLeft = Math.max(parseInt(w.container.offsetLeft) / PXSCALE + deltaX, 0)
if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.left = newLeft
}
newWidgets.push(updateWidget(w, {editedProps: ['top', 'left'], preventSelect: this.selectedWidgets.length > 1}))
newWidgets.push(updateWidget(w, {changedProps: ['top', 'left'], preventSelect: this.selectedWidgets.length > 1}))
}
this.pushHistory()
// if (newWidgets.length > 1) this.select(newWidgets)
this.createSelectionBlock()
if (newWidgets.length > 1) this.select(newWidgets)
}
@ -1035,9 +793,7 @@ class Editor {
pushHistory(indexes) {
if (!ENV.noWarning) {
this.unsavedSession = true
}
this.unsavedSession = true
if (this.historyState > -1) {
this.history.splice(0, this.historyState + 1)
@ -1110,7 +866,7 @@ class Editor {
if (indexes) {
options = {...indexes}
} else {
options.editedProps = Object.keys(subpatch)
options.changedProps = Object.keys(subpatch)
options.reuseChildren = false
}
@ -1133,4 +889,6 @@ class Editor {
var editor = new Editor()
export default editor
module.exports = editor
require('./context-menu')

View file

@ -1,7 +1,4 @@
import iOS from '../ui/ios.mjs'
import editor from '../editor/index.mjs'
import {DOM, FOCUSABLE, ENV} from '../globals.mjs'
const iOS = require('../ui/ios')
const macOs = (navigator.platform || '').match('Mac')
var longTouchTimer = false,
@ -21,11 +18,7 @@ if (macOs) {
})
} else {
document.body.addEventListener('contextmenu', (event)=>{
if (
event.target &&
!event.target.classList.contains('ace_content') &&
!event.target.tagName.match(/INPUT|TEXTAREA|OSC-CONSOLE|OSC-CONSOLE-MESSAGE/)
) event.preventDefault()
if (event.target && (!event.target.tagName.match(/INPUT|TEXTAREA|OSC-CONSOLE|OSC-CONSOLE-MESSAGE/))) event.preventDefault()
})
}
@ -40,10 +33,6 @@ function mouseToFastClick(event) {
DOM.dispatchEvent(e.target, name, e)
if (!FOCUSABLE && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
console.debug('ELECTRON.BLUR()')
}
}
function touchToFastClick(event) {
@ -70,10 +59,6 @@ function touchToFastClick(event) {
}, 600)
if (ENV.nofocus && !editor.enabled && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
console.debug('ELECTRON.BLUR()')
}
}
if (!iOS) document.addEventListener('pointerdown', mouseToFastClick, true)

View file

@ -1,42 +0,0 @@
export default function(eventName, options={}){
var widget_storage_key = '_' + eventName + '_widget'
function closestWidgetContainer(target) {
var container = target
while (container !== null) {
if (container[widget_storage_key]) {
return container
} else {
container = container.parentNode
}
}
return null
}
function triggerWidgetEvent(target, event) {
var container = closestWidgetContainer(target)
if (container) container[widget_storage_key].trigger(eventName, event)
}
document.addEventListener(eventName, (event)=>{
triggerWidgetEvent(event.target, event)
}, {passive: !!options.passive, capture: !!options.capture})
return {
setup: function(options) {
var {element} = options || {element: this.container}
element[widget_storage_key] = this
},
teardown: function(options) {
var {element} = options || {element: this.container}
delete element[widget_storage_key]
}
}
}

View file

@ -1,6 +1,4 @@
import {DOUBLE_TAP_TIME} from '../globals.mjs'
export default (element, callback, options={})=>{
module.exports = (element, callback, options={})=>{
var lastTapTime = 0,
lastTapX,

331
src/client/events/drag.js Normal file
View file

@ -0,0 +1,331 @@
const {normalizeDragEvent, resetEventOffset, TRAVERSING_SAMEWIDGET} = require('./utils')
const iOS = require('../ui/ios')
var targets = {},
previousPointers = {}
function pointerDownHandler(event) {
if (event.capturedByEditor || event.touchPunch) return
if (!event.multitouch) {
for (var i in targets) {
if (targets[i] == event.target) return
}
}
event = normalizeDragEvent(event)
if (event.traversingStack) {
event.target = event.target.closest('.drag-event')
var widget = event.target.closest('.drag-event')._drag_widget,
local = event.traversingStack.stack[event.traversingStack.stack.length - 1]
if (widget.getProp) event.traversingStack.firstType = widget.getProp('type')
if (local.mode === TRAVERSING_SAMEWIDGET && local.type && local.type !== event.traversingStack.firstType) {
event.traversing = false
} else {
event.traversing = true
}
}
targets[event.pointerId] = event.target
previousPointers[event.pointerId] = event
triggerWidgetEvent(targets[event.pointerId], 'draginit', event)
}
function pointerMoveHandler(event) {
event = normalizeDragEvent(event, previousPointers[event.pointerId])
event.stopPropagation = true
if (event.traversing) {
var previousTarget = targets[event.pointerId],
target = event.isTouch ?
document.elementFromPoint(event.clientX, event.clientY)
: event.target
if (target) target = target.closest('.drag-event')
var local = null
if (target && event.traversingStack) {
for (var i = event.traversingStack.stack.length - 1; i > -1; i--) {
if (event.traversingStack.stack[i].container.contains(target)) {
local = event.traversingStack.stack[i]
break
}
}
if (!local) {
target = null
} else if (local.mode === TRAVERSING_SAMEWIDGET && local.type) {
var widget = target.closest('.drag-event')._drag_widget
if (widget.getProp && local.type !== widget.getProp('type')) target = null
}
}
if (target && event.isTouch) {
resetEventOffset(event, target)
}
if (previousTarget !== target) {
triggerWidgetEvent(previousTarget, 'dragend', event)
}
if (target && event.traversing) {
triggerWidgetEvent(target, previousTarget !== target ? 'draginit' : 'drag', event)
}
targets[event.pointerId] = target
} else {
triggerWidgetEvent(targets[event.pointerId], 'drag', event)
}
previousPointers[event.pointerId] = event
}
function pointerUpHandler(event) {
event = normalizeDragEvent(event, previousPointers[event.pointerId])
triggerWidgetEvent(targets[event.pointerId], 'dragend', event)
delete targets[event.pointerId]
delete previousPointers[event.pointerId]
}
// Move / Up Filter
function pointerMoveFilter(event) {
if (targets[event.pointerId] !== undefined) {
pointerMoveHandler.call(targets[event.pointerId], event)
}
}
function pointerUpFilter(event) {
if (targets[event.pointerId] !== undefined) {
pointerUpHandler.call(targets[event.pointerId], event)
delete targets[event.pointerId]
}
}
// Mouse events wrappers
function mouseMultiWrapper(event) {
mouseDownCapture(event, true)
}
function mouseDownCapture(event, multitouch) {
if (event.pointerType === 'touch') return
// event.pointerId = 'mouse'
event.multitouch = multitouch
pointerDownHandler(event)
}
function mouseMoveCapture(event) {
if (event.pointerType === 'touch') return
// event.pointerId = 'mouse'
event.inertia = event.ctrlKey ? 10 : 1
pointerMoveFilter(event)
}
function mouseUpCapture(event){
if (event.pointerType === 'touch') return
// event.pointerId = 'mouse'
pointerUpFilter(event)
}
// Touch events wrappers
function touchMultiWrapper(event) {
touchDownCapture(event, true)
}
function touchDownCapture(event, multitouch) {
event.preventDefault()
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
if (event.traversingStack) {
touchEvent.traversingStack = event.traversingStack
}
touchEvent.pointerId = touchEvent.identifier
touchEvent.multitouch = multitouch
pointerDownHandler(touchEvent)
}
}
function touchMoveCapture(event) {
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
var fingers = 0
for (var j in event.touches) {
if (event.touches[j].target && event.touches[j].target.isSameNode(touchEvent.target)) {
fingers += 1
if (fingers == 2) {
touchEvent.inertia = 10
break
}
}
}
touchEvent.pointerId = touchEvent.identifier
pointerMoveFilter(touchEvent)
}
}
function touchUpCapture(event) {
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
touchEvent.pointerId = touchEvent.identifier
pointerUpFilter(touchEvent)
}
}
// Callback trigger
function triggerWidgetEvent(target, name, event) {
if (target !== null && target._drag_widget) {
target._drag_widget.trigger(name, event)
} else if (target !== null) {
triggerWidgetEvent(target.closest('.drag-event'), name, event)
}
}
// init
DOM.ready(()=>{
if (!iOS) document.addEventListener('pointermove', mouseMoveCapture, true)
if (!iOS) document.addEventListener('pointerup', mouseUpCapture, true)
document.addEventListener('touchmove', touchMoveCapture, true)
DOM.addEventListener(document, 'touchend touchcancel', touchUpCapture, true)
})
module.exports = {
setup: function(options) {
if (
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
!options || options.ignoreCustomBindings
) {
return
}
var {element, multitouch} = options
element._drag_widget = this
element.style.touchAction = 'none'
element.classList.add('drag-event')
if (multitouch) {
element.addEventListener('touchstart', touchMultiWrapper, false)
if (!iOS) element.addEventListener('pointerdown', mouseMultiWrapper)
} else {
element.addEventListener('touchstart', touchDownCapture, false)
if (!iOS) element.addEventListener('pointerdown', mouseDownCapture)
}
},
teardown: function(options) {
if (
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
!options || options.ignoreCustomBindings
) {
return
}
var {element, multitouch} = options
delete element._drag_widget
element.style.touchAction = ''
element.classList.remove('drag-event')
if (multitouch) {
element.removeEventListener('touchstart', touchMultiWrapper, false)
if (!iOS) element.removeEventListener('pointerdown', mouseMultiWrapper)
} else {
element.removeEventListener('touchstart', touchDownCapture, false)
if (!iOS) element.removeEventListener('pointerdown', mouseDownCapture)
}
},
enableTraversingGestures: function(element, options={}) {
if (element._traversing) return
var traversing = options.type ? TRAVERSING_SAMEWIDGET : true,
traversingType = options.type === 'auto' ? '' : options.type
element._traversing = traversing
function makeEventTraversing(event) {
if (event.ctrlKey) return
if (!event.traversingStack) event.traversingStack = {firstType: '', stack: []}
event.traversingStack.stack.push({
container: element,
mode: traversing,
type: traversingType
})
}
if (!iOS) element.addEventListener('pointerdown', makeEventTraversing, true)
element.addEventListener('touchstart', makeEventTraversing, true)
element.addEventListener('disableTraversingGestures', (e)=>{
e.stopPropagation()
if (!iOS) element.removeEventListener('pointerdown', makeEventTraversing, true)
element.removeEventListener('touchstart', makeEventTraversing, true)
})
},
disableTraversingGestures: function(element) {
if (!element._traversing) return
delete element._traversing
DOM.dispatchEvent(element, 'disableTraversingGestures')
}
}

View file

@ -1,426 +0,0 @@
import {normalizeDragEvent, resetEventOffset, TRAVERSING_SAMEWIDGET} from './utils.mjs'
import iOS from '../ui/ios.mjs'
import {DOM} from '../globals.mjs'
var targets = {},
previousPointers = {}
function pointerDownHandler(event) {
if (event.capturedByEditor || event.touchPunch) return event
if (!event.target._drag_multitouch) {
for (var i in targets) {
if (targets[i] == event.target) return event
}
}
event = normalizeDragEvent(event)
event.stopPropagation = true
var target = closestDragContainer(event.target)
if (!target) return event
if (event.traversingStack) {
var widget = target._drag_widget,
local = event.traversingStack.stack[event.traversingStack.stack.length - 1]
if (widget.getProp) {
// if first touched widget is a container, wait until another widget is touched while moving
event.traversingStack.firstType = widget.isContainer ? '?' : widget.getProp('type')
}
if (local.mode === TRAVERSING_SAMEWIDGET) {
if (local.type === '') {
local.type = event.traversingStack.firstType
}
event.traversing = local.type === event.traversingStack.firstType || event.traversingStack.firstType === '?'
} else {
event.traversing = true
}
}
targets[event.pointerId] = target
previousPointers[event.pointerId] = event
if (event.pointerType !== 'mouse') domObserver.activate()
triggerWidgetEvent(targets[event.pointerId], 'draginit', event)
if (event.cancelDragEvent) clearPointer(event)
return event
}
function pointerMoveHandler(event) {
event = normalizeDragEvent(event, previousPointers[event.pointerId])
event.stopPropagation = true
if (event.traversing) {
var previousTarget = targets[event.pointerId],
target = event.isTouch ?
document.elementFromPoint(event.clientX, event.clientY)
: event.target
if (target) target = closestDragContainer(target)
var local = null,
containersOnly = false,
backupTarget = target
if (target && event.traversingStack) {
for (var i = event.traversingStack.stack.length - 1; i > -1; i--) {
if (event.traversingStack.stack[i].container.contains(target)) {
local = event.traversingStack.stack[i]
break
}
}
if (!local) {
target = null
} else if (local.mode === TRAVERSING_SAMEWIDGET) {
var widget = target._drag_widget
if (local.type === '?' && widget.getProp && !widget.isContainer) local.type = widget.getProp('type')
if (widget.getProp && local.type !== widget.getProp('type')) target = null
}
}
if (target && event.isTouch) {
resetEventOffset(event, target)
}
if (previousTarget !== target && !containersOnly) {
triggerWidgetEvent(previousTarget, 'dragend', event)
}
if (target) {
if (previousTarget === target) {
triggerWidgetEvent(target, 'drag', event)
} else {
triggerWidgetEvent(target, 'draginit', event)
}
} else {
// notify container of move events if no draggable widget is under the pointer
triggerWidgetEvent(backupTarget, 'drag', event, true)
}
targets[event.pointerId] = target
} else {
triggerWidgetEvent(targets[event.pointerId], 'drag', event)
}
previousPointers[event.pointerId] = event
}
function pointerUpHandler(event) {
event = normalizeDragEvent(event, previousPointers[event.pointerId])
event.stopPropagation = true
triggerWidgetEvent(targets[event.pointerId], 'dragend', event)
clearPointer(event)
}
function clearPointer(event) {
delete targets[event.pointerId]
delete previousPointers[event.pointerId]
if (domObserver.active) {
var t
for (var k in targets) {t=targets[k]}
if (t === undefined) domObserver.deactivate()
}
}
// Move / Up Filter
function pointerMoveFilter(event) {
if (targets[event.pointerId] !== undefined) {
pointerMoveHandler.call(targets[event.pointerId], event)
}
}
function pointerUpFilter(event) {
if (targets[event.pointerId] !== undefined) {
pointerUpHandler.call(targets[event.pointerId], event)
delete targets[event.pointerId]
}
}
// Mouse events wrappers
function mouseDownCapture(event) {
if (event.pointerType === 'touch') return
event.stopPropagation()
// event.pointerId = 'mouse'
pointerDownHandler(event)
}
function mouseMoveCapture(event) {
if (event.pointerType === 'touch') return
// event.pointerId = 'mouse'
event.inertia = event.ctrlKey ? 10 : 1
pointerMoveFilter(event)
}
function mouseUpCapture(event){
if (event.pointerType === 'touch') return
// event.pointerId = 'mouse'
pointerUpFilter(event)
}
// Touch events wrappers
// Touchend event is not emitted when target element is removed/detached
// Watch for DOM mutations and simulate pointerUp if a registered
// target is removed/detached
const domObserver = new MutationObserver(function(mutations) {
for (var id in targets) {
var event = previousPointers[id],
target = targets[id]
if (!event || event.pointerType === 'mouse') continue
for (var mutation of mutations) {
for (var node of mutation.removedNodes) {
if (node == target || node.contains(target)){
pointerUpHandler(event)
}
}
}
}
})
domObserver.active = false
domObserver.activate = ()=>{
if (!domObserver.active) {
domObserver.observe(DOM.get('#osc-container')[0], {subtree: true, childList: true})
domObserver.active = true
}
}
domObserver.deactivate = ()=>{
if (domObserver.active) {
domObserver.disconnect()
domObserver.active = false
}
}
function touchDownCapture(event) {
var preventDefault = true
event.stopPropagation()
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
if (event.traversingStack) {
touchEvent.traversingStack = event.traversingStack
}
touchEvent.pointerId = touchEvent.identifier
touchEvent = pointerDownHandler(touchEvent)
// allow scroll if drag is cancelled or widget is a container
if (touchEvent.cancelDragEvent || touchEvent.allowScroll) preventDefault = false
}
if (preventDefault) event.preventDefault()
}
function touchMoveCapture(event) {
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
touchEvent.fingers = 0
for (var j in event.touches) {
if (event.touches[j].target && event.touches[j].target.isSameNode(touchEvent.target)) {
touchEvent.fingers += 1
}
}
touchEvent.pointerId = touchEvent.identifier
pointerMoveFilter(touchEvent)
}
}
function touchUpCapture(event) {
for (var i in event.changedTouches) {
if (isNaN(i) || !event.changedTouches[i]) continue
var touchEvent = event.changedTouches[i]
touchEvent.pointerId = touchEvent.identifier
pointerUpFilter(touchEvent)
}
}
function ancestorDragContainers(target) {
var containers = [],
container = target
while (container !== null) {
if (container._drag_widget) {
containers.splice(0, 0, container._drag_widget)
if (container._drag_widget.root) break
}
container = container.parentNode
}
return containers
}
function closestDragContainer(target) {
var container = target
while (container !== null) {
if (container._drag_widget) {
return container
} else {
container = container.parentNode
}
}
return null
}
// Callback trigger
function triggerWidgetEvent(target, name, event, containersOnly) {
// trigger drag events from parent to child
var widgets = ancestorDragContainers(target),
widget
for (widget of widgets) {
if (containersOnly && !widget.isContainer) continue
widget.trigger(name, event)
if (event.preventDefault) break
}
// if child is a container, let it scroll
if (widget && widget.scroll) event.allowScroll = true
}
// init
if (!iOS) {
document.addEventListener('pointermove', mouseMoveCapture, true)
if ('onwebkitmouseforcechanged' in document) document.addEventListener('webkitmouseforcechanged', mouseMoveCapture, true)
}
if (!iOS) document.addEventListener('pointerup', mouseUpCapture, true)
document.addEventListener('touchmove', touchMoveCapture, true)
if ('ontouchforcechange' in document) document.addEventListener('touchforcechange', touchMoveCapture, true)
DOM.addEventListener(document, 'touchend touchcancel', touchUpCapture, true)
if (!iOS) document.addEventListener('pointerdown', mouseDownCapture)
export function setup(options) {
if (
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
!options || options.ignoreCustomBindings
) {
return
}
var {element, multitouch} = options
element.addEventListener('touchstart', touchDownCapture, false)
element._drag_widget = this
element._drag_multitouch = multitouch
}
export function teardown(options) {
if (
this._customBindings['drag'] !== 0 ||
this._customBindings['draginit'] !== 0 ||
this._customBindings['dragend'] !== 0 ||
!options || options.ignoreCustomBindings
) {
return
}
var {element} = options
element.style.touchAction = ''
element.removeEventListener('touchstart', touchDownCapture, false)
delete element._drag_widget
delete element._drag_multitouch
}
export function enableTraversingGestures(element, options={}) {
if (element._traversing) return
var traversing = options.type ? TRAVERSING_SAMEWIDGET : true,
traversingType = options.type === 'smart' || options.type === 'auto' ? '' : options.type
element._traversing = traversing
function makeEventTraversing(event) {
if (event.ctrlKey) return
if (!event.traversingStack) event.traversingStack = {firstType: '', stack: []}
event.traversingStack.stack.push({
container: element.parentNode,
mode: traversing,
type: traversingType
})
}
if (!iOS) element.addEventListener('pointerdown', makeEventTraversing, true)
element.addEventListener('touchstart', makeEventTraversing, true)
element.addEventListener('disableTraversingGestures', (e)=>{
e.stopPropagation()
if (!iOS) element.removeEventListener('pointerdown', makeEventTraversing, true)
element.removeEventListener('touchstart', makeEventTraversing, true)
})
}
export function disableTraversingGestures(element) {
if (!element._traversing) return
delete element._traversing
DOM.dispatchEvent(element, 'disableTraversingGestures')
}

View file

@ -1,25 +1,13 @@
import domEvent from './dom-event.mjs'
import * as drag from './drag.mjs'
import * as resize from './resize.mjs'
var customEvents = {
'draginit': drag,
'drag': drag,
'dragend': drag,
'resize': resize,
'wheel': domEvent('wheel'),
'scroll': domEvent('scroll', {capture: true}),
'click': domEvent('click'),
'fast-click': domEvent('fast-click'),
'focus': domEvent('focus', {capture: true}),
'blur': domEvent('blur', {capture: true}),
'change': domEvent('change')
}
var customEvents = {}
setTimeout(()=>{
customEvents['draginit'] = customEvents['drag'] = customEvents['dragend'] = require('./drag')
customEvents['resize'] = require('./resize')
})
// micro optimisation from eventemitter3
var has = Object.prototype.hasOwnProperty
export default class EventEmitter {
module.exports = class EventEmitter {
constructor() {
@ -43,8 +31,6 @@ export default class EventEmitter {
}
// Event bubbling
// DOM events won't bubble
// Virtual events will unless data.stopPropagation is set
if (!data || !data.stopPropagation) {
if (this.parent) this.parent.trigger(evt, data)
}

View file

@ -0,0 +1,64 @@
var elements = []
function checkResizes(context, force){
// Iterate over all elements to which the 'resize' event is bound.
var resizedElems = [],
cachedStyles = []
for (let i = elements.length - 1; i >= 0; i--) {
var elem = elements[i]
if (!context.contains(elem)) continue
var style = window.getComputedStyle(elem),
width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
if (!width || !height) continue
// If element size has changed since the last time, update the element
// data store and trigger the 'resize' event.
if (force || width != elem.resizedataw || height != elem.resizedatah) {
elem.resizedataw = width
elem.resizedatah = height
resizedElems.push(elem)
cachedStyles.push(style)
}
}
for (let i = resizedElems.length - 1; i >= 0; i--) {
resizedElems[i]._resize_widget.trigger('resize', {
width: resizedElems[i].resizedataw,
height: resizedElems[i].resizedatah,
style:cachedStyles[i],
stopPropagation: true
})
}
}
window.addEventListener('resize', ()=>{checkResizes(document)})
module.exports = {
setup: function(options) {
if (!options) return
if (elements.indexOf(options.element) == -1) {
elements.push(options.element)
options.element._resize_widget = this
}
},
teardown: function(options) {
if (!options) return
if (elements.indexOf(options.element) != -1) {
elements.splice(elements.indexOf(options.element), 1)
delete options.element._resize_widget
}
},
check: checkResizes
}

View file

@ -1,63 +0,0 @@
import fastdom from 'fastdom'
var elements = []
export function check(context, force){
fastdom.measure(()=>{
// Iterate over all elements to which the 'resize' event is bound.
let resizedElems = [],
cachedStyles = []
for (let i = elements.length - 1; i >= 0; i--) {
var elem = elements[i]
if (!context.contains(elem)) continue
var style = window.getComputedStyle(elem),
width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
if (!width || !height) continue
// If element size has changed since the last time, update the element
// data store and trigger the 'resize' event.
if (force || width != elem.resizedataw || height != elem.resizedatah) {
elem.resizedataw = width
elem.resizedatah = height
resizedElems.push(elem)
cachedStyles.push(style)
}
}
for (let i = resizedElems.length - 1; i >= 0; i--) {
resizedElems[i]._resize_widget.trigger('resize', {
width: resizedElems[i].resizedataw,
height: resizedElems[i].resizedatah,
style:cachedStyles[i],
stopPropagation: true
})
}
})
}
window.addEventListener('resize', ()=>{check(document)})
export function setup(options) {
if (!options) return
if (elements.indexOf(options.element) == -1) {
elements.push(options.element)
options.element._resize_widget = this
}
}
export function teardown(options) {
if (!options) return
if (elements.indexOf(options.element) != -1) {
elements.splice(elements.indexOf(options.element), 1)
delete options.element._resize_widget
}
}

View file

@ -4,12 +4,9 @@
Disabled for now
*/
/* global WebKitCSSMatrix */
var I = new WebKitCSSMatrix()
function Point(x, y, z) {
@ -48,7 +45,7 @@ function getTransformationMatrix(w) {
}
export default function cssTransformCoords(node, x, y) {
module.exports = function cssTransformCoords(node, x, y) {
return new Point(x, y, 0).transformBy(getTransformationMatrix(node).inverse())

Some files were not shown because too many files have changed in this diff Show more