diff --git a/config.js b/config.js index fa5db5e1..0c452a90 100644 --- a/config.js +++ b/config.js @@ -15,7 +15,7 @@ nmPorts = { } TABS = { - /* + testingshits: { widgets:{ button1: { @@ -31,7 +31,7 @@ TABS = { }, } }, - */ + MainMix: { title:'MainMix', diff --git a/lib/oschtmlgui.js b/lib/oschtmlgui.js index 3e46a1ca..d49d8865 100644 --- a/lib/oschtmlgui.js +++ b/lib/oschtmlgui.js @@ -17,7 +17,8 @@ document.title = 'INIT' init = function() { -__strips__ = []; +__faders__ = []; +__buttons__ = []; parsetabs(TABS,false,false) @@ -70,25 +71,63 @@ function parsetabs(TABS,parent,sub) { switch(widgetData.type) { case 'button': + + var dv = widgetData.args?widgetData.args.off:0; var $widget = $('\ -
\ +
\
'+title+'
\ -
\ - \ +
\ + \
\ '); + $widget.input = $widget.find('input') + $widget.button = $widget.find('.button') + + $widget.button + .on('on',function(){ + $(this).addClass('on'); + var t = widgetData.target?widgetData.target:defaultTarget, + p = widgetData.path, + a = widgetData.args?widgetData.args.on:1; + sendOsc([t,p,a]); + $widget.input.val(a) + }) + .on('off',function(){ + $(this).removeClass('on'); + var t = widgetData.target?widgetData.target:defaultTarget, + p = widgetData.path, + a = widgetData.args?widgetData.args.off:0; + sendOsc([t,p,a]); + $widget.input.val(a) + }) + + .click(function(){ + switch($(this).hasClass('on')){ + case true: + $(this).trigger('off') + break + case false: + $(this).trigger('on') + break + } + }) + + + __buttons__.push($widget) + + break - case 'strip': + case 'fader': default: var $widget = $('\ -
\ +
\
'+title+'
\ -
\ +
\
\
\ \ @@ -142,18 +181,18 @@ function parsetabs(TABS,parent,sub) { .Link('lower').to($widget.find('input')) .on('slide',function(){ if ($(this).hasClass('locked')) return; - var p = widgetData.path, - n = widgetData.args, - t = widgetData.target?widgetData.target:defaultTarget, + var t = widgetData.target?widgetData.target:defaultTarget, + p = widgetData.path, + a = widgetData.args, v = widgetData.scale1? Math.max(0,Math.round(10000*((Math.abs(range.min)/(range.max-range.min)) + $(this).val()/(range.max-range.min)))/10000) : $(this).val(); - sendOsc([t,p,n,v]); + sendOsc([t,p,a,v]); }) .on('set',function(){ if ($(this).hasClass('locked')) return; - var p = widgetData.path, - t = widgetData.target?widgetData.target:defaultTarget, + var t = widgetData.target?widgetData.target:defaultTarget, + p = widgetData.path, a = widgetData.args, v = widgetData.scale1? Math.max(0,Math.round(10000*((Math.abs(range.min)/(range.max-range.min)) + $(this).val()/(range.max-range.min)))/10000) @@ -162,9 +201,9 @@ function parsetabs(TABS,parent,sub) { sendOsc([t,p,a,v]); }); // store reference for state saving/loading - __strips__.push($widget) + __faders__.push($widget) - + break } $tabContent.append($widget); @@ -275,7 +314,7 @@ function sendOsc(argsPack){ function saveState() { data = [] - $.each(__strips__,function(i,strip) { + $.each(__faders__,function(i,strip) { data.push('strip:'+strip.fader.attr('name')+':'+strip.fader.val()) }) document.title = 'Save,'+data.join(';') diff --git a/lib/style.css b/lib/style.css index 4bccc724..12dc4789 100644 --- a/lib/style.css +++ b/lib/style.css @@ -171,7 +171,7 @@ a.on, a:active { font-size:13px; border:1px solid rgba(0,0,0,0.2); padding:33px 0; - + width:100px; } .widget .title { @@ -213,20 +213,18 @@ a.on, a:active { /* BUTTON */ -.button { - width:100px; -} -.button-inner-wrapper { + +.button-wrapper { height:100%; overflow:hidden; } -.push { +.button { width:100%; height:100%; position:relative; } -.push:after { +.button:after { content:""; position:absolute; width:20px; @@ -237,21 +235,19 @@ a.on, a:active { background:#222; } -.push:active:after { +.button.on:after { background:rgba(20,240,250,.4); } /* STRIP (vertical fader) */ -.strip { - width:100px; -} -.strip-inner-wrapper { + +.fader-wrapper { padding:20px 10px; overflow:hidden; height:100%; } -.strip .fader{ +.fader{ height:100%; width:18px; }