Compare commits

..

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

389 changed files with 15602 additions and 52203 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}}

18
.gitignore vendored
View file

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

42
.travis.yml Normal file
View file

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

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: npm run build-js && npm run build-css && cd app && node index.js -n $PORT --examples

View file

@ -1,21 +1,56 @@
<img src="resources/images/logo.png" alt="Open Stage Control" height="50px"/>
# <img src="app/resources/images/logo.png" height="80px"/> Open Stage Control
Open Stage Control
Open Stage Control is a libre desktop OSC bi-directionnal control surface application. It's built with HTML, JavaScript & CSS on top of [Electron](http://electron.atom.io/) framework.
*Libre and modular OSC / MIDI controller*
## Documentation
[Read the documentation](http://jean-emmanuel.github.io/open-stage-control/)
*The docs' sources are located in [resources/](resources/)*
## Download
Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page.
## Demo
You can try the app here [http://openstagecontrol.herokuapp.com/](http://openstagecontrol.herokuapp.com/)
Please note that :
- Chrome/Chromium **49** at least is required
- Since there is only one instance running, all connected guests are synchronized (widgets using the same osc paths update each other's states) : you might experience some unwanted synchronization with other users unless you specify custom parameters for your widgets.
- You might want to download the examples sessions files under *examples/* and load them in the app to get started.
- Website: https://openstagecontrol.ammd.net/
- Forum: https://openstagecontrol.discourse.group/
- IRC: Libera.chat #openstagecontrol
## Features
----
- mouse & multi-touch sensitive widgets
- modular & responsive layout
- built-in live editor
- bi-directionnal osc bindings
- headless server mode with any number of clients using chromium
- app state store / recall & import / export
- themes !
Docker additions by Rik Berkelder.
## Supported platforms
mount `/sessions` directory. default session file is created and loaded there.
Same as [Electron's supported platforms](https://github.com/electron/electron/blob/master/docs/tutorial/supported-platforms.md)
---
Copyleft © Jean-Emmanuel Doucet 2014-2025.
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
## License & credits
Copyleft © Jean-Emmanuel @ [AMMD](http://ammd.net). This program is released under the GNU/GPL3 license.
It relies on the use of several libraries :
- [Node.js](https://nodejs.org/)
- [Electron](http://electron.atom.io/)
- [node-osc](https://github.com/TheAlphaNerd/node-osc)
- [socket.io](http://socket.io)
- [browserify](http://browserify.org)
- [express](http://expressjs.com)
- [node-sass](https://github.com/sass/node-sass)
- [jQuery](http://jquery.com/)
- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
- [Font Awesome](http://fontawesome.io/)

1
app/browser/favicon.ico Symbolic link
View file

@ -0,0 +1 @@
../resources/images/logo.ico

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.

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

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

19
app/browser/index.html Normal file
View file

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

54
app/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')

View file

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

View file

@ -0,0 +1,106 @@
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)
continue
}
}
} else {
args = data.args
}
if (args.length==0) args = null
else if (args.length==1) args = args[0]
for (i in WIDGETS_BY_PATH[pathref]) {
if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true)
}
},
stateLoad: function(event,data){
var data = data || event
data = JSON.parse(data)
actions.stateSet(data,true)
actions.stateQuickSave(data)
},
sessionList: function(event,data){
var data = data || event
$('#lobby').append(`
<div class="main">
<div class="header">
Open Stage Control
</div>
<div class="list"></div>
<div class="footer"></div>
</div>`)
for (i in data) {
$('#lobby .list').append('<a class="btn load" data-session="'+data[i]+'">'+data[i]+'<span>'+icon('remove')+'</span></a>')
}
$('#lobby .footer').append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
$('#lobby .footer').append('<a class="btn new">'+icon('file-o')+' New</a>')
$('#lobby .load').click(function(e){
e.stopPropagation()
IPC.send('sessionOpen',{path:$(this).data('session')})
})
$('#lobby a span').click(function(e){
e.stopPropagation()
IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
$('#lobby .browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
$('#lobby .new').click(function(e){
e.stopPropagation()
init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
})
},
sessionOpen: function(event,data){
var data = data || event
var session = JSON.parse(data)
init(session)
},
error: function(event,data){
var data = data || event
utils.createPopup(icon('warning')+'&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,59 @@
var correctPosition = function (m, parent){
var pos = m.offset(),
width = m.outerWidth(),
height = m.outerHeight(),
totalWidth = $('body').outerWidth(),
totalHeight = $('body').outerHeight(),
leftAdjust = parent=='body'?0:parent.outerWidth()-2
if (width + pos.left > totalWidth) {
m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
}
if (height + pos.top > totalHeight) {
m.css({'margin-top':totalHeight-(height + pos.top)})
}
}
var ev = 'fake-click'
var menu = function(e,actions,parent){
var m = $('<div class="context-menu"></div>')
if (parent=='body') {
m.css({top:e.pageY+'px',left:e.pageX+'px'})
}
for (label in actions) {
if (typeof actions[label] == 'object') {
var item = $(`<div class="item has-sub" tabIndex="1">${label}</div>`).appendTo(m).on(ev,function(e){e.stopPropagation()})
menu(e,actions[label],item)
} else {
$(`<div class="item">${label}</div>`).on(ev + '.editor',function(){
var callback = actions[label]
return function(e){
callback()
$('.context-menu').remove()
}
}()).appendTo(m)
}
}
m.appendTo(parent)
if (parent=='body') {
correctPosition(m,parent)
} else {
parent.hover(function(){correctPosition(m,parent)})
}
}
module.exports = menu

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

@ -0,0 +1,143 @@
var actions = require('./actions'),
icon = require('./utils').icon
var data = [
{
actions: [
{
title:'Fullscreen (F11)',
action:actions.toggleFullscreen
}
]
},
{
title: icon('sliders') + '&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')
$(window).resize()
},t)
}).on('mousedown touchstart',function(e){e.stopPropagation()})
// in case where are hot loading a session
if ($('#sidepanel').hasClass('sidepanel-open')) {
$('#open-toggle, #container').addClass('sidepanel-open')
}
}
module.exports = {
init:function(){
$('#sidepanel').append(sidepanel)
toggle()
},
createToggle:toggle
}

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

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

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).off('.popup')
popup.remove()
}
popup.find('.popup-content').append(content)
$('body').append(popup)
$(document).on('keydown.popup', function(e){
if (e.keyCode==27) popup.close()
})
return popup
},
icon: function(i) {
return `<i class="fa fa-fw fa-${i}"></i>`
}
}

View file

@ -0,0 +1,81 @@
var widgets = {
// sliders
fader: require('./widgets/sliders/fader'),
knob: require('./widgets/sliders/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/plots/led'),
plot: require('./widgets/plots/plot'),
eq: require('./widgets/plots/eq'),
visualizer: require('./widgets/plots/visualizer'),
meter: require('./widgets/plots/meter'),
text: require('./widgets/plots/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','eq','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,63 @@
var _widgets_base = require('./_widgets_base')
var _canvas_base = module.exports = function() {
_widgets_base.apply(this,arguments)
this.canvas = this.widget.find('canvas')
this.ctx = this.canvas[0].getContext('2d')
this.height = undefined
this.width = undefined
this.visible = false
this.colors = {}
this.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
this.canvas.resize(this.resizeHandleProxy.bind(this))
}
_canvas_base.prototype = Object.create(_widgets_base.prototype)
_canvas_base.prototype.constructor = _canvas_base
_canvas_base.prototype.resizeHandleProxy = function() {
this.resizeHandle.apply(this,arguments)
}
_canvas_base.prototype.resizeHandle = function(){
var width = this.canvas.width(),
height = this.canvas.height()
if (height==100 && width==100) return
this.height=height
this.width=width
this.canvas[0].setAttribute('width',width)
this.canvas[0].setAttribute('height',height)
if (!self.visible) {
this.visible = true
this.colors.custom = getComputedStyle(this.widget[0]).getPropertyValue('--color-custom')
this.colors.text = getComputedStyle(this.widget[0]).getPropertyValue('--color-text')
this.colors.raised = getComputedStyle(this.widget[0]).getPropertyValue('--color-raised')
this.colors.bg = getComputedStyle(this.widget[0]).getPropertyValue('--color-bg')
this.colors.fg = getComputedStyle(this.widget[0]).getPropertyValue('--color-fg')
this.colors.faded = getComputedStyle(this.widget[0]).getPropertyValue('--color-faded')
}
requestAnimationFrame(this.draw.bind(this))
}
_canvas_base.prototype.draw = function(){
//
}

View file

@ -0,0 +1,3 @@
var _widget_base = module.exports = function(widgetData) {
this.widgetData = widgetData
}

View file

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

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.enableTraversingGestures()
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.enableTraversingGestures()
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',
scroll:true,
color:'auto',
css:'',
separator2:'chilren',
widgets:[],
tabs:[]
}
module.exports.create = function(widgetData,container) {
var parser = require('../parser'),
parsewidgets = parser.widgets,
parsetabs = parser.tabs
var widget = $(`
<div class="panel">
</div>
`)
if (!widgetData.scroll) widget.addClass('noscroll')
if (widgetData.tabs.length) {
parsetabs(widgetData.tabs,widget)
widget.addClass('has-tabs')
} else {
parsewidgets(widgetData.widgets,widget)
}
return widget
}

View file

@ -0,0 +1,137 @@
//
// calcBiquad
//
// Dec 14, 2010 njr
// original @ Nigel Redmon
module.exports = function(options,linear,resolution) {
var {type, freq, q, gain} = options,
Fs = 44100,
a0,a1,a2,b1,b2,norm,
ymin, ymax, minVal, maxVal,
len = resolution
var V = Math.pow(10, Math.abs(gain) / 20)
var K = Math.tan(Math.PI * freq / Fs)
switch (type) {
case "lowpass":
norm = 1 / (1 + K / q + K * K)
a0 = K * K * norm
a1 = 2 * a0
a2 = a0
b1 = 2 * (K * K - 1) * norm
b2 = (1 - K / q + K * K) * norm
break
case "highpass":
norm = 1 / (1 + K / q + K * K)
a0 = 1 * norm
a1 = -2 * a0
a2 = a0
b1 = 2 * (K * K - 1) * norm
b2 = (1 - K / q + K * K) * norm
break
case "bandpass":
norm = 1 / (1 + K / q + K * K)
a0 = K / q * norm
a1 = 0
a2 = -a0
b1 = 2 * (K * K - 1) * norm
b2 = (1 - K / q + K * K) * norm
break
case "notch":
norm = 1 / (1 + K / q + K * K)
a0 = (1 + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = a0
b1 = a1
b2 = (1 - K / q + K * K) * norm
break
case "peak":
if (gain >= 0) {
norm = 1 / (1 + 1/q * K + K * K)
a0 = (1 + V/q * K + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = (1 - V/q * K + K * K) * norm
b1 = a1
b2 = (1 - 1/q * K + K * K) * norm
}
else {
norm = 1 / (1 + V/q * K + K * K)
a0 = (1 + 1/q * K + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = (1 - 1/q * K + K * K) * norm
b1 = a1
b2 = (1 - V/q * K + K * K) * norm
}
break
case "lowshelf":
if (gain >= 0) {
norm = 1 / (1 + Math.SQRT2 * K + K * K)
a0 = (1 + Math.sqrt(2*V) * K + V * K * K) * norm
a1 = 2 * (V * K * K - 1) * norm
a2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
b1 = 2 * (K * K - 1) * norm
b2 = (1 - Math.SQRT2 * K + K * K) * norm
}
else {
norm = 1 / (1 + Math.sqrt(2*V) * K + V * K * K)
a0 = (1 + Math.SQRT2 * K + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = (1 - Math.SQRT2 * K + K * K) * norm
b1 = 2 * (V * K * K - 1) * norm
b2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
}
break
case "highshelf":
if (gain >= 0) {
norm = 1 / (1 + Math.SQRT2 * K + K * K)
a0 = (V + Math.sqrt(2*V) * K + K * K) * norm
a1 = 2 * (K * K - V) * norm
a2 = (V - Math.sqrt(2*V) * K + K * K) * norm
b1 = 2 * (K * K - 1) * norm
b2 = (1 - Math.SQRT2 * K + K * K) * norm
}
else {
norm = 1 / (V + Math.sqrt(2*V) * K + K * K)
a0 = (1 + Math.SQRT2 * K + K * K) * norm
a1 = 2 * (K * K - 1) * norm
a2 = (1 - Math.SQRT2 * K + K * K) * norm
b1 = 2 * (K * K - V) * norm
b2 = (V - Math.sqrt(2*V) * K + K * K) * norm
}
break
}
var magPlot = []
for (var i = 0; i < len; i++) {
var w, phi, y
if (linear)
w = i / (len - 1) * Math.PI; // 0 to pi, linear scale
else
w = Math.exp(Math.log(1 / 0.001) * i / (len - 1)) * 0.001 * Math.PI; // 0.001 to 1, times pi, log scale
phi = Math.pow(Math.sin(w/2), 2)
y = Math.log(Math.pow(a0+a1+a2, 2) - 4*(a0*a1 + 4*a0*a2 + a1*a2)*phi + 16*a0*a2*phi*phi) - Math.log(Math.pow(1+b1+b2, 2) - 4*(b1 + 4*b2 + b1*b2)*phi + 16*b2*phi*phi)
y = y * 10 / Math.LN10
if (y == -Infinity) y = -200
if (linear)
magPlot.push([i / (len - 1) * Fs / 2, y])
else
magPlot.push([i / (len - 1) * Fs / 2, y])
if (i == 0)
minVal = maxVal = y
else if (y < minVal)
minVal = y
else if (y > maxVal)
maxVal = y
}
return magPlot
}

View file

@ -0,0 +1,126 @@
var {mapToScale} = require('../utils'),
_canvas_base = require('../common/_canvas_base')
var _plots_base = module.exports = function(){
this.widget = $(`
<div class="plot">
<canvas></canvas>
</div>
`)
_canvas_base.apply(this,arguments)
this.data = []
this.linkedWidgets = []
this.rangeX = this.widgetData.rangeX || {min:0,max:1}
this.rangeY = this.widgetData.rangeY || {min:0,max:1}
this.pips = {
x : {
min: Math.abs(this.rangeX.min)>=1000?this.rangeY.min/1000+'k':this.rangeX.min,
max: Math.abs(this.rangeX.max)>=1000?this.rangeY.max/1000+'k':this.rangeX.max
},
y : {
min: Math.abs(this.rangeY.min)>=1000?this.rangeY.min/1000+'k':this.rangeY.min,
max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max
}
}
$('body').on('sync',this.syncHandleProxy.bind(this))
}
_plots_base.prototype = Object.create(_canvas_base.prototype)
_plots_base.prototype.constructor = _plots_base
_plots_base.prototype.syncHandleProxy = function() {
this.syncHandle.apply(this,arguments)
}
_plots_base.prototype.syncHandle = function(e,id,w) {
if (this.linkedWidgets.indexOf(id)==-1 || !WIDGETS[id]) return
this.updateData()
requestAnimationFrame(this.draw.bind(this))
}
_plots_base.prototype.resizeHandle = function(){
this.updateData()
_canvas_base.prototype.resizeHandle.call(this)
}
_plots_base.prototype.draw = function() {
this.ctx.clearRect(0,0,this.width,this.height)
this.ctx.beginPath()
this.draw_data()
this.ctx.lineWidth = 1*PXSCALE
this.ctx.strokeStyle = this.colors.custom
this.ctx.stroke()
this.ctx.font = PXSCALE * 10 + 'px sans-serif'
this.ctx.fillStyle = this.colors.text
this.ctx.textBaseline = "bottom"
this.ctx.textAlign = 'left'
this.ctx.fillText(this.pips.x.min,12*PXSCALE,this.height)
this.ctx.textAlign = 'right'
this.ctx.fillText(this.pips.x.max,this.width-10,this.height)
this.ctx.save()
this.ctx.translate(0, this.height)
this.ctx.rotate(-Math.PI/2)
this.ctx.textBaseline = "top"
this.ctx.textAlign = 'left'
this.ctx.fillText(this.pips.y.min,12*PXSCALE,2*PXSCALE)
this.ctx.textAlign = 'right'
this.ctx.fillText(this.pips.y.max,this.height-10*PXSCALE,2*PXSCALE)
this.ctx.rotate(Math.PI/2)
this.ctx.restore()
}
_plots_base.prototype.draw_data = function() {
var first = true
var point = []
for (i in this.data) {
if (this.data[i][1]>this.rangeY.max || this.data[i][1]<this.rangeY.min ||
this.data[i][0]>this.rangeX.max || this.data[i][0]<this.rangeX.min) continue
var newpoint = this.data[i].length?
[
mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[15*PXSCALE,this.width-15*PXSCALE],0,this.widgetData.logScaleX,true),
mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-15*PXSCALE,15*PXSCALE],0,this.widgetData.logScaleY,true),
]
:
[
mapToScale(i,[0,this.data.length-1],[15*PXSCALE,this.width-15*PXSCALE],0,this.widgetData.logScaleX,true),
mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-15*PXSCALE,15*PXSCALE],0,this.widgetData.logScaleY,true),
]
if (first) {
this.ctx.moveTo(newpoint[0],newpoint[1])
first = false
} else {
this.ctx.moveTo(point[0],point[1])
this.ctx.lineTo(newpoint[0],newpoint[1])
}
point = newpoint
}
}
_plots_base.prototype.setValue = function(v) {
this.data = v
requestAnimationFrame(this.draw.bind(this))
}
_plots_base.prototype.updateData = function(){
// update the coordinates to draw
}

View file

@ -0,0 +1,112 @@
var {mapToScale, clip} = require('../utils'),
_biquad_response = require('./_biquad_response'),
_plots_base = require('./_plots_base')
module.exports.options = {
type:'eq',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
css:'',
separator2:'plot',
filters:[],
resolution:128,
rangeY: {min:-20,max:20},
logScaleX: false,
separator3:'osc',
path:'auto',
preArgs:[],
}
var Eq = function(widgetData) {
_plots_base.call(this,widgetData)
this.rangeX = {min:20,max:22050}
this.pips.x.min = '20'
this.pips.x.max = '22k'
widgetData.resolution = clip(widgetData.resolution,[64,1024])
for (i in widgetData.filters) {
for (j in widgetData.filters[i]) {
if (typeof widgetData.filters[i][j]=='string' && !(j=='type' && widgetData.filters[i][j].match(/peak|notch|highpass|highshelf|lowpass|lowshelf/))) {
this.linkedWidgets.push(widgetData.filters[i][j])
}
}
}
}
Eq.prototype = Object.create(_plots_base.prototype)
Eq.prototype.constructor = Eq
Eq.prototype.updateData = function(){
var filters = [],
eqResponse = []
for (i in this.widgetData.filters) {
var filter = this.widgetData.filters[i]
filters[i] = {}
for (j in filter) {
if (typeof filter[j]=='string' && WIDGETS[filter[j]]) {
filters[i][j] = WIDGETS[filter[j]][WIDGETS[filter[j]].length-1].getValue()
} else {
filters[i][j] = filter[j]
}
}
}
for (i in filters) {
var filterResponse
if (!filters[i].type) filters[i].type = "peak"
if (!filters[i].on) {
filterResponse = _biquad_response({type:"peak",freq:1,gain:0,q:1},!this.widgetData.logScaleX,this.widgetData.resolution)
} else {
filterResponse = _biquad_response(filters[i],!this.widgetData.logScaleX,this.widgetData.resolution)
}
for (k in filterResponse) {
if (eqResponse[k]===undefined) {
eqResponse[k]=[0,0]
}
eqResponse[k] = [filterResponse[k][0], eqResponse[k][1]+filterResponse[k][1]]
}
}
if (eqResponse.length) this.data = eqResponse
}
module.exports.create = function(widgetData) {
var eq = new Eq(widgetData)
return eq.widget
}

View file

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

View file

@ -0,0 +1,88 @@
var {mapToScale} = require('../utils'),
_plots_base = require('./_plots_base')
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:[],
}
var Plot = function(widgetData) {
_plots_base.call(this,widgetData)
if (typeof widgetData.points=='string') {
this.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') {
this.linkedWidgets.push(widgetData.points[i][j])
}
}
}
}
this.updateData = 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) this.data = data
}
}
Plot.prototype = Object.create(_plots_base.prototype)
Plot.prototype.constructor = Plot
module.exports.create = function(widgetData) {
var plot = new Plot(widgetData)
return plot.widget
}

View file

@ -0,0 +1,51 @@
module.exports.options = {
type:'text',
id:'auto',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
vertical:false,
color:'auto',
css:'',
separator2:'osc',
preArgs:[],
path:'auto',
defaultText:''
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="text">
</div>
`),
label = widgetData.defaultText!==''?
widgetData.defaultText:
widgetData.label===false?
widgetData.id:
widgetData.label=='auto'?
widgetData.id:
widgetData.label,
text = label
if (widgetData.vertical) widget.addClass('vertical')
widget.setValue = function(v,send,sync){
text = typeof v=='object' && !v.length?label:v
widget.text(text)
}
widget.getValue = function(){
return text
}
widget.setValue(label)
return widget
}

View file

@ -0,0 +1,126 @@
var {mapToScale, clip} = require('../utils'),
_plots_base = require('./_plots_base')
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:[],
}
var Visualizer = function(widgetData) {
_plots_base.call(this,widgetData)
this.pips.y.min = Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min
this.pips.y.max = Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
this.pips.x.min = ''
this.pips.x.max = ''
this.length = Math.round(clip(60*widgetData.duration,[8,4096]))
this.data = new Array(this.length)
this.value = widgetData.range.min
this.cancel = false
this.loop = false
}
Visualizer.prototype = Object.create(_plots_base.prototype)
Visualizer.prototype.constructor = Visualizer
Visualizer.prototype.syncHandle = function(e,id,w) {
if (this.widgetData.widgetId!=id || !WIDGETS[id]) return
this.startLoop()
}
Visualizer.prototype.startLoop = function(){
if (this.cancel) clearTimeout(this.cancel)
this.cancel = setTimeout(function(){
clearInterval(this.loop)
this.loop = false
this.cancel = false
},1000*this.widgetData.duration)
if (this.loop) return
this.loop = setInterval(function(){
this.updateData()
this.draw()
}.bind(this),1000*this.widgetData.duration/this.length)
}
Visualizer.prototype.draw_data = function(){
var first = true
var point = []
for (var i=this.length-1;i>=0;i=i-1) {
var newpoint = [
mapToScale(i,[0,this.length-1],[15*PXSCALE,this.width-15*PXSCALE],1),
mapToScale(this.data[i],[this.widgetData.range.min,this.widgetData.range.max],[this.height-15*PXSCALE,15*PXSCALE],1,this.widgetData.logScale,true),
]
if (first) {
this.ctx.moveTo(newpoint[0],newpoint[1])
first = false
} else {
if (this.widgetData.logScale) {
this.ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
} else {
this.ctx.lineTo(newpoint[0],newpoint[1])
}
}
point = newpoint
}
}
Visualizer.prototype.updateData = function(){
var id = this.widgetData.widgetId
if (typeof id == 'string' && WIDGETS[id]) {
var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
this.data.push(v)
this.value = v
} else {
this.data.push(this.value)
}
this.data.splice(0,1)
}
Visualizer.prototype.setValue = function(v) {
this.value = v
this.startLoop()
}
module.exports.create = function(widgetData,container) {
var visualizer = new Visualizer(widgetData)
return visualizer.widget
}

View file

@ -0,0 +1,107 @@
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="light">
</div>\
`),
$document = $(document)
widget.value = widget.find('span')
widget.state = 0
widget.active = 0
widget.lastChanged = 'state'
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit.push',function(){
widget.off('draginit.push')
widget.fakeclick()
})
widget.fakeclick = function(){
if (!widget.active) widget.setValuePrivate(widgetData.on,true,true)
$document.on('dragend.push',function(){
widget.setValuePrivate(widgetData.off,true,true)
$document.off('dragend.push')
widget.on('draginit.push',function(){
widget.off('draginit.push')
widget.fakeclick()
})
})
}
widget.getValue = function() {
return widget[widget.lastChanged]?widgetData.on:widgetData.off
}
widget.setValuePrivate = function(v,send,sync) {
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
widget.addClass('active')
widget.active = 1
if (send) widget.sendValue(v)
widget.lastChanged = 'active'
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
widget.removeClass('active')
widget.active = 0
if (send) widget.sendValue(v)
widget.lastChanged = 'active'
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
}
widget.setValue = function(v,send,sync) {
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
widget.addClass('on')
widget.state = 1
if (send) widget.sendValue(v)
widget.lastChanged = 'state'
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
widget.removeClass('on')
widget.state = 0
if (send) widget.sendValue(v)
widget.lastChanged = 'state'
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
}
widget.sendValue = function(v) {
if (v===false) return
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.setValue()
return widget
}

View file

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

View file

@ -0,0 +1,180 @@
var {clip, roundTo, mapToScale, sendOsc} = require('../utils')
var _canvas_base = require('../common/_canvas_base')
var _sliders_base = module.exports = function(){
this.widget = $(`
<div class="slider">
<div class="wrapper">
<canvas></canvas>
</div>
<div class="input"></div>
</div>
`)
_canvas_base.apply(this, arguments)
this.wrapper = this.widget.find('.wrapper')
this.input = this.widget.find('.input').fakeInput({align:'center'})
this.roundFactor = Math.pow(10,this.widgetData.precision)
this.value = undefined
this.percent = 0
this.unit = this.widgetData.unit ? ' ' + this.widgetData.unit : ''
this.rangeKeys = []
this.rangeVals = []
this.rangeLabels = []
for (k in this.widgetData.range) {
var key = k=='min'?0:k=='max'?100:parseInt(k),
val = typeof this.widgetData.range[k] == 'object'?
this.widgetData.range[k][Object.keys(this.widgetData.range[k])[0]]:
this.widgetData.range[k],
label = typeof this.widgetData.range[k] == 'object'?
Object.keys(this.widgetData.range[k])[0]:
val
this.rangeKeys.push(key)
this.rangeVals.push(val)
this.rangeLabels.push(label)
}
this.rangeValsMax = Math.max.apply(Math, this.rangeVals),
this.rangeValsMin = Math.min.apply(Math, this.rangeVals)
this.originValue = this.widgetData.origin=='auto'?
this.rangeValsMin:
clip(this.widgetData.origin,[this.rangeValsMin,this.rangeValsMax])
this.widget.on('fake-right-click',function(e){
if (!EDITING) {
e.stopPropagation()
e.preventDefault()
this.input.focus()
}
}.bind(this))
this.widget.on('mousewheel',this.mousewheelHandleProxy.bind(this))
this.canvas.on('draginit',this.draginitHandleProxy.bind(this))
this.canvas.on('drag',this.dragHandleProxy.bind(this))
this.input.change(function(){
this.widget.setValue(parseFloat(this.input.val()),true,true)
}.bind(this))
this.widget.getValue = function(){
return this.value
}.bind(this)
this.widget.setValue = this.setValue.bind(this)
this.setValue(this.originValue)
}
_sliders_base.prototype = Object.create(_canvas_base.prototype)
_sliders_base.prototype.constructor = _sliders_base
_sliders_base.prototype.mousewheelHandleProxy = function() {
this.mousewheelHandle.apply(this,arguments)
}
_sliders_base.prototype.draginitHandleProxy = function() {
this.draginitHandle.apply(this,arguments)
}
_sliders_base.prototype.dragHandleProxy = function() {
this.dragHandle.apply(this,arguments)
}
_sliders_base.prototype.mousewheelHandle = function(e, data, traversing) {
if (e.originalEvent.wheelDeltaX) return
e.preventDefault()
e.stopPropagation()
var direction = e.originalEvent.wheelDelta / Math.abs(e.originalEvent.wheelDelta),
increment = e.ctrlKey?0.25:1
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.widgetData.precision)) * direction ,[0,100])
this.setValue(this.percentToValue(this.percent), true, true)
}
_sliders_base.prototype.draginitHandle = function(e, data, traversing) {
}
_sliders_base.prototype.dragHandle = function(e, data, traversing) {
}
_sliders_base.prototype.resizeHandle = function() {
if (!self.visible) {
this.colors.track = getComputedStyle(this.widget[0]).getPropertyValue('--color-track')
this.colors.gauge = getComputedStyle(this.widget[0]).getPropertyValue('--color-gauge')
this.colors.knob = getComputedStyle(this.widget[0]).getPropertyValue('--color-knob')
}
_canvas_base.prototype.resizeHandle.call(this)
}
_sliders_base.prototype.percentToValue = function(percent) {
var h = clip(percent,[0,100])
for (var i=0;i<this.rangeKeys.length-1;i++) {
if (h <= this.rangeKeys[i+1] && h >= this.rangeKeys[i]) {
return mapToScale(h,[this.rangeKeys[i],this.rangeKeys[i+1]],[this.rangeVals[i],this.rangeVals[i+1]],false,this.widgetData.logScale)
}
}
}
_sliders_base.prototype.valueToPercent = function(value) {
for (var i=0;i<this.rangeVals.length-1;i++) {
if (value <= this.rangeVals[i+1] && value >= this.rangeVals[i]) {
return mapToScale(value,[this.rangeVals[i],this.rangeVals[i+1]],[this.rangeKeys[i],this.rangeKeys[i+1]],false,this.widgetData.logScale,true)
}
}
}
_sliders_base.prototype.setValue = function(v,send,sync, dragged) {
if (typeof v != 'number') return
var value = roundTo(clip(Math.round(v*this.roundFactor)/this.roundFactor,[this.rangeValsMin,this.rangeValsMax]),this.widgetData.precision)
if (dragged && this.value == value) send = false
this.value = value
if (!dragged) this.percent = this.valueToPercent(this.value)
this.draw()
this.showValue()
if (sync) this.widget.trigger('sync',[this.widgetData.id,this.widget,this.widgetData.linkId])
if (send) this.sendValue(v)
}
_sliders_base.prototype.sendValue = function(value) {
var args = this.widgetData.preArgs.concat(value)
sendOsc({
target:this.widgetData.target,
path:this.widgetData.path,
precision:this.widgetData.precision,
args:args
})
}
_sliders_base.prototype.showValue = function() {
this.input.val(this.value + this.unit)
}

View file

@ -0,0 +1,260 @@
var {clip, mapToScale, sendOsc} = require('../utils'),
_sliders_base = require('./_sliders_base')
module.exports.options = {
type:'fader',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
alignRight:false,
horizontal:false,
noPip:false,
compact:false,
color:'auto',
css:'',
separator2:'behaviour',
snap:false,
separator3:'osc',
range:{min:0,max:1},
origin: 'auto',
logScale:false,
precision:2,
meter:false,
path:'auto',
preArgs:[],
target:[]
}
var Fader = function(widgetData){
_sliders_base.apply(this,arguments)
this.widget.addClass('fader')
this.margin = 20
if (widgetData.horizontal) {
this.widget.addClass('horizontal')
}
if (widgetData.compact) {
this.widget.addClass('compact')
this.margin = 0
}
if (widgetData.alignRight && !widgetData.horizontal) {
this.widget.addClass('align-right')
}
if (!widgetData.noPip&&!widgetData.compact) {
this.widget.addClass('has-pips')
var pips = $('<div class="pips"></div>').appendTo(this.widget.find('.wrapper'))
var pipTexts = {}
for (k in this.rangeKeys) {
pipTexts[this.rangeKeys[k]]=this.rangeLabels[k]
}
var pipsInner = ''
for (var i=0;i<=100;i++) {
if (pipTexts[i]==undefined) continue
var pos = widgetData.horizontal?'left':'bottom';
var piptext = `<span>${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]}</span>`
var add = `
<div class="pip val" style="${pos}:${i}%">${piptext}</div>
`
pipsInner = pipsInner + add
}
pips[0].innerHTML = pipsInner
}
if (widgetData.meter) {
var parsewidgets = require('../../parser').widgets
var data = {
type:'meter',
id: widgetData.id + '/meter',
label:false,
horizontal:widgetData.horizontal,
range:widgetData.range,
logScale:widgetData.logScale,
path:widgetData.path + '/meter',
preArgs:widgetData.preArgs,
color:widgetData.color
}
var element = parsewidgets([data],this.widget.find('.wrapper'))
element[0].classList.add('not-editable')
this.widget[0].classList.add('has-meter')
}
}
Fader.prototype = Object.create(_sliders_base.prototype)
Fader.prototype.constructor = Fader
Fader.prototype.draginitHandle = function(e, data, traversing){
this.percent = clip(this.percent,[0,100])
if (!(traversing || this.widgetData.snap)) return
this.percent = this.widgetData.horizontal?
(data.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100:
(this.height - data.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100
// this.percent = clip(this.percent,[0,100])
this.setValue(this.percentToValue(this.percent), true, true, true)
}
Fader.prototype.dragHandle = function(e, data) {
this.percent = this.widgetData.horizontal?
this.percent + ( data.speedX/(this.width - this.margin * PXSCALE * 2)) * 100:
this.percent + (-data.speedY/(this.height - this.margin * PXSCALE * 2)) * 100
this.setValue(this.percentToValue(this.percent), true, true, true)
}
Fader.prototype.percentToCoord = function(percent) {
if (this.widgetData.horizontal) {
return clip(percent / 100,[0,1]) * (this.width - 2 * PXSCALE * this.margin)
} else {
return (this.height - this.margin * PXSCALE) - clip(percent / 100, [0,1]) * (this.height - 2 * PXSCALE * this.margin)
}
}
Fader.prototype.draw = function(){
var d = this.percentToCoord(this.percent),
o = this.percentToCoord(this.valueToPercent(this.originValue))
this.ctx.clearRect(0,0,this.width,this.height)
if (this.widgetData.horizontal) {
if (this.widgetData.compact) {
this.ctx.save()
this.ctx.globalAlpha = 0.3
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
this.ctx.moveTo(d, this.height / 2)
this.ctx.lineTo(o, this.height / 2)
this.ctx.lineWidth = this.height
this.ctx.stroke()
this.ctx.restore()
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.knob
this.ctx.rect(Math.min(d,this.width-PXSCALE), 0, PXSCALE, this.height)
this.ctx.fill()
} else {
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.track
this.ctx.rect(this.margin * PXSCALE, this.height / 2 - 1 * PXSCALE, this.width - this.margin * 2 * PXSCALE, 2 * PXSCALE)
this.ctx.fill()
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.moveTo(d + this.margin * PXSCALE, this.height / 2)
this.ctx.lineTo(o + this.margin * PXSCALE, this.height / 2)
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.stroke()
this.ctx.fillStyle = this.colors.knob
this.ctx.save()
this.ctx.globalAlpha = 0.3
this.ctx.arc(d + this.margin * PXSCALE, this.height / 2, 10 * PXSCALE, Math.PI * 2)
this.ctx.fill()
this.ctx.restore()
this.ctx.beginPath()
this.ctx.arc(d + this.margin * PXSCALE, this.height / 2, 4 * PXSCALE, Math.PI * 2)
this.ctx.fill()
}
} else {
if (this.widgetData.compact) {
this.ctx.save()
this.ctx.globalAlpha = 0.3
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
this.ctx.moveTo(this.width / 2, d)
this.ctx.lineTo(this.width / 2, o)
this.ctx.lineWidth = this.width
this.ctx.stroke()
this.ctx.restore()
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.knob
this.ctx.rect(0, Math.min(d, this.height - PXSCALE), this.width, PXSCALE)
this.ctx.fill()
} else {
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.track
this.ctx.rect(this.width / 2 - 1 * PXSCALE, this.margin * PXSCALE, 2 * PXSCALE, this.height - this.margin *2 * PXSCALE)
this.ctx.fill()
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.moveTo(this.width / 2, d)
this.ctx.lineTo(this.width / 2, o)
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.stroke()
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.knob
this.ctx.save()
this.ctx.globalAlpha = 0.3
this.ctx.arc(this.width / 2, d, 10 * PXSCALE, Math.PI * 2,false)
this.ctx.fill()
this.ctx.restore()
this.ctx.beginPath()
this.ctx.arc(this.width / 2, d, 4 * PXSCALE, Math.PI * 2,false)
this.ctx.fill()
}
}
}
module.exports.create = function(widgetData,container) {
var fader = new Fader(widgetData, container)
return fader.widget
}

View file

@ -0,0 +1,236 @@
var {clip, mapToScale, sendOsc} = require('../utils'),
_sliders_base = require('./_sliders_base')
module.exports.options = {
type:'knob',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
unit:'',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
color:'auto',
noPip:true,
compact:false,
angle:270,
css:'',
separator2:'behaviour',
snap:false,
separator3:'osc',
range:{min:0,max:1},
origin: 'auto',
logScale:false,
precision:2,
path:'auto',
preArgs:[],
target:[]
}
Knob = function(widgetData) {
_sliders_base.apply(this,arguments)
this.widget.addClass('knob')
this.margin = 5
if (widgetData.compact) {
this.widget.addClass('compact')
this.margin = 0
}
if (!widgetData.noPip) {
this.wrapper.append(`
<div class="pips">
<div>${this.rangeLabels[0]}</div><div>${this.rangeLabels[this.rangeLabels.length-1]}</div>
</div>
`)
}
this.lastOffsetX = 0
this.lastOffsetY = 0
this.minDimension = 0
this.maxAngle = widgetData.angle
// calculate lost height factor
var a = Math.sin((360 - this.maxAngle)),
h = a < 0 ? 1 - a : a
this.lostHeightFactor = h / 4
}
Knob.prototype = Object.create(_sliders_base.prototype)
Knob.prototype.constructor = Knob
Knob.prototype.draginitHandle = function(e, data, traversing){
this.percent = clip(this.percent,[0,100])
this.lastOffsetX = data.offsetX
this.lastOffsetY = data.offsetY
if (!(traversing || this.widgetData.snap)) return
this.percent = this.angleToPercent(this.coordsToAngle(data.offsetX, data.offsetY))
this.setValue(this.percentToValue(this.percent), true, true, true)
}
Knob.prototype.dragHandle = function(e, data, traversing) {
if (!(traversing || this.widgetData.snap)) {
this.percent = -data.speedY + this.percent
} else {
this.lastOffsetX = this.lastOffsetX + data.speedX
this.lastOffsetY = this.lastOffsetY + data.speedY
this.percent = this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY))
}
this.percent = this.percent,[0,100]
this.setValue(this.percentToValue(this.percent), true, true, true)
}
Knob.prototype.coordsToAngle = function(x,y) {
var xToCenter = x - this.width /2,
yToCenter = y - this.height / 2,
angle = Math.atan2(-yToCenter, -xToCenter) * 180 / Math.PI + 90
return angle<0?360+angle:angle
}
Knob.prototype.angleToPercent = function(angle) {
return clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
}
Knob.prototype.percentToAngle = function(percent) {
var percent = clip(percent, [0, 100])
return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle
+ Math.PI / 2 // quarter circle offset
+ Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle
}
Knob.prototype.resizeHandle = function() {
_sliders_base.prototype.resizeHandle.call(this)
this.minDimension = Math.min(this.width, this.height)
this.canvas[0].style.top = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
if (this.widgetData.compact) {
this.input[0].style.marginTop = (this.minDimension / 2 - 15) * this.lostHeightFactor + 'px'
}
}
Knob.prototype.draw = function(){
var o = this.percentToAngle(this.valueToPercent(this.originValue)),
d = this.percentToAngle(this.percent),
min = this.percentToAngle(0),
max = this.percentToAngle(100)
this.ctx.clearRect(0,0,this.width,this.height)
if (this.widgetData.compact) {
this.ctx.lineWidth = 10 * PXSCALE
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.track
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, min, max)
this.ctx.stroke()
this.ctx.save()
this.ctx.globalAlpha = 0.5
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.stroke()
this.ctx.restore()
this.ctx.save()
this.ctx.translate(this.width / 2, this.height / 2)
this.ctx.rotate(d)
this.ctx.translate(-this.width / 2, -this.height / 2)
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.knob
this.ctx.lineWidth = 1 * PXSCALE
this.ctx.moveTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin - 5) * PXSCALE, this.height / 2)
this.ctx.lineTo(this.width / 2 + this.minDimension / 2 - (10 + this.margin + 5) * PXSCALE, this.height / 2)
this.ctx.stroke()
this.ctx.restore()
} else {
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.raised
this.ctx.arc(this.width / 2, this.height / 2, Math.max(this.minDimension / 2 - (30 + this.margin) * PXSCALE, 2 * PXSCALE), 0, Math.PI * 2)
this.ctx.fill()
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.track
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, min, max)
this.ctx.stroke()
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (10 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.stroke()
this.ctx.save()
this.ctx.translate(this.width / 2, this.height / 2)
this.ctx.rotate(d)
this.ctx.translate(-this.width / 2, -this.height / 2)
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.knob
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 4 * PXSCALE, 0, Math.PI * 2)
this.ctx.fill()
this.ctx.globalAlpha = 0.3
this.ctx.fillStyle = this.colors.knob
this.ctx.arc(this.width / 2 + this.minDimension / 2 - (10 + this.margin) * PXSCALE, this.height / 2, 10 * PXSCALE, 0, Math.PI * 2)
this.ctx.fill()
this.ctx.restore()
}
}
module.exports.create = function(widgetData) {
var knob = new Knob(widgetData)
return knob.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,83 @@
var sendOsc = require('./utils').sendOsc
module.exports.options = {
type:'switch',
id:'auto',
linkId:'',
separator1:'style',
label:'auto',
left:'auto',
top:'auto',
width:'auto',
height:'auto',
horizontal:false,
color:'auto',
css:'',
separator2:'osc',
values:{"Value 1":1,"Value 2":2},
precision:2,
path:'auto',
preArgs:[],
target:[]
}
module.exports.create = function(widgetData,container) {
var widget = $(`
<div class="switch">
</div>
`),
$document = $(document)
if (widgetData.horizontal) {
widget.addClass('horizontal')
}
widget.values = []
for (k in widgetData.values) {
widget.values.push(widgetData.values[k])
$('<div class="value">'+k+'</div>').data({value:widgetData.values[k]}).appendTo(widget)
}
widget.value = undefined
widget.find('.value').on('draginit',function(e,dd){
var data = $(this).data()
if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
})
widget.getValue = function() {
return widget.value
}
widget.setValue = function(v,send,sync) {
var i = widget.values.indexOf(v)
if (i!=-1) {
widget.value = widget.values[i]
widget.find('.on').removeClass('on')
widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
$(this).removeClass('ripple')
next()
})
if (send) widget.sendValue(widget.value)
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
}
widget.sendValue = function(v) {
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
return widget
}

View file

@ -0,0 +1,87 @@
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="light">
</div>\
`),
$document = $(document)
widget.value = widget.find('span')
widget.state = 0
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit.toggle',function(){
widget.off('draginit.toggle')
widget.fakeclick()
})
widget.fakeclick = function(){
var newVal = widget.state?widgetData.off:widgetData.on
widget.setValue(newVal,true,true)
$document.on('dragend.toggle',function(){
$document.off('dragend.toggle')
widget.on('draginit.toggle',function(){
widget.off('draginit.toggle')
widget.fakeclick()
})
})
}
widget.getValue = function() {
return widget.state?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
widget.addClass('on')
widget.state = 1
if (send) widget.sendValue(widgetData.on)
} else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
widget.removeClass('on')
widget.state = 0
if (send) widget.sendValue(widgetData.off)
}
if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
}
widget.sendValue = function(v) {
if (v===false) return
var args = widgetData.preArgs.concat(v)
sendOsc({
target:widgetData.target,
path:widgetData.path,
precision:widgetData.precision,
args:args
})
}
widget.setValue()
return widget
}

View file

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

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')

View file

@ -0,0 +1,7 @@
var electron = require('electron')
WEBFRAME = electron.webFrame
// mainProcess & renderProcess communication engine
IPC = electron.ipcRenderer
require('./app')

View file

@ -0,0 +1,337 @@
// jQuery drag event handler
// note: triggerHandler() is used instead of trigger() when event bubblig is not
// necessary, this increases performances a lot.
;(function($){
var events = {
touch:{start:'touchstart',stop:'touchend touchcancel',move:'touchmove',touch:true},
mouse:{start:'mousedown',stop:'mouseup',move:'mousemove',out:'mouseout',touch:false}
},
$document = $(document),
getOffset = function(obj) {
var offsetLeft = 0
var offsetTop = 0
if (obj) {
do {
if (!isNaN(obj.offsetLeft)) {
offsetLeft += obj.offsetLeft - obj.scrollLeft
}
if (!isNaN(obj.offsetTop)) {
offsetTop += obj.offsetTop - obj.scrollTop
}
} while(obj = obj.offsetParent )
}
return {left: offsetLeft, top: offsetTop}
}
$.event.special.draginit = $.event.special.drag = {
setup:function(){
var $this = $(this)
if ($this.data('dragSetup')) return
$this.data('dragSetup','true')
// mouse single touch handler
var previousEvent = null,
target = null,
traversing = false,
mouseStartHandler = function(e){
// ignore mouse event when fired by a simulated touch event
if (e.originalEvent.sourceCapabilities.firesTouchEvents || e.button == 2) return
isPointerDown = true
target = $this
previousEvent = e
e.speedX = 0
e.speedY = 0
e.deltaX = 0
e.deltaY = 0
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
$document.on(events.mouse.move,mouseMoveHandler)
$document.on(events.mouse.stop,mouseStopHandler)
$document.on(events.mouse.out,mouseOutHandler)
},
mouseMoveHandler = function(e){
e.stopPropagation()
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.speedX + previousEvent.deltaX
e.deltaY = e.speedY + previousEvent.deltaY
if (e.originalEvent.traversing) {
target = $(e.target)
e.preventDefault()
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
} else {
target.triggerHandler('drag',[e,e.originalEvent.traversing])
}
previousEvent = e
},
mouseStopHandler = function(e){
e.stopPropagation()
// ignore mouse event when fired by a simulated touch event
if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.deltaX + previousEvent.deltaX
e.deltaY = e.deltaY + previousEvent.deltaY
target.trigger('dragend',[e,e.originalEvent.traversing])
isPointerDown = false
$document.off(events.mouse.move,mouseMoveHandler)
$document.off(events.mouse.stop,mouseStopHandler)
$document.off(events.mouse.out,mouseOutHandler)
},
mouseOutHandler = function(e){
if (e.originalEvent.traversing) {
e.stopPropagation()
e.speedX = e.pageX - previousEvent.pageX
e.speedY = e.pageY - previousEvent.pageY
e.deltaX = e.deltaX + previousEvent.deltaX
e.deltaY = e.deltaY + previousEvent.deltaY
target.trigger('dragend',[e,e.originalEvent.traversing])
previousEvent = e
}
}
$this.on(events.mouse.start,mouseStartHandler)
// multi touch hanlder
window.targets = window.targets || {}
window.previousTouches = window.previousTouches || {}
window.touchActive = window.touchActive || false
var self = this,
touchStartHandler = function(e){
e.preventDefault()
var oE = e.originalEvent
for (i in oE.changedTouches) {
if (isNaN(i)) continue
var touch = oE.changedTouches[i],
id = touch.identifier
targets[id] = $(touch.target)
previousTouches[id] = touch
touch.speedX = 0
touch.speedY = 0
touch.deltaX = 0
touch.deltaY = 0
var off = getOffset(touch.target)
touch.offsetX = touch.pageX-off.left
touch.offsetY = touch.pageY-off.top
targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
}
if (!touchActive) {
$document.on(events.touch.move,touchMoveHandler)
$document.on(events.touch.stop,touchStopHandler)
touchActive = true
}
},
touchMoveHandler = function(e){
var oE = e.originalEvent
for (i in oE.changedTouches) {
if (isNaN(i)) continue
var touch = oE.changedTouches[i],
id = touch.identifier
if (e.originalEvent.traversing) {
targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY))
}
// touched[targets[id]] = touched[targets[id]]?touched[targets[id]]+1:1
touch.speedX = touch.pageX - previousTouches[id].pageX
touch.speedY = touch.pageY - previousTouches[id].pageY
touch.deltaX = touch.speedX + previousTouches[id].deltaX
touch.deltaY = touch.speedY + previousTouches[id].deltaY
touch.offsetX = previousTouches[id].offsetX+touch.speedX
touch.offsetY = previousTouches[id].offsetY+touch.speedY
if (e.originalEvent.traversing) {
touch.traversing = true
var previousTarget = document.elementFromPoint(previousTouches[id].clientX, previousTouches[id].clientY)
if (targets[id][0]!=previousTarget) {
var off = getOffset(targets[id][0])
touch.offsetX = touch.pageX-off.left
touch.offsetY = touch.pageY-off.top
$(previousTarget).trigger('dragend',[touch,e.originalEvent.traversing])
}
e.preventDefault()
if (oE.traversingContainer.contains(targets[id][0])) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
} else {
targets[id].triggerHandler('drag',[touch,e.originalEvent.traversing])
}
previousTouches[id] = touch
}
},
touchStopHandler = function(e){
var oE = e.originalEvent
for (i in oE.changedTouches) {
if (isNaN(i)) continue
var touch = oE.changedTouches[i],
id = touch.identifier
$(oE.changedTouches[i].target).trigger('dragend',[touch,e.originalEvent.traversing])
delete previousTouches[id]
delete targets[id]
}
if (oE.touches.length==0) {
$document.off(events.touch.move,touchMoveHandler)
$document.off(events.touch.stop,touchStopHandler)
touchActive = false
}
}
$this.on(events.touch.start,touchStartHandler)
}
}
var makeEventTraversing = function(e){
e.traversing=true
if (!e.traversingContainer) e.traversingContainer=this
}
$.fn.enableTraversingGestures = function() {
var self = this[0]
var down = function(e){
makeEventTraversing(e)
self.addEventListener("mousemove", makeEventTraversing, true)
self.addEventListener("touchmove", makeEventTraversing, true)
self.addEventListener("mouseout", makeEventTraversing, true)
document.addEventListener("mouseup",up,true)
document.addEventListener("touchend",up,true)
},
up = function(){
self.removeEventListener("mousemove", makeEventTraversing, true)
self.removeEventListener("touchmove", makeEventTraversing, true)
self.removeEventListener("mouseout", makeEventTraversing, true)
document.removeEventListener("mouseup",up,true)
document.removeEventListener("touchend",up,true)
}
self.addEventListener("mousedown", down, true)
self.addEventListener("touchstart", down, true)
this.on('disableTraversingGestures',function() {
self.removeEventListener("mousedown", down, true)
self.removeEventListener("touchstart", down, true)
})
return this
}
$document.on('mousedown',function(e){
if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
$(e.target).trigger('fake-click')
if (e.button==2) {
e.preventDefault()
$(e.target).trigger('fake-right-click',e)
}
})
var touchTapTimer = false,
clearTouchTapTimer = function() {
clearTimeout(touchTapTimer)
touchTapTimer = false
}
$document.on(events.touch.start,function(e){
$(e.target).trigger('fake-click')
if (!touchTapTimer&&e.originalEvent.touches.length==1) {
touchTapTimer = setTimeout(function(){
if (touchTapTimer) {
var touch = e.originalEvent.changedTouches[0],
off = getOffset(touch.target)
touch.offsetX = touch.pageX-off.left
touch.offsetY = touch.pageY-off.top
$(e.originalEvent.changedTouches[0].target).trigger('fake-right-click',touch)
}
touchTapTimer = false
},600)
} else {
clearTouchTapTimer()
}
})
$document.on(events.touch.stop + ' ' + events.touch.move,function(e){
clearTouchTapTimer()
})
$document.on('contextmenu',function(){return false})
})(jQuery)

View file

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

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

File diff suppressed because one or more lines are too long

View file

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

View file

@ -0,0 +1,128 @@
body {
background:var(--color-bg);
}
#container {
position: absolute;
top:0;
left:0;
bottom:0;
right:0;
display:flex;
flex-direction: column;
background:var(--color-bg);
padding:2rem;
// transition:right .2s;
&.sidepanel-open {
right:var(--sidepanel-size);
}
}
.content {
height:100%;
overflow: hidden;
position: relative;
background:var(--color-fg);
padding:2rem;
}
.tab {
position: absolute;
overflow: auto;
left:0;
right:-1rem; // because widgets have a fake 1rem right-border
top:0;
bottom:0;
background:var(--color-bg);
transform: rotateZ(0);
}
.has-tabs {
display: flex;
flex-direction: column;
> .navigation {
background:var(--color-bg);
margin-right:1rem; // because widgets have a fake 1rem right-border
}
> .content {
background:none;
margin-right:1rem; // because widgets have a fake 1rem right-border
}
}
.navigation {
height:var(--nav-height);
margin-bottom: 2rem;
flex-shrink:0;
font-weight:bold;
text-transform: uppercase;
&.main {
li:last-child {
width:var(--nav-height);
max-width:var(--nav-height);
min-width:var(--nav-height);
i {
margin:0 auto;
}
}
}
ul {
list-style:none;
display: flex;
overflow: hidden;
height:100%;
li {
display:block;
min-width:0;
flex: 1;
cursor:pointer;
height:100%;
margin-right: 1rem;
&:last-child {
margin-right:0;
}
a {
background: var(--color-fg);
pointer-events: none;
padding: 5rem;
height:100%;
display: flex;
align-items: center;
overflow:hidden;
text-align:center;
position:relative;
span {
display:block;
width:100%;
-webkit-mask: linear-gradient(to left, rgba(0, 0, 0, 0), #000000 10rem) no-repeat;
}
}
a:after {
content:"";
background:var(--color-accent);
position: absolute;
bottom:0;
left:0;
right:0;
top:0;
opacity: 0;
transition: opacity .2s;
z-index: -1;
}
&.on a, .sidepanel-open {
position: relative;
background: var(--color-raised);
z-index: 0;
&:after {
opacity:0.3;
}
}
}
.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,78 @@
::-webkit-scrollbar {
width: var(--scrollbar-size);
height:var(--scrollbar-size);
opacity:1;
}
::-webkit-scrollbar-track-piece {
background: var(--color-bg);
&:vertical {
border-left:2rem solid var(--color-bg);
}
&:horizontal {
border-top:2rem solid var(--color-bg);
}
}
::-webkit-scrollbar-corner {
background: var(--color-fg);
border-left:2rem solid var(--color-bg);
border-top:2rem solid var(--color-bg);
}
::-webkit-scrollbar-thumb {
background:var(--color-raised);
&:vertical {
border-left:2rem solid var(--color-bg);
}
&:horizontal {
border-top:2rem solid var(--color-bg);
}
}
@mixin arrow($i) {
background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="50px" width="50px"><text x="50%" y="50%" font-size="30" fill="rgba(255,255,255,0.5)" alignment-baseline="central" text-anchor="middle" font-family="fontawesome"> '+$i+' </text></svg>');
background-blend-mode: difference, normal;
}
::-webkit-scrollbar-button:decrement:start, ::-webkit-scrollbar-button:increment:end {
background:var(--color-fg);
height:var(--scrollbar-size);
width: var(--scrollbar-size);
display: block;
color:red;
background-size:contain;
background-position: center;
&:vertical {
&:decrement:start {
border-left:2rem solid var(--color-bg);
border-bottom:2rem solid var(--color-bg);
@include arrow()
}
&:increment:end {
border-left:2rem solid var(--color-bg);
border-top:2rem solid var(--color-bg);
@include arrow()
}
}
&:horizontal {
&:decrement:start {
border-right:2rem solid var(--color-bg);
border-top:2rem solid var(--color-bg);
@include arrow()
}
&:increment:end {
border-left:2rem solid var(--color-bg);
border-top:2rem solid var(--color-bg);
@include arrow()
}
}
}

View file

@ -0,0 +1,149 @@
#sidepanel {
position:absolute;
z-index: 999999;
width:var(--sidepanel-size);
border: 8rem solid var(--color-fg);
top:0;
right:0;
bottom:0;
margin-right:calc(-1 * var(--sidepanel-size));
background:var(--color-fg);
transition:transform .25s, opacity .25s;
transform: translate3d(0,0,0);
opacity: 0;
overflow-y: auto;
overflow-x: visible;
&.sidepanel-open {
transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0);
opacity: 1;
}
#options {
position:absolute;
left:0;top:0;
right:0;bottom:0;
list-style:none;
li {
display:block;
margin-bottom:8rem;
position: relative;
&:last-child {
margin: 0;
}
.btn + span {
position: absolute;
right:0rem;
top:0rem;
padding:8rem;
color:var(--color-text-fade);
&:hover {
color:var(--color-text);
}
}
ul {
padding: 4rem;
li {
margin-bottom: 4rem;
}
}
}
.editor .form {
margin-top: 10rem;
}
.help {
margin-top:10rem;
font-size: .75em;
text-align: center;
font-style: italic;
}
}
&::-webkit-scrollbar-track-piece {
background: var(--color-bg);
&:vertical {
border-left:8rem solid var(--color-fg);
}
}
&::-webkit-scrollbar-thumb {
background:var(--color-raised);
&:vertical {
border-left:8rem solid var(--color-fg);
}
}
&::-webkit-scrollbar-button {
border-color: var(--color-fg);
border-width:8rem;
background-color: var(--color-raised);
}
}
.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 {
z-index: 0;
pointer-events: none;
&:after {
opacity:.3;
}
}
&: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;
bottom:0;
opacity: 0;
transition: opacity .2s;
z-index: -1;
}
}
}

View file

@ -0,0 +1,29 @@
: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%); // faded
--color-track: lighten(#1a1d22,1%); // widgets unfilled value
--color-accent:#528bff;
--color-custom:var(--color-accent);
--nav-height:40rem;
--sidepanel-size:300rem;
--scrollbar-size:30rem;
--pixel-scale:1;
/* Unset variables by default
--display-input:none; // Hides widgets' numeric inputs
*/
}

View file

@ -0,0 +1,109 @@
.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-raised);
border-bottom:1rem solid var(--color-bg);
flex-shrink: 0;
&.accent {
color:var(--color-accent);
}
}
.input {
width:100%;
height:24rem;
border:0;
background:transparent;
color:var(--color-text-fade);
display:block;
padding:4rem 5rem;
position: relative;
display: var(--display-input);
input {
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
padding:4rem 5rem;
width: 100%;
font: inherit;
text-align:center;
border:0;
background: transparent;
color:var(--color-accent);
}
canvas {
width:100%;
height:100%;
opacity: 0.8;
}
input + canvas {
visibility: hidden;
}
&:focus {
color:var(--color-accent);
}
&[disabled] {
color:var(--color-text-fade);
}
}
}
@import 'widgets/fader';
@import 'widgets/knob';
@import 'widgets/matrices';
@import 'widgets/pads';
@import 'widgets/plots';
@import 'widgets/toggle';
@import 'widgets/push';
@import 'widgets/switch';
@import 'widgets/strip';
@import 'widgets/panel';

