Compare commits

..

No commits in common. "master" and "v0.4.2" have entirely different histories.

374 changed files with 13591 additions and 52210 deletions

View file

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

View file

@ -1,57 +0,0 @@
{
"env": {
"es2021": true,
"browser": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-prototype-builtins": "off",
"no-console": "off",
"no-useless-escape": "off",
"no-self-assign": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-unused-vars": [
"error",
{
"args": "none"
}
],
"space-before-function-paren": [
"error",
"never"
],
"indent": [
"error",
4,
{
"SwitchCase": 1,
"ObjectExpression": 1,
"ArrayExpression": 1,
"MemberExpression": "off",
"ignoredNodes": ["ConditionalExpression", "TemplateElement"]
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single",
{ "allowTemplateLiterals": true }
],
"semi": [
"error",
"never"
]
}
}

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

17
.gitignore vendored
View file

@ -1,17 +1,2 @@
# npmg
node_modules/
# build
/app/
# python/midi build
src/server/python/*
!src/server/python/*.py
# docs build
src/docs/widgets-reference.js
properties-reference.md
# packaging
dist/
sessions/
config.json

35
.travis.yml Normal file
View file

@ -0,0 +1,35 @@
language: node_js
node_js:
- "4.1"
addons:
apt:
packages:
- wine
install: npm install --save-optional --production
deploy:
provider: releases
api-key:
secure: Nb4qJlmLEE2/ETHEYe8V8eGI08d4GuE5kdQef5ZnB4PrstppLlAjShv5E4DNTsyalMOMDjpw9v+9aQNzxGiGv+lCVVL5oFvqvDpcYusRuF9Qua7oJtFh+5FvjgC1DDjauk5Z7WQWMvzWwfNmqbY/lxPbA4zVy4kdYkGV/8WnzA9AL5fU0ZU8gDsFjcr9Pz81XDsDXtPH/+iMuclMsEl8V/ZuswWlZaFn1Jnb1tcGC5WUCsuNQo/+gGfSK6Qcf9AKsIrOjdzi55s4jqH1N7P/kKi4a2tWUTwmSLrOxdUmSYjXVOxMu0cAEnHSeYREv/5o6J0MbfQrDoxh2y5roPZzqE+FAuFLl+b/+bYlW0mrfYfSuP/VX9LYh5JSvrhN7rZuUfMqS1iM7c9Dx8sZadMnvYEAAJhH8IV/9SkuRa/8QoIpXf7YB9v1jERxs4gk5CPT5Aml6nY/CvMWiEQ/wJhC7iZd/QRHshgfNLfAGlbbNU2KP6ZsVAGD601fyST/8neoQqLqS9mteOr1QME3c5EFw+XaauIQNYZSl+wJr8Y1YMcKY+fbJqqR0TXkbsoxFgV9PRf/4ZCjIJYtmelQVlM7j20XavOHM/Ko6/y7a3pohFz+ql3YR9jGF5XW2foXb4+e6DwTGL91/f75hYcsvXxoKbeaBjWpaSK8532UTeVkhPM=
file:
- "./dist/open-stage-control-i386.deb"
- "./dist/open-stage-control-amd64.deb"
- "./dist/open-stage-control-linux-ia32.zip"
- "./dist/open-stage-control-linux-x64.zip"
- "./dist/open-stage-control-osx.zip"
- "./dist/open-stage-control-win32.zip"
- "./dist/open-stage-control-win64.zip"
skip_cleanup: true
on:
tags: true
before_deploy:
- cd dist
- zip -q -r --symlinks open-stage-control-osx open-stage-control-darwin-x64/open-stage-control.app
- zip -q -r open-stage-control-win32 open-stage-control-win32-ia32
- zip -q -r open-stage-control-win64 open-stage-control-win32-x64
- zip -q -r open-stage-control-linux-ia32 open-stage-control-linux-ia32
- zip -q -r open-stage-control-linux-x64 open-stage-control-linux-x64
- cd ..
- npm run deb32
- npm run deb64
- mv dist/open-stage-control-linux-ia32/*.deb dist/open-stage-control-i386.deb
- mv dist/open-stage-control-linux-x64/*.deb dist/open-stage-control-amd64.deb

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

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 index.js -n $PORT

View file

@ -1,21 +1,84 @@
<img src="resources/images/logo.png" alt="Open Stage Control" height="50px"/>
[![Build Status](https://travis-ci.org/jean-emmanuel/open-stage-control.svg?branch=master)](https://travis-ci.org/jean-emmanuel/open-stage-control)
Open Stage Control
## Open Stage Control
*Libre and modular OSC / MIDI controller*
Open Stage Control is a libre desktop OSC bi-directionnal control surface application. It's built with HTML, JavaScript & CSS on top of [Electron](http://electron.atom.io/) framework.
### Demo
You can try the app here http://openstagecontrol.herokuapp.com/
Please note that :
- Chrome/Chromium **49** at least is required
- Since there is only one instance running, all connected guests are synchronized (widgets using the same osc paths update each other's states) : you might experience some unwanted synchronization with other users unless you specify custom parameters for your widgets.
- You might want to download the examples sessions files under *examples/* and load them in the app to get started.
- Website: https://openstagecontrol.ammd.net/
- Forum: https://openstagecontrol.discourse.group/
- IRC: Libera.chat #openstagecontrol
### Features
- mouse & multi-touch sensitive widgets
- modular & responsive layout
- built-in live editor
- bi-directionnal osc bindings
- headless server mode with any number of clients using chromium
- app state store / recall & import / export
- themes !
----
### Getting started
Docker additions by Rik Berkelder.
Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page. If you want to build or run the app from sources, here's how to:
- [Build from sources](resources/docs/build-from-sources.md)
- [Run from sources](resources/docs/run-from-sources.md)
mount `/sessions` directory. default session file is created and loaded there.
**Command line switches**
```
Options:
-h, --help display help
-s, --sync synchronized hosts (ip:port pairs) (all osc messages will also be sent to these)
-l, --load session file to load
-p, --port osc input port (for synchronization)
-n, --nogui disable default gui and makes the app availabe through http on specified port
-t, --theme theme name or path (mutliple values allowed)
---
Exemples:
Copyleft © Jean-Emmanuel Doucet 2014-2025.
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
$ open-stage-control -s 127.0.0.1:5555 127.0.0.1:6666 -p 7777
This will create an app listening on port 7777 for synchronization messages, and sending its widgets state changes to ports 5555 and 6666.
$ open-stage-control -n 8080 -l path/to/session.js
This will create a headless app available through http on port 8080. Multiple clients can use the app (with chrome only) simultaneously, their widgets will be synchronized.
$ open-stage-control -t light noinput /path/to/custom_theme.css
This will apply three themes (light ui, remove all inputs, and a custom theme file)
Available themes:
- light
- noinput
```
### Documentation
- [Editor reference](resources/docs/editor-reference.md)
- [Session reference](resources/docs/session-reference.md)
- [Widgets reference](resources/docs/widgets-reference.md)
- [Theming](resources/docs/theming.md)
### License & credits
Copyleft © Jean-Emmanuel @ [AMMD](http://ammd.net). This program is released under the GNU/GPL3 license.
It relies on the use of several libraries :
- [Node.js](https://nodejs.org/)
- [Electron](http://electron.atom.io/)
- [node-osc](https://github.com/TheAlphaNerd/node-osc)
- [socket.io]()
- [browserify]()
- [express]()
- [node-sass](https://github.com/sass/node-sass)
- [jQuery](http://jquery.com/)
- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
- [Font Awesome](http://fontawesome.io/)

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

1
browser/css/style.css Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,6 @@
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 400;
src: local('Droid Sans'), local('DroidSans'), url('droid-sans.woff2') format('woff2');
}

Binary file not shown.

4
browser/fonts/font-awesome.min.css vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
<link rel="stylesheet" href="css/style.css"/>
<script src="/js/browser-headless.js"></script>
</head>
<body>
<div id="lobby"></div>
<div id="container"></div>
<div id="sidepanel"></div>
</body>
</html>

18
browser/index.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
<link rel="stylesheet" href="css/style.css"/>
<script>
require( __dirname + "/js/browser.js")
</script>
</head>
<body>
<div id="lobby"></div>
<div id="container"></div>
<div id="sidepanel"></div>
</body>
</html>

54
browser/js/app.js Normal file
View file

@ -0,0 +1,54 @@
///////////////////////
WIDGETS = {}
WIDGETS_LINKED = {}
WIDGETS_BY_PATH = {}
SESSION = []
STATE = []
CLIPBOARD = null
EDITING = false
TRAVERSING = false
TABS = {}
MISC = {
iterators: {
widget:{},
tab:{}
}
}
PXSCALE = getComputedStyle(document.documentElement).getPropertyValue("--pixel-scale")
INITIALZOOM = PXSCALE
///////////////////////
$ = jQuery = require('./jquery/jquery.min')
require('./jquery/jquery.ui')
require('./jquery/jquery.drag')
require('./jquery/jquery.resize')
require('./jquery/jquery.fake-input')
///////////////////////
var callbacks = require('./app/callbacks')
var bindCallback = function(i) {
IPC.on(i,function(event,data){
callbacks[i](event,data)
})
}
for (i in callbacks) {
bindCallback(i)
}
///////////////////////
IPC.send('ready')

191
browser/js/app/actions.js Normal file
View file

@ -0,0 +1,191 @@
module.exports = {
stateQuickSave: function(preset){
if (preset) {
STATE = preset
} else {
STATE = module.exports.stateGet()
}
$('.quickload').removeClass('disabled')
},
stateQuickLoad: function(){
module.exports.stateSet(STATE,true)
},
stateSave: function() {
state = JSON.stringify(module.exports.stateGet(),null,' ')
if (WEBFRAME) {
IPC.send('stateSave',state)
} else {
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.preset"></a>')
var blob = new Blob([state],{type : 'text/plain'});
down.attr('href', window.URL.createObjectURL(blob))
down[0].click()
}
},
stateGet: function (){
var data = []
for (i in WIDGETS) {
var widget = WIDGETS[i]
for (var j=widget.length-1;j>=0;j--) {
if (widget[j].setValue && widget[j].getValue) {
var v = widget[j].getValue()
if (v!=undefined) data.push([i,v])
break
}
}
}
return data
},
stateLoad: function() {
if (WEBFRAME) {
IPC.send('stateLoad')
} else {
var prompt = $('<input type="file" accept=".preset"/>')
prompt.click()
prompt.on('change',function(e){
var reader = new FileReader();
reader.onloadend = function(e) {
var preset = e.target.result
module.exports.stateSet(JSON.parse(preset),true)
STATE = preset
}
reader.readAsText(e.target.files[0],'utf-8');
})
}
},
stateSend: function(){
var data = module.exports.stateGet()
module.exports.stateSet(data,true)
},
stateSet: function(preset,send){
for (i in preset) {
var data = preset[i]
if (WIDGETS[data[0]]!=undefined) {
for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
if (WIDGETS[data[0]][i].setValue) {
WIDGETS[data[0]][i].setValue(data[1],send,false)
}
}
}
}
},
toggleFullscreen: function(){
if (WEBFRAME) {
IPC.send('fullscreen')
} else {
var isInFullScreen = document.webkitIsFullScreen
if (isInFullScreen) {
document.webkitExitFullscreen()
} else {
document.documentElement.webkitRequestFullScreen()
}
}
},
sessionBrowse: function(){
if (WEBFRAME) {
IPC.send('sessionBrowse')
} else {
var prompt = $('<input type="file" accept=".js"/>')
prompt.click()
prompt.on('change',function(e){
var reader = new FileReader();
reader.onloadend = function(e) {
var session = e.target.result
IPC.send('sessionOpen',{file:session})
}
reader.readAsText(e.target.files[0],'utf-8');
})
}
},
sessionSave: function() {
var sessionfile = JSON.stringify(SESSION,null,' ')
if (WEBFRAME) {
IPC.send('sessionSave',sessionfile)
} else {
var down = $('<a download="'+new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16)+'.js"></a>')
var blob = new Blob([sessionfile],{type : 'text/plain'});
down.attr('href', window.URL.createObjectURL(blob))
down[0].click()
}
},
createPopup: function(title,content) {
var popup = $(`
<div class="popup">
<div class="popup-wrapper">
<div class="popup-title">${title}<span class="closer">${module.exports.icon('remove')}</span></div>
<div class="popup-content"></div>
</div>
</div>`),
closer = popup.find('.popup-title .closer')
closer.click(function(){
popup.close()
})
popup.close = function(){
$(document).unbind('keydown.popup')
popup.remove()
}
popup.find('.popup-content').append(content)
$('body').append(popup)
$(document).on('keydown.popup', function(e){
if (e.keyCode==27) popup.close()
})
return popup
},
editorEnable: function(){
$('.editor-root').attr('data-tab','#container').removeClass('disabled')
$('.enable-editor').addClass('on')
$('.disable-editor').removeClass('on')
EDITING = true
},
editorDisable: function(){
$('.widget.ui-resizable').resizable('destroy')
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
$('.editing').removeClass('editing')
$('.editor-root').addClass('disabled')
$('.editor-container').remove()
$('.disable-editor').addClass('on')
$('.enable-editor').removeClass('on')
EDITING = false
},
traversingDisable: function(){
$('#container').delegateDrag('disable')
$('.traversingEnable, .traversingDisable').toggleClass('on')
TRAVERSING = false
},
traversingEnable: function(){
$('#container').delegateDrag()
$('.traversingEnable, .traversingDisable').toggleClass('on')
TRAVERSING = true
}
}

101
browser/js/app/callbacks.js Normal file
View file

@ -0,0 +1,101 @@
var init = require('./init'),
actions = require('./actions'),
utils = require('./utils'),
icon = utils.icon
module.exports = {
receiveOsc: function(event,data){
var data = data || event
// fetch ids corresponding to the osc path
var path = data.path,
pathref = path,
args = data.args
if (typeof data.args == 'object') {
for (var i=data.args.length-1;i>=0;i--) {
var ref = path+'||||'+data.args.slice(0,i).join('||||')
if (WIDGETS_BY_PATH[ref]) {
pathref = ref
args = data.args.slice(i,data.args.length)
args = args.length==1?args[0]:args
continue
}
}
} else {
args = data.args
}
for (i in WIDGETS_BY_PATH[pathref]) {
if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true)
}
},
stateLoad: function(event,data){
var data = data || event
data = JSON.parse(data)
actions.stateSet(data,true)
actions.stateQuickSave(data)
},
sessionList: function(event,data){
var data = data || event
$('#lobby').append('\
<div class="main">\
<div class="header">\
Session selection\
</div>\
<div class="list"></div>\
</div>')
for (i in data) {
$('#lobby .list').append('<li><a class="btn load" data-session="'+data[i]+'">'+data[i]+'<span>'+icon('remove')+'</span></a></li>')
}
$('#lobby .list').append('<a class="btn browse">...</a>')
$('#lobby .list').append('<a class="btn new">New</a>')
$('#lobby .load').click(function(e){
e.stopPropagation()
IPC.send('sessionOpen',{path:$(this).data('session')})
})
$('#lobby a span').click(function(e){
e.stopPropagation()
IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('li').hide()
})
$('#lobby .browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
$('#lobby .new').click(function(e){
e.stopPropagation()
init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
})
},
sessionOpen: function(event,data){
var data = data || event
var session = JSON.parse(data)
init(session)
},
error: function(event,data){
var data = data || event
utils.createPopup(icon('warning')+'&nbsp;'+data.title,data.text)
},
applyStyle: function(event,data){
var data = data || event
var style = document.createElement('style');
style.innerHTML = data.join('');
document.body.appendChild(style);
if (data.indexOf('--pixel-scale')!=-1) {
PXSCALE = data.match(/--pixel-scale\s*:\s*([^;]*)/)[1]
INITIALZOOM = PXSCALE
}
}
}

View file

@ -0,0 +1,56 @@
var correctPosition = function (m, parent){
var pos = m.offset(),
width = m.outerWidth(),
height = m.outerHeight(),
totalWidth = $('body').outerWidth(),
totalHeight = $('body').outerHeight(),
leftAdjust = parent=='body'?0:parent.outerWidth()-2
if (width + pos.left > totalWidth) {
m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
}
if (height + pos.top > totalHeight) {
m.css({'margin-top':totalHeight-(height + pos.top)})
}
}
var menu = function(e,actions,parent){
var m = $('<div class="context-menu"></div>')
if (parent=='body') {
m.css({top:e.pageY+'px',left:e.pageX+'px'})
}
for (label in actions) {
if (typeof actions[label] == 'object') {
var item = $(`<div class="item has-sub" tabIndex="1">${label}</div>`).appendTo(m).on('touchstart mousedown',function(e){e.stopPropagation()})
menu(e,actions[label],item)
} else {
$(`<div class="item">${label}</div>`).on('mousedown.editor touchstart.editor',function(){
var callback = actions[label]
return function(e){
callback()
$('.context-menu').remove()
}
}()).appendTo(m)
}
}
m.appendTo(parent)
if (parent=='body') {
correctPosition(m,parent)
} else {
parent.hover(function(){correctPosition(m,parent)})
}
}
module.exports = menu

View file

@ -0,0 +1,165 @@
var widgets = require('../widgets'),
widgetOptions = widgets.widgetOptions,
sync = widgets.sync,
parser = require('../parser')
parsewidgets = parser.widgets,
parsetabs = parser.tabs,
ui = require('../ui'),
actions = require('../actions'),
sidepanelCreateToggle = require('../sidepanel').createToggle,
editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
purgeStores = require('./purge')
var getObjectData = function(obj){
var path = []
if (obj.hasClass('tab')) {
return TABS['#'+obj.attr('id')].data
}
if (obj.is('#container')) {
return SESSION
}
while(true) {
if (obj.hasClass('widget')) {
path.unshift(obj.index())
path.unshift('widgets')
} else if (obj.hasClass('tab')){
path.unshift(obj.data('index'))
path.unshift('tabs')
} else if (obj.is('#container')) {
break
}
obj = obj.parent()
}
path.splice(0,1)
for (var i=0,data=SESSION, path=path, len=path.length; i<len; i++){
data = data[path[i]]
}
return data
}
var updateDom = function(container,data) {
// save state
var scroll = $('#sidepanel').scrollTop(),
state = actions.stateGet(),
purgetabs = data.tabs?true:false
if (container.hasClass('widget')) {
// widget
var newContainer = parsewidgets([data],container.parent())
container.replaceWith(newContainer)
editObject(newContainer,data)
} else if (container.hasClass('tab')) {
// tab
var newContainer = container.empty()
if (data.widgets && data.widgets.length) parsewidgets(data.widgets,container)
if (data.tabs && data.tabs.length) {
parsetabs(data.tabs,container,false,data.label)
container.addClass('has-tabs')
} else {
container.removeClass('has-tabs')
}
$(`[data-tab="#${container.attr('id')}"]`).html(`<a><span>${data.label}</span></a>`)
editObject(newContainer,data)
} else if (container.attr('id')=='container') {
// session
var newContainer = $('#container')
container.empty()
parsetabs(data,container,true)
editSession(newContainer,data)
sidepanelCreateToggle()
}
newContainer.find('[data-tab]:first-child').click()
purgeStores(purgetabs)
// restore state
actions.stateSet(state,false)
sync()
ui.scrolls()
$('#sidepanel').scrollTop(scroll)
// return updated node
return newContainer
}
var incrementWidget = function(data){
delete data.linkId
var id = data.id,
label = data.label,
path = data.path
if (id && id==label) {
data.label = 'auto'
}
if (id && path == '/'+id) {
data.path = 'auto'
} else if (path){
var pathref
while (WIDGETS_BY_PATH[pathref]) {
path = path.replace(/([0-9]*)$/,function(m){
var n = parseInt(m)+1
n = isNaN(n)?1:n
return n
})
pathref = data.preArgs&&data.preArgs.length?data.path+'||||'+data.preArgs.join('||||'):data.path
}
data.path = path
}
if (id) {
while (WIDGETS[id]) {
id = id.replace(/([0-9]*)$/,function(m){
var n = parseInt(m)+1
n = isNaN(n)?1:n
return n
})
}
data.id = id
}
for (i in data) {
if (typeof data[i] == 'object') data[i] = incrementWidget(data[i])
}
return data
}
module.exports = {
updateDom:updateDom,
getObjectData:getObjectData,
incrementWidget:incrementWidget
}

View file

@ -0,0 +1,307 @@
var updateDom = require('./data-workers').updateDom,
widgetOptions = require('../widgets').widgetOptions
var editObject = function(container, data, refresh){
if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
var isWidget = container.hasClass('widget')
$('.editing').removeClass('editing')
$('.widget.ui-resizable').resizable('destroy')
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
if (isWidget) {
$(container).addClass('editing')
} else {
$(`[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
$(container).parent().addClass('editing')
}
$('.editor-container').remove()
$('.editor').append('<div class="editor-container"></div>')
var form = $('<div class="form"></div>').appendTo('.editor-container')
var params = isWidget?widgetOptions[data.type]:{label:''}
for (i in params) {
if (i.indexOf('separator')!=-1) {
$(`<div class="separator"><span>${params[i]}</span></div>`).appendTo(form)
continue
} else if (data[i]===undefined) {
continue
}
// Common options edit
if (i!='widgets' && i!='tabs') {
var type = typeof data[i],
value = type == 'object'?JSON.stringify(data[i]):data[i],
wrapper = $('<div class="input-wrapper"></div>').appendTo(form),
label = $(`<label>${i}</label>`).appendTo(wrapper),
input
if (i=='type') {
input = $(`<select class="input" data-type="${type}" title="${i}"/>`)
for (t in widgetOptions) {
input.append(`<option ${t==value?'selected=':''} value="${t}">${t}</option>`)
}
select = $('<div class="select-wrapper"></div>').append(input)
select.appendTo(wrapper)
} else if (typeof params[i]=='boolean') {
input = $(`<input class="checkbox" data-type="${type}" value='${value}' title="${i}"/>`)
input.click(function(){
$(this).val(!eval($(this).val())).trigger('change')
})
input.appendTo(wrapper)
} else {
input = $(`<input data-type="${type}" value='${value}' title="${i}"/>`)
input.appendTo(wrapper)
}
input.on('change',function(){
// var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
var v
try {
eval(`v=${$(this).val()}`)
} catch(err) {
v = $(this).val()
}
data[$(this).attr('title')] = v
if (v==='') delete data[$(this).attr('title')]
updateDom(container,data)
})
}
}
// widget list edit
if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
var list = $('<ul class="input"></ul>'),
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
var editItem = function(i) {
return function(){
container.find('.widget').first().siblings().addBack().eq(i).trigger('mousedown.editor')
}
}
for (i in data.widgets) {
var item = $(`<li data-index="${i}" class="sortables" data-id="${data.widgets[i].id}"><a class="btn small">${data.widgets[i].id||data.widgets[i].label}</a></li>`)
.appendTo(list)
.click(editItem(i))
var remove = $('<span><i class="fa fa-remove"></i></span>')
.appendTo(item)
.click(function(e){
e.stopPropagation()
data.widgets.splice($(this).parent().attr('data-index'),1)
updateDom(container,data)
})
}
list.sortable({
forcePlaceholderSize: true,
items: '.sortables',
start:function(){$(this).sortable( "refreshPositions" )},
update: function(e,ui){
var prevIndex = $(ui.item).attr('data-index')
var newIndex = $(ui.item).index()
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
updateDom(container,data)
}
})
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
data.widgets = data.widgets || []
data.widgets.push({})
updateDom(container,data)
})
$('<label>widgets</label>').appendTo(wrapper)
list.appendTo(wrapper)
}
// tab list edit
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
//tabs
var list = $('<ul class="input"></ul>'),
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
var editItem = function(i) {
return function(){
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
}
}
for (i in data.tabs) {
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data.tabs[i].label}</a></li>`)
.appendTo(list)
.click(editItem(i))
var remove = $('<span><i class="fa fa-remove"></i></span>')
.appendTo(item)
.click(function(e){
e.stopPropagation()
data.tabs.splice($(this).parent().attr('data-index'),1)
updateDom(container,data)
})
}
list.sortable({
start:function(){$(this).sortable( "refreshPositions" )},
forcePlaceholderSize: true,
items: '.sortables',
update: function(e,ui){
var prevIndex = $(ui.item).attr('data-index')
var newIndex = $(ui.item).index()
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
updateDom(container,data)
}
})
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
data.tabs = data.tabs || []
data.tabs.push({})
updateDom(container,data)
})
$('<label>tabs</label>').appendTo(wrapper)
list.appendTo(wrapper)
}
if (data.hasOwnProperty('width')) {
var handleTarget
container.resizable({
handles:'s, e, se',
helper: "ui-helper",
start: function(event, ui){
handleTarget = $(event.originalEvent.target)
},
stop: function( event, ui ) {
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
updateDom(container,data)
}
})
}
if (data.hasOwnProperty('top')) {
container.draggable({
cursor:'-webkit-grabbing',
stop: function( event, ui ) {
event.preventDefault()
data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
ui.helper.remove()
updateDom(container,data)
},
handle:'.ui-draggable-handle, > .label',
snap:'.widget',
snapTolerance:5,
helper:function(){return $('<div class="ui-helper"></div>').css({height:container.outerHeight(),width:container.outerWidth()})}
}).append('<div class="ui-draggable-handle"></div>')
}
}
var editSession = function(container,data,refresh){
if (!refresh && $('.editor-root').hasClass('editing')) return
$('.widget.ui-resizable').resizable('destroy')
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
$('.editing').removeClass('editing')
$('.editor-root, #container').addClass('editing')
$('.editor-container').remove()
$('.editor').append('<div class="editor-container"></div>')
var form = $('<div class="form"></div>').appendTo('.editor-container'),
list = $('<ul class="input"></ul>'),
wrapper = $('<div class="input-wrapper column"></div>').appendTo(form)
var editItem = function(i) {
return function(){
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
}
}
for (i in data) {
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data[i].label}</a></li>`)
.appendTo(list)
.click(editItem(i))
var remove = $('<span><i class="fa fa-remove"></i></span>')
.appendTo(item)
.click(function(e){
e.stopPropagation()
data.splice($(this).parent().attr('data-index'),1)
updateDom(container,data)
})
}
list.sortable({
start:function(){$(this).sortable( "refreshPositions" )},
forcePlaceholderSize: true,
items: '.sortables',
update: function(e,ui){
var prevIndex = $(ui.item).attr('data-index')
var newIndex = $(ui.item).index()
data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
updateDom(container,data)
}
})
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
data = data || []
data.push({})
updateDom(container,data)
})
$('<label>tabs</label>').appendTo(wrapper)
list.appendTo(wrapper)
$('.editor-container').append(form)
}
module.exports = {
editObject:editObject,
editSession:editSession
}

View file

@ -0,0 +1,184 @@
var data = require('./data-workers'),
getObjectData = data.getObjectData,
updateDom = data.updateDom,
incrementWidget = data.incrementWidget,
edit = require('./edit-objects'),
editObject = edit.editObject,
editSession = edit.editSession,
createPopup = require('../utils').createPopup,
widgetOptions = require('../widgets').widgetOptions,
widgetCategories = require('../widgets').categories,
menu = require('./context-menu')
var init = function(){
document.addEventListener("contextmenu", function(e){
e.preventDefault()
}, false);
$('body').off('.editor').on('mousedown.editor touchstart.editor',function(e){
if (!EDITING) return
$('.context-menu').remove()
var target = $(e.target).is('.widget:not(.not-editable), .tab, [data-tab], #container')?
$(e.target):
$(e.target).closest('.widget:not(.not-editable), .tab, [data-tab], #container')
if (!target.length) return
var container = target.attr('data-tab')?TABS[target.attr('data-tab')].tab:target,
type = target.hasClass('widget')?'widget':'tab',
parent = container.parent(),
index = container.index(),
data = getObjectData(container)
if (container.attr('id')=='container') {
editSession(container,SESSION)
} else {
editObject(container,data)
}
if (e.button!=2) return
if (container.attr('id')=='container') {
menu(e,{
'<i class="fa fa-plus"></i> Add tab': function(){
data.push({})
updateDom(container,data)
}
},'body')
return
}
var actions = {}
// actions['<i class="fa fa-edit"></i> Edit'] = function(){editObject(container,data)}
if (type=='widget') actions['<i class="fa fa-copy"></i> Copy'] = function(){CLIPBOARD=data}
if (type=='widget') actions['<i class="fa fa-cut"></i> Cut'] = function(){
CLIPBOARD=JSON.parse(JSON.stringify(data))
var parentContainer = container.parents('.widget, .tab, #container').first()
parentData = getObjectData(parentContainer)
parentData.widgets.splice(container.index(),1)
updateDom(parentContainer,parentData)
}
if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
if (CLIPBOARD!=null) {
actions['<i class="fa fa-paste"></i> Paste'] = {
'<i class="fa fa-plus-circle"></i> ID + 1':function(){
data.widgets = data.widgets || []
var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
if (!target.attr('data-tab')) {
newData.top = e.offsetY
newData.left= e.offsetX
} else {
delete newData.top
delete newData.left
}
data.widgets.push(newData)
updateDom(container,data)
},
'<i class="fa fa-clone"></i> Clone':function(){
data.widgets = data.widgets || []
var newData = JSON.parse(JSON.stringify(CLIPBOARD))
if (!target.attr('data-tab')) {
newData.top = e.offsetY
newData.left= e.offsetX
} else {
delete newData.top
delete newData.left
}
data.widgets.push(newData)
updateDom(container,data)
}
}
}
actions['<i class="fa fa-plus"></i> Add widget'] = {}
var createFunction = function(widgetType,container,data){
return function() {
data.widgets = data.widgets || []
var newData = {type:widgetType}
if (!target.attr('data-tab')) {
newData.top = e.offsetY
newData.left= e.offsetX
}
data.widgets.push(newData)
updateDom(container,data)
}
}
for (category in widgetCategories) {
actions['<i class="fa fa-plus"></i> Add widget'][category] = {}
for (t in widgetCategories[category]) {
var wtype = widgetCategories[category][t]
actions['<i class="fa fa-plus"></i> Add widget'][category][wtype] = createFunction(wtype,container,data)
}
}
}
if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
actions['<i class="fa fa-plus"></i> Add tab'] = function(){
data.tabs = data.tabs || []
data.tabs.push({})
updateDom(container,data)
}
}
actions['<i class="fa fa-trash"></i> Delete'] = function(){
var popup = createPopup('Are you sure ?',`
<div class="actions">
<div class="btn warning confirm-delete">DELETE</div>
<div class="btn cancel-delete">CANCEL</div>
</div>
`)
$('.confirm-delete').click(function(){
popup.close()
var parentContainer = container.parents('.widget, .tab, #container').first()
parentData = getObjectData(parentContainer)
if (type=='widget') {
parentData.widgets.splice(container.index(),1)
} else if (type=='tab' && parentContainer.attr('id')!='container') {
parentData.tabs.splice(container.data('index'),1)
} else {
parentData.splice(container.data('index'),1)
}
updateDom(parentContainer,parentData)
})
$('.cancel-delete').click(function(){
popup.close()
})
$(document).on('keydown.popup', function(e){
if (e.keyCode==13) $('.confirm-delete').click()
})
}
menu(e,actions,'body')
})
}
module.exports = init

View file

@ -0,0 +1,70 @@
module.exports = function(purgetabs) {
// prune tabs store
var count, newcount, formerBuffuredTabs, bufferedTabs
if (purgetabs) {
while (true) {
// we need to do that several times since tabs are referenced in each of their parents
// get all buffered tabs
formerBuffuredTabs = []
for (i in TABS) {
formerBuffuredTabs.push(TABS[i].tab[0])
}
// remove deleted tabs that are not referenced (have no navigation link pointing to them)
var $f = $(formerBuffuredTabs)
for (i in TABS) {
if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
delete TABS[i]
}
}
newcount = Object.keys(TABS).length
if (count == newcount) break
count = newcount
}
}
bufferedTabs = []
for (i in TABS) {
bufferedTabs.push(TABS[i].tab[0])
}
// prune widget stores
// if widgets cannot be found in buffered tabs, it must be unreferenced
var $b = $(bufferedTabs)
for (i in WIDGETS) {
for (var j=WIDGETS[i].length-1;j>=0;j--) {
if (!$b.find(WIDGETS[i][j]).length) {
WIDGETS[i].splice(j,1)
}
}
if (!WIDGETS[i].length) {
delete WIDGETS[i]
}
}
for (i in WIDGETS_LINKED) {
for (var j=WIDGETS_LINKED[i].length-1;j>=0;j--) {
if (!$b.find(WIDGETS_LINKED[i][j]).length) {
WIDGETS_LINKED[i].splice(j,1)
}
}
if (!WIDGETS_LINKED[i].length) {
delete WIDGETS_LINKED[i]
}
}
for (i in WIDGETS_BY_PATH) {
for (var j=WIDGETS_BY_PATH[i].length-1;j>=0;j--) {
if (!$b.find(WIDGETS_BY_PATH[i][j]).length) {
WIDGETS_BY_PATH[i].splice(j,1)
}
}
if (!WIDGETS_BY_PATH[i].length) {
delete WIDGETS_BY_PATH[i]
}
}
}

28
browser/js/app/init.js Normal file
View file

@ -0,0 +1,28 @@
var parsetabs = require('./parser').tabs,
ui = require('./ui'),
sync = require('./widgets').sync,
editorDisable = require('./actions').editorDisable,
editorInit = require('./editor/init')
module.exports = function(session,callback) {
$('#lobby').remove()
$('#container').empty()
var spinner = $('<div id="loading"><div class="spinner"></div></div>').appendTo('#container')
setTimeout(function(){
parsetabs(session,$('#container'),true)
ui.init()
editorDisable()
editorInit()
sync()
setTimeout(function(){
spinner.remove()
if (!callback) return
setTimeout(function(){
callback()
},25)
},25)
},25)
}

175
browser/js/app/parser.js Normal file
View file

@ -0,0 +1,175 @@
var widgets = require('./widgets'),
widgetOptions = widgets.widgetOptions,
createWidget = widgets.createWidget
var getIterator = function(id,type){
var iterator = MISC.iterators[type]
if (iterator[id]==undefined) iterator[id] = 0
iterator[id] += 1
return iterator[id]
}
var hashCode = function(s){
return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
}
module.exports.tabs = function(data,parent,main,parentLabel){
if (main) {
// Reset Globals
WIDGETS = {}
WIDGETS_LINKED = {}
WIDGETS_BY_PATH = {}
SESSION = data
TABS['#container'] = {
tab:$('#container')
}
MISC.iterators.tab = {}
}
var main = main?'main ':'',
nav = $(document.createElement('div')).addClass(main + 'navigation'),
navtabs = $(document.createElement('ul')).addClass('tablist'),
content = $(document.createElement('div')).addClass('content')
if (parentLabel) navtabs.append(`<li class="parent"><a><span>${parentLabel}</span></a></li>`)
for (i in data) {
var tabData = data[i]
var label = tabData.label||tabData.id||'Unnamed',
hash = hashCode(label),
id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
tabData.label = label
delete tabData.id
navtabs.append(`<li data-tab="#${id}"><a><span>${label}</span></a></li>`)
var tabContent = $(`<div class="tab ${tabData.tabs&&tabData.tabs.length?'has-tabs':''}" id="${id}" data-index="${i}"></div>`)
tabContent.data(tabData)
if (tabData.tabs && tabData.tabs.length) {
module.exports.tabs(tabData.tabs,tabContent,false,label)
} else if (tabData.widgets && tabData.widgets.length) {
module.exports.widgets(tabData.widgets,tabContent)
}
// content.append(tabContent)
TABS['#'+id]= {
parent:content,
tab:tabContent,
data:tabData
}
}
nav[0].appendChild(navtabs[0])
parent[0].appendChild(nav[0])
parent[0].appendChild(content[0])
}
module.exports.widgets = function(data,parent) {
for (i in data) {
var widgetData = data[i]
widgetData.type = widgetData.type || 'fader'
var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
for (i in tmpWidgetOptions[widgetData.type]) {
if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
}
if (widgetData.id=='auto') {
var id
while (!id || WIDGETS[id]) {
id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
}
widgetData.id = id
}
widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
for (i in widgetData) {
if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
}
for (t in {width:'',height:'',top:'',left:''}) {
widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
}
if (parent.hasClass('strip')) {
delete widgetData.top
delete widgetData.left
}
if (widgetData.preArgs!=undefined) {
widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
}
if (widgetData.target!=undefined) {
widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
}
var width = parseFloat(widgetData.width)==widgetData.width?parseFloat(widgetData.width)+'rem' : widgetData.width,
height = parseFloat(widgetData.height)==widgetData.height?parseFloat(widgetData.height)+'rem' : widgetData.height,
left = parseFloat(widgetData.left)==widgetData.left?parseFloat(widgetData.left)+'rem' : widgetData.left,
top = parseFloat(widgetData.top)==widgetData.top?parseFloat(widgetData.top)+'rem' : widgetData.top
var styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:auto;`:'',
styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:auto;`:'',
styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
var label = widgetData.label == 'auto'?widgetData.id:widgetData.label
var widgetContainer = $(`
<div class="widget ${widgetData.type}-container ${styleL.length || styleT.length?'absolute-position':''}" style="${styleW + styleH + styleL + styleT + widgetData.css}">
<div class="label"><span>${label}</span></div>
</div>
`)
if (widgetData.label===false) widgetContainer.addClass('nolabel')
// create widget
var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
if (widgetData.color && widgetData.color!='auto') widgetInner[0].style.setProperty('--color-accent',widgetData.color)
widgetContainer[0].appendChild(widgetInner[0])
// store widget reference for cross widget sync
if (WIDGETS[widgetData.id]==undefined) WIDGETS[widgetData.id] = []
WIDGETS[widgetData.id].push(widgetInner)
// store widget with linkId for widgte linking
if (widgetData.linkId && widgetData.linkId.length) {
if (WIDGETS_LINKED[widgetData.linkId]==undefined) WIDGETS_LINKED[widgetData.linkId] = []
WIDGETS_LINKED[widgetData.linkId].push(widgetInner)
}
// store widget by path and encode preArgs for perfect cross-app sync
if (widgetData.path)  {
var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path
if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = []
WIDGETS_BY_PATH[pathref].push(widgetInner)
}
parent[0].appendChild(widgetContainer[0])
}
// Editor needs to get the container object
if (data && data.length==1) return widgetContainer
}

142
browser/js/app/sidepanel.js Normal file
View file

@ -0,0 +1,142 @@
var actions = require('./actions'),
icon = require('./utils').icon
var data = [
{
actions: [
{
title:'Fullscreen (F11)',
action:actions.toggleFullscreen
}
]
},
{
title: icon('sliders') + '&nbsp; State',
actions: [
{
title:'Store',
action:actions.stateQuickSave
},
{
title:'Recall',
action:actions.stateQuickLoad,
class:'disabled quickload'
},
{
title:'Send All',
action:actions.stateSend
},
{
title:'Import',
action:actions.stateLoad
},
{
title:'Export',
action:actions.stateSave
}
]
},
{
title: icon('magic') + '&nbsp; Traversing gestures',
actions: [
{
title:'On',
action:actions.traversingEnable,
class:'traversingEnable'
},
{
title:'Off',
action:actions.traversingDisable,
class:'traversingDisable on'
}
]
},
{
title: icon('edit') + '&nbsp; Editor',
class:'editor',
actions: [
{
title:'On',
action:actions.editorEnable,
class:'enable-editor'
},
{
title:'Off',
action:actions.editorDisable,
class:'on disable-editor'
},
{
title:'Root',
class:'editor-root disabled'
},
{
title:'Load',
action:actions.sessionBrowse
},
{
title:'Save',
action:actions.sessionSave
}
]
},
]
var sidepanel = function(data){
var bindAction = function(el,callback) {
el.click(function(){callback()})
}
var html = $('<ul id="options"></ul>')
for (i in data) {
var itemData = data[i]
var item = $('<li></li>'),
inner = $('<div></div>').appendTo(item)
wrapper = $('<div class="actions"></div>').appendTo(inner)
if (itemData.title) $('<div class="title">'+itemData.title+'</div>').prependTo(wrapper)
if (itemData.class) inner.attr('class',itemData.class)
for (j in itemData.actions) {
var actionData = itemData.actions[j]
var el = $('<a class="btn">'+actionData.title+'</a>').appendTo(wrapper)
if (actionData.action) bindAction(el, actionData.action)
if (actionData.class) el.addClass(actionData.class)
}
item.appendTo(html)
}
return html
}(data)
var toggle = function(){
$(`<li><a id="open-toggle">${icon('navicon')}</a></li>`).appendTo('.navigation.main ul').click(function(e){
var t = 0
if (!$('#sidepanel').hasClass('sidepanel-open')) t = 250
$('#open-toggle, #sidepanel').toggleClass('sidepanel-open')
setTimeout(function(){
$('#container').toggleClass('sidepanel-open')
},t)
}).on('mousedown touchstart',function(e){e.stopPropagation()})
// in case where are hot loading a session
if ($('#sidepanel').hasClass('sidepanel-open')) {
$('#open-toggle, #container').addClass('sidepanel-open')
}
}
module.exports = {
init:function(){
$('#sidepanel').append(sidepanel)
toggle()
},
createToggle:toggle
}

70
browser/js/app/ui.js Normal file
View file

@ -0,0 +1,70 @@
var actions = require('./actions'),
icon = require('./utils').icon
var sidepanel = require('./sidepanel').init
// Tabs...
var tabs = function() {
$('#container').click(function(e){
var link = $(e.target)
if (!link.is('li[data-tab]') || link.hasClass('on')) return
var id = link.data('tab')
link.addClass('on')
var previous = link.siblings('.on').removeClass('on').data('tab')
// TABS[id].tab.appendTo(TABS[id].parent)
TABS[id].parent[0].appendChild(TABS[id].tab[0])
$(previous).detach()
$(id).find('li[data-tab]:first-child, li.parent + li[data-tab]').each(function(){
if (!$(this).siblings('.on').length) $(this).click()
})
})
$('li[data-tab]').first().click()
}
// horizontal scrolling & zoom with mousewheel
// if shift is pressed (native), or if there is no vertical scrollbar,
// or if mouse is on h-scrollbar
var scrollbarHeight = 20
var scrolls = function(){
$('html').on('mousewheel.zoom',function(e) {
// console.log(e)
if (e.ctrlKey) {
e.preventDefault()
if (e.originalEvent.deltaY==0) return
var d = -e.originalEvent.deltaY/(10*Math.abs(e.originalEvent.deltaY))
PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
document.documentElement.style.setProperty("--pixel-scale",'')
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
}
})
$(document).on('keydown.resetzoom', function(e){
if (e.keyCode==96||e.keyCode==48) {
PXSCALE = INITIALZOOM
document.documentElement.style.setProperty("--pixel-scale",'')
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
}
})
}
module.exports = {
init: function(){
sidepanel()
tabs()
scrolls()
},
tabs:tabs,
scrolls:scrolls
}

39
browser/js/app/utils.js Normal file
View file

@ -0,0 +1,39 @@
module.exports = {
createPopup: function(title,content) {
var popup = $(`
<div class="popup">
<div class="popup-wrapper">
<div class="popup-title">${title}<span class="closer">${module.exports.icon('remove')}</span></div>
<div class="popup-content"></div>
</div>
</div>`),
closer = popup.find('.popup-title .closer')
closer.click(function(){
popup.close()
})
popup.close = function(){
$(document).unbind('.popup')
popup.remove()
}
popup.find('.popup-content').append(content)
$('body').append(popup)
$(document).on('keydown.popup', function(e){
if (e.keyCode==27) popup.close()
})
return popup
},
icon: function(i) {
return `<i class="fa fa-fw fa-${i}"></i>`
}
}

80
browser/js/app/widgets.js Normal file
View file

@ -0,0 +1,80 @@
var widgets = {
// sliders
fader: require('./widgets/fader'),
knob: require('./widgets/knob'),
// buttons
toggle: require('./widgets/toggle'),
switch: require('./widgets/switch'),
push: require('./widgets/push'),
// pads
xy: require('./widgets/xy'),
rgb: require('./widgets/rgb'),
// matrices
multitoggle: require('./widgets/multitoggle'),
multipush: require('./widgets/multipush'),
multifader: require('./widgets/multifader'),
// plots
led: require('./widgets/led'),
plot: require('./widgets/plot'),
visualizer: require('./widgets/visualizer'),
meter: require('./widgets/meter'),
text: require('./widgets/text'),
// containers
strip: require('./widgets/strip'),
panel: require('./widgets/panel'),
}
module.exports.categories = {
'Sliders':['fader','knob'],
'Buttons':['toggle','push','switch'],
'Pads':['xy','rgb'],
'Matrices':['multifader','multitoggle','multipush'],
'Plots':['plot','visualizer','led','meter','text'],
'Containers':['panel','strip']
}
module.exports.widgetOptions = function(){
var r = {}
for (i in widgets) {
r[i] = widgets[i].options
}
return r
}()
module.exports.createWidget = function(){
var r = {}
for (i in widgets) {
r[i] = widgets[i].create
}
return r
}()
module.exports.sync = function() {
$('body').off('sync.global').on('sync.global',function(e,id,widget,linkId){
// Widget that share the same id will update each other
// without sending any extra osc message
if (WIDGETS[id] && WIDGETS[id].length>1) {
var v = widget.getValue()
for (i in WIDGETS[id]) {
if (!WIDGETS[id][i].is(widget) && WIDGETS[id][i].setValue) {
WIDGETS[id][i].setValue(v,false,false)
}
}
}
// widgets that share the same linkId will update each other.
// Updated widgets will send osc messages normally
if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
var v = widget.getValue()
for (i in WIDGETS_LINKED[linkId]) {
if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
WIDGETS_LINKED[linkId][i].setValue(v,true,false)
}
}
}
})
}

View file

@ -0,0 +1,252 @@
var utils = require('./utils'),
sizeToAngle = utils.sizeToAngle,
clip = utils.clip,
mapToScale = utils.mapToScale,
sendOsc = utils.sendOsc
module.exports.options = {
type:'fader',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
align:'center',
horizontal:false,
color:'auto',
css:'',
separator2:'behaviour',
absolute:false,
separator3:'osc',
range:{min:0,max:1},
logScale:false,
precision:2,
meter:false,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="fader-wrapper-outer">
<div class="fader-wrapper">
<div class="fader">
<div class="handle"><span></span></div>
<div class="pips"></div>
</div>
</div>
<div class="input"></div>
</div>
`),
handle = widget.find('.handle'),
knob = widget.find('span')[0],
wrapper = widget.find('.fader-wrapper'),
fader = widget.find('.fader'),
pips = widget.find('.pips'),
input = widget.find('.input').fakeInput({align:'center'}),
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
dimension = widgetData.horizontal?'width':'height',
axe = dimension=='height'?'X':'Y',
absolute = widgetData.absolute,
logScale = widgetData.logScale,
roundFactor = Math.pow(10,widgetData.precision)
if (widgetData.horizontal) {
container.addClass('horizontal')
delete widgetData.align
} else {
container.addClass('align-'+widgetData.align)
}
handle.size = 0
fader.size = 0
wrapper.size = 0
if (widgetData.meter) {
var parsewidgets = require('../parser').widgets
var data = {
type:'meter',
id: widgetData.id + '#meter',
label:false,
horizontal:widgetData.horizontal,
range:widgetData.range,
logScale:widgetData.logScale,
path:widgetData.path + '/meter',
preArgs:widgetData.preArgs
}
var element = parsewidgets([data],fader)
element[0].classList.add('not-editable')
}
var range = {}
for (k in widgetData.range) {
if (k=='min') {
range[0]=widgetData.range[k]
} else if (k=='max') {
range[100]=widgetData.range[k]
} else {
range[parseInt(k)]=widgetData.range[k]
}
}
var pipsInner = ''
for (var i=0;i<=100;i++) {
var piptext = range[i]!=undefined?`<span>${Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]}</span>`:'',
add = `
<div class="pip ${range[i]!=undefined?'val':''}">${piptext}${piptext}</div>
`
pipsInner = dimension=='height'?
add + pipsInner:
pipsInner + add
}
pips[0].innerHTML = pipsInner
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
fader.resize(function(){
fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
})
wrapper.on('mousewheel',function(e){
if (e.originalEvent.wheelDeltaX) return
e.preventDefault()
e.stopPropagation()
var divider = e.ctrlKey?4:.25
handle.size = clip(handle.size+e.originalEvent.wheelDelta/(fader.size*divider),[0,100])
widget.updateUi(handle.size)
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
var off = 0
wrapper.on('draginit',function(e,data){
if (absolute || TRAVERSING) {
var d = (dimension=='height')?
((fader.size-data.offsetY+(wrapper.size-fader.size)/2) * 100 / fader.size):
(data.offsetX - (wrapper.size-fader.size)/2) * 100 / fader.size
d = clip(d,[0,100])
widget.updateUi(d)
handle.size = d
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
off = handle.size
})
wrapper.on('drag',function(e,data){
e.stopPropagation()
if (TRAVERSING) return
var d = (dimension=='height')?-data.deltaY:data.deltaX
d = clip(d*100/fader.size+off,[0,100])
widget.updateUi(d)
handle.size = d
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
widget.updateUi = function(v){
var r = sizeToAngle(v)
handle[0].setAttribute('style','transform:rotate'+axe+'('+ r +'deg)')
knob.setAttribute('style','transform:rotate'+axe+'('+ (-r) +'deg)')
}
widget.getValue = function(){
var h = clip(handle.size,[0,100])
for (var i=0;i<rangeKeys.length-1;i++) {
if (h <= rangeKeys[i+1] && h >= rangeKeys[i]) {
return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
}
}
}
widget.setValue = function(v,send,sync) {
if (typeof v != 'number') return
var h,
v=clip(Math.round(v*roundFactor)/roundFactor,[rangeVals[0],rangeVals.slice(-1)[0]])
for (var i=0;i<rangeVals.length-1;i++) {
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],widgetData.precision,logScale,true)
break
}
}
widget.updateUi(h)
handle.size = h
widget.showValue(v)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.showValue = function(v) {
input.val(v+unit)
}
input.change(function(){
widget.setValue(parseFloat(input.val()),true,true)
})
widget.setValue(rangeVals[0])
return widget
}

View file

@ -0,0 +1,215 @@
var utils = require('./utils'),
clip = utils.clip,
mapToScale = utils.mapToScale,
sendOsc = utils.sendOsc
module.exports.options = {
type:'knob',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'behaviour',
absolute:false,
pan:false,
separator3:'osc',
range:{min:0,max:1},
logScale:false,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="knob-wrapper-outer">
<div class="knob-wrapper">
<div class="knob-mask">
<div class="knob"><span></span></div>
<div class="handle"></div>
<div class="round"></div>
</div>
<div class="pips">
<div class="pip min"></div>
<div class="pip max"></div>
</div>
</div>
<div class="input"></div>
</div>
`),
wrapper = widget.find('.knob-wrapper'),
mask = widget.find('.knob-mask'),
knob = widget.find('.knob'),
handle = widget.find('.handle'),
input = widget.find('.input').fakeInput({align:'center'}),
range = widgetData.range,
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
absolute = widgetData.absolute,
pan = widgetData.pan,
logScale = widgetData.logScale,
roundFactor = Math.pow(10,widgetData.precision)
var pipmin = Math.abs(range.min)>=1000?range.min/1000+'k':range.min,
pipmax = Math.abs(range.max)>=1000?range.max/1000+'k':range.max
widget.find('.pip.min').text(pipmin)
widget.find('.pip.max').text(pipmax)
mask.size = 0
wrapper.resize(function(){
var w = Math.floor(wrapper[0].offsetWidth*.58)
if (!w || mask.size==w) return
mask.size=w
mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
})
wrapper.on('mousewheel',function(e){
if (e.originalEvent.wheelDeltaX) return
e.preventDefault()
e.stopPropagation()
var divider = e.ctrlKey?48:8
knob.rotation = clip(knob.rotation+e.originalEvent.wheelDeltaY/divider,[0,270])
widget.updateUi(knob.rotation)
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
knob.rotation = 0
var offR = 0,
offX = 0,
offY = 0
wrapper.on('draginit',function(e,data){
if (absolute || TRAVERSING) {
var w = data.target.clientWidth,
h = data.target.clientHeight,
x = data.offsetX-w/2,
y = data.offsetY-h/2,
angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
r = angle<-90?angle+360:angle
r = (angle>=-90 && angle<-45)?270:r
r = clip(r,[0,270])
offX = x
offY = y
widget.updateUi(r)
knob.rotation = r
var v = widget.getValue(r)
widget.sendValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
widget.showValue(v)
}
offR = knob.rotation
})
wrapper.on('drag',function(e,data){
e.stopPropagation()
if (TRAVERSING) return
var r = clip(-data.deltaY*2+offR,[0,270])
if (absolute || data.ctrlKey || data.shiftKey) {
var w = data.target.clientWidth,
h = data.target.clientHeight,
x = data.deltaX + offX,
y = data.deltaY + offY,
angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
r = angle<-90?angle+360:angle
r = (angle>=-90 && angle<-45)?270:r
r = clip(r,[0,270])
}
widget.updateUi(r)
knob.rotation = r
var v = widget.getValue(r)
widget.sendValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
widget.showValue(v)
})
widget.updateUi = function(r) {
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
if (pan && r<135) {mask.removeClass('pan-right').addClass('pan-left')}
else if (pan) {mask.removeClass('pan-left').addClass('pan-right')}
if (r>180) {knob.addClass('d3')}
else if (r>90) {knob.removeClass('d3').addClass('d2')}
else {knob.removeClass('d3 d2')}
}
widget.getValue = function() {
return mapToScale(knob.rotation,[0,270],[range.min,range.max],widgetData.precision,logScale)
}
widget.showValue = function(v) {
input.val(v+unit)
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.setValue = function(v,send,sync) {
if (typeof v != 'number') return
var r = mapToScale(Math.round(v*roundFactor)/roundFactor,[range.min,range.max],[0,270],widgetData.precision,logScale,true)
knob.rotation = r
widget.updateUi(r)
var v = widget.getValue()
widget.showValue(v)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
if (send) widget.sendValue(v)
}
input.change(function(){
widget.setValue(parseFloat(input.val()),true,true)
})
widget.setValue(range.min)
return widget
}

View file

@ -0,0 +1,42 @@
var utils = require('./utils'),
mapToScale = utils.mapToScale
module.exports.options = {
type:'led',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
range:{min:0,max:1},
logScale:false,
preArgs:[],
path:'auto'
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="led">
<div><span></span></div>
</div>
`),
led = widget.find('span'),
range = widgetData.range
widget.setValue = function(v,send,sync){
if (typeof v != 'number') return
led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale,true))
}
widget.setValue(range.min)
return widget
}

View file

@ -0,0 +1,88 @@
var utils = require('./utils'),
sizeToAngle = utils.sizeToAngle,
clip = utils.clip,
mapToScale = utils.mapToScale
module.exports.options = {
type:'fader',
id:'auto',
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
horizontal:false,
color:'auto',
css:'',
separator3:'osc',
range:{min:0,max:1},
logScale:false,
path:'auto',
preArgs:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="meter">
<div class="level"></div>
</div>
`),
level = widget.find('.level'),
logScale = widgetData.logScale,
dimension = widgetData.horizontal?'width':'height',
axe = dimension=='height'?'X':'Y'
if (widgetData.horizontal) level.addClass('horizontal')
var range = {}
for (k in widgetData.range) {
if (k=='min') {
range[0]=widgetData.range[k]
} else if (k=='max') {
range[100]=widgetData.range[k]
} else {
range[parseInt(k)]=widgetData.range[k]
}
}
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
widget.updateUi = function(v){
var r = sizeToAngle(v)
level[0].setAttribute('style','transform:rotate'+axe+'('+ r +'deg)')
}
widget.setValue = function(v) {
if (typeof v != 'number') return
var h,
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
for (var i=0;i<rangeVals.length-1;i++) {
if (v <= rangeVals[i+1] && v >= rangeVals[i]) {
h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],2,logScale,true)
break
}
}
widget.updateUi(h)
}
widget.setValue(rangeVals[0])
return widget
}

View file

@ -0,0 +1,82 @@
module.exports.options = {
type:'multifader',
id:'auto',
separator0:'Matrix',
strips:2,
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
range:{min:0,max:1},
logScale:false,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var parsewidgets = require('../parser').widgets
var widget = $(`
<div class="matrix">
</div>\
`),
$document = $(document)
widget.value = []
for (var i=0;i<widgetData.strips;i++) {
var data = {
type:'fader',
id: widgetData.id + '#' + i,
label:i,
horizontal:false,
absolute:true,
range:widgetData.range,
logScale:widgetData.logScale,
precision:widgetData.precision,
path:widgetData.path + '/' + i,
preArgs:widgetData.preArgs,
target:widgetData.target
}
var element = parsewidgets([data],widget)
element[0].setAttribute('style',`width:${100/widgetData.strips}%`)
element[0].classList.add('not-editable')
element.find('.fader-wrapper').off('drag')
widget.value[i] = widgetData.range.min
}
widget.on('sync',function(e,id,w){
if (id==widgetData.id) return
widget.value[w.parent().index()] = w.getValue()
widget.trigger('sync',[widgetData.id,widget])
})
widget.getValue = function(){
return widget.value
}
widget.delegateDrag()
return widget
}

View file

@ -0,0 +1,76 @@
module.exports.options = {
type:'multipush',
id:'auto',
separator0: 'Matrix',
matrix: [2,2],
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
on:1,
off:0,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var parsewidgets = require('../parser').widgets
var widget = $(`
<div class="matrix">
</div>\
`),
$document = $(document)
widget.value = []
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
var data = {
type:'push',
id: widgetData.id + '#' + i,
label:i,
on:widgetData.on,
off:widgetData.off,
precision:widgetData.precision,
path:widgetData.path + '/' + i,
preArgs:widgetData.preArgs,
target:widgetData.target
}
var element = parsewidgets([data],widget)
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
element[0].classList.add('not-editable')
widget.value[i] = widgetData.off
}
widget.on('sync',function(e,id,w){
if (id==widgetData.id) return
widget.value[w.parent().index()] = w.getValue()
widget.trigger('sync',[widgetData.id,widget])
})
widget.getValue = function(){
return widget.value
}
widget.delegateDrag()
return widget
}

View file

@ -0,0 +1,76 @@
module.exports.options = {
type:'multitoggle',
id:'auto',
separator0: 'Matrix',
matrix: [2,2],
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
on:1,
off:0,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var parsewidgets = require('../parser').widgets
var widget = $(`
<div class="matrix">
</div>\
`),
$document = $(document)
widget.value = []
for (var i=0;i<widgetData.matrix[0]*widgetData.matrix[1];i++) {
var data = {
type:'toggle',
id: widgetData.id + '#' + i,
label:i,
on:widgetData.on,
off:widgetData.off,
precision:widgetData.precision,
path:widgetData.path + '/' + i,
preArgs:widgetData.preArgs,
target:widgetData.target
}
var element = parsewidgets([data],widget)
element[0].setAttribute('style',`width:${100/widgetData.matrix[0]}%`)
element[0].classList.add('not-editable')
widget.value[i] = widgetData.off
}
widget.on('sync',function(e,id,w){
if (id==widgetData.id) return
widget.value[w.parent().index()] = w.getValue()
widget.trigger('sync',[widgetData.id,widget])
})
widget.getValue = function(){
return widget.value
}
widget.delegateDrag()
return widget
}

View file

@ -0,0 +1,41 @@
module.exports.options = {
type:'panel',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
stretch:false,
color:'auto',
css:'',
separator2:'chilren',
widgets:[],
tabs:[]
}
module.exports.create = function(widgetData,container) {
var parser = require('../parser'),
parsewidgets = parser.widgets,
parsetabs = parser.tabs
var widget = $(`
<div class="panel">
</div>
`)
if (widgetData.stretch) widget.addClass('stretch')
if (widgetData.tabs.length) {
parsetabs(widgetData.tabs,widget)
widget.addClass('has-tabs')
} else {
parsewidgets(widgetData.widgets,widget)
}
return widget
}

View file

@ -0,0 +1,215 @@
var utils = require('./utils'),
mapToScale = utils.mapToScale
module.exports.options = {
type:'plot',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'plot',
points:[],
rangeX: {min:0,max:1},
rangeY: {min:0,max:1},
logScaleX: false,
logScaleY: false,
separator3:'osc',
path:'auto',
preArgs:[],
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="plot">
<canvas></canvas>
</div>
`),
canvas = widget.find('canvas'),
ctx = canvas[0].getContext('2d')
widget.data = []
widget.height = undefined
widget.width = undefined
widget.linkedWidgets = []
widget.visible = false
widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
widget.pips = {
x : {
min: Math.abs(widgetData.rangeX.min)>=1000?widgetData.rangeX.min/1000+'k':widgetData.rangeX.min,
max: Math.abs(widgetData.rangeX.max)>=1000?widgetData.rangeX.max/1000+'k':widgetData.rangeX.max
},
y : {
min: Math.abs(widgetData.rangeY.min)>=1000?widgetData.rangeY.min/1000+'k':widgetData.rangeY.min,
max: Math.abs(widgetData.rangeY.max)>=1000?widgetData.rangeY.max/1000+'k':widgetData.rangeY.max
}
}
if (typeof widgetData.points=='string') {
widget.linkedWidgets.push(widgetData.points)
} else if (typeof widgetData.points=='object') {
for (i in widgetData.points) {
for (j in widgetData.points[i]) {
if (typeof widgetData.points[i][j] == 'string') {
widget.linkedWidgets.push(widgetData.points[i][j])
}
}
}
}
canvas.resize(function(){
var width = canvas.width(),
height = canvas.height()
if (height==100 && width==100) return
if (!self.visible) {
widget.visible = true
canvas.addClass('visible')
widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
}
widget.height=height
widget.width=width
canvas[0].setAttribute('width',width)
canvas[0].setAttribute('height',height)
widget.fetchValues()
requestAnimationFrame(widget.draw)
})
widget.handleSync = function(e,id,w) {
if (widget.linkedWidgets.indexOf(id)==-1 || !WIDGETS[id]) return
widget.fetchValues()
requestAnimationFrame(widget.draw)
}
$('body').on('sync',widget.handleSync)
widget.draw = function(){
ctx.clearRect(0,0,widget.width,widget.height)
ctx.beginPath()
var first = true
var point = []
for (i in widget.data) {
var newpoint = widget.data[i].length?
[
mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
]
:
[
mapToScale(i,[0,widget.data.length-1],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
]
if (first) {
ctx.moveTo(newpoint[0],newpoint[1])
first = false
} else {
ctx.moveTo(point[0],point[1])
if (widgetData.logScaleX&&!widgetData.logScaleY) {
ctx.quadraticCurveTo(point[0], newpoint[1], newpoint[0], newpoint[1])
} else if (widgetData.logScaleY&&!widgetData.logScaleX) {
ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
} else {
ctx.lineTo(newpoint[0],newpoint[1])
}
}
ctx.arc(newpoint[0],newpoint[1],1,0,2*Math.PI)
point = newpoint
}
ctx.lineWidth = 1.5*PXSCALE
ctx.strokeStyle= widget.lineColor
ctx.stroke()
ctx.font = PXSCALE * 10 + 'px sans-serif'
ctx.fillStyle = widget.textColor
ctx.textBaseline = "bottom"
ctx.textAlign = 'left'
ctx.fillText(widget.pips.x.min,12*PXSCALE,widget.height)
ctx.textAlign = 'right'
ctx.fillText(widget.pips.x.max,widget.width-10,widget.height)
ctx.save()
ctx.translate(0, widget.height)
ctx.rotate(-Math.PI/2)
ctx.textBaseline = "top"
ctx.textAlign = 'left'
ctx.fillText(widget.pips.y.min,12*PXSCALE,2*PXSCALE)
ctx.textAlign = 'right'
ctx.fillText(widget.pips.y.max,widget.height-10*PXSCALE,2*PXSCALE)
ctx.rotate(Math.PI/2)
ctx.restore()
}
widget.fetchValues = function(){
var data = [],
points = widgetData.points
if (typeof points=='string' && WIDGETS[points]) {
data = WIDGETS[points][WIDGETS[points].length-1].getValue()
} else if (typeof points=='object') {
for (i in points) {
data[i] = []
for (k in [0,1]) {
if (typeof points[i][k] == 'string' && WIDGETS[points[i][k]]) {
data[i][k] = WIDGETS[points[i][k]][WIDGETS[points[i][k]].length-1].getValue()
} else {
data[i][k] = points[i][k]
}
}
}
}
if (data.length) widget.data = data
}
widget.setValue = function(v) {
widget.data = v
requestAnimationFrame(widget.draw)
}
return widget
}

View file

@ -0,0 +1,87 @@
var sendOsc = require('./utils').sendOsc
module.exports.options = {
type:'push',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
on:1,
off:0,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="push toggle">
<div class="light"</div>
</div>\
`),
$document = $(document),
light = widget.find('.light')[0]
widget.value = widget.find('span')
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit.push',function(){
widget.off('draginit.push')
widget.fakeclick()
})
widget.fakeclick = function(){
widget.setValue(widgetData.on,true,true)
$document.on('dragend.push',function(){
widget.setValue(widgetData.off,true,true)
$document.off('dragend.push')
widget.on('draginit.push',function(){
widget.off('draginit.push')
widget.fakeclick()
})
})
}
widget.getValue = function() {
return widget.hasClass('on')?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
var on = widgetData.on,
off= widgetData.off
if (v==on) {
widget.addClass('on')
if (send) widget.sendValue(v)
} else if (v==off) {
widget.removeClass('on')
if (send) widget.sendValue(v)
}
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
widget.sendValue = function(v) {
if (v===false) return
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.setValue()
return widget
}

View file

@ -0,0 +1,273 @@
var utils = require('./utils'),
clip = utils.clip,
mapToScale = utils.mapToScale,
hsbToRgb = utils.hsbToRgb,
rgbToHsb = utils.rgbToHsb,
sendOsc = utils.sendOsc
module.exports.options = {
type:'rgb',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
css:'',
separator2:'behaviour',
absolute:false,
separator3:'osc',
precision:0,
path:'auto',
preArgs:[],
split:false,
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="xy-wrapper rgb-wrapper">
<div class="xy rgb">
<div class="bg"></div>
<div class="handle"></div>
</div>
<div class="hue">
<div class="bg"></div>
<div class="handle"></div>
</div>
<div class="value">
<div class="input disabled">R</div><div class="input disabled">G</div><div class="input disabled">B</div>
<div class="input r"></div><div class="input g"></div><div class="input b"></div>
</div>
</div>`),
rgbHandle = widget.find('.rgb .handle'),
hueHandle = widget.find('.hue .handle'),
pad = widget.find('.xy'),
huePad = widget.find('.hue'),
rgbBg = pad.find('.bg')[0],
value = {r:widget.find('.r').fakeInput({align:'center'}),g:widget.find('.g').fakeInput({align:'center'}),b:widget.find('.b').fakeInput({align:'center'})},
absolute = widgetData.absolute,
split = widgetData.split?
typeof widgetData.split == 'object'?
widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
:false
pad.width = 0
pad.height = 0
rgbHandle.height = 0
rgbHandle.width = 0
hueHandle.width = 0
pad.resize(function(){
var width = pad.innerWidth(),
height = pad.innerHeight()
if (!width || (pad.height==height && pad.width==width)) return
pad.width = width
pad.height = height
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*rgbHandle.width/100}px, -${pad.height*rgbHandle.height/100}px,0)`)
})
var rgbOff = {x:0,y:0}
pad.on('draginit',function(e,data){
if (absolute || TRAVERSING) {
var h = ((pad.height-data.offsetY) * 100 / pad.height),
w = (data.offsetX * 100 / pad.width)
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
rgbHandle.height = h
rgbHandle.width = w
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
})
pad.on('drag',function(e,data){
e.stopPropagation()
if (TRAVERSING) return
var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
rgbHandle.height = h
rgbHandle.width = w
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
var hueOff = 0
huePad.on('draginit',function(e,data){
if (absolute || data.ctrlKey || data.shiftKey) {
var d = (data.offsetX * 100 / pad.width)
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
hueHandle.width = d
var h = clip(hueHandle.width*3.6,[0,360]),
rgb = hsbToRgb({h:h,s:100,b:100}),
v = widget.getValue()
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
hueOff = hueHandle.width
})
huePad.on('drag',function(e,data){
e.stopPropagation()
if (TRAVERSING) return
var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
hueHandle.width = w
var h = clip(hueHandle.width*3.6,[0,360]),
rgb = hsbToRgb({h:h,s:100,b:100}),
v = widget.getValue()
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
widget.getValue = function() {
var s = clip(rgbHandle.width,[0,100]),
l = clip(rgbHandle.height,[0,100]),
h = mapToScale(hueHandle.width,[0,100],[0,360],widgetData.precision),
rgb = hsbToRgb({h:h,s:s,b:l})
return [rgb.r,rgb.g,rgb.b]
}
widget.setValue = function(v,send,sync) {
if (!v || v.length!=3) return
for (i in [0,1,2]) {
v[i] = clip(v[i],[0,255])
}
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
var w = mapToScale(hsb.s,[0,100],[0,100],widgetData.precision),
h = mapToScale(hsb.b,[0,100],[0,100],widgetData.precision),
hueW = mapToScale(hsb.h,[0,360],[0,100],widgetData.precision)
rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*hueW/100}px,0,0)`)
rgbHandle.height = h
rgbHandle.width = w
hueHandle.width = hueW
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
widget.showValue(v)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:split?false:widgetData.target,
path:widgetData.path,
args:args,
precision:widgetData.precision,
})
if (split) {
sendOsc({
target:widgetData.target,
path:split.r,
args:widgetData.preArgs.concat(v[0]),
precision:widgetData.precision,
sync:false
})
sendOsc({
target:widgetData.target,
path:split.g,
args:widgetData.preArgs.concat(v[1]),
precision:widgetData.precision,
sync:false
})
sendOsc({
target:widgetData.target,
path:split.b,
args:widgetData.preArgs.concat(v[2]),
precision:widgetData.precision,
sync:false
})
}
}
widget.showValue = function(v) {
value.r.val(v[0])
value.g.val(v[1])
value.b.val(v[2])
}
value.r.change(function(){
var r = clip(value.r.val(),[0,255])
var v = widget.getValue()
widget.setValue([r,v[1],v[2]],true,true)
})
value.g.change(function(){
var g = clip(value.g.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],g,v[2]],true,true)
})
value.b.change(function(){
var b = clip(value.b.val(),[0,255])
var v = widget.getValue()
widget.setValue([v[0],v[1],b],true,true)
})
widget.setValue([0,0,0])
return widget
}

View file

@ -0,0 +1,38 @@
module.exports.options = {
type:'strip',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
horizontal:false,
color:'auto',
css:'',
separator2:'children',
widgets:[]
}
module.exports.create = function(widgetData,container) {
var parsewidgets = require('../parser').widgets
var widget = $(`
<div class="strip">
</div>
`)
if (widgetData.horizontal) {
container.addClass('horizontal')
} else {
container.addClass('vertical')
}
parsewidgets(widgetData.widgets,widget)
return widget
}

View file

@ -0,0 +1,85 @@
var sendOsc = require('./utils').sendOsc
module.exports.options = {
type:'switch',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
horizontal:false,
color:'auto',
css:'',
separator2:'osc',
values:{"Value 1":1,"Value 2":2},
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="switch">
</div>
`),
$document = $(document)
if (widgetData.horizontal) {
widget.addClass('horizontal')
}
widget.values = []
for (k in widgetData.values) {
widget.values.push(widgetData.values[k])
$('<div class="value">'+k+'</div>').data({value:widgetData.values[k]}).appendTo(widget)
}
widget.value = undefined
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit',function(e,dd){
var data = $(dd.target).data()
if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
})
widget.getValue = function() {
return widget.value
}
widget.setValue = function(v,send,sync) {
var i = widget.values.indexOf(v)
if (i!=-1) {
widget.value = widget.values[i]
widget.find('.on').removeClass('on')
widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
$(this).removeClass('ripple')
next()
})
if (send) widget.sendValue(widget.value)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
return widget
}

View file

@ -0,0 +1,38 @@
var utils = require('./utils'),
mapToScale = utils.mapToScale
module.exports.options = {
type:'text',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
preArgs:[],
path:'auto'
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="text">
</div>
`),
label = widgetData.label===false?widgetData.id:widgetData.label=='auto'?widgetData.id:widgetData.label=='auto'
widget.setValue = function(v,send,sync){
widget.text(v)
}
widget.setValue(label)
return widget
}

View file

@ -0,0 +1,86 @@
var sendOsc = require('./utils').sendOsc
module.exports.options = {
type:'toggle',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'osc',
on:1,
off:0,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="toggle">
<div class="light"></div>
</div>\
`),
$document = $(document),
light = widget.find('.light')[0]
widget.value = widget.find('span')
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit.toggle',function(){
widget.off('draginit.toggle')
widget.fakeclick()
})
widget.fakeclick = function(){
var newVal = widget.hasClass('on')?widgetData.off:widgetData.on
widget.setValue(newVal,true,true)
$document.on('dragend.toggle',function(){
$document.off('dragend.toggle')
widget.on('draginit.toggle',function(){
widget.off('draginit.toggle')
widget.fakeclick()
})
})
}
widget.getValue = function() {
return widget.hasClass('on')?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
if (v==widgetData.on) {
widget.addClass('on')
if (send) widget.sendValue(widgetData.on)
} else if (v==widgetData.off) {
widget.removeClass('on')
if (send) widget.sendValue(widgetData.off)
}
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
widget.sendValue = function(v) {
if (v===false) return
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.setValue()
return widget
}

View file

@ -0,0 +1,82 @@
module.exports = {
sendOsc: function(data){
IPC.send('sendOsc', data)
},
clip: function(value,range) {
var value = parseFloat(value)
if (isNaN(value)) value = range[0]
return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
},
// map a value from a scale to another input and output must be range arrays
mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
roundFactor = precision!=undefined?Math.pow(10,precision):100,
value = log?
revertlog?
(Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
:Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
:((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
value = Math.round(value*roundFactor)/roundFactor
return value
},
sizeToAngle: function(size) {
return module.exports.clip(Math.acos((size/100))*180/Math.PI,[0,90])
},
hsbToRgb: function (hsb) {
var rgb = {}
var h = hsb.h
var s = hsb.s*255/100
var v = hsb.b*255/100
if(s == 0) {
rgb.r = rgb.g = rgb.b = v
} else {
var t1 = v
var t2 = (255-s)*v/255
var t3 = (t1-t2)*(h%60)/60
if(h==360) h = 0
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
else {rgb.r=0; rgb.g=0; rgb.b=0}
}
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}
},
rgbToHsb: function (rgb) {
var hsb = {h: 0, s: 0, b: 0}
var min = Math.min(rgb.r, rgb.g, rgb.b)
var max = Math.max(rgb.r, rgb.g, rgb.b)
var delta = max - min
hsb.b = max
hsb.s = max != 0 ? 255 * delta / max : 0
if (hsb.s != 0) {
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
else hsb.h = 4 + (rgb.r - rgb.g) / delta
} else hsb.h = 0
hsb.h *= 60
if (hsb.h < 0) hsb.h += 360
hsb.s *= 100/255
hsb.b *= 100/255
return hsb
}
}

View file

@ -0,0 +1,177 @@
var utils = require('./utils'),
mapToScale = utils.mapToScale,
clip = utils.clip
module.exports.options = {
type:'visualizer',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'plot',
widgetId:'',
duration:1,
range: {min:0,max:1},
logScale: false,
separator3:'osc',
path:'auto',
preArgs:[],
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="plot">
<canvas></canvas>
</div>
`),
canvas = widget.find('canvas'),
ctx = canvas[0].getContext('2d')
widget.height = 0
widget.width = 0
widget.visible = false
widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
widget.pips = {
min: Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min,
max: Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
}
widget.length = Math.round(clip(60*widgetData.duration,[8,4096]))
widget.data = new Array(widget.length)
widget.value = widgetData.range.min
canvas.resize(function(){
var width = canvas.width(),
height = canvas.height()
if (height==100 && width==100) return
if (!self.visible) {
widget.visible = true
canvas.addClass('visible')
widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
}
widget.height=height
widget.width=width
canvas[0].setAttribute('width',width)
canvas[0].setAttribute('height',height)
requestAnimationFrame(widget.draw)
})
widget.handleSync = function(e,id,w) {
if (widgetData.widgetId!=id || !WIDGETS[id]) return
widget.startLoop()
}
$('body').on('sync',widget.handleSync)
widget.cancel = false
widget.loop = false
widget.startLoop = function(){
if (widget.cancel) clearTimeout(widget.cancel)
widget.cancel = setTimeout(function(){
clearInterval(widget.loop)
widget.loop = false
widget.cancel = false
},1000*widgetData.duration)
if (widget.loop) return
widget.loop = setInterval(function(){
widget.fetchValue()
widget.draw()
},1000*widgetData.duration/widget.length)
}
widget.draw = function(){
ctx.clearRect(0,0,widget.width,widget.height)
ctx.beginPath()
var first = true
var point = []
for (var i=widget.length-1;i>=0;i=i-1) {
var newpoint = [
mapToScale(i,[0,widget.length-1],[15*PXSCALE,widget.width-15*PXSCALE],1),
mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15*PXSCALE,15*PXSCALE],1,widgetData.logScale,true),
]
if (first) {
ctx.moveTo(newpoint[0],newpoint[1])
first = false
} else {
if (widgetData.logScale) {
ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
} else {
ctx.lineTo(newpoint[0],newpoint[1])
}
}
point = newpoint
}
ctx.lineWidth = 1.5*PXSCALE
ctx.strokeStyle= widget.lineColor
ctx.stroke()
ctx.font = PXSCALE * 10 + 'px sans-serif'
ctx.fillStyle = widget.textColor
ctx.save()
ctx.translate(0, widget.height)
ctx.rotate(-Math.PI/2)
ctx.textBaseline = "top"
ctx.textAlign = 'left'
ctx.fillText(widget.pips.min,12*PXSCALE,2*PXSCALE)
ctx.textAlign = 'right'
ctx.fillText(widget.pips.max,widget.height-10*PXSCALE,2*PXSCALE)
ctx.rotate(Math.PI/2)
ctx.restore()
}
widget.fetchValue = function(){
var id = widgetData.widgetId
if (typeof id == 'string' && WIDGETS[id]) {
var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
widget.data.push(v)
widget.value = v
} else {
widget.data.push(widget.value)
}
widget.data.splice(0,1)
}
widget.setValue = function(v) {
widget.value = v
widget.startLoop()
}
return widget
}

View file

@ -0,0 +1,197 @@
var utils = require('./utils'),
clip = utils.clip,
mapToScale = utils.mapToScale,
sendOsc = utils.sendOsc
module.exports.options = {
type:'xy',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'behaviour',
absolute:false,
separator3:'osc',
rangeX:{min:0,max:1},
rangeY:{min:0,max:1},
logScaleX:false,
logScaleY:false,
precision:2,
path:'auto',
preArgs:[],
split:false,
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="xy-wrapper">
<div class="xy">
<div class="handle"></div>
</div>
<div class="value">
<div class="input disabled">X</div><div class="input disabled">Y</div>
<div class="input x"></div><div class="input y"></div>
</div>
</div>
`),
handle = widget.find('.handle'),
pad = widget.find('.xy'),
value = {x:widget.find('.x').fakeInput({align:'center'}),y:widget.find('.y').fakeInput({align:'center'})},
range = {x:widgetData.rangeX,y:widgetData.rangeY},
absolute = widgetData.absolute,
split = widgetData.split?
typeof widgetData.split == 'object'?
widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
:false;
logScaleX = widgetData.logScaleX,
logScaleY = widgetData.logScaleY,
roundFactor = Math.pow(10,widgetData.precision)
if (widgetData.height!='auto') widget.addClass('manual-height')
pad.width = 0
pad.height = 0
handle.height = 0
handle.width = 0
pad.resize(function(){
var width = pad.innerWidth(),
height = pad.innerHeight()
if (!width || (pad.height==height && pad.width==width)) return
pad.width = width
pad.height = height
widget.updateUi(handle.width,handle.height)
})
var off = {x:0,y:0}
pad.on('draginit',function(e,data){
if (absolute || TRAVERSING) {
var h = ((pad.height-data.offsetY) * 100 / pad.height),
w = (data.offsetX * 100 / pad.width)
widget.updateUi(w,h)
handle.height = h
handle.width = w
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
off = {x:handle.width,y:handle.height}
})
pad.on('drag',function(e,data){
e.stopPropagation()
if (TRAVERSING) return
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
widget.updateUi(w,h)
handle.height = h
handle.width = w
var v = widget.getValue()
widget.sendValue(v)
widget.showValue(v)
widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
})
widget.updateUi = function(w,h) {
handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
}
widget.getValue = function() {
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,logScaleX),
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,logScaleY)
return [x,y]
}
widget.setValue = function(v,send,sync) {
if (!v || v.length!=2) return
for (i in [0,1]) {
v[i] = clip(Math.round(v[i]*roundFactor)/roundFactor,[range[['x','y'][i]].min,range[['x','y'][i]].max])
}
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],widgetData.precision,logScaleX,true)
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],widgetData.precision,logScaleY,true),
widget.updateUi(w,h)
handle.height = h
handle.width = w
widget.showValue(v)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:split?false:widgetData.target,
path:widgetData.path,
args:args,
precision:widgetData.precision,
})
if (split) {
sendOsc({
target:widgetData.target,
path:split.x,
args:widgetData.preArgs.concat(v[0]),
precision:widgetData.precision,
sync:false
})
sendOsc({
target:widgetData.target,
path:split.y,
args:widgetData.preArgs.concat(v[1]),
precision:widgetData.precision,
sync:false
})
}
}
widget.showValue = function(v) {
value.x.val(v[0])
value.y.val(v[1])
}
value.x.change(function(){
var v = widget.getValue()
v[0] = clip(value.x.val(),[range.x.min,range.x.max])
widget.setValue(v,true,true)
})
value.y.change(function(){
var v = widget.getValue()
v[1] = clip(value.y.val(),[range.y.min,range.y.max])
widget.setValue(v,true,true)
})
widget.setValue([range.x.min,range.y.min])
return widget
}

View file

@ -0,0 +1,11 @@
WEBFRAME = false
// mainProcess & renderProcess communication engine
// electron's ipc module is not available here, we use socket.io as a replacement
var socket = require('socket.io-client')
IPC = socket.connect()
IPC.send = IPC.emit
require('./app')

6
browser/js/browser.js Normal file
View file

@ -0,0 +1,6 @@
WEBFRAME = require('web-frame')
// mainProcess & renderProcess communication engine
IPC = require('ipc-renderer')
require('./app')

View file

@ -0,0 +1,140 @@
// jQuery drag event handler
;(function($){
var $document = $(document)
$.event.special.drag = {
setup: function() {
var element = $(this),
previousEvent = null
var mousemove = function(e) {
e.preventDefault()
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.speedX + previousEvent.deltaX
e.deltaY = e.speedY + previousEvent.deltaY
element.trigger("drag",e)
previousEvent = e
}
var mouseup = function(e) {
$document.off("mouseup")
$document.off("mousemove")
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.deltaX + previousEvent.deltaX
e.deltaY = e.deltaY + previousEvent.deltaY
element.trigger("dragend", e)
}
var touchend = function(e) {
e.pageX = e.originalEvent.changedTouches[0].pageX
e.pageY = e.originalEvent.changedTouches[0].pageY
e.offsetX = e.pageX-getOffset(e.target).left
e.offsetY = e.pageY-getOffset(e.target).top
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.deltaX + previousEvent.deltaX
e.deltaY = e.deltaY + previousEvent.deltaY
element.trigger("dragend", e)
}
function getOffset(obj) {
var offsetLeft = 0
var offsetTop = 0
if (obj) {
do {
if (!isNaN(obj.offsetLeft)) {
offsetLeft += obj.offsetLeft - obj.scrollLeft
}
if (!isNaN(obj.offsetTop)) {
offsetTop += obj.offsetTop - obj.scrollTop
}
} while(obj = obj.offsetParent )
}
return {left: offsetLeft, top: offsetTop}
}
element.on("touchstart.drag mousedown.drag", function(e) {
previousEvent = e
if (!e.originalEvent.changedTouches) {
// mouse
$document.on("mousemove", mousemove)
$document.on("mouseup", mouseup)
} else {
// touch
e.pageX = e.originalEvent.changedTouches[0].pageX
e.pageY = e.originalEvent.changedTouches[0].pageY
e.offsetX = e.pageX-getOffset(e.target).left
e.offsetY = e.pageY-getOffset(e.target).top
}
e.speedX = 0
e.speedY = 0
e.deltaX = 0
e.deltaY = 0
element.trigger("draginit", e)
})
element.on("touchmove.drag", function(e) {
e.preventDefault()
e.pageX = e.originalEvent.targetTouches[0].pageX
e.pageY = e.originalEvent.targetTouches[0].pageY
e.speedX = previousEvent?e.pageX - previousEvent.pageX:0
e.speedY = previousEvent?e.pageY - previousEvent.pageY:0
e.deltaX = previousEvent?e.speedX + previousEvent.deltaX:0
e.deltaY = previousEvent?e.speedY + previousEvent.deltaY:0
e.offsetX = previousEvent&&!e.shiftKey?previousEvent.offsetX+e.speedX:e.pageX-getOffset(e.target).left
e.offsetY = previousEvent&&!e.shiftKey?previousEvent.offsetY+e.speedY:e.pageY-getOffset(e.target).top
// do now allow two touch points to drag the same element
if (e.originalEvent.targetTouches.length > 1) return
element.trigger("drag",e)
previousEvent = e
})
element.on("touchend.drag", touchend)
element.on("touchcancel.drag", touchend)
},
teardown: function() {
var element = $(this)
element.off(".drag")
}
}
$.fn.delegateDrag = function(action) {
if (action=='disable') {
this.off('.delegateDrag')
} else {
var target = null
this.on('drag.delegateDrag',function(ev,dd){
dd.target = dd.originalEvent&&dd.originalEvent.changedTouches?
document.elementFromPoint(dd.originalEvent.changedTouches[0].clientX, dd.originalEvent.changedTouches[0].clientY)
:dd.target
if (target!=dd.target) {
$(target).trigger('dragend',[dd])
$(dd.target).trigger('draginit',[dd])
} else {
$(dd.target).trigger('draginit',[dd])
}
target = dd.target
})
this.on('dragend.delegateDrag',function(){
target = null
})
}
return this
}
})(jQuery)

View file

@ -0,0 +1,91 @@
(function ($) {
$.fn.fakeInput = function(options) {
var settings = $.extend({
align:'left'
}, options );
var self= this,
canvas = $('<canvas></canvas>').appendTo(self),
ctx = canvas[0].getContext('2d')
self.value = undefined
self.height = undefined
self.width = undefined
self.color = undefined
self.center = settings.align == 'center'
self.visible = false
self.attr('tabindex',"0")
canvas.resize(function(e){
e.stopPropagation()
var width = canvas.width(),
height = canvas.height()
if (height==100 && width==100) return
if (!self.visible) {
self.visible = true
canvas.addClass('visible')
}
self.color = getComputedStyle(document.documentElement).getPropertyValue("--color-text")
self.height=height
self.width=width
canvas[0].setAttribute('width',width)
canvas[0].setAttribute('height',height)
self.val(self.value)
})
self.val = function(newVal) {
if (newVal==undefined) return self.value
self.value = newVal
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
ctx.clearRect(0,0,self.width,self.height)
ctx.font = PXSCALE * 13 + 'px Droid Sans'
ctx.textBaseline = "top"
ctx.fillStyle = self.color
if (self.center) {
ctx.textAlign = settings.align
ctx.fillText(newVal,self.width/2,0)
} else {
ctx.fillText(newVal,0,0)
}
}
self.on('click focus',function(){
self.attr('tabindex','-1')
var i = $('<input></input>')
.prependTo(self)
.val(self.value)
.focus()
.change(function(){
self.val($(this).val())
// $(this).remove()
})
i.blur(function(){
self.attr('tabindex','0')
i.remove()
$(document).off('mousedown.fakeInput touchstart.fakeInput')
})
$(document).on('mousedown.fakeInput touchstart.fakeInput',function(){
i.blur()
})
})
return self
}
})(jQuery)

5
browser/js/jquery/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,93 @@
/* jquery.resize
* based on jQuery resize event (@ "Cowboy" Ben Alman http://benalman.com/projects/jquery-resize-plugin/)
* just lighter and faster
*/
(function($){
var elems = [],
pollInterval = 250,
resizeTimeout
$.event.special.resize = {
setup: function() {
if (this===window) return false
var elem = this
// Add this element to the list of internal elements to monitor.
elems.push( elem )
// If this is the first element added, start the polling loop.
if ( elems.length === 1 ) {
resizePollingLoop()
}
},
teardown: function() {
if (this===window) return false
var elem = this
// Remove this element from the list of internal elements to monitor.
for (var i = elems.length - 1; i >= 0; i--) {
if(elems[i] == this){
elems.splice(i, 1)
break
}
}
if ( !elems.length ) {
clearTimeout(resizeTimeout)
}
},
add: function(handleObj) {
if (this===window) return false
// Save a reference to the bound event handler.
var old_handler = handleObj.handler
handleObj.handler = function(event,data) {
// Call the originally-bound event handler and return its result.
return old_handler.apply(this, arguments)
}
}
}
function resizePollingLoop() {
// yep, setTimeout, 'cuz requestAnimation doesn't seem to perform that well
resizeTimeout = window.setTimeout(function(){
// Iterate over all elements to which the 'resize' event is bound.
for (var i = elems.length - 1; i >= 0; i--) {
var elem = elems[i],
width = elem.offsetWidth,
height = elem.offsetHeight
if (!width) continue
var data = {
w:elem.resizedataw,
h:elem.resizedatah
}
// If element size has changed since the last time, update the element
// data store and trigger the 'resize' event.
if ( width != data.w || height != data.h ) {
elem.resizedataw = width
elem.resizedatah = height
$(elem).trigger('resize',[width,height])
}
}
// Loop.
resizePollingLoop()
}, pollInterval )
}
})(jQuery)

