diff --git a/index.js b/index.js
index dc1f5ef6..9a0fd555 100644
--- a/index.js
+++ b/index.js
@@ -1,9 +1,39 @@
+/* TODO
+
+- configuration panel
+ - defaultTarget
+ - syncTargets
+
+
+*/
+
+
+// config file handling
+
var defaultConfig = {
presetPath : __dirname,
sessionPath: __dirname,
- recentSessions: []
+ recentSessions: [],
+ syncTargets: [],
+ oscInPort:5555
}
+writeConfig = function(newconfig) {
+ for (i in newconfig) {
+ config[i] = newconfig[i]
+ }
+ fs.writeFile(__dirname + '/lib-dev/config/config.json',JSON.stringify(config,null,4), function (err, data) {
+ if (err) throw err;
+ });
+
+}
+
+readConfig = function(key) {
+ return config[key] || defaultConfig[key]
+}
+
+
+
// dependencies
var app = require('app')
@@ -13,8 +43,9 @@ var app = require('app')
, osc = require("osc")
, fs = require("fs")
, ipc = require('ipc')
- , renderProcess = {}
+
, config = require(__dirname + '/lib-dev/config/config.json')
+ , args = process.argv.slice(2);
// static files serving
@@ -44,7 +75,7 @@ app.on('ready', function() {
window = new BrowserWindow({
width: 800,
height: 600,
- 'auto-hide-menu-bar':true,
+ 'auto-hide-menu-bar':true
});
// and load the index.html of the app.
@@ -64,8 +95,8 @@ app.on('ready', function() {
// osc event listener
var udpPort = new osc.UDPPort({
- localAddress: "0.0.0.0",
- localPort: 5555
+ localAddress: "127.0.0.1",
+ localPort: readConfig('oscInPort')
});
@@ -75,7 +106,7 @@ udpPort.open();
udpPort.on("message", function (data) {
renderProcess.send('receiveOsc',data);
- console.log('Received OSC : ',data)
+ // console.log('Received OSC : ',data)
});
@@ -83,39 +114,50 @@ udpPort.on("message", function (data) {
// mainProcess & renderProcess async i/o
-
-renderProcess.send = function(name,data) {
- window.webContents.send(name,data);
+renderProcess = {
+ send : function(name,data) {
+ window.webContents.send(name,data);
+ }
}
-
ipc.on('loadSession',function(event, data){
var sessionlist = readConfig('recentSessions')
if (data == 'browse') {
dialog.showOpenDialog(window,{title:'Load session file',defaultPath:readConfig('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){
+
if (file==undefined) {return}
+
+ // save path to configfile
writeConfig({sessionPath:file[0].replace(file[0].split('/').pop(),'')})
+ // open session
renderProcess.send('openSession',file[0]);
+
+ // add session to history
sessionlist.unshift(file[0])
+ // remove doubles from history
sessionlist = sessionlist.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})
+ // save history
writeConfig({recentSessions:sessionlist})
})
} else {
-
+ // open session
renderProcess.send('openSession',sessionlist[data]);
+ // add session to history
sessionlist.unshift(sessionlist[data])
+ // remove doubles from history
sessionlist = sessionlist.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})
+ // save history
writeConfig({recentSessions:sessionlist})
}
@@ -127,9 +169,16 @@ ipc.on('removeSessionFromHistory',function(event, data){
sessionlist.splice(data,1)
writeConfig({recentSessions:sessionlist})
})
+
+
ipc.on('ready',function(){
var recentSessions = readConfig('recentSessions')
renderProcess.send('listSessions',recentSessions)
+
+ if ('testing'==args[0]) {
+ var sessionlist = readConfig('recentSessions')
+ renderProcess.send('openSession',sessionlist[0]);
+ }
})
@@ -183,19 +232,3 @@ ipc.on('fullscreen', function(event){
window.setFullScreen(!window.isFullScreen())
})
-
-
-
-writeConfig = function(newconfig) {
- for (i in newconfig) {
- config[i] = newconfig[i]
- }
- fs.writeFile(__dirname + '/lib-dev/config/config.json',JSON.stringify(config), function (err, data) {
- if (err) throw err;
- });
-
-}
-
-readConfig = function(key) {
- return config[key] || defaultConfig[key]
-}
diff --git a/lib-dev/config/config.json b/lib-dev/config/config.json
index 46df6735..f131499a 100644
--- a/lib-dev/config/config.json
+++ b/lib-dev/config/config.json
@@ -1 +1,9 @@
-{"presetPath":"/home/bordun/oscwork/oschtmlgui/lib-dev/presets/","sessionPath":"/home/bordun/oscwork/oschtmlgui/lib-dev/js/","recentSessions":["/home/bordun/oscwork/oschtmlgui/lib-dev/js/demo.js"]}
\ No newline at end of file
+{
+ "presetPath": "/home/bordun/oscwork/oschtmlgui/",
+ "sessionPath": "/home/bordun/oscwork/oschtmlgui/lib-dev/js/",
+ "recentSessions": [
+ "/home/bordun/oscwork/oschtmlgui/lib-dev/js/demo-full.js",
+ "/home/bordun/oscwork/oschtmlgui/lib-dev/js/demo.js",
+ "/home/bordun/oscwork/oschtmlgui/monitorsjeannot.js"
+ ]
+}
\ No newline at end of file
diff --git a/lib-dev/css/style.scss b/lib-dev/css/style.scss
index 8171170f..cb3a8a08 100644
--- a/lib-dev/css/style.scss
+++ b/lib-dev/css/style.scss
@@ -40,10 +40,44 @@ $sidepanel-size:300px;
}
+$scrollbar-margin:5px;
+::-webkit-scrollbar {
+ width: 20px;
+ height:20px;opacity:1;
+
+}
+
+::-webkit-scrollbar-track-piece {
+ background: rgba(0,0,0,.2);
+ &:vertical {
+ border-left:$scrollbar-margin solid $color-fg;
+ }
+ &:horizontal {
+ border-top:$scrollbar-margin solid $color-fg;
+ }
+}
+::-webkit-scrollbar-corner {
+ background: none;
+}
+::-webkit-scrollbar-thumb {
+ background:$bg-button;
+ width:10px!important;
+ opacity:1;
+ &:vertical {
+ border-left:$scrollbar-margin solid $color-fg;
+ }
+ &:horizontal {
+ border-top:$scrollbar-margin solid $color-fg;
+ }
+}
-* ::selection{
- background:rgba(0,0,0,0);
+
+* {
+ -webkit-user-select: none;
+}
+.inspector *{
+ -webkit-user-select: initial;
}
.inspector *::selection{
background:$color-accent!important;
@@ -53,6 +87,13 @@ input:focus::selection{
}
+
+
+
+
+
+
+
html, body {
height:100%;
overflow:hidden;
@@ -219,7 +260,15 @@ body {
white-space: pre;
word-wrap: break-word;
width:100%;
-
+ max-height: 300px;
+ overflow-y: auto;
+ &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb {
+ border-color:$color-border!important
+ }
+ &::-webkit-scrollbar-thumb{
+ background:$color-bg!important;
+ opacity:0.6!important;
+ }
}
}
}
@@ -387,24 +436,58 @@ a {
}
+
+
+
+.spinner {
+ position: absolute;
+ top:50%;
+ left:50%;
+ margin:-15px 0 0 -15px;
+ height:30px;
+ width:30px;
+ border-radius: 50%;
+ border:2px solid rgba(0,0,0,.2);
+ border-top-color:$color-accent;
+ animation: spin .5s linear infinite;
+}
+
+@keyframes spin {
+ 0% {transform: rotate(0deg);}
+ 100% {transform: rotate(360deg);}
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
// WIDGETS
.widget {
display:inline-block;
height:100%;
+ overflow: visible;
position:relative;
font-size:13px;
// box-shadow: 0 0 0 1px $color-border;
padding-top:35px;
- padding-bottom: 8px;
+ //padding-bottom: 8px;
vertical-align:top;
- overflow: hidden;
+ // overflow: hidden;
margin-right: 10px;
&:last-child {
margin-right: 0
}
.title {
-
+ z-index: 1;
padding:10px 10px;
position:absolute;
top:0px;
@@ -496,7 +579,7 @@ width:400px;
.stack-wrapper {
- height:100%;
+ //height:100%;
}
.stack-wrapper .widget {
@@ -515,6 +598,11 @@ width:400px;
border-right:0;
border-left:0;
margin-top: 10px;
+ &:after {
+ content:"";
+ display:block;
+ clear:both;
+ }
}
.stack .fader {
width:100%;
@@ -534,6 +622,9 @@ width:400px;
height:70px;
padding: 0 0 0 10px;
position: static;
+ input {
+ bottom:0
+ }
}
.stack .widget .title {
width:30%;
@@ -587,8 +678,8 @@ width:400px;
.xy-wrapper {
width:400px;
- padding: 10px 0px 140px;
- height:540px;
+ padding: 10px 0px 90px;
+ height:490px;
overflow: hidden;
.value {
margin-top:10px;
diff --git a/lib-dev/index.html b/lib-dev/index.html
index ce076be5..043046bd 100644
--- a/lib-dev/index.html
+++ b/lib-dev/index.html
@@ -21,7 +21,7 @@ var ipc = require('ipc');
var fs = require('fs');
// jquery
-window.$ = window.jQuery = require( __dirname + "/js/jquery.min.js")
+window.$ = window.jQuery = require( __dirname + "/js/jquery.min.js")
@@ -29,6 +29,12 @@ window.$ = window.jQuery = require( __dirname + "/js/jquery.min.js")
require( __dirname + "/js/jquery.nicescroll.min.js")
require( __dirname + "/js/jquery.nouislider.all.js")
require( __dirname + "/js/jquery-ui.draggable.min.js")
+require( __dirname + "/js/jquery.mousewheel.min.js")
+
+// mouse to touch emulation
+require( __dirname + "/js/jquery.ui.touch-punch.min.js")
+
+
// main js
require( __dirname + "/js/oschtmlgui.js")
@@ -85,7 +91,13 @@ ipc.on('openSession',function(data){
TABS=false
require(data)
if (TABS!=false) {
- init();
+ $('#lobby').hide()
+ $('#container').append('
')
+ setTimeout(function(){
+ init();
+ $('#container .spinner').hide()
+ },1)
+
} else {
console.log('ERROR: invalid session file (TABS must be defined)')
}
diff --git a/lib-dev/js/jquery.nouislider.all.js b/lib-dev/js/jquery.nouislider.all.js
index 691a33e9..42ba5fae 100644
--- a/lib-dev/js/jquery.nouislider.all.js
+++ b/lib-dev/js/jquery.nouislider.all.js
@@ -1,6 +1,6 @@
/*! noUiSlider - 7.0.3 - 2014-09-11 16:30:11 */
/* With rate mod @ 1561 (Jean-Emmanuel Doucet) */
-
+
(function(){
'use strict';
@@ -1558,7 +1558,7 @@ function closure ( target, options, originalOptions ){
callback ( e, data );
});
}
-
+
// BIG FAT & UGLY MOD
// Limit move's rate for better performances
// It skips events, but we don't need that much precision here
@@ -1572,10 +1572,10 @@ function closure ( target, options, originalOptions ){
// first call
window.last = window.now;
moveP(event, data);
- }
+ }
}
-
-
+
+
// Handle movement on document for handle and range drag.
function moveP ( event, data ) {
@@ -1596,7 +1596,7 @@ function closure ( target, options, originalOptions ){
if ( state ) {
fireEvents(['slide']);
}
-
+
}
// Unbind move events on document, call callbacks.
@@ -2063,12 +2063,12 @@ function closure ( target, options, originalOptions ){
// Extend jQuery/Zepto with the noUiSlider method.
$.fn.noUiSlider = function ( options, rebuildFlag ) {
-
+
switch ( options ) {
case 'step': return this[0].getCurrentStep();
case 'options': return this[0].getOriginalOptions();
}
-
+
return ( rebuildFlag ? rebuild : initialize ).call(this, options);
};
diff --git a/lib-dev/js/oschtmlgui.js b/lib-dev/js/oschtmlgui.js
index da307b6e..3bca211c 100644
--- a/lib-dev/js/oschtmlgui.js
+++ b/lib-dev/js/oschtmlgui.js
@@ -1,17 +1,14 @@
-
// defaultTarget
-defaultTarget = 'localhost:9999'
+defaultTarget = '127.0.0.1:9999'
+
-init = function() {
createWidget= {}
__widgets__ = {}
-
-
-function parsetabs(TABS,parent,sub){
+function parsetabs(tabs,parent,sub){
if (!sub) {
var $nav = $(document.createElement('div')).addClass('main navigation'),
@@ -29,7 +26,8 @@ function parsetabs(TABS,parent,sub){
}
- $.each(TABS,function(tabId,tabData){
+ for (tabId in tabs) {
+ var tabData = tabs[tabId]
var title = tabData.title||tabId
@@ -45,20 +43,21 @@ function parsetabs(TABS,parent,sub){
}
$content.append($tabContent);
- })
+ }
}
function parsewidgets(widgets,parent) {
- $.each(widgets,function(widgetId,widgetData){// parse widgets
+ for (widgetId in widgets) {
+ var widgetData = widgets[widgetId]
var color = widgetData.color?'style="background:'+widgetData.color+'"':'';
var title = widgetData.title || widgetId;
var type = widgetData.type || 'fader'
widgetData.path = widgetData.path || '/' + widgetId
- var $widget = $('\
+ var widget = $('\
\
@@ -68,79 +67,79 @@ function parsewidgets(widgets,parent) {
var widgetInner = createWidget[type](widgetData,parent)
widgetInner.type = widgetData.type || 'fader'
- $widget.append(widgetInner)
+ widget.append(widgetInner)
if (__widgets__[widgetId]==undefined) {
__widgets__[widgetId] = []
}
__widgets__[widgetId].push(widgetInner)
- parent.append($widget);
- });// widgets parsed
+ parent.append(widget);
+ }
}
createWidget.stack = function(widgetData) {
- var $widget = $('\
+ var widget = $('\
\
\
');
- parsewidgets(widgetData.widgets,$widget)
- $widget.getValue = function(){return}
- $widget.setValue = function(){return}
- return $widget;
+ parsewidgets(widgetData.widgets,widget)
+ widget.getValue = function(){return}
+ widget.setValue = function(){return}
+ return widget;
}
createWidget.button = function(widgetData) {
- var $widget = $('\
+ var widget = $('\
\
');
- $widget.input = $widget.find('input')
- $widget.button = $widget.find('.button')
+ widget.input = widget.find('input')
+ widget.button = widget.find('.button')
widgetData.args = widgetData.args || {off:0,on:1}
- $widget.button.click(function(){
- var newVal = $widget.button.hasClass('on')?widgetData.args.off||0:widgetData.args.on||1
- $widget.setValue(newVal,true)
+ widget.button.click(function(){
+ var newVal = widget.button.hasClass('on')?widgetData.args.off||0:widgetData.args.on||1
+ widget.setValue(newVal,true)
})
- $widget.getValue = function() {
- return $widget.button.hasClass('on')?widgetData.args.on||1:widgetData.args.off||0
+ widget.getValue = function() {
+ return widget.button.hasClass('on')?widgetData.args.on||1:widgetData.args.off||0
}
- $widget.setValue = function(v,send,sync) {
+ widget.setValue = function(v,send,sync) {
var on = widgetData.args.on||1,
off= widgetData.args.off||0
if (v==on) {
- $widget.button.addClass('on')
- if (send) $widget.sendValue(v)
+ widget.button.addClass('on')
+ if (send) widget.sendValue(v)
} else if (v==off) {
- $widget.button.removeClass('on')
- if (send) $widget.sendValue(v)
+ widget.button.removeClass('on')
+ if (send) widget.sendValue(v)
}
- $widget.input.val($widget.getValue())
- if (send) $widget.trigger('sync')
+ widget.input.val(widget.getValue())
+ if (send) widget.trigger('sync')
}
- $widget.sendValue = function(v) {
- var t = widgetData.target?widgetData.target:defaultTarget,
+ widget.sendValue = function(v) {
+ var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v]);
}
- $widget.setValue()
- return $widget;
+ widget.setValue()
+ return widget;
}
createWidget.xy = function(widgetData) {
- var $widget = $('\
+ var widget = $('\
\
\
\
@@ -151,67 +150,95 @@ createWidget.xy = function(widgetData) {
\
\
');
- $widget.xy = $widget.find('.xy')
- $widget.xy.handle = $widget.find('.handle')
- $widget.xy.handle.css({top:0,left:0}).draggable({
+ widget.xy = widget.find('.xy')
+ widget.xy.handle = widget.find('.handle')
+ widget.xy.handle.css({top:0,left:0}).draggable({
addClasses: false,
+ scroll:false,
containment:'parent'
});
- $widget.xy.value = {x:$widget.find('.x'),y:$widget.find('.y')}
+ widget.xy.value = {x:widget.find('.x'),y:widget.find('.y')}
- $widget.xy.on('drag',function(e, data){
- var v = $widget.getValue();
+ widget.xy.on('drag',function(e, data){
+ var v = widget.getValue();
- $widget.sendValue(v);
- $widget.showValue(v)
- $widget.trigger('sync')
+ widget.sendValue(v);
+ widget.showValue(v)
+ widget.trigger('sync')
})
widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
- $widget.getValue = function() {
- var x = mapToScale($widget.xy.handle.css('left'),[0,$widget.xy.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
- y = mapToScale($widget.xy.handle.css('top'),[0,$widget.xy.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max],true)
+ widget.getValue = function() {
+ var x = mapToScale(widget.xy.handle.css('left'),[0,widget.xy.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
+ y = mapToScale(widget.xy.handle.css('top'),[0,widget.xy.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max],true)
return [x,y]
}
- $widget.setValue = function(v,send,sync) {
+ widget.setValue = function(v,send,sync) {
if (v[1]==undefined) var v = [v,v]
- var left = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,$widget.xy.innerWidth()])
- ytop = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,$widget.xy.innerHeight()],true),
+ var left = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,widget.xy.innerWidth()])
+ ytop = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,widget.xy.innerHeight()],true),
- $widget.xy.handle.css({'top':ytop+'px','left':left+'px'})
+ widget.xy.handle.css({'top':ytop+'px','left':left+'px'})
- $widget.showValue(v)
- if (sync) $widget.trigger('sync')
- if (send) $widget.sendValue(v);
+ widget.showValue(v)
+ if (sync) widget.trigger('sync')
+ if (send) widget.sendValue(v);
}
- $widget.sendValue = function(v) {
- var t = widgetData.target?widgetData.target:defaultTarget,
- p = widgetData.path || widgetData.path
+ widget.sendValue = function(v) {
+ var t = widgetData.target,
+ p = widgetData.path
sendOsc([t,p,v]);
}
- $widget.showValue = function(v) {
- $widget.xy.value.x.val(v[0])
- $widget.xy.value.y.val(v[1])
+ widget.showValue = function(v) {
+ widget.xy.value.x.val(v[0])
+ widget.xy.value.y.val(v[1])
}
- $widget.xy.value.x.change(function(){
- var v = $widget.getValue();
+ widget.xy.value.x.change(function(){
+ var v = widget.getValue();
v[0] = limit($(this).val(),[widgetData.range.x.min,widgetData.range.x.max])
- $widget.setValue(v,true,true)
+ widget.setValue(v,true,true)
})
- $widget.xy.value.y.change(function(){
- var v = $widget.getValue();
+ widget.xy.value.y.change(function(){
+ var v = widget.getValue();
v[1] = limit($(this).val(),[widgetData.range.y.min,widgetData.range.y.max])
- $widget.setValue(v,true,true)
+ widget.setValue(v,true,true)
})
- return $widget;
+ return widget;
+
+
+ // alternate technique to jqueryui using css transform (hw accelerated)
+ // doesn't seem to increase performance (there's no transition to optimize)
+ // add require( __dirname + "/js/jquery.event.drag-2.2.js") to index.html to enable
+
+ // widget.xy.handle.drag(function( ev, dd ){
+ // var x = limit(dd.offsetX,[0,widget.xy.innerWidth()]),
+ // y = limit(dd.offsetY,[0,widget.xy.innerHeight()])
+ // $( this ).css({
+ // 'transform': 'translate3d('+x+'px,'+y+'px,0px)'
+ // });
+ //
+ // var v = widget.getValue([0,0,0,x,y]);
+ // widget.sendValue(v);
+ // widget.showValue(v)
+ // widget.trigger('sync')
+ // },{ relative:true });
+ //
+ // widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
+ //
+ // widget.getValue = function(css) {
+ // var css = css || widget.xy.handle.css('transform').split('(')[1].split(',')
+ // x = mapToScale(css[4],[0,widget.xy.innerWidth()],[widgetData.range.x.min,widgetData.range.x.max]),
+ // y = mapToScale(css[5],[0,widget.xy.innerHeight()],[widgetData.range.y.min,widgetData.range.y.max],true)
+ // return [x,y]
+ // }
}
@@ -294,7 +321,7 @@ var mapToScale = function(value,rangeIn,rangeOut,reverse) {
createWidget.rgb = function(widgetData) {
- var $widget = $('\
+ var widget = $('\
\
\
\
@@ -308,48 +335,50 @@ createWidget.rgb = function(widgetData) {
\
\
');
- $widget.xy = $widget.find('.xy')
- $widget.xy.saturation = $widget.find('.rgb .handle')
- $widget.xy.hue = $widget.find('.hue .handle')
- $widget.xy.saturation.css({top:0,left:0}).draggable({
+ widget.xy = widget.find('.xy')
+ widget.xy.saturation = widget.find('.rgb .handle')
+ widget.xy.hue = widget.find('.hue .handle')
+ widget.xy.saturation.css({top:0,left:0}).draggable({
addClasses: false,
+ scroll:false,
containment:'parent'
});
- $widget.xy.hue.css({left:0}).draggable({
+ widget.xy.hue.css({left:0}).draggable({
addClasses: false,
+ scroll:false,
containment:'parent'
});
- $widget.xy.value = {r:$widget.find('input.r'),g:$widget.find('input.g'),b:$widget.find('input.b')}
+ widget.xy.value = {r:widget.find('input.r'),g:widget.find('input.g'),b:widget.find('input.b')}
- $widget.xy.hue.on('drag',function(e, data){
- var h = parseFloat($widget.xy.hue.css('left'))/$widget.xy.innerWidth()*360,
+ widget.xy.hue.on('drag',function(e, data){
+ var h = parseFloat(widget.xy.hue.css('left'))/widget.xy.innerWidth()*360,
rgb = hsbToRgb({h:h,s:100,b:100}),
- v = $widget.getValue();
+ v = widget.getValue();
- $widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
- $widget.sendValue(v);
- $widget.showValue(v);
+ widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+ widget.sendValue(v);
+ widget.showValue(v);
- $widget.trigger('sync')
+ widget.trigger('sync')
})
- $widget.xy.saturation.on('drag',function(e, data){
- var v = $widget.getValue();
- $widget.sendValue(v);
- $widget.showValue(v);
+ widget.xy.saturation.on('drag',function(e, data){
+ var v = widget.getValue();
+ widget.sendValue(v);
+ widget.showValue(v);
- $widget.trigger('sync')
+ widget.trigger('sync')
})
- $widget.xy.saturation.on('stop',function(e, data){
- var v = $widget.getValue();
- $widget.sendValue(v);
- $widget.showValue(v);
+ widget.xy.saturation.on('stop',function(e, data){
+ var v = widget.getValue();
+ widget.sendValue(v);
+ widget.showValue(v);
- //$widget.trigger('sync')
+ //widget.trigger('sync')
})
@@ -357,14 +386,14 @@ createWidget.rgb = function(widgetData) {
- $widget.getValue = function() {
- var s = mapToScale($widget.xy.saturation.css('left'),[0,$widget.xy.innerWidth()],[0,100]),
- l = mapToScale($widget.xy.saturation.css('top'),[0,$widget.xy.innerHeight()],[0,100],true),
- h = mapToScale($widget.xy.hue.css('left'),[0,$widget.xy.innerWidth()],[0,360]),
+ widget.getValue = function() {
+ var s = mapToScale(widget.xy.saturation.css('left'),[0,widget.xy.innerWidth()],[0,100]),
+ l = mapToScale(widget.xy.saturation.css('top'),[0,widget.xy.innerHeight()],[0,100],true),
+ h = mapToScale(widget.xy.hue.css('left'),[0,widget.xy.innerWidth()],[0,360]),
rgb = hsbToRgb({h:h,s:s,b:l})
return [rgb.r,rgb.g,rgb.b]
}
- $widget.setValue = function(v,send,sync) {
+ widget.setValue = function(v,send,sync) {
if (v[1]==undefined && v[2]==undefined) var v = [v,v,v]
if (v[2]==undefined) var v = [v[0],v[1],v[1]]
@@ -375,54 +404,54 @@ createWidget.rgb = function(widgetData) {
var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
- var left = mapToScale(hsb.s,[0,100],[0,$widget.xy.innerWidth()]),
- top = mapToScale(hsb.b,[0,100],[0,$widget.xy.innerHeight()],true),
- leftHue = mapToScale(hsb.h,[0,360],[0,$widget.xy.innerWidth()])
- $widget.xy.saturation.css({'top':top+'px','left':left+'px'})
- $widget.xy.hue.css({'left':leftHue+'px'})
+ var left = mapToScale(hsb.s,[0,100],[0,widget.xy.innerWidth()]),
+ top = mapToScale(hsb.b,[0,100],[0,widget.xy.innerHeight()],true),
+ leftHue = mapToScale(hsb.h,[0,360],[0,widget.xy.innerWidth()])
+ widget.xy.saturation.css({'top':top+'px','left':left+'px'})
+ widget.xy.hue.css({'left':leftHue+'px'})
var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
- $widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+ widget.xy.css('background-color','rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
- $widget.showValue(v);
+ widget.showValue(v);
- if (sync) $widget.trigger('sync');
- if (send) $widget.sendValue(v);
+ if (sync) widget.trigger('sync');
+ if (send) widget.sendValue(v);
}
- $widget.sendValue = function(v) {
- var t = widgetData.target?widgetData.target:defaultTarget,
- p = widgetData.path || widgetData.path
+ widget.sendValue = function(v) {
+ var t = widgetData.target,
+ p = widgetData.path
sendOsc([t,p,v]);
}
- $widget.showValue = function(v) {
- $widget.xy.value.r.val(v[0])
- $widget.xy.value.g.val(v[1])
- $widget.xy.value.b.val(v[2])
+ widget.showValue = function(v) {
+ widget.xy.value.r.val(v[0])
+ widget.xy.value.g.val(v[1])
+ widget.xy.value.b.val(v[2])
}
- $widget.xy.value.r.change(function(){
+ widget.xy.value.r.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
- var v = $widget.getValue()
- $widget.setValue([$(this).val(),v[1],v[2]],true,true)
+ var v = widget.getValue()
+ widget.setValue([$(this).val(),v[1],v[2]],true,true)
})
- $widget.xy.value.g.change(function(){
+ widget.xy.value.g.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
- var v = $widget.getValue()
- $widget.setValue([v[0],$(this).val(),v[2]],true,true)
+ var v = widget.getValue()
+ widget.setValue([v[0],$(this).val(),v[2]],true,true)
})
- $widget.xy.value.b.change(function(){
+ widget.xy.value.b.change(function(){
if (!0<=$(this).val()<=255) {$(this).val(Math.min(255,Math.max(0,$(this).val())))}
- var v = $widget.getValue()
- $widget.setValue([v[0],v[1],$(this).val()],true,true)
+ var v = widget.getValue()
+ widget.setValue([v[0],v[1],$(this).val()],true,true)
})
- return $widget;
+ return widget;
}
@@ -431,7 +460,7 @@ createWidget.rgb = function(widgetData) {
createWidget.fader = function(widgetData,parent) {
- var $widget = $('\
+ var widget = $('\
\
\
\
@@ -440,8 +469,8 @@ createWidget.fader = function(widgetData,parent) {
\
');
- $widget.fader = $widget.find('.fader')
- $widget.lock = false
+ widget.fader = widget.find('.fader')
+ widget.lock = false
var range = (widgetData.range=='db'||!widgetData.range)?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'max': 6}:widgetData.range;
@@ -470,7 +499,7 @@ createWidget.fader = function(widgetData,parent) {
direction = parent.hasClass('stack')?'ltr':'rtl',
density = parent.hasClass('stack')?'2':'1';
- $widget.fader
+ widget.fader
.noUiSlider({
orientation:orientation,
direction: direction,
@@ -487,41 +516,41 @@ createWidget.fader = function(widgetData,parent) {
values: pips,
format: wNumb({})
})
- .Link('lower').to($widget.find('input'))
+ .Link('lower').to(widget.find('input'))
.on('slide',function(){
- if (!$widget.lock) {
- $widget.sendValue();
+ if (!widget.lock) {
+ widget.sendValue();
}
})
.on('set',function(){
- if (!$widget.lock) {
- $widget.sendValue();
- $widget.trigger('sync')
+ if (!widget.lock) {
+ widget.sendValue();
+ widget.trigger('sync')
}
});
- $widget.getValue = function(v,send){
- return $widget.fader.val();
+ widget.getValue = function(v,send){
+ return widget.fader.val();
}
- $widget.setValue = function(v,send,sync){
- if (!send) {$widget.lock=true}
- $widget.fader.val(v);
- if (sync) $widget.trigger('sync')
- $widget.lock=false;
+ widget.setValue = function(v,send,sync){
+ if (!send) {widget.lock=true}
+ widget.fader.val(v);
+ if (sync) widget.trigger('sync')
+ widget.lock=false;
}
- $widget.sendValue = function(){
- var t = widgetData.target?widgetData.target:defaultTarget,
+ widget.sendValue = function(){
+ var t = widgetData.target,
p = widgetData.path,
v = widgetData.scale1?
- Math.max(0,Math.round(10000*((Math.abs(range.min)/(range.max-range.min)) + $widget.fader.val()/(range.max-range.min)))/10000)
- : $widget.fader.val();
+ Math.max(0,Math.round(10000*((Math.abs(range.min)/(range.max-range.min)) + widget.fader.val()/(range.max-range.min)))/10000)
+ : widget.fader.val();
sendOsc([t,p,parseFloat(v)]);
}
- return $widget
+ return widget
}
@@ -529,150 +558,6 @@ createWidget.fader = function(widgetData,parent) {
-parsetabs(TABS,false,false)
-$('#lobby').hide()
-
-
-
-// Widget Synchronization : widget that share the same id will update each other
-// without sending any extra osc message (they must be of the same type as well)
-
-$.each(__widgets__,function(i,widget) {
- if (widget.length>1) {
- var script ='';
- for (j in widget) {
-
- // Oh dear this looks hacky
- // I didn't manage to cross-bind all widgets together the usual way
- // ( getValue() always returns the last element's value, maybe a scope problem)
-
- script += ' \n\
- widget['+j+'].on(\'sync\',function(){ \n\
- var v = widget['+j+'].getValue() \n\
- for (k=0;k
\
- \
- \
- \
- Save
\
- Load
\
- Send ALL
\
- Fullscreen
\
- - \
-
\
- Inspector\
-
Click on a widges\'s title to inspect
\
-
\
- \
-
\
-')
-
-$('#sidepanel .open-toggle').click(function(){
- $('#sidepanel .open-toggle, #sidepanel .open-toggle .bars, #sidepanel, #container').toggleClass('sidepanel-open');
- setTimeout(function(){
- updateScrollbar();
- },300)
-})
-
-
-// Options menu
-$('.showOptions a').click(function(e){
- e.preventDefault();
- $('#options').toggleClass('open');
-})
-$('.goFullscreen').click(function(e){
- e.preventDefault();
- ipc.send('fullscreen')
- updateScrollbar();
-
-})
-
-$('.saveState').click(function(e){
- e.preventDefault();
- saveState();
-})
-$('.loadState').click(function(e){
- e.preventDefault();
- loadState();
-})
-$('.sendState').click(function(e){
- e.preventDefault();
- sendState();
-})
-
-
-
-
-
function sendOsc(data){
@@ -729,12 +614,6 @@ function findNode(searchID, searchObject) {
})
return result
}
-$('.title').click(function(){
- if (!$('#sidepanel').hasClass('sidepanel-open')){return}
- var id = $(this).parents('.widget').attr('widgetid');
- var data = id + ':
' + String(JSON.stringify(findNode(id,TABS),null,2)).split('\n').join('
')
- $('.inspector .result').html(data);
-})
// CALLBACKS
@@ -753,4 +632,146 @@ ipc.on('load',function(preset){
setState(preset)
})
+
+
+
+
+
+
+
+
+
+
+
+
+init = function() {
+
+
+parsetabs(TABS,false,false)
+
+
+
+// Widget Synchronization : widget that share the same id will update each other
+// without sending any extra osc message (they must be of the same type as well)
+
+$.each(__widgets__,function(i,widget) {
+ if (widget.length>1) {
+ var script ='';
+ for (j in widget) {
+
+ // Oh dear this looks hacky
+ // I didn't manage to cross-bind all widgets together the usual way
+ // ( getValue() always returns the last element's value, maybe a scope problem)
+
+ script += ' \n\
+ widget['+j+'].on(\'sync\',function(){ \n\
+ var v = widget['+j+'].getValue() \n\
+ for (k=0;k=h) {
+ $(this).scrollLeft($(this).scrollLeft()+e.originalEvent.deltaY);
+ e.preventDefault()
+ }
+});
+
+
+
+// sidepanel
+
+
+$('#sidepanel').append('\
+ \
+ \
+
\
+ \
+ Save
\
+ Load
\
+ Send ALL
\
+ Fullscreen
\
+ - \
+
\
+ Inspector\
+
Click on a widges\'s title to inspect
\
+
\
+ \
+
\
+')
+
+$('#sidepanel .open-toggle').click(function(){
+ $('#sidepanel .open-toggle, #sidepanel .open-toggle .bars, #sidepanel, #container').toggleClass('sidepanel-open');
+})
+
+$('.title').click(function(){
+ if (!$('#sidepanel').hasClass('sidepanel-open')){return}
+ var id = $(this).parents('.widget').attr('widgetid');
+ var data = id + ':
' + String(JSON.stringify(findNode(id,TABS),null,2)).split('\n').join('
')
+ $('.inspector .result').html(data);
+})
+
+
+// Options menu
+$('.showOptions a').click(function(e){
+ e.preventDefault();
+ $('#options').toggleClass('open');
+})
+$('.goFullscreen').click(function(e){
+ e.preventDefault();
+ ipc.send('fullscreen')
+})
+
+$('.saveState').click(function(e){
+ e.preventDefault();
+ saveState();
+})
+$('.loadState').click(function(e){
+ e.preventDefault();
+ loadState();
+})
+$('.sendState').click(function(e){
+ e.preventDefault();
+ sendState();
+})
+
+
+
}// END INIT