257
app/browser/scss/style.scss Normal file
View file

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

View file

@ -0,0 +1,204 @@
.fader-container {
--color-pips: var(--color-text-fade);
--color-gauge: var(--color-custom);
--color-knob: var(--color-custom);
height:100%;
width:100rem;
}
.fader {
height:100%;
overflow: hidden;
display: flex;
flex-direction: column;
position: relative;
.wrapper {
overflow: hidden;
flex:1;
display: flex;
max-height: 100%;
width: 100%;
position: relative;
canvas {
flex:1;
max-height: 100%;
width: 100%;
}
.meter-container {
pointer-events: none;
position: absolute;
top:20rem;
bottom:19rem;
left:50%;
height: auto;
width:3rem;
min-width: 3rem;
}
}
&.has-pips {
.wrapper canvas {
padding-right: 28rem;
}
.pips {
pointer-events: none;
position: absolute;
top:20rem;
bottom:20rem;
left:50%;
z-index: 0;
width: 4rem;
margin-left: 7rem;
background: linear-gradient(to bottom, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
background-size: 100% 5px;
background-repeat: repeat-y;
.pip {
height:1px;
background: var(--color-pips);
color:var(--color-fg);
position: absolute;
width:8rem;
left:0;
&:before {
content:"";
position: absolute;
top:-4px;
left:0;
right:0;
bottom:-4px;
background: var(--color-fg);
z-index: -1;
}
span {
position: absolute;
width:30rem;
display: block;
text-align: center;
font-size:10rem;
line-height: 12rem;
left:3rem;
top:-5.5rem;
color:var(--color-pips);
}
}
}
&.horizontal {
.wrapper canvas {
padding-right:0;
padding-bottom: 20rem;
}
.wrapper .meter-container {
left:20rem;
right:20rem;
height: 3rem;
min-height: 3rem;
width: auto;
top:50%;
margin-top: 3rem;
}
.pips {
top:50%;
left:20rem;
right:20rem;
font-size: 0;
height:4rem;
width:auto;
margin:0;
margin-top: 10rem;
background: linear-gradient(to right, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);
background-size: 5px 100%;
background-repeat: repeat-x;
.pip {
width:1px;
height:6rem;
margin: 0;
&:before {
top:0;
bottom:0;
left:-4px;
right:-4px;
}
span {
top:15rem;
left:-15rem!important;
right:auto;
}
}
}
}
&.align-right {
.wrapper canvas {
padding-right: 0;
padding-left: 28rem;
}
.wrapper .meter-container {
left: auto;
right:50%;
margin-left: 0;
}
.pips {
margin-left: 0;
margin-right: 7rem;
left:auto;
right:50%;
.pip {
right:0;
left:auto;
span {
right:3rem;
left:auto;
}
}
}
}
}
&.compact {
.wrapper canvas {
background: var(--color-faded)
}
.input {
overflow: hidden;
position: absolute;
top:50%;
transform: rotate(-90deg);
pointer-events: none;
width: 100rem;
margin-left: -50rem;
left:50%;
z-index: 3;
margin-top: -12rem;
}
.meter-container {
top: 0;
bottom: 0;
left: auto;
right:0;
}
&.horizontal {
.meter-container {
top: auto;
bottom: 0;
left: 0;
right:0;
height: 3rem;
min-height: 3rem;
width: auto;
}
.input {
transform: none;
top:50%;
}
}
}
}

View file

@ -0,0 +1,56 @@
.knob-container {
--color-pips: var(--color-text-fade);
--color-gauge: var(--color-custom);
--color-knob: var(--color-custom);
width: 100rem;
height: 120rem;
align-items: center;
flex-shrink: 0;
}
.knob {
height:100%;
width: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
position: relative;
.wrapper {
overflow: hidden;
flex:1;
display: flex;
max-height: 100%;
width: 100%;
position: relative;
canvas {
flex:1;
max-height: 100%;
width: 100%;
position: relative;
}
}
&.compact {
.input {
position: absolute;
top:calc(50% - 12rem);
pointer-events: none;
}
}
.pips {
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
pointer-events: none;
div {
padding: 0 8%;
font-size: 11rem;
color: var(--color-text-fade);
}
}
}

View file

@ -0,0 +1,44 @@
/* 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;
}
}
}

View file

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

View file

@ -0,0 +1,64 @@
.panel-container {
width: 200rem;
height: 200rem;
border:0;
background: var(--color-faded);
&:before {
content:"";
position: absolute;
top:0;
bottom:0;
right: 0;
left: 0;
border-bottom: 1rem solid var(--color-bg);
border-right: 1rem solid var(--color-bg);
pointer-events: none;
z-index: 2;
}
&.nolabel .panel {
top:0;
}
.panel {
overflow: auto;
position: absolute;
top:35rem;
left:0;
right:0;
bottom:0;
&.has-tabs {
display: flex;
flex-direction: column;
background: var(--color-bg);
}
&.noscroll {
overflow: hidden;
> .widget {
max-width: 100%;
max-height: 100%;
}
}
}
.navigation {
border-top: 0;
background: transparent;
&:after {
background: var(--color-bg);
}
a.on {
border-color: var(--color-bg);
}
}
.content {
background: transparent;
}
}

View file

@ -0,0 +1,122 @@
.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-custom);
&:after {
content:"";
border-radius:100%;
position: absolute;
top:-1rem;left:-1rem;right:-1rem;bottom:-1rem;
display:block;
border: 6rem solid var(--color-fg);
opacity: 0.8;
}
}
}
}
}
.plot-container, .visualizer-container, .eq-container {
--color-custom:var(--color-accent);
height: 200rem;
width: 200rem;
.plot {
display: flex;
flex-direction: row;
flex:1;
position: relative;
}
canvas {
position: absolute;
top:0;left:0;
width:100%;
height: 100%;
}
}
.meter-container {
--color-custom:var(--color-accent);
--color-gauge: var(--color-custom);
height: 100rem;
.meter {
display: flex;
flex-direction: row;
flex:1;
position: relative;
background: var(--color-track);
.level {
width:100%;
flex:1;
transform-origin: bottom;
background:var(--color-custom);
// opacity: .5;
}
&::after {
content:"";
position: absolute;
top:0;
left:0;
bottom:0;
right:0;
background-image: linear-gradient(transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
background-size: 100% 2px;
background-repeat: repeat;
}
&.horizontal {
&::after {
background-image: linear-gradient(to left, transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px );
background-size: 2px 100% ;
}
.level {
transform-origin: left;
}
}
}
}
.text-container {
--color-custom:var(--color-accent);
.text {
flex: 1;
height:35rem;
padding: 10rem;
justify-content: center;
display: flex;
align-items: center;
background: var(--color-faded);
color:var(--color-custom);
&.vertical {
transform: rotate(180deg);
text-overflow: ellipsis;
overflow: hidden;
-webkit-writing-mode:vertical-lr;
}
}
}

View file

@ -0,0 +1,9 @@
.push-container {
@extend .toggle-container;
.active {
background: var(--color-fg);
}
.light:after{
display: none;
}
}

View file

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

View file

@ -0,0 +1,75 @@
.switch-container {
width:100rem;
flex-shrink: 0;
.switch {
height:100%;
width:100%;
cursor: pointer;
display: flex;
flex-direction:column;
align-items: stretch;
flex:1;
z-index: 1;
&.horizontal {
flex-direction:row;
.value {
padding: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;
}
}
}
.value {
background:var(--color-raised);
color:var(--color-text);
width:100%;
height:100%;
position: relative;
border-top: 1rem solid var(--color-bg);
white-space: normal;
padding:12rem;
text-align: center;
word-break: break-all;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
box-shadow: 0 0 1rem 0 var(--color-text-fade) inset;
&:first-child {
border-top:0;
}
&:last-child {
margin-bottom:0;
}
&:before {
content:"";
position: absolute;
left:0;
top:0;
right:0;
bottom:0;
background: var(--color-custom);
opacity: 0;
z-index: 2;
}
&.on:before {
opacity: .3;
box-shadow: 0 0 1rem 0 var(--color-custom) inset;
}
}
}
}

View file

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

3842
app/examples/audio.js Normal file

File diff suppressed because it is too large Load diff

731
app/examples/eq.js Normal file
View file

@ -0,0 +1,731 @@
[
{
"label": "Unnamed",
"widgets": [
{
"type": "panel",
"top": 0,
"left": 0,
"id": "panel_1",
"label": "Equalizer",
"width": 600,
"height": 620,
"scroll": false,
"color": "auto",
"css": "",
"widgets": [
{
"type": "eq",
"top": 0,
"left": 0,
"id": "eq_1",
"label": false,
"width": "100%",
"height": 210,
"color": "auto",
"css": "",
"filters": [
{
"type": "highpass",
"freq": "eq_freq_1",
"q": "eq_q_1",
"on": "eq_on_1"
},
{
"type": "lowshelf",
"freq": "eq_freq_2",
"gain": "eq_gain_2",
"on": "eq_on_2"
},
{
"type": "eq_type_3",
"freq": "eq_freq_3",
"q": "eq_q_3",
"gain": "eq_gain_3",
"on": "eq_on_3"
},
{
"type": "eq_type_4",
"freq": "eq_freq_4",
"q": "eq_q_4",
"gain": "eq_gain_4",
"on": "eq_on_4"
},
{
"type": "highshelf",
"freq": "eq_freq_5",
"gain": "eq_gain_5",
"on": "eq_on_5"
},
{
"type": "lowpass",
"freq": "eq_freq_6",
"q": "eq_q_6",
"on": "eq_on_6"
}
],
"rangeY": {
"min": -20,
"max": 20
},
"logScaleX": true,
"path": "/eq_1",
"preArgs": [],
"resolution": 512
},
{
"id": "Band 1",
"type": "strip",
"label": "Highpass",
"widgets": [
{
"id": "eq_on_1",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"linkId": "",
"on": 1,
"off": 0,
"path": "/eq_on_1",
"target": []
},
{
"id": "eq_freq_1",
"label": "Frequency",
"type": "fader",
"range": {
"min": 20,
"max": 22050
},
"path": "/eq_freq_1",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"linkId": "",
"alignRight": false,
"horizontal": true,
"meter": false,
"origin": "auto",
"target": []
},
{
"id": "eq_q_1",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_1",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"linkId": "",
"alignRight": false,
"horizontal": true,
"meter": false,
"origin": "auto",
"target": []
}
],
"left": 0,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
},
{
"id": "Band 2",
"type": "strip",
"label": "Lowshelf",
"widgets": [
{
"id": "eq_on_2",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"on": 1,
"off": 0,
"linkId": "",
"target": [],
"path": "/eq_on_2"
},
{
"id": "eq_freq_2",
"label": "Frequency",
"type": "fader",
"range": {
"min": 20,
"max": 22050
},
"path": "/eq_freq_2",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_q_2",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_2",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_gain_2",
"label": "Gain",
"type": "fader",
"range": {
"min": -20,
"max": 20
},
"path": "/eq_gain_2",
"unit": "dB",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"width": "auto",
"origin": "auto",
"target": []
}
],
"left": 100,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
},
{
"id": "Band 3",
"type": "strip",
"label": "auto",
"widgets": [
{
"id": "eq_on_3",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"on": 1,
"off": 0,
"linkId": "",
"path": "/eq_on_3",
"target": []
},
{
"id": "eq_freq_3",
"label": "Frequency",
"type": "fader",
"range": {
"min": 20,
"max": 22050
},
"path": "/eq_freq_3",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_q_3",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_3",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_gain_3",
"label": "Gain",
"type": "fader",
"range": {
"min": -20,
"max": 20
},
"path": "/eq_gain_3",
"unit": "dB",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"width": "auto",
"origin": "auto",
"target": []
},
{
"type": "switch",
"id": "eq_type_3",
"label": "Mode",
"width": "auto",
"height": 79,
"horizontal": true,
"color": "auto",
"css": "",
"precision": 2,
"path": "/eq_type_3",
"preArgs": [],
"target": [],
"values": {
"notch": "notch",
"peak": "peak"
},
"linkId": ""
}
],
"left": 200,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
},
{
"id": "Band 4",
"type": "strip",
"label": "auto",
"widgets": [
{
"id": "eq_on_4",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"on": 1,
"off": 0,
"linkId": "",
"path": "/eq_on_4",
"target": []
},
{
"id": "eq_freq_4",
"label": "Frequency",
"type": "fader",
"range": {
"min": 20,
"max": 22050
},
"path": "/eq_freq_4",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_q_4",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_4",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_gain_4",
"label": "Gain",
"type": "fader",
"range": {
"min": -20,
"max": 20
},
"path": "/eq_gain_4",
"unit": "dB",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"width": "auto",
"origin": "auto",
"target": []
},
{
"type": "switch",
"id": "eq_type_4",
"label": "Mode",
"width": "auto",
"height": 79,
"horizontal": true,
"color": "auto",
"css": "",
"precision": 2,
"path": "/eq_type_4",
"preArgs": [],
"target": [],
"values": {
"notch": "notch",
"peak": "peak"
},
"linkId": ""
}
],
"left": 300,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
},
{
"id": "Band 5",
"type": "strip",
"label": "Highshelf",
"widgets": [
{
"id": "eq_on_5",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"on": 1,
"off": 0,
"linkId": "",
"path": "/eq_on_5",
"target": []
},
{
"id": "eq_freq_5",
"label": "Frequency",
"type": "fader",
"range": {
"min": 10000,
"max": 22050
},
"path": "/eq_freq_5",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_q_5",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_5",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_gain_5",
"label": "Gain",
"type": "fader",
"range": {
"min": -20,
"max": 20
},
"path": "/eq_gain_5",
"unit": "dB",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"width": "auto",
"origin": "auto",
"target": []
}
],
"left": 400,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
},
{
"id": "Band 6",
"type": "strip",
"label": "Lowpass",
"widgets": [
{
"id": "eq_on_6",
"type": "toggle",
"label": "ON",
"width": "auto",
"height": 50,
"color": "auto",
"css": "",
"precision": 2,
"preArgs": [],
"on": 1,
"off": 0,
"linkId": "",
"path": "/eq_on_6",
"target": []
},
{
"id": "eq_freq_6",
"label": "Frequency",
"type": "fader",
"range": {
"min": 10000,
"max": 22050
},
"path": "/eq_freq_6",
"unit": "Hz",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
},
{
"id": "eq_q_6",
"label": "Q",
"type": "fader",
"range": {
"min": 0.125,
"max": 8
},
"path": "/eq_q_6",
"unit": "",
"width": "auto",
"height": 70,
"color": "auto",
"noPip": false,
"compact": true,
"css": "",
"snap": false,
"logScale": false,
"precision": 2,
"preArgs": [],
"alignRight": false,
"horizontal": true,
"meter": false,
"linkId": "",
"origin": "auto",
"target": []
}
],
"left": 500,
"top": 210,
"width": "auto",
"height": 375,
"horizontal": false,
"color": "auto",
"css": ""
}
],
"tabs": []
}
]
}
]

329
app/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
app/examples/widgets.js Normal file

File diff suppressed because it is too large Load diff

1
app/index.js Normal file
View file

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

142
app/main/callbacks.js Normal file
View file

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

41
app/main/main.js Normal file
View file

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

64
app/main/osc.js Normal file
View file

@ -0,0 +1,64 @@
var osc = require('node-osc')
module.exports = function(ipc, settings) {
var inPort = settings.read('oscInPort'),
debug = settings.read('debug')
if (inPort) {
var oscServer = new osc.Server(inPort, '127.0.0.1')
oscServer.on('message', function (msg, rinfo) {
var data = {path:msg.shift(),args:msg}
if (data.args.length==1) data.args = data.args[0]
ipc.send('receiveOsc',data)
if (debug) console.log('OSC received: ',data, 'From : ' + rinfo.address + ':' + rinfo.port)
})
}
return {
send: function(host,port,path,args,precision) {
var client = new osc.Client(host, port)
client._sock.bind({exclusive:false,reuseAddr:true,port:inPort},function(){
var message = new osc.Message(path)
var numberType = precision==0?'integer':'float'
if (typeof args=='object' && args!==null) {
for (i in args) {
var arg = args[i]
if (typeof arg == 'number' && arg!==null && typeof arg != 'object') {
message.append({type:numberType,value:arg})
} else if (arg!==null && typeof arg != 'object'){
message.append({type:'string',value:String(arg)})
} else if (arg!==null && typeof arg == 'object' && arg.type && arg.value!=undefined) {
message.append({type:arg.type,value:arg.value})
}
}
} else if (args!==null){
if (typeof args == 'number') {
message.append({type:numberType,value:args})
} else if (typeof args == 'object' && arg.type && arg.value!=undefined) {
message.append({type:args.type,value:args.value})
} else {
message.append({type:'string',value:String(args)})
}
}
client.send(message, function () {
client.kill()
})
if (debug) console.log('OSC sent: ',{path:path,args:message.args}, 'To : ' + host + ':' + port)
})
}
}
}

View file

@ -0,0 +1,66 @@
var path = require('path'),
shortcut = require('electron-localshortcut')
module.exports = function(settings,app,ipc,browserWindow) {
window = new browserWindow({
width: 800,
height: 600,
icon: path.resolve(__dirname + '/../resources/images/logo.png'),
title:settings.read('appName'),
backgroundColor:'#1a1d22'
})
window.loadURL('file://' + __dirname + '/../browser/index.html')
window.on('closed', function() {
window = null
})
window.setMenuBarVisibility(false)
shortcut.register(window,'CmdOrCtrl+R',function(){
window.reload()
})
shortcut.register(window,'F11',function(){
window.setFullScreen(!window.isFullScreen())
})
shortcut.register(window,'F12',function(){
window.toggleDevTools();
})
// 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
}
}

View file

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

66
app/main/settings.js Normal file
View file

@ -0,0 +1,66 @@
// This prevents argv parsing to be breaked when the app is packaged (executed without 'electron' prefix)
if (process.argv[1]&&process.argv[1].indexOf('-')==0) process.argv.unshift('')
var baseDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'],
configFile = require('path').join(baseDir, '.open-stage-control')
var argv = require('yargs')
.help('help').usage(`\nUsage:\n $0 [options]`).alias('h', 'help')
.options({
's':{alias:'sync',type:'array',describe:'synchronized hosts (ip:port pairs)'},
'l':{alias:'load',type:'string',describe:'session file to load'},
'p':{alias:'port',describe:'osc input port (for synchronization)'},
'd':{alias:'debug',describe:'log received osc messages in the console'},
'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'},
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'},
'examples':{describe:'list examples instead of recent sessions'}
})
.check(function(a,x){if(a.p==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.s==undefined || a.s.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Sync hosts must be ip:port pairs & port must be >= 1024'}})
.strict()
.argv
module.exports = function(fs) {
var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8'))} catch(err) {return {}}}(),
defaultConfig = {
presetPath : process.cwd(),
sessionPath: process.cwd(),
recentSessions: [],
appName: 'Open Stage Control',
syncTargets: argv.s || false,
oscInPort: argv.p || 0,
debug: argv.d || false,
sessionFile: argv.l || false,
noGui: argv.n || false,
examples: argv.examples,
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
app/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: #bbb;
--color-fg: #ddd;
--color-raised: #eee;
--color-faded: #ccc;
--color-track: #aaa;
--color-accent: #307aaa;
}

View file

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

33
app/package.json Normal file
View file

@ -0,0 +1,33 @@
{
"name": "open-stage-control",
"productName": "Open Stage Control",
"description": "A libre desktop OSC bi-directionnal control surface application.",
"version": "0.7.0",
"main": "index.js",
"author": {
"name": "Jean-Emmanuel Doucet / AMMD",
"email": "jeannot@ammd.net"
},
"dependencies": {
"electron-localshortcut":"0.6.1",
"node-osc": "2.0.3",
"yargs": "5.0.0",
"socket.io": "1.4.8",
"socket.io-client": "1.4.8",
"socketio-wildcard": "0.3.0",
"express": "4.14.0"
},
"scripts": {
"start": "electron ."
},
"keywords": [
"osc",
"interface",
"multi-touch"
],
"repository": {
"type": "git",
"url": "https://github.com/jean-emmanuel/open-stage-control"
},
"licence": "GPL-3.0"
}

11
app/resources/README.md Normal file
View file

@ -0,0 +1,11 @@
# How to build the docs
```bash
$ sudo apt-get install python python-pip # python package manager
$ sudo pip install mkdocs # docs site builder
$ sudo pip install mkdocs-cinder # theme
$ mkdocs serve # make docs available on http://127.0.0.1:8000
$ mkdocs build # build docs static site
$ mkdocs gh-deploy --clean # deploy static site on gh-pages branch
```

View file

@ -0,0 +1,105 @@
# Getting started
----
## Run from binaries
Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page.
```bash
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 / feedback)
-d, --debug log received osc in the console
-n, --nogui disable default gui and makes the app availabe through http on specified port
-t, --theme theme name or path (mutliple values allowed)
Examples:
$ 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
```
----
## Run from sources
Running the app from the sources slightly differs from using built binaries : instead of running a binary, we'll launch the app with npm.
**Requirements**
- [Node.js >= 4.0](https://nodejs.org/)
- [npm](https://www.npmjs.com/)
```bash
$ sudo apt-get install nodejs npm # install nodejs & npm
$ sudo npm install -g npm # update npm
```
**Download**
```bash
$ git clone https://github.com/jean-emmanuel/open-stage-control
$ cd open-stage-control/
$ npm install
```
**Run**
```bash
$ npm start [ -- options]
# A double hyphen ("--") is used here to tell npm that the following options are to be given to the app.
```
----
## 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
$ 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
$ # or
$ npm run debarm
```
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

@ -0,0 +1,45 @@
# <img src="img/logo.png" height="80px"/> <small>Open Stage Control</small>
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/](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.
## 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 !
## Supported platforms
Same as [Electron's supported platforms](https://github.com/electron/electron/blob/master/docs/tutorial/supported-platforms.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](http://socket.io)
- [browserify](http://browserify.org)
- [express](http://expressjs.com)
- [node-sass](https://github.com/sass/node-sass)
- [jQuery](http://jquery.com/)
- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
- [Font Awesome](http://fontawesome.io/)

View file

@ -0,0 +1,31 @@
# User interface
----
## Editor
The session editor can be enabled in the side panel. Once enabled, clicking on a widget or on a tab will make it the *selected object*, adding a fancy dashed blue border to it.
### Properties
All the selected object's properties are displayed and can be modified in the side panel. Any modification will redraw the object **and all its children** if the submitted data is valid. Please refer to the [widgets reference](widgets-generics.md) for the list of valid options.
Widgets containers such as tabs, strips and panels will also list their children here, which can be reordered using drag-and-drop.
### Size / Position
The selected object can be resized using its south, south-east and east handles. It can be dragged with its north handle.
### Context menu
Right clicking on a widget or on a tab will also display a context menu providing useful utilities :
- `copy`: copy widget's data
- `cut`: copy widget's data and delete selected widget
- `paste`: paste copied widget in selected container
- `Add widget`: create a new widget in selected container
- `Add tab`: create a new tab in selected container
- `Delete`: delete selected tab or widget

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