File diff suppressed because one or more lines are too long

268
browser/scss/_editor.scss Normal file
View file

@ -0,0 +1,268 @@
.form {
.input-wrapper {
display: flex;
margin-bottom:var(--gutter);
background:var(--color-bg);
align-items: center;
&:last-child {
margin-bottom:0;
}
label {
background: var(--color-fg);
flex-shrink: 0;
padding: 5rem;
border:1rem solid var(--color-bg);
}
.input, input {
background: var(--color-bg);
width:100%;
padding:5rem;
}
&.column {
flex-direction: column;
label {
width:100%;
padding:7rem;
margin-bottom: 0;
}
}
}
label {
display: block;
font-size: 10rem;
background: var(--color-faded);
}
.info {
color:var(--color-text-fade);
margin-bottom:10rem;
}
input, .input {
display:block;
border:0;
font:inherit;
color:var(--color-text);
width:100%;
&:focus {
border-color:var(--color-accent);
}
.btn {
background:var(--color-raised);
box-shadow: 0 0 0 1rem var(--color-bg);
}
}
.checkbox {
background:var(--color-raised);
cursor: pointer;
}
.select-wrapper {
position: relative;
width:100%;
&:after{
content:"\f107";
font-family: FontAwesome;
position: absolute;
padding:5rem;
right:0;
top:0;
font-size: 20rem;
}
}
select {
-webkit-appearance:none;
}
.submit {
margin-top:30rem;
}
.separator {
line-height: 30rem;
height: 30rem;
margin-bottom: 5rem;
position: relative;
display: flex;
align-items: center;
&:before, &:after {
content:"";
top:14rem;
width: 100%;
height: 1rem;
background: var(--color-text-fade);
}
span {
font-variant: small-caps;
position: relative;
display: block;
width:100%;
text-align:center;
}
}
}
.widget.editing {
z-index: 11!important;
overflow: visible;
}
.widget.editing:after, li.editing a:before, a.editing:before, .content.editing:before, #container.editing:before{
content:"";
z-index: 999;
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
border:1rem dashed var(--color-accent);
pointer-events: none;
}
.widget.editing:after {
right:-1rem;
bottom:-1rem;
}
.context-menu {
position:fixed;
z-index: 999999999;
background: var(--color-raised);
box-shadow: 0 0 4rem 0 var(--color-track);
.context-menu {
position: absolute;
left:100%;
top:0;
opacity:0;
pointer-events: none;
margin-left: 2rem;
&:before {
content:"";
position: absolute;
top:0;
bottom:0;
left:-2rem;
width:2rem;
}
}
> .item {
padding: 10rem 15rem 10rem 10rem;
position:relative;
cursor: pointer;
i {
margin-right:5rem;
width: 15rem;
text-align: center;
}
&:hover, &:focus {
> .context-menu {
pointer-events: auto;
opacity: 1;
}
background:var(--color-accent);
}
&.has-sub:before {
content:"\f105";
display: block;
font-family: FontAwesome;
float:right;
margin-right:-10rem;
padding-left: 10rem;
}
}
}
.ui-resizable-handle {
position: absolute;
z-index: 1000000;
display: flex;
justify-content: center;
align-items: center;
background: var(--color-accent);
width:20rem;
height:20rem;
border-radius:100%;
box-shadow: 0 0 4rem 0 var(--color-bg);
&:after {
content:"";
position: absolute;
top:-5rem;
right:-5rem;
left:-5rem;
bottom:-5rem;
}
&.ui-resizable-se {
content:"";
bottom: 5rem;
right: 5rem;
cursor: se-resize;
&:before {
content:"\f065";
font-family: FontAwesome;
transform:rotate(90deg)
}
}
&.ui-resizable-e {
top: 50%;
margin-top:-10rem;
right: 5rem;
cursor: e-resize;
&:before {
content:"\f051";
font-family: FontAwesome;
}
}
&.ui-resizable-s {
bottom: 5rem;
left: 50%;
margin-left:-10rem;
cursor: s-resize;
&:before {
content:"\f051";
font-family: FontAwesome;
transform: rotate(90deg);
}
}
}
.ui-helper {
border: 1rem dashed var(--color-accent);
min-width:30rem!important;
min-height:30rem!important;
z-index: 12!important;
opacity: 1!important;
&:after {
content:"";
display: block;
width:100%;
height:100%;
background: var(--color-accent);
opacity: .25;
}
}
.ui-draggable-handle:not(.label) {
position: absolute;
top: 5rem;
left: 5rem;
z-index: 100000;
height:20rem;
width: 20rem;
display: flex;
justify-content: center;
align-items: center;
border-radius:100%;
background: var(--color-accent);
box-shadow: 0 0 4rem 0 var(--color-bg);
&:before {
content:"\f0b2";
font-family: FontAwesome;
transform: rotate(45deg);
}
}
.ui-draggable-handle {
cursor: -webkit-grab;
&:active {
cursor:-webkit-grabbing;
}
}

161
browser/scss/_layout.scss Normal file
View file

@ -0,0 +1,161 @@
body {
background:var(--color-bg);
}
#container {
position: absolute;
top:0;
left:0;
bottom:0;
right:0;
display:flex;
flex-direction: column;
background:var(--color-bg);
padding:var(--gutter);
// transition:right .2s;
&.sidepanel-open {
right:var(--sidepanel-size);
}
}
.content {
height:100%;
overflow: hidden;
position: relative;
background:var(--color-fg);
padding:var(--gutter);
}
.tab {
position: absolute;
overflow: auto;
left:0;
right:0;
top:0;
bottom:0;
background:var(--color-bg);
&.has-tabs {
// border:$gutter*2 solid $color-fg;
// padding: $gutter;
display: flex;
flex-direction: column;
> .navigation {
background:var(--color-bg);
// padding: $gutter;
// margin-bottom: 0;
}
> .content {
background:none;
}
}
}
.navigation {
height:var(--nav-height);
margin-bottom: var(--gutter);
flex-shrink:0;
font-weight:bold;
text-transform: uppercase;
&.main {
li:last-child {
width:var(--nav-height);
max-width:var(--nav-height);
min-width:var(--nav-height);
i {
margin:0 auto;
}
}
}
ul {
list-style:none;
display: flex;
overflow: hidden;
height:100%;
li {
display:block;
min-width:0;
flex: 1;
cursor:pointer;
height:100%;
margin-right: 1rem;
&.parent {
max-width: 150rem;
width:auto;
position: relative;
padding-right: 1rem;
a {
background: var(--color-raised);
}
&:before {
content:"";
display: block;
position: absolute;
border-left:calc(0.5 * var(--nav-height)) solid var(--color-bg);
border-bottom: calc(0.5 * var(--nav-height)) solid transparent;
border-top: calc(0.5 * var(--nav-height)) solid transparent;
top:0;
right:calc(-0.5 * var(--nav-height) - 1rem);
z-index: 1;
}
&:after {
content:"";
display: block;
position: absolute;
border-left:calc(0.5 * var(--nav-height)) solid var(--color-raised);
border-bottom: calc(0.5 * var(--nav-height)) solid transparent;
border-top: calc(0.5 * var(--nav-height)) solid transparent;
top:0;
right:calc(1rem - 0.5 * var(--nav-height));
z-index: 2;
}
}
&:last-child {
margin-right:0;
}
a {
background: var(--color-fg);
pointer-events: none;
padding: 5rem;
height:100%;
display: flex;
align-items: center;
overflow:hidden;
text-align:center;
position:relative;
span {
display:block;
width:100%;
-webkit-mask: linear-gradient(to left, rgba(0, 0, 0, 0), #000000 10rem) no-repeat;
}
}
a:after {
content:"";
background:var(--color-accent);
position: absolute;
bottom:0;
left:0;
right:0;
height:2rem;
opacity: 0;
transition: all .2s;
transform: scale(0);
}
&.on a, .sidepanel-open {
position: relative;
background: var(--color-raised);
&:after {
opacity:1;
transform: scale(1);
}
}
}
.parent + li a {
padding-left: calc(5rem + 0.5 * var(--nav-height));
}
}
}

View file

@ -1,3 +1,4 @@
* {
margin:0;
padding:0;
@ -10,6 +11,4 @@
cursor: inherit;
-webkit-tap-highlight-color:transparent;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}

View file

@ -0,0 +1,29 @@
::-webkit-scrollbar {
width: 20rem;
height:20rem;
opacity:1;
}
::-webkit-scrollbar-track-piece {
background: var(--color-bg);
&:vertical {
border-left:var(--gutter) solid var(--color-bg);
}
&:horizontal {
border-top:var(--gutter) solid var(--color-bg);
}
}
::-webkit-scrollbar-corner {
background: transparent;
}
::-webkit-scrollbar-thumb {
background:var(--color-raised);
&:vertical {
border-left:var(--gutter) solid var(--color-bg);
}
&:horizontal {
border-top:var(--gutter) solid var(--color-bg);
}
}

View file

@ -0,0 +1,144 @@
#sidepanel {
position:absolute;
z-index: 999999;
width:var(--sidepanel-size);
border: calc(var(--gutter)*2) solid var(--color-fg);
top:0;
right:0;
bottom:0;
margin-right:calc(-1 * var(--sidepanel-size));
background:var(--color-fg);
transition:transform .25s, opacity .25s;
transform: translate3d(0,0,0);
opacity: 0;
overflow-y: auto;
overflow-x: visible;
&.sidepanel-open {
transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0);
opacity: 1;
}
#options {
position:absolute;
left:0;top:0;
right:0;bottom:0;
list-style:none;
li {
display:block;
margin-bottom:calc(var(--gutter)*2);
position: relative;
&:last-child {
margin: 0;
}
.btn + span {
position: absolute;
right:0rem;
top:0rem;
padding:8rem;
color:var(--color-text-fade);
&:hover {
color:var(--color-text);
}
}
ul {
padding: var(--gutter);
li {
margin-bottom: var(--gutter);
}
}
}
.editor .form {
margin-top: 10rem;
}
.help {
margin-top:10rem;
font-size: .75em;
text-align: center;
font-style: italic;
}
}
&::-webkit-scrollbar-track-piece {
background: var(--color-bg);
&:vertical {
border-left:calc(var(--gutter)*2) solid var(--color-fg);
}
}
&::-webkit-scrollbar-thumb {
background:var(--color-raised);
&:vertical {
border-left:calc(var(--gutter)*2) solid var(--color-fg);
}
}
}
.actions {
padding:1rem;
background:var(--color-bg);
display: flex;
align-items: stretch;
flex-wrap:wrap;
.title {
background: var(--color-faded);
min-width: 100%;
flex-grow: 2;
padding: 10rem;
position: relative;
&:before {
content:"";
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
box-shadow: 0 0 0 1rem;
color:var(--color-bg);
}
}
a {
min-width:33%;
flex-grow:4;
padding:10rem;
display: block;
text-align: center;
position: relative;
color:var(--color-text);
overflow: visible;
&.on {
pointer-events: none;
&:after {
opacity:1;
transform: scale(1);
}
}
&:before {
content:"";
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
box-shadow: 0 0 0 1rem;
color:var(--color-bg);
}
&:after {
content:"";
background:var(--color-accent);
position: absolute;
top:0;
left:0;
right:0;
height:2rem;
opacity: 0;
transition: all .2s;
transform: scale(0);
}
}
}

21
browser/scss/_vars.scss Normal file
View file

@ -0,0 +1,21 @@
:root {
--color-text:rgba(white,.8);
--color-text-fade:rgba(white,0.5);
--color-bg:darken(#2b2f37,5%); // secondary
--color-fg:lighten(#2b2f37,1%); // primary
--color-raised:lighten(#2b2f37,5%); // raised
--color-faded: darken(#2b2f37,1%); // raised
--color-track: lighten(#1a1d22,1%); // widgets unfilled value
--color-accent:#528bff;
--gutter:4rem;
--nav-height:40rem;
--sidepanel-size:300rem;
--pixel-scale:1;
}

110
browser/scss/_widgets.scss Normal file
View file

@ -0,0 +1,110 @@
.widget {
display:inline-block;
height:auto;
overflow: hidden;
position:relative;
vertical-align:top;
box-shadow: -0.5rem -0.5rem 0 0.5rem;
color:var(--color-bg);
border-right:1rem solid var(--color-bg);
border-bottom:1rem solid var(--color-bg);
background:var(--color-fg);
-webkit-tap-highlight-color:transparent;
min-height:30rem;
min-width:30rem;
display: inline-flex;
flex-direction: column;
> * {
color:var(--color-text)
}
&.absolute-position {
position: absolute;
z-index: 10;
}
&.nolabel {
> .label {
display:none;
}
}
.label {
padding:10rem 10rem;
text-overflow:ellipsis;
overflow:hidden;
text-align:center;
height:35rem;
max-height:35rem;
width: 100%;
background: var(--color-faded);
border-bottom:1rem solid var(--color-bg);
&.accent {
color:var(--color-accent);
}
}
.input {
width:100%;
height:30rem;
border:0;
background:transparent;
color:var(--color-text-fade);
display:block;
padding:7rem 5rem;
position: relative;
input {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
padding:7rem 5rem;
width: 100%;
font: inherit;
text-align:center;
border:0;
background: transparent;
color:var(--color-accent);
}
canvas {
width:100%;
height:100%;
opacity: 0;
transition: opacity .2s;
&.visible {
opacity:.8;
}
}
input + canvas {
visibility: hidden;
}
&:focus {
color:var(--color-accent);
}
&[disabled] {
color:var(--color-text-fade);
}
}
}
@import 'widgets/fader';
@import 'widgets/knob';
@import 'widgets/matrices';
@import 'widgets/pads';
@import 'widgets/plots';
@import 'widgets/toggle';
@import 'widgets/push';
@import 'widgets/switch';
@import 'widgets/strip';
@import 'widgets/panel';

228
browser/scss/style.scss Normal file
View file

@ -0,0 +1,228 @@
@import 'vars';
@import 'reset';
@import 'scrollbars';
@import 'layout';
@import 'editor';
@import 'sidepanel';
@import 'widgets';
input:focus::selection{
background:var(--color-accent);
color:var(--color-text);
}
input {
cursor: text;
}
html, body {
height:100%;
overflow:hidden;
position:relative;
}
html{
font-size: calc(var(--pixel-scale) * 1px);
}
body {
font-size:13rem;
line-height:16rem;
font-family:Droid Sans;
color:var(--color-text);
white-space:nowrap;
opacity:1;
cursor: default;
}
i {
font-size: 14rem!important;
}
.btn {
background: var(--color-raised);
display: block;
padding:15rem;
position: relative;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
cursor: pointer;
&.small {
padding:8rem;
padding-right: 15rem;
}
&.warning {
background:firebrick;
}
&.disabled {
pointer-events: none;
color:var(--color-text-fade);
}
&.align-center {
text-align: center
}
}
#lobby {
background: var(--color-bg);
position: absolute;
top:0;
left:0;
right: 0;
bottom:0;
z-index: 2;
border:1rem solid var(--color-track);
display: flex;
align-items: center;
justify-content: center;
overflow-y: auto;
padding:20rem;
.main {
width:600rem;
max-height:100%;
}
.header {
background: var(--color-raised);
padding:20rem;
font-weight:bold;
box-shadow: 0 0 0 1rem var(--color-track) inset;
white-space: nowrap;
text-overflow: ellipsis;
}
a {
padding-right:35rem;
overflow: hidden;
margin-top:10rem;
position: relative;
white-space: nowrap;
text-overflow: ellipsis;
span {
position: absolute;
right:0rem;
top:0rem;
padding:15rem;
color:var(--color-text-fade);
}
}
}
#loading {
position: absolute;
top:50%;
left:50%;
margin-top:-15rem;
text-align: center;
.spinner {
display: block;
margin: 0 auto;
height:30rem;
width:30rem;
border-radius: 50%;
border:2rem solid var(--color-track);
border-top-color:var(--color-accent);
animation: spin .5s linear infinite;
}
#status {
margin-top: 10rem;
display: inline-block;
}
}
@keyframes spin {
0% {transform: rotate(0deg);}
100% {transform: rotate(360deg);}
}
.popup {
position: fixed;
top:0;
left:0;
right:0;
bottom:0;
padding:10%;
display: flex;
align-items: center;
z-index:1000000;
&:before {
content: "";
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
background:var(--color-bg);
opacity: .5;
}
.popup-title {
position: relative;
padding:15rem;
background:var(--color-raised);
.closer {
position:absolute;
right:0rem;
top:0;
padding:15rem;
color:var(--color-text-fade);
cursor: pointer;
}
}
.popup-wrapper {
display: flex;
flex-direction: column;
align-items: stretch;
background:var(--color-fg);
width:auto;
max-width:600rem;
margin:0 auto;
position: relative;
overflow: hidden;
border:1rem solid var(--color-track);
.popup-content {
height:100%;
width:100%;
padding:10rem;
overflow-y:auto;
white-space: normal;
}
}
}

View file

@ -0,0 +1,257 @@
.fader-container {
width:100rem;
min-height: 200rem;
height:100%;
&.align-right .fader-wrapper {
.fader {
margin-left:calc(50% + 15rem);
&:before {
box-shadow: 20rem 0 0 35rem;
}
}
.meter-container {
-webkit-mask:none;
right:auto!important;
width:1rem;
}
}
&.align-left .fader-wrapper {
.fader {
margin-right:calc(50% + 15rem);
&:before {
box-shadow: -20rem 0 0 35rem;
}
}
.meter-container {
-webkit-mask:none;
left:auto!important;
width:1rem;
}
}
.input {
margin-top:-5rem;
}
.fader-wrapper-outer {
display: flex;
flex-direction: column;
flex:1;
}
.fader-wrapper {
padding:20rem;
flex:1;
overflow:hidden;
position: relative;
display: flex;
flex-direction: column;
cursor: -webkit-grab;
&:active {
cursor: -webkit-grabbing;
}
.fader {
width:4rem;
position: relative;
margin:0 auto;
pointer-events: none;
flex:1;
&:before {
content:"";
width:100%;
height:100%;
background:var(--color-track);
z-index: 1;
display:block;
box-shadow: 0 0 0 15rem;
color: var(--color-fg);
position: absolute;
}
.handle {
position: absolute;
bottom:0!important;
top:auto!important;
width:100%;
height:100%;
transform-origin: bottom;
max-height:100%;
max-width:100%;
background:var(--color-accent);
z-index: 3;
transform-style: preserve-3d;
backface-visibility: hidden;
span {
position: absolute;
bottom:0;
top:0;
width:100%;
height:100%;
transform-origin: top;
backface-visibility: hidden;
}
span:before {
content:"";
position: absolute;
top:-4rem;
left:-2rem;
height:8rem;
width:8rem;
background:var(--color-accent);
border:none!important;
border-radius: 100%!important;
}
span:after {
content:"";
position: absolute;
top:-10rem;
left:-8rem;
height:20rem;
width:20rem;
border:none!important;
border-radius: 100%!important;
background:var(--color-accent);
opacity: .2;
}
}
.meter-container {
position: absolute;
z-index: 2;
left:-12rem;
right:-12rem;
bottom:0;
top:0;
min-width: 0;
min-height: 0;
border:0;
box-shadow: none;
-webkit-mask:linear-gradient(to right,#000 1rem, rgba(0,0,0,0) 1rem, rgba(0,0,0,0) 27rem, #000 27rem);
opacity:0.75;
.meter {
margin:0;
}
}
}
.pips {
position: absolute;
top:0;
bottom:0;
left:50%;
z-index: 0;
.pip {
height:1%;
width:38rem;
margin-left:-19rem;
background: linear-gradient(var(--color-text),transparent 1rem);
&.val {
position: relative;
width:44rem;
margin-left:-22rem;
span {
position: absolute;
width:30rem;
display: block;
text-align: center;
font-size:11rem;
line-height: 12rem;
left:44rem;
top:-5.5rem;
color:var(--color-text-fade);
&:last-child {
left:auto;
right:44rem;
}
}
}
}
}
}
}
.fader-container.horizontal {
min-height: 80rem;
height: auto;
width:300rem;
flex-shrink: 0;
.fader-wrapper-outer {
position: relative;
top:auto;
justify-content: center;
overflow: hidden;
.fader-wrapper {
padding:20rem 20rem 35rem;
display: block;
flex:0;
flex-shrink: 0;
}
.fader {
width:100%;
left:auto;
top:50%;
height:4rem;
&:before {
box-shadow:none;
}
.handle {
height:100%important;
width:100%;
transform-origin: left;
span {
transform-origin: right;
}
span:before {
top:-2rem;
right:-4rem;
left:auto;
}
span:after {
top:-8rem;
right:-10rem;
left:auto
}
}
.meter-container {
top:-12rem;
left:0;
right:0;
bottom:auto;
height:1rem;
min-width: 0;
min-height: 0;
box-shadow: none;
-webkit-mask:none;
}
}
.pips {
top:14rem;left:0;
right:0;
font-size: 0;
}
.pip {
width:1%;
display: inline-block;
height:4rem;
margin-bottom:5rem;
margin-left:0;
background: linear-gradient(90deg,var(--color-text),transparent 1rem );
&.val {
width:1%;
height:10rem;
margin-left:0;
margin-bottom:0;
span {
top:15rem;
left:-15rem;
&:last-child {
display: none;
}
}
}
}
}
}

View file

@ -0,0 +1,189 @@
.knob-container {
width: 100rem;
align-items: center;
flex-shrink: 0;
.input {
margin-top:-5rem;
}
.knob-wrapper-outer {
width: 100%;
display: flex;
flex:1;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
.knob-wrapper {
margin:15rem auto 5rem;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
cursor: -webkit-grab;
&:active {
cursor: -webkit-grabbing;
}
.knob-mask {
width:58%;
padding-bottom:58%;
flex-shrink: 0;
border-radius:100%;
pointer-events: none;
position: relative;
&:before {
position:absolute;
top:0;left:0;
right:0;
bottom:0;
border-radius:100%;
border:4rem solid var(--color-track);
transform: rotate(45deg);
z-index:4;
}
&.pan-left {
&:before {
content:"";
border-left-color: transparent;
border-bottom-color: transparent;
}
.knob:after {
border-color: var(--color-track);
border-left-color: var(--color-accent);
border-top-color: var(--color-accent);
}
}
&.pan-right {
&:before {
content:"";
border-right-color: transparent;
border-top-color: transparent;
}
.knob:after {
border-color: var(--color-track);
border-right-color: var(--color-accent);
border-bottom-color: var(--color-accent);
}
}
&:after {
content:"";
position:absolute;
top:0rem;left:-3rem;
right:-3rem;
bottom:-2rem;
border-radius:100%;
border:12rem solid transparent;
border-bottom-color: var(--color-fg);
z-index:4;
}
}
.round {
position:absolute;
top:16rem;
left:16rem;
right:16rem;
bottom:16rem;
border-radius:100%;
background:var(--color-raised);
box-shadow: 0 2rem 0 0;
color:var(--color-faded);
}
.knob {
position:absolute;
top:0;left:0;
right:0;
bottom:0;
pointer-events: none;
transform:rotateZ(0deg);
backface-visibility: hidden;
z-index: 2;
&:after {
content:"";
position:absolute;
top:0;left:0;
right:0;
bottom:0;
border-radius:100%;
border:4rem solid var(--color-track);
border-bottom-color: var(--color-accent);
}
&.d2:after {
border-right-color: var(--color-accent);
}
&.d3:after {
border-top-color: var(--color-accent);
border-right-color: var(--color-accent);
}
}
.handle {
position:absolute;
top:0;left:0;
right:0;
bottom:0;
pointer-events: none;
transform:rotateZ(-45deg);
backface-visibility: hidden;
z-index: 5;
&:before {
content:"";
position: absolute;
top:50%;
left:-2rem;
margin-top:-4rem;
height:8rem;
width:8rem;
background:var(--color-accent);
border:none!important;
border-radius: 100%!important;
}
&:after {
content:"";
position: absolute;
top:50%;
margin-top:-10rem;
left:-8rem;
height:20rem;
width:20rem;
border:none!important;
border-radius: 100%!important;
background:var(--color-accent);
opacity: .2;
}
}
.pips {
width:100%;
}
.pip {
font-size:11rem;
color:var(--color-text);
pointer-events: none;
display:inline-block;
&.min {
width:50%;
text-align:center;
}
&.max {
width:50%;
text-align:center;
}
}
}
}
}

View file

@ -0,0 +1,49 @@
/* Multiple widgets (push|toggle|fader) matrix */
.multitoggle-container, .multipush-container, .multifader-container {
height:200rem;
width:200rem;
&.nolabel .matrix {
top:0;
}
}
.matrix {
flex:1;
overflow: auto;
background: var(--color-bg);
display: flex;
flex-wrap: wrap;
flex-direction: row;
margin-right:-1rem;
margin-bottom: -1rem;
> .widget {
min-height: 0;
min-width: 0;
margin:0!important;
.label {
background:none;
border:0;
}
}
}
.multifader-container {
.matrix {
padding:0!important;
align-items:stretch;
}
.widget {
height: auto;
}
.fader-wrapper {
padding:10rem 0 20rem!important;
.fader {
left:0!important;
.pips {
display:none;
}
}
}
}

View file

@ -0,0 +1,174 @@
.xy-container, .rgb-container {
width:200rem;
height:250rem;
flex-shrink: 0;
display: flex;
}
.xy-wrapper {
height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
.value {
width:100%;
border-top: 1rem solid var(--color-bg);
}
.input, input {
width:50%;
float:left;
height: 30rem;
text-align: center;
position: relative;
}
}
.xy {
position:relative;
width:auto;
height:100%;
overflow: hidden;
cursor: -webkit-grab;
background:var(--color-faded);
&:active {
cursor: -webkit-grabbing;
.handle:after,.handle:before {
transform: scale(1.5);
}
}
.handle {
position:absolute;
bottom:0;
left:0;
z-index:2;
pointer-events: none;
backface-visibility: hidden;
transform-origin: center;
transform:translate3d(0,0,0);
&:before {
content:"";
position: absolute;
top:-4rem;
right:-4rem;
height:8rem;
width:8rem;
background:var(--color-accent);
border:none!important;
border-radius: 100%!important;
}
&:after {
content:"";
position: absolute;
top:-10rem;
right:-10rem;
height:20rem;
width:20rem;
border:none!important;
border-radius: 100%!important;
background:var(--color-accent);
opacity: .2; }
}
}
.rgb-wrapper {
.input, input {
width:33.33%;
}
}
.rgb {
.bg {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
background-color: red;
opacity: .75;
&:before, &:after {
content:"";
position: absolute;
left:0;
top:0;
width: 100%;
height: 100%;
}
&:before {
background: linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
}
&:after {
background:linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%);
}
}
.handle {
&:before {
content:"";
position: absolute;
top:-4rem;
right:-4rem;
height:8rem;
width:8rem;
background:var(--color-text);
border:none!important;
border-radius: 100%!important;
}
&:after {
content:"";
position: absolute;
top:-10rem;
right:-10rem;
height:20rem;
width:20rem;
border:none!important;
border-radius: 100%!important;
background:var(--color-text);
}
}
}
.hue {
width:auto;
min-height:30rem;
overflow: hidden;
cursor: -webkit-grab;
position: relative;
flex-shrink: 0;
.bg {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
opacity: 0.5;
background:transparent linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
}
&:active {
cursor: -webkit-grabbing;
.handle:after {
transform: scale(1.5);
}
}
.handle {
position:absolute;
z-index:2;
left:0;
top:50%;
pointer-events: none;
transform: translate3d(0,0,0);
&:before {
content:"";
position: absolute;
top:-4rem;
right:-4rem;
height:8rem;
width:8rem;
border:none!important;
border-radius: 100%!important;
box-shadow: none;
background:var(--color-text);
}
}
}

View file

@ -0,0 +1,65 @@
.panel-container {
z-index: 2;
min-width: 200rem;
min-height: 200rem;
&.label {
position: absolute;
top:0;
left:0;
right:0;
width:auto;
}
::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece {
border-top: 1rem solid var(--color-bg);
}
&.nolabel .panel {
top:1rem;
}
.panel {
overflow: auto;
position: absolute;
top:35rem;
left:1rem;
right:1rem;
bottom:1rem;
background: var(--color-bg);
z-index: 1;
&.has-tabs {
display: flex;
flex-direction: column;
}
&.stretch {
display:flex;
justify-content: space-between;
> .widget {
width:100%;
}
}
> .navigation:before {
display:none;
}
}
.navigation {
border-top: 0;
background: transparent;
&:after {
background: var(--color-bg);
}
a.on {
border-color: var(--color-bg);
}
}
.content {
background: transparent;
}
}

View file

@ -0,0 +1,97 @@
.led-container {
width:100rem;
flex-shrink: 0;
.led {
display: flex;
align-items: center;
height: 100%;
padding:10rem 0;
overflow: hidden;
div {
border-radius: 100%;
width:calc(100% - 20rem);
padding-bottom:calc(100% - 20rem);
margin: 0 auto;
background:var(--color-track);
position: relative;
span {
position: absolute;
top:0;left:0;right:0;bottom:0;
border-radius: 100%;
display:block;
background-color:var(--color-accent);
&:after {
content:"";
border-radius:100%;
position: absolute;
top:-1rem;left:-1rem;right:-1rem;bottom:-1rem;
display:block;
border: 6rem solid var(--color-fg);
opacity: 0.8;
}
}
}
}
}
.plot-container, .visualizer-container {
min-height: 200rem;
min-width: 200rem;
.plot {
display: flex;
flex-direction: row;
flex:1;
position: relative;
}
canvas {
position: absolute;
top:0;left:0;
width:100%;
height: 100%;
opacity: 0;
transition: opacity .2s;
&.visible {
opacity:1;
}
}
}
.meter-container {
.meter {
display: flex;
flex-direction: row;
flex:1;
margin: 0 1rem 1rem;
background: var(--color-bg);
.level {
width:100%;
flex:1;
transform-origin: bottom;
background:var(--color-accent);
&.horizontal {
transform-origin: left;
}
}
}
}
.text-container {
.text {
flex: 1;
height:35rem;
padding: 10rem;
justify-content: center;
display: flex;
align-items: center;
background: var(--color-faded);
color:var(--color-accent);
}
}

View file

@ -0,0 +1,44 @@
.push-container {
width:100rem;
min-height: 65rem;
flex-shrink: 0;
padding:0!important;
background: var(--color-raised);
.label {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
height:auto;
max-height: initial;
border:0;
background: none!important;
text-align: center;
pointer-events:none;
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
}
cursor: pointer;
.push {
&.on {
background: var(--color-fg);
}
border-bottom:4rem solid var(--color-fg);
.light {
position: absolute;
left:auto;
background: var(--color-accent);
height:4rem;
width:4rem;
border-radius: 4rem;
overflow: hidden;
}
}
}

View file

@ -0,0 +1,71 @@
.strip-container {
width:100rem;
height:100%;
overflow: visible;
background: none;
> .strip {
height: 100%;
display: flex;
flex-direction: column;
> .widget {
width:auto;
margin:0;
box-shadow: none;
}
}
&.vertical {
border-bottom:0;
> .strip > .widget {
max-width: 100%;
border-right:0;
&:last-child {
border-bottom:0;
}
}
}
&.horizontal {
width:100%;
height:200rem;
display: flex;
border-right:0;
flex-direction: row;
> .strip {
flex-direction: row;
flex:1;
> .widget {
flex-shrink: initial;
width: 100%;
min-height: 100%;
max-height: 100%;
height:100%;
border-bottom:0;
&:last-child {
border-right:0;
}
}
}
> .label {
width:35rem;
height:100%;
border-bottom:0;
border-right:1rem solid var(--color-bg);
max-height: initial;
span {
transform: rotate(180deg);
display: block;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
-webkit-writing-mode:vertical-lr;
text-align: center;
height:100%;
}
}
}
}

View file

@ -0,0 +1,84 @@
.switch-container {
// height: 100%;
width:100rem;
flex-shrink: 0;
.switch {
height:100%;
width:100%;
cursor: pointer;
display: flex;
flex-direction:column;
align-items: stretch;
flex:1;
&.horizontal {
flex-direction:row;
.value {
padding:28rem 6rem 6rem 6rem;
text-align: center;
display: flex;
justify-content: center;
flex-direction: column;
border-top:0;
border-right:1rem solid var(--color-bg);
flex:1;
height:auto;
&:last-child {
border-right:0;
}
&:before {
left:50%;
top:8rem;
width:8rem;
height:8rem;
margin-left: -4rem;
margin-top:0;
}
}
}
.value {
background:var(--color-raised);
color:var(--color-text);
width:100%;
height:100%;
position: relative;
border-top: 1rem solid var(--color-bg);
padding:12rem 12rem 12rem 24rem ;
white-space: normal;
text-align: left;
word-break: break-all;
overflow: hidden;
border-bottom:2rem solid var(--color-faded);
display: flex;
flex-direction: column;
justify-content: center;
&:first-child {
border-top:0;
}
&:last-child {
margin-bottom:0;
}
&:before {
content:"";
position: absolute;
left:8rem;
top:50%;
width:8rem;
height:8rem;
margin-top: -4rem;
background: var(--color-track);
border-radius: 8rem;
}
&.on:before {
background: var(--color-accent);
}
}
}
}

View file

@ -0,0 +1,55 @@
.toggle-container {
width:100rem;
min-height: 65rem;
flex-shrink: 0;
padding:0!important;
background: var(--color-raised);
.label {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
height:auto;
max-height: initial;
border:0;
background: none!important;
text-align: center;
pointer-events:none;
display: flex;
justify-content: center;
align-items: center;
}
cursor: pointer;
}
.toggle {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
border-bottom:4rem solid var(--color-fg);
.light {
position: absolute;
left:4rem;
right:4rem;
top:4rem;
height:4rem;
pointer-events: none;
background: var(--color-accent);
&:after {
content:"";
width: 100%;
height: 100%;
display: block;
background: var(--color-track);
}
}
&.on .light:after {
display: none;
}
}

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

3842
examples/audio.js Normal file

File diff suppressed because it is too large Load diff

329
examples/plot.js Normal file
View file

@ -0,0 +1,329 @@
[
{
"label": "Plots and ploplots",
"widgets": [
{
"type": "fader",
"id": "fader_1",
"linkId": "",
"label": "auto",
"unit": "",
"left": "auto",
"top": "auto",
"width": "auto",
"height": 254,
"horizontal": false,
"css": "",
"absolute": false,
"range": {
"min": 0,
"max": 1
},
"logScale": false,
"precision": 2,
"path": "/fader_1",
"target": [],
"meter": false
},
{
"type": "fader",
"id": "fader_2",
"linkId": "",
"label": "auto",
"unit": "",
"left": "auto",
"top": "auto",
"width": "auto",
"height": 253,
"horizontal": false,
"css": "",
"absolute": false,
"range": {
"min": 0,
"max": 1
},
"logScale": false,
"precision": 2,
"path": "/fader_2",
"target": [],
"meter": false
},
{
"type": "fader",
"id": "fader_3",
"linkId": "",
"label": "auto",
"unit": "",
"left": "auto",
"top": "auto",
"width": "auto",
"height": 253,
"horizontal": false,
"css": "",
"absolute": false,
"range": {
"min": 0,
"max": 1
},
"logScale": false,
"precision": 2,
"path": "/fader_3",
"target": [],
"meter": false
},
{
"type": "fader",
"id": "fader_4",
"linkId": "",
"label": "auto",
"unit": "",
"left": "auto",
"top": "auto",
"width": "auto",
"height": 253,
"horizontal": false,
"css": "",
"absolute": false,
"range": {
"min": 0,
"max": 1
},
"logScale": false,
"precision": 2,
"path": "/fader_4",
"target": [],
"meter": false
},
{
"type": "plot",
"id": "plot_1",
"label": "plot (faders)",
"left": 400,
"top": 122,
"width": 200,
"height": 131,
"css": "",
"points": [
[
0,
"fader_1"
],
[
0.25,
"fader_2"
],
[
0.75,
"fader_3"
],
[
1,
"fader_4"
]
],
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 1
},
"logScaleX": false,
"logScaleY": false,
"path": "/plot_1"
},
{
"type": "visualizer",
"left": 400,
"top": 0,
"width": "auto",
"height": 122,
"css": "",
"id": "visualizer_(fader_1)",
"widgetId": "fader_1",
"duration": 1,
"range": {
"min": 0,
"max": 1
},
"logScale": false,
"label": "visualizer (fader1)",
"path": "/visualizer_(fader_1)"
},
{
"type": "rgb",
"id": "rgb_1",
"linkId": "",
"label": "auto",
"left": 0,
"top": 254,
"width": "auto",
"height": "auto",
"css": "",
"absolute": false,
"precision": 0,
"path": "/rgb_1",
"split": false,
"target": []
},
{
"type": "plot",
"left": 200,
"top": 253,
"width": 400,
"height": 251,
"css": "",
"points": "rgb_1",
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 255
},
"logScaleX": false,
"logScaleY": false,
"id": "plot_2",
"label": "plot_2 (rgb)",
"path": "/plot_2"
}
]
},
{
"label": "Multifader plot !",
"widgets": [
{
"type": "multifader",
"id": "multifader_1",
"strips": 10,
"label": "auto",
"unit": "",
"left": 0,
"top": 0,
"width": 557,
"height": 228,
"range": {
"min": 0,
"max": 1
},
"precision": 2,
"path": "/multifader_1",
"target": [],
"logScale": false,
"css": ""
},
{
"type": "plot",
"id": "plot_3",
"label": "plot (multifader)",
"left": 0,
"top": 228,
"width": 557,
"height": 220,
"points": "multifader_1",
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 1
},
"logScaleX": false,
"logScaleY": false,
"path": "/plot_3",
"css": "z-index:1"
},
{
"type": "multitoggle",
"id": "multitoggle_1",
"label": "auto",
"left": 557,
"top": 0,
"width": 209,
"height": 229,
"css": "",
"precision": 2,
"path": "/multifader_2",
"target": [],
"matrix": [
2,
2
],
"on": 1,
"off": 0
},
{
"type": "plot",
"left": 557,
"top": 228,
"width": 209,
"height": 220,
"css": "",
"label": "plot (toggles)",
"points": "multitoggle_1",
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 1
},
"logScaleX": false,
"logScaleY": false,
"id": "plot_4",
"path": "/plot_4"
}
]
},
{
"label": "Hacking",
"widgets": [
{
"type": "multifader",
"strips": 10,
"unit": "",
"left": 6,
"top": 17,
"width": 564,
"height": 267,
"css": "z-index:8;opacity:0",
"range": {
"min": 0,
"max": 1
},
"precision": 2,
"target": [],
"logScale": false,
"id": "multifader_2",
"label": "auto",
"path": "/multifader_2"
},
{
"type": "plot",
"left": 16,
"top": 41,
"width": 541,
"height": 220,
"points": "multifader_2",
"rangeX": {
"min": 0,
"max": 1
},
"rangeY": {
"min": 0,
"max": 1
},
"logScaleX": false,
"logScaleY": false,
"css": "z-index:1",
"label": "There is a transparent multifader above this plot, just touch it... incredible, isn't it ?",
"path": "/plot_6",
"id": "plot_7"
}
]
}
]

1856
examples/widgets.js Normal file

File diff suppressed because it is too large Load diff

1
index.js Normal file
View file

@ -0,0 +1 @@
require(__dirname+'/main/main.js')

128
main/callbacks.js Normal file
View file

@ -0,0 +1,128 @@
var vm = require('vm')
module.exports = function(settings,fs,ipc,osc,dialog) {
return {
ready: function(data,clientId) {
if (settings.read('theme')) ipc.send('applyStyle',settings.read('theme'),clientId)
if (settings.read('sessionFile')) this.sessionOpen({path:settings.read('sessionFile')},clientId)
var recentSessions = settings.read('recentSessions')
ipc.send('sessionList',recentSessions,clientId)
},
sessionBrowse: function(data) {
var sessionlist = settings.read('recentSessions'),
self = this
dialog.showOpenDialog(window,{title:'Load session file',defaultPath:settings.read('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){
if (file==undefined) {return}
settings.write('sessionPath',file[0].replace(file[0].split('/').pop(),''))
self.sessionOpen({path:file[0]})
})
},
sessionSave: function(data) {
dialog.showSaveDialog(window,{title:'Save current session',defaultPath:settings.read('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){
if (file==undefined) {return}
settings.write('sessionPath',file.replace(file.split('/').pop(),''))
if (file.indexOf('.js')==-1){file+='.js'}
fs.writeFile(file,data, function (err, data) {
if (err) throw err
console.log('The session was saved in '+file)
})
})
},
sessionAddToHistory: function(data) {
var sessionlist = settings.read('recentSessions')
// add session to history
sessionlist.unshift(data)
// remove doubles from history
sessionlist = sessionlist.filter(function(elem, index, self) {
return index == self.indexOf(elem)
})
// save history
settings.write('recentSessions',sessionlist)
},
sessionRemoveFromHistory: function(data) {
var sessionlist = settings.read('recentSessions')
sessionlist.splice(data,1)
settings.write('recentSessions',sessionlist)
},
sessionOpen: function(data,clientId) {
var file = data.file || (function(){try {return fs.readFileSync(data.path,'utf8')} catch(err) {return false}})(),
error = file===false&&data.path?'Session file "' + data.path + '" not found.':false,
session
try {
session = vm.runInNewContext(file)
} catch(err) {
error = err
}
if (!session) error= 'No session object returned'
if (!error) {
if (data.path) this.sessionAddToHistory(data.path)
ipc.send('sessionOpen',JSON.stringify(session),clientId)
} else {
ipc.send('error',{title:'Error: invalid session file',text:'<p>'+error+'</p>'})
}
},
sendOsc: function(data) {
var targets = []
if (settings.read('syncTargets') && data.sync!==false) Array.prototype.push.apply(targets, settings.read('syncTargets'))
if (data.target) Array.prototype.push.apply(targets, data.target)
for (i in targets) {
var host = targets[i].split(':')[0],
port = targets[i].split(':')[1]
if (port) osc.send(host,port,data.path,data.args,data.precision)
}
},
stateSave: function(data) {
dialog.showSaveDialog(window,{title:'Save current state to preset file',defaultPath:settings.read('presetPath').replace(settings.read('presetPath').split('/').pop(),''),filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){
if (file==undefined) {return}
settings.write('presetPath',file)
if (file.indexOf('.preset')==-1){file+='.preset'}
fs.writeFile(file,data, function (err, data) {
if (err) throw err
console.log('The current state was saved in '+file)
})
})
},
stateLoad: function(data,clientId) {
dialog.showOpenDialog(window,{title:'Load preset file',defaultPath:settings.read('presetPath').replace(settings.read('presetPath').split('/').pop(),''),filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){
if (file==undefined) {return}
settings.write('presetPath',file[0])
fs.readFile(file[0],'utf-8', function read(err, data) {
if (err) throw err
ipc.send('stateLoad',data,clientId)
})
})
},
fullscreen: function(data) {
window.setFullScreen(!window.isFullScreen())
}
}
}

41
main/main.js Normal file
View file

@ -0,0 +1,41 @@
var fs = require('fs'),
settings = require('./settings')(fs)
if (!settings.read('noGui')) {
var app = require('app'),
browserWindow = require('browser-window'),
dialog = require('dialog'),
ipc = require('ipc-main')
dialog.showErrorBox = function(title,err) {
console.log(title + ': ' + err)
}
app.commandLine.appendSwitch('--touch-events')
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit()
}
})
app.on('ready',function(){
var server = require('./server-electron')(settings,app,ipc,browserWindow),
osc = require('./osc')(ipc,settings),
callbacks = require('./callbacks')(settings,fs,ipc,osc,dialog)
server.bindCallbacks(callbacks)
})
} else {
var server = require('./server-express')(settings),
ipc = server.ipc,
osc = require('./osc')(ipc,settings),
callbacks = require('./callbacks')(settings,fs,ipc,osc,dialog)
server.bindCallbacks(callbacks)
}

47
main/osc.js Normal file
View file

@ -0,0 +1,47 @@
var osc = require('node-osc')
module.exports = function(ipc, settings) {
if (settings.read('oscInPort')) {
var oscServer = new osc.Server(settings.read('oscInPort'), '127.0.0.1')
oscServer.on('message', function (msg, rinfo) {
var data = {path:msg.shift(),args:msg}
if (data.args.length==1) data.args = data.args[0]
ipc.send('receiveOsc',data)
})
}
return {
send: function(host,port,path,args,precision) {
var client = new osc.Client(host, port)
var message = new osc.Message(path)
var numberType = precision==0?'integer':'float'
if (typeof args=='object') {
for (i in args) {
var arg = args[i]
if (typeof arg == 'number') {
message.append({type:numberType,value:arg})
} else {
message.append({type:'string',value:String(arg)})
}
}
} else {
if (typeof args == 'number') {
message.append({type:numberType,value:args})
} else {
message.append({type:'string',value:String(args)})
}
}
client.send(message, function () {
client.kill()
})
}
}
}

82
main/server-electron.js Normal file
View file

@ -0,0 +1,82 @@
var path = require('path')
module.exports = function(settings,app,ipc,browserWindow) {
window = new browserWindow({
width: 800,
height: 600,
icon: path.resolve(__dirname + '/../resources/images/logo.png'),
title:settings.read('appName'),
autoHideMenuBar:true,
backgroundColor:'#1a1d22',
// show:false
})
window.loadURL('file://' + __dirname + '/../browser/index.html')
window.on('closed', function() {
window = null
})
var Menu = require('menu')
Menu.setApplicationMenu(Menu.buildFromTemplate(
[
{
label: 'View',
submenu: [
{
label: 'Restart',
accelerator: 'CmdOrCtrl+R',
click: function(){
window.reload()
}
},
{
label: 'Toggle DevTools',
accelerator: 'F12',
click: function() { window.toggleDevTools(); }
},
{
label: 'Toggle Fullscreen',
accelerator: 'F11',
click: function() { window.setFullScreen(!window.isFullScreen()); }
}
]
},
]
))
// mainProcess > renderProcess ipc shorthand
ipc.send = function(name,data) {
window.webContents.send(name,data)
}
// ipc bindings
var bindCallbacks = function(callbacks) {
var bindCallback = function(i) {
ipc.on(i,function(event,data){
callbacks[i](data)
})
}
for (i in callbacks) {
bindCallback(i)
}
ipc.on('ready',function(){
window.show()
})
}
return {
ipc:ipc,
bindCallbacks:bindCallbacks
}
}

62
main/server-express.js Normal file
View file

@ -0,0 +1,62 @@
module.exports = function(settings) {
// Headless (noGui) mode
var express = require('express')(),
path = require('path'),
http = require('http'),
server = http.createServer(express),
io = require('socket.io')(),
ioWildcard = require('socketio-wildcard')(),
browserify = require('browserify'),
ipc = {}
express.get('/', function(req, res){
res.sendFile(path.resolve(__dirname + '/../browser/index-headless.html'))
})
express.get('*browser-headless.js', function(req, res){
browserify().add(path.resolve(__dirname + '/../browser' + req.path)).bundle().pipe(res);
})
express.get('*', function(req, res){
res.sendFile(path.resolve(__dirname + '/../browser' + req.path))
})
io.use(ioWildcard)
io.listen(server);
server.listen(settings.read('noGui'))
ipc.send = function(name,data,clientId) {
if (clientId) {
io.to(clientId).emit(name,data)
} else {
io.emit(name,data)
}
}
var bindCallbacks = function(callbacks) {
io.on('connection', function(socket) {
socket.on('*', function(e){
var name = e.data[0],
data = e.data[1]
if (callbacks[name]) callbacks[name](data,socket.id)
if (name=='sendOsc' && data.sync!==false) {
// synchronize all other connected clients
socket.broadcast.emit('receiveOsc',data)
}
});
});
}
console.log('Headless mode: app available at http://127.0.0.1:'+settings.read('noGui'))
return {
ipc:ipc,
bindCallbacks:bindCallbacks
}
}

62
main/settings.js Normal file
View file

@ -0,0 +1,62 @@
// This prevents argv parsing to be breaked when the app is packaged (executed without 'electron' prefix)
if (process.argv[1]&&process.argv[1].indexOf('-')==0) process.argv.unshift('')
var baseDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'],
configFile = require('path').join(baseDir, '.open-stage-control')
var argv = require('yargs')
.help('help').usage(`\nUsage:\n $0 [options]`).alias('h', 'help')
.options({
's':{alias:'sync',type:'array',describe:'synchronized hosts (ip:port pairs)'},
'l':{alias:'load',type:'string',describe:'session file to load'},
'p':{alias:'port',describe:'osc input port (for synchronization)'},
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'}
})
.check(function(a,x){if(a.port==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.sync==undefined || a.s.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Sync hosts must be ip:port pairs & port must be >= 1024'}})
.strict()
.argv
module.exports = function(fs) {
var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8'))} catch(err) {return {}}}(),
defaultConfig = {
presetPath : process.cwd(),
sessionPath: process.cwd(),
recentSessions: [],
appName: 'Open Stage Control',
syncTargets: argv.s || false,
oscInPort: argv.p || false,
sessionFile: argv.l || false,
noGui: argv.n || false,
theme: function(){
if (!argv.t) return
var style = []
for (i in argv.t) {
try {style.push(fs.readFileSync(__dirname + '/themes/' + argv.t[i] + '.css','utf-8'))}
catch(err) {
try {style.push(fs.readFileSync(argv.t[i],'utf-8'))}
catch(err) {
console.log('Theme "' + argv.t[i] + '" not found.')
}
}
}
return style
}()
}
return {
read:function(key){
var x = config[key] || defaultConfig[key]
return x
},
write:function(key,value) {
config[key] = value
fs.writeFile(configFile,JSON.stringify(config,null,4), function (err, data) {
if (err) throw err
})
}
}
}

10
main/themes/light.css Normal file
View file

@ -0,0 +1,10 @@
:root {
--color-text: rgba(0,0,0,0.7);
--color-text-fade: rgba(0,0,0,0.5);
--color-bg: #aaa;
--color-fg: #ddd;
--color-raised: #eee;
--color-faded: #ccc;
--color-track: #aaa;
--color-accent: #307aaa;
}

3
main/themes/noinput.css Normal file
View file

@ -0,0 +1,3 @@
.widget .input {
display: none;
}

9718
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,110 +1,48 @@
{
"name": "open-stage-control",
"productName": "Open Stage Control",
"description": "Libre and modular OSC / MIDI controller",
"version": "1.31.2",
"description": "A libre desktop OSC bi-directionnal control surface application.",
"version": "0.4.2",
"main": "index.js",
"author": {
"name": "Jean-Emmanuel Doucet",
"email": "jean-emmanuel@ammd.net"
"name": "Jean-Emmanuel Doucet / AMMD",
"email": "jeannot@ammd.net"
},
"dependencies": {
"node-osc": "1.2",
"yargs": "4.2.0",
"socket.io": "1.4.5",
"socket.io-client": "1.4.5",
"socketio-wildcard": "0.1.1",
"browserify": "13.0.0",
"express": "4.13.3",
"electron-prebuilt": "0.37.2"
},
"devDependencies": {
"node-sass": "^3.4.2",
"nodemon": "^1.9.1"
},
"optionalDependencies": {
"electron-installer-debian": "*",
"electron-packager": "5.2.1"
},
"scripts": {
"start": "electron .",
"build": "electron-packager . open-stage-control --platform=$PLATFORM --arch=$ARCH --out dist/ --icon=resources/images/logo --overwrite --ignore \"(dist|node_modules/electron.*)\"",
"deb32": "electron-installer-debian --src dist/open-stage-control-linux-ia32/ --arch i386 --dest dist/open-stage-control-linux-ia32/ --icon resources/images/logo.png",
"deb64": "electron-installer-debian --src dist/open-stage-control-linux-x64/ --arch amd64 --dest dist/open-stage-control-linux-x64/ --icon resources/images/logo.png",
"test": "npm run build",
"build-css": "node-sass --include-path browser/scss browser/scss/style.scss browser/css/style.css --output-style compressed",
"watch-css": "nodemon --watch browser/scss -e scss -x \"npm run build-css\""
},
"keywords": [
"osc",
"midi",
"interface",
"multi-touch"
],
"repository": {
"type": "git",
"url": "https://framagit.org/jean-emmanuel/open-stage-control"
"url": "https://github.com/jean-emmanuel/Open-Stage-Control"
},
"homepage": "http://openstagecontrol.ammd.net/",
"license": "GPL-3.0",
"dependencies": {
"@babel/core": "7.18.0",
"@babel/preset-env": "7.18.0",
"@electron/packager": "18.4.4",
"@electron/remote": "2.1.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"ace-builds": "1.39.0",
"ansi-html": "0.0.9",
"babelify": "10.0.0",
"balanced-match": "2.0.0",
"bonjour": "git+https://framagit.org/jean-emmanuel/bonjour.git",
"chokidar": "3.5.3",
"chroma-js": "2.4.2",
"core-js": "3.22.5",
"cpr": "3.0.1",
"deep-extend": "0.6.0",
"electron-localshortcut": "3.2.1",
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "1.0.2",
"env-paths": "2.2.1",
"eslint": "8.16.0",
"fastdom": "1.0.10",
"file-saver": "2.0.5",
"http-auth": "4.1.9",
"json5": "2.2.1",
"jsondiffpatch": "0.4.1",
"keyboardjs": "2.6.4",
"minimatch": "5.1.0",
"nanohtml": "1.10.0",
"nanoid": "3.3.4",
"nanomorph": "5.4.3",
"node-forge": "1.3.1",
"node-mouse": "0.0.2",
"nodemon": "2.0.16",
"nosleep.js": "0.12.0",
"open": "8.4.0",
"osc": "2.4.5",
"python-shell": "3.0.1",
"qrcode": "1.5.1",
"replacestream": "4.0.3",
"rollup": "4.50.1",
"rollup-plugin-copy": "3.5.0",
"rollup-plugin-license": "^3.6.0",
"rollup-plugin-node-externals": "^8.1.1",
"sass": "1.89.2",
"scope-css": "1.2.1",
"screenfull": "5.2.0",
"semver": "7.3.7",
"send": "0.18.0",
"sortablejs": "1.15.0",
"source-map-support": "0.5.21",
"stacktrace-js": "2.0.2",
"ua-parser-js": "2.0.7",
"ws": "8.6.0",
"yargs": "17.5.1"
},
"optionalDependencies": {
"electron": "36.9.5",
"electron-installer-debian": "3.1.0",
"electron-installer-redhat": "git+https://framagit.org/jean-emmanuel/electron-installer-redhat.git"
},
"scripts": {
"postinstall": "echo '\\033[36m=> Dependencies installed successfully. Run \"npm run build\" to build the assets.\\033[0m\n'",
"start": "electron app/",
"build": "npm run build-css && npm run build-js && echo '\\033[36m=> JS and CSS assets built successfully. Run \"npm run package\" to build an executable or \"npm start\" to run the app.\\033[0m\n'",
"package": "node scripts/package.js",
"package-node": "node scripts/package-node.js",
"deb64": "electron-installer-debian --src dist/open-stage-control-linux-x64/ --arch amd64 --dest dist/ --icon resources/images/logo.png",
"rpm64": "electron-installer-redhat --src dist/open-stage-control-linux-x64/ --arch x86_64 --dest dist/ --icon resources/images/logo.png",
"build-css": "node scripts/build-css.js",
"watch-css": "nodemon --watch src/scss -e scss -x \"npm run build-css -- --reload\"",
"build-js": "npm run build-launcher-js && npm run build-client-js && npm run build-server-js",
"build-client-js": "rollup -c scripts/client.rollup.config.js",
"watch-client": "npm run build-client-js -- --watch",
"build-server-js": "rollup -c scripts/server.rollup.config.js",
"watch-server": "npm run build-server-js -- --watch",
"build-launcher-js": "rollup -c scripts/launcher.rollup.config.js",
"watch-launcher": "npm run build-launcher-js -- --watch",
"build-docs": "rollup -c scripts/docs.rollup.config.js && node src/docs/widgets-reference.js > resources/docs/docs/widgets/properties-reference.md && cd resources && python3 -m mkdocs build",
"lint": "eslint src --ext mjs",
"test": "npm run lint && npm run build"
},
"engines": {
"node": ">=16"
}
"licence": "GPL-3.0"
}

View file

@ -1,11 +0,0 @@
# How to build the docs
```bash
# https://squidfunk.github.io/mkdocs-material/getting-started/
$ python3 -m pip install mkdocs-material
$ mkdocs serve # make docs available on http://127.0.0.1:8000
# or
$ mkdocs build # build docs in site/
```

View file

@ -1,898 +0,0 @@
[
[
"greeter_text",
"Ardour Control"
],
[
"osc_logo",
"/assets/favicon.png"
],
[
"strip_type_1",
1
],
[
"strip_type_2",
2
],
[
"strip_type_3",
4
],
[
"strip_type_4",
8
],
[
"strip_type_5",
16
],
[
"strip_type_6",
0
],
[
"strip_type_7",
0
],
[
"strip_type_8",
128
],
[
"strip_type_9",
0
],
[
"strip_type_10",
0
],
[
"trip_type_bitsum",
159
],
[
"bank_size",
8
],
[
"display_session_name",
1
],
[
"display_transport",
1
],
[
"display_monitor",
1
],
[
"display_trim",
1
],
[
"display_recbar",
1
],
[
"display_input",
1
],
[
"display_pan",
1
],
[
"display_expand",
1
],
[
"display_compact_faders",
0
],
[
"display_polarity_sel",
1
],
[
"display_trim_sel",
1
],
[
"display_recbar_sel",
1
],
[
"display_pan_sel",
1
],
[
"spacer",
-1
],
[
"connect",
0
],
[
"loading",
"<div class=\"spinner\"></div>"
],
[
"hidden_utils",
-1
],
[
"settings_tab",
-1
],
[
"sess_name",
" "
],
[
"shttl",
0
],
[
"zero",
0
],
[
"end",
0
],
[
"play",
0
],
[
"transport_stop",
0
],
[
"masterrec",
0
],
[
"time",
"00:00:00:00"
],
[
"chan_1",
1
],
[
"trim_label_1",
"Trim"
],
[
"trim_input_1",
0
],
[
"trim_knob_1",
0
],
[
"record_1",
0
],
[
"mon_1",
0
],
[
"disk_1",
0
],
[
"meter_1",
-193
],
[
"fader_1",
0
],
[
"fader_input_1",
0
],
[
"pan_1",
0.5
],
[
"mute_1",
0
],
[
"solo_1",
0
],
[
"sel_1",
0
],
[
"expand_1",
0
],
[
"chan_2",
2
],
[
"trim_label_2",
"Trim"
],
[
"trim_input_2",
0
],
[
"trim_knob_2",
0
],
[
"record_2",
0
],
[
"mon_2",
0
],
[
"disk_2",
0
],
[
"meter_2",
-193
],
[
"fader_2",
0
],
[
"fader_input_2",
0
],
[
"pan_2",
0.5
],
[
"mute_2",
0
],
[
"solo_2",
0
],
[
"sel_2",
0
],
[
"expand_2",
0
],
[
"chan_3",
3
],
[
"trim_label_3",
"Trim"
],
[
"trim_input_3",
0
],
[
"trim_knob_3",
0
],
[
"record_3",
0
],
[
"mon_3",
0
],
[
"disk_3",
0
],
[
"meter_3",
-193
],
[
"fader_3",
0
],
[
"fader_input_3",
0
],
[
"pan_3",
0.5
],
[
"mute_3",
0
],
[
"solo_3",
0
],
[
"sel_3",
0
],
[
"expand_3",
0
],
[
"chan_4",
4
],
[
"trim_label_4",
"Trim"
],
[
"trim_input_4",
0
],
[
"trim_knob_4",
0
],
[
"record_4",
0
],
[
"mon_4",
0
],
[
"disk_4",
0
],
[
"meter_4",
-193
],
[
"fader_4",
0
],
[
"fader_input_4",
0
],
[
"pan_4",
0.5
],
[
"mute_4",
0
],
[
"solo_4",
0
],
[
"sel_4",
0
],
[
"expand_4",
0
],
[
"chan_5",
5
],
[
"trim_label_5",
"Trim"
],
[
"trim_input_5",
0
],
[
"trim_knob_5",
0
],
[
"record_5",
0
],
[
"mon_5",
0
],
[
"disk_5",
0
],
[
"meter_5",
-193
],
[
"fader_5",
0
],
[
"fader_input_5",
0
],
[
"pan_5",
0.5
],
[
"mute_5",
0
],
[
"solo_5",
0
],
[
"sel_5",
0
],
[
"expand_5",
0
],
[
"chan_6",
6
],
[
"trim_label_6",
"Trim"
],
[
"trim_input_6",
0
],
[
"trim_knob_6",
0
],
[
"record_6",
0
],
[
"mon_6",
0
],
[
"disk_6",
0
],
[
"meter_6",
-193
],
[
"fader_6",
0
],
[
"fader_input_6",
0
],
[
"pan_6",
0.5
],
[
"mute_6",
0
],
[
"solo_6",
0
],
[
"sel_6",
0
],
[
"expand_6",
0
],
[
"master_label",
"Master"
],
[
"mastertrim_label",
"Trim"
],
[
"mastertrim_input",
0
],
[
"mastertrim",
0
],
[
"monitor",
-200
],
[
"monmute",
0
],
[
"mondim",
0
],
[
"monmono",
0
],
[
"monitor_modal",
0
],
[
"Master_meter",
-193
],
[
"Master",
0
],
[
"master_input",
0
],
[
"master_pan",
0.5
],
[
"mastermute",
0
],
[
"solocan",
0
],
[
"bank_dn",
0
],
[
"bank_up",
0
],
[
"mixer_tab",
-1
],
[
"sess_name",
" "
],
[
"shttl",
0
],
[
"zero",
0
],
[
"end",
0
],
[
"play",
0
],
[
"transport_stop",
0
],
[
"masterrec",
0
],
[
"time",
"00:00:00:00"
],
[
"select_name",
" sel"
],
[
"select_trim_label",
"Trim"
],
[
"select_trim_input",
0
],
[
"select_trim_knob",
0
],
[
"polarity_select",
0
],
[
"record_select",
0
],
[
"mon_select",
0
],
[
"disk_select",
0
],
[
"receives_panel",
0
],
[
"sends_panel",
0
],
[
"meter_select",
-193
],
[
"fader_select",
0
],
[
"fader_input_select",
0
],
[
"pan_select",
0.5
],
[
"mute_select",
0
],
[
"solo_select",
0
],
[
"expand_select",
0
],
[
"text_1",
"Plugins"
],
[
"push_6",
0
],
[
"master_label",
"Master"
],
[
"mastertrim_label",
"Trim"
],
[
"mastertrim_input",
0
],
[
"mastertrim",
0
],
[
"monitor",
-200
],
[
"monmute",
0
],
[
"mondim",
0
],
[
"monmono",
0
],
[
"monitor_modal",
0
],
[
"Master_meter",
-193
],
[
"Master",
0
],
[
"master_input",
0
],
[
"master_pan",
0.5
],
[
"mastermute",
0
],
[
"solocan",
0
],
[
"bank_dn",
0
],
[
"bank_up",
0
],
[
"track_tab",
-1
],
[
"root",
1
],
[
"chan_7",
7
],
[
"trim_label_7",
"Trim"
],
[
"trim_input_7",
""
],
[
"trim_knob_7",
0
],
[
"record_7",
0
],
[
"mon_7",
0
],
[
"disk_7",
0
],
[
"meter_7",
-193
],
[
"fader_7",
0
],
[
"fader_input_7",
0
],
[
"pan_7",
0.5
],
[
"mute_7",
0
],
[
"solo_7",
0
],
[
"sel_7",
0
],
[
"expand_7",
0
],
[
"chan_8",
8
],
[
"trim_label_8",
"Trim"
],
[
"trim_input_8",
""
],
[
"trim_knob_8",
0
],
[
"record_8",
0
],
[
"mon_8",
0
],
[
"disk_8",
0
],
[
"meter_8",
-193
],
[
"fader_8",
0
],
[
"fader_input_8",
0
],
[
"pan_8",
0.5
],
[
"mute_8",
0
],
[
"solo_8",
0
],
[
"sel_8",
0
],
[
"expand_8",
0
]
]

View file

@ -0,0 +1,29 @@
## Build from sources
**Requirements**
- [Node.js](https://nodejs.org/)
- [npm](https://www.npmjs.com/)
```bash
$ sudo apt-get install npm # install nodejs & npm
$ sudo npm install -g npm # update npm
```
**Build**
```bash
$ git clone https://github.com/jean-emmanuel/open-stage-control
$ cd open-stage-control
$ npm install --save-optional
$ export PLATFORM=TARGET_PLATFORM # TARGET_PLATFORM can be linux, win32 (windows) or darwin (os x)
$ export ARCH=TARGET_ARCH # TARGET_ARCH can be ia32 or x64
$ npm run build
$ # Do the following if you want a deb package for debian/ubuntu
$ npm run deb32
$ # or
$ npm run deb64
```
This will build the app in `dist/open-stage-control-PLATFORM-ARCH`.
*Please note that building the app for windows from a linux system requires wine to be installed.*

View file

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

View file

@ -1,26 +0,0 @@
Client options can be set either with the server's `--client-options` option, or per client by adding query parameters to the server's url. One must prepend the url with a question mark (`?`) followed by `parameter=value` pairs separated with ampersands (`&`).
| Option | Value | Default | Description |
|----|----|----|----|
| hdpi | 1 / 0 | 0 | enable high resolution canvas |
| forceHdpi | number | 0 | force canvas scaling (ignore `hdpi`) |
| doubleTap | number | 375 | sets the double tap/click time threshold in milliseconds |
| zoom | number | 1 | sets the initial zoom |
| framerate | number | 60 | limit canvas drawing framerate |
| desyncCanvas | number | 0 | set to 1 to enable desynchronized canvas (may improve rendering performances) |
| lang | string | *system_default* | use a different language than the default if available (available languages: en, fr, de, pl) |
| consoleLength | number | 300 | sets the maximum number of log messages in the client's console |
| id | string | *random_id* | client's unique id (use with caution: two clients should never have the same id) |
| usePercents | 1 / 0 | 0 | sets the editor's "relative units" option |
| noFocus | 1 / 0 | 0 | (built-in client only) prevent the client window from taking focus |
| clientSync | 1 / 0 | 1 | set to 0 to prevent the client from syncing with other clients |
| altTraversing | 1 / 0 | 0 | set to 1 to enable an alternative traversing behavior for toggle buttons (traversing gestures on toggle buttons will change their values in only one way depending on the first touched button's state) |
| virtualKeyboard | 1 / 0 | 0 | (desktop only) set to 1 to enable the virtual keyboard by default |
| notifications | 1 / 0 | 1 | set to 0 to hide notifications by default |
| title | string | '' | replace window title |
| noWarning | 1 / 0 | 0 | set to 0 to disable unsaved session warnings |
Example:
`http://server-ip:port?hdpi=1`

View file

@ -1,40 +0,0 @@
## License
Copyleft © Jean-Emmanuel Doucet 2014-2025.
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
## Dependencies
Open Stage Control relies on several other free softwares listed in [package.json](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/package.json).
The default theme was based on [Nord](https://www.nordtheme.com/), some UI components were inspired by the text editor formerly known as Atom (now [Pulsar](https://pulsar-edit.dev/)).
## Contributors
[Jean-Emmanuel](https://framagit.org/jean-emmanuel), [MartinHN](https://github.com/MartinHN), [Eric Theise](https://github.com/erictheise), [danielappelt](https://github.com/erictheise), [ritschwumm](https://github.com/ritschwumm), [matthijskooijman](https://github.com/matthijskooijman), [WillyKaze](https://github.com/WillyKaze), [stefanboca](https://github.com/stefanboca), [pixelnerve](https://github.com/pixelnerve), [AdamAdamsMusic](https://github.com/AdamAdamsMusic), [wicast](https://github.com/wicast), [kdallafior](https://github.com/kdallafior), [brunetton](https://github.com/brunetton), [cyberic99](https://github.com/cyberic99), [kdejaeger](https://github.com/kdejaeger), [trebmuh](https://github.com/trebmuh), [MagnusReichel](https://github.com/MagnusReichel), [jpcima](https://github.com/jpcima), [t1st3](https://github.com/t1st3")
## Infrastructure supports
----
<a href="https://ammd.net/" class="sp-logo">
<img src="/img/sponsors/ammd.png" width="140px"/>
</a>
AMMD hosts this website and made this project possible by funding its first 2 years of development.
----
<a href="https://discourse.org/" class="sp-logo">
<img src="/img/sponsors/discourse.png" width="140px"/>
</a>
Discourse provides the community forum.
----
<a href="https://browserstack.com/" class="sp-logo">
<img src="/img/sponsors/browserstack.png" width="140px"/>
</a>
BrowserStack provides remote browsers for debugging.

View file

@ -1,220 +0,0 @@
# Custom module
Using the server's `custom-module` option, users can load a custom javascript module that filters incoming and outgoing OSC / MIDI messages.
## Writing a custom module
```js
// Do whatever you want
// initialize variables
// declare functions
// listen to app events
// load modules
// etc
module.exports = {
init: function(){
// this will be executed once when the osc server starts after
// connections are set up
// it is called for the main module only
},
stop: function(){
// this will be executed once when the osc server stops
// it is called for the main module only
},
reload: function(){
// this will be executed after the custom module is reloaded
// it is called for the main module only
},
oscInFilter:function(data){
// Filter incoming osc messages
var {address, args, host, port} = data
// do what you want
// address = string
// args = array of {value, type} objects
// host = string
// port = integer
// return data if you want the message to be processed
return {address, args, host, port}
},
oscOutFilter:function(data){
// Filter outgoing osc messages
var {address, args, host, port, clientId} = data
// same as oscInFilter
// return data if you want the message to be and sent
return {address, args, host, port}
},
unload: function(){
// this will be executed before the custom module is reloaded
// it is called for all modules, including other loaded modules
},
}
```
## Available globals
The module is executed in a restricted context, only a few globals are available :
----
#### `app`
[`Event Emitter`](https://nodejs.org/api/events.html#events_class_eventemitter), useful for monitoring the events sent by the different clients. Event names can be found in [callbacks.js](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/ipc/callbacks.mjs), callbacks are called with 2 arguments: `data` (object) and `client` (object: `{address, id}`)
----
#### `receive(host, port, address, ...args, options)`
Send osc/midi message to connected clients. `host` and `port` can be specified to simulate a specific origin for the message.
- `host` (optional): `string` ip address, valid hostname or `"midi"`
- `port` (optional): `integer` port number or `string` midi device name
- `address`: osc address
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object` (objects that don't match this format will simply be turned to a JSON string).
- `options` (optional): set to `{clientId: id}` to define which client receives the message (where `id` is the client's id as retrieved from `app` events or `oscOutFilter`)
For convenience, `host` and `port` can be provided both as single string argument joined with a colon.
----
#### `send(host, port, address, ...args)`
Send osc/midi to a target (see `receive()`).
----
#### `settings.read(name)`
Returns specified server option. `name` must be the option's long name without the leading dashes (ie: `"send"`, not `"s"`)
----
#### `settings.appAddresses()`
Returns the server's http addresses.
----
#### `loadJSON(path, errorCallback)`
Loads a json file (path is relative to the custom module location)
- `path`: `string`, path to file (any extension allowed, but the content must be valid JSON)
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
----
#### `saveJSON(path, data, errorCallback)`
Saves an object/array to a json file (path is relative to the custom module location)
- `path`: `string`, path to file (any extension allowed)
- `data`: `object`, `array` or any value that can be encoded to JSON
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
----
#### `require(path)`
Load another javascript module. Returns the value of `module.exports` defined in this module. If `path` is a relative path, it will be resolved against its parent module's path. See [Managing Big Modules](../managing-big-modules).
This function is different from node's native `require` function, it's merely a way to split a custom module into separate files.
----
#### `nativeRequire(moduleName)`
This function can be used to load native node modules or locally installed modules (e.g. with npm) if a `node_modules` folder is found in the custom module's location.
??? "Installing node modules: resources"
- https://nodejs.dev/
- https://nodejs.dev/learn/an-introduction-to-the-npm-package-manager
- https://nodejs.dev/learn/the-package-json-guide
----
#### `tcpServer`
Raw access to the server's [TCP backend](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/osc/tcp.mjs). Can be used to monitor the state of TCP connections:
```js
for (var ip in tcpServer.clients) {
tcpServer.clients[ip].port.on('ready', ()=>{
console.log(`TCP connection established with ${ip}:${tcpServer.clients[ip].remotePort}`)
})
tcpServer.clients[ip].port.on('close', ()=>{
console.log(`TCP connection lost with ${ip}:${tcpServer.clients[ip].remotePort}`)
})
}
```
#### `restartMidiBackend()`
This function can be used to restart the midi backend (if already running) without restarting the server
#### Other javascript globals
- `console`
- `setTimeout`
- `clearTimeout`
- `setInterval`
- `clearInterval`
- `__dirname`
- `__filename`
- `process`
- `global`
----
## Autoreload
Custom modules (including submodules loaded with `require()`) are reloaded automatically when they are modified. Upon reload, timers (`setTimeout` and `setInterval`) and event listeners (added to the  `app` object) are reset. After each reload the `module.exports.reload()` function (if any) is called.
The `global` object persists accross reloads.
??? "Reloading native modules"
When using modules loaded with `nativeRequire()`, you may need to tell the custom module how to unload some components to allow reloading using the `module.exports.unload` definition. For example, if a port is bound using the `http` module, you'll need to unbind it otherwise the custom module will fail to bind it again when reloading:
```js
var http = nativeRequire('http'),
server = http.createServer((req, res)=>{
res.writeHead(200)
res.end('Hello world')
})
server.listen(5555, 'localhost')
module.exports = {
unload: function() {
server.close()
// otherwise you'd get "Error: listen EADDRINUSE: address already in use 127.0.0.1:5555"
}
}
```

View file

@ -1,471 +0,0 @@
## Basic address routing
```js
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
if (address === '/some_address') {
address = '/fader_1'
}
return {address, args, host, port}
},
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
if (address === '/fader_1') {
address = '/some_address'
}
return {address, args, host, port}
}
}
```
## Value conversion
```js
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
if (address === '/some_address') {
args[0].value = args[0].value * 10
}
return {address, args, host, port}
},
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
if (address === '/some_address') {
args[0].value = args[0].value / 10
}
return {address, args, host, port}
}
}
```
## Arguments split / merge
```js
var xyValue = [0, 0]
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
// split
if (address === '/some_xy_address') {
var arg1 = args[0].value,
arg2 = args[1].value
receive('/fader_1', arg1)
receive('/fader_2', arg2)
return // bypass original message
}
return {address, args, host, port}
},
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
// merge
if (address === '/fader_1') {
xyValue[0] = args[0].value
send(host, port, '/some_xy_address', ...xyValue)
return // bypass original message
} else if (address === '/fader_2') {
xyValue[1] = args[1].value
send(host, port, '/some_xy_address', ...xyValue)
return // bypass original message
}
return {address, args, host, port}
}
}
```
## Reply
```js
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
if (address === '/knock_knock') {
send(host, port, '/who_is_there')
return // bypass original message
}
return {address, args, host, port}
},
}
```
## Simulate user input on a single client
```js
// keep track of connected clients
var clients = []
app.on('open', (data, client)=>{
if (!clients.includes(client.id)) clients.push(client.id)
})
app.on('close', (data, client)=>{
if (clients.includes(client.id)) clients.splice(clients.indexOf(client.id))
})
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
if (address === '/some_osc_address') {
// simulate user input on the first client in the array
receive('/SET', 'widget_id', 1, {clientId: clients[0]})
return // bypass original message
}
return {address, args, host, port}
}
}
```
## Auto-save client state
```js
// store state in a variable
var state = {}
// keep track of connected clients
var clients = []
app.on('sessionOpened', (data, client)=>{
// client connected (and in a session)
if (!clients.includes(client.id)) clients.push(client.id)
// when a client opens a session, send the state
// but only if it's the only connected client (otherwise, let the regular sync happen)
if (clients.length === 1) {
receive('/STATE/SET', state, {clientId: clients[0]})
}
})
app.on('close', (data, client)=>{
// client disconnected
if (clients.includes(client.id)) clients.splice(clients.indexOf(client.id))
})
// request 1st client's state every 10 seconds
setInterval(()=>{
if (clients.length > 0) {
receive('/STATE/GET', '127.0.0.1:8888', {clientId: clients[0]})
}
}, 10000)
module.exports = {
oscOutFilter: function(data) {
if (data.address === '/STATE/GET') {
// update state variable when the client responds
state = data.args[0].value
// bypass the osc message
return
}
return data
}
}
```
## MIDI routing
```js
var routing = {
// midi cc vs widget id
60: 'fader_1',
61: 'fader_2',
// etc
}
module.exports = {
oscInFilter:function(data){
// Filter incoming osc messages
var {address, args, host, port} = data
if (host === 'midi') {
// MIDI routing !
if (address === '/control') {
// assign args to variables
var [channel, ctrl, value] = args.map(arg=>arg.value)
// simple conditions
if (ctrl === 80) receive('/SET', 'widget_id', value / 127)
// simple routing table (midi cc vs widget id)
if (routing[ctrl]) receive('/SET', routing[ctrl], value / 127)
// note: /SET simulates a user interaction and makes the widget send its osc message
// but it adds some delay (we wait for the UI to respond)
// AND it may trigger multiple replies if more than one client are connected.
// Alternatively, we could do this:
// send('/osc_address', value / 127)
// receive('/osc_address', value / 127)
// Or, to send /SET to a single client:
// receive('/SET', '/osc_address', value / 127, {clientId: ID})
}
return // bypass original message
}
// return data if you want the message to be processed
return {address, args, host, port}
}
}
```
## Read file
```js
var fs = nativeRequire('fs')
module.exports = {
oscOutFilter:function(data){
// Filter outgoing osc messages
var {address, args, host, port} = data
if (address === '/file') {
fs.readFile(args[0].value, 'utf8' , (err, data) => {
if (err) {
console.error(err)
return
}
receive('/html', data)
})
return // bypass original message
}
// return data if you want the message to be processed
return {address, args, host, port}
}
}
```
## Display RTSP Stream
```js
// requires ffmpeg installed on the system
// and rtsp-ffmpeg installed in the custom module's folder (by running npm install rtsp-ffmpeg)
// see https://github.com/agsh/rtsp-ffmpeg#ffmpeg for available options
var rtsp = nativeRequire('rtsp-ffmpeg')
var stream = new rtsp.FFMpeg({
input: 'rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream',
})
stream.on('data', (data)=>{
// send frame to image widget with address set to "/stream"
receive('/stream', 'data:image/jpeg;base64,' + data.toString('base64'))
})
module.exports = {
unload: ()=>{
stream.stop()
}
}
```
## Custom module merger
```js
var submodules = [
require('./custom_modA.js'),
require('./custom_modB.js'),
// etc
]
module.exports = {
init: function(){
for (var m of submodules) {
if (m.init) m.init()
}
},
reload: function(){
for (var m of submodules) {
if (m.reload) m.reload()
}
},
oscInFilter: function(data){
for (var m of submodules) {
if (m.oscInFilter) data = m.oscInFilter(data)
if (!data) return
}
return data
},
oscOutFilter: function(data){
for (var m of submodules) {
if (m.oscOutFilter) data = m.oscOutFilter(data)
if (!data) return
}
return data
}
}
```
## Dynamic widget creation
```js
function create_widgets() {
receive('', '', '/EDIT', 'root', {
widgets: [{
type: 'panel',
id: 'my_panel',
layout: 'vertical',
width: '100%',
height: '200%',
widgets: [
{
type: 'text',
id: 'notice',
value: 'Hello, world!',
width: '100%',
},
{
type: 'button',
id: 'button',
address: '/foo',
preArgs: [1],
},
]
}]
})
}
module.exports = {
reload: function(){
// Create widgets whenever the custom modules is edited
create_widgets()
},
}
// Create widgets whenever an existing session is loaded
app.on('sessionOpened', ()=>{
create_widgets()
})
// And when a new session is created
app.on('sessionSetPath', (e)=>{
if (e.path === '') {
create_widgets()
}
})
```
## Simple bridge
```js
module.exports = {
oscInFilter: function(data) {
// pass through incoming messages directly to another application
send('127.0.0.1', 12345, data.address, ...args)
return data // let original message reach clients / widgets
}
}
```

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