preparing next feature : differents widgets (strip, button, switch, xy pad?)
This commit is contained in:
parent
84d2ed54b9
commit
ff7fb651ec
4 changed files with 271 additions and 184 deletions
|
|
@ -62,85 +62,113 @@ function parsetabs(TABS,parent,sub) {
|
|||
|
||||
} else {
|
||||
|
||||
$.each(tabData.strips,function(stripId,stripData){// parse strips
|
||||
var color = stripData.color?'style="background-color:'+stripData.color+'"':'';
|
||||
var title = stripData.title || stripId;
|
||||
var $strip = $('\
|
||||
<div class="strip">\
|
||||
<div class="title" '+color+'>'+title+'</div>\
|
||||
<div class="fader-wrapper"><div class="fader locked" path="'+stripData.path+'" name="'+stripId+'"></div></div>\
|
||||
<input value="0"></input>\
|
||||
</div>\
|
||||
');
|
||||
$strip.fader = $strip.find('.fader')
|
||||
|
||||
var range = stripData.range=='db'?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'max': 6}:stripData.range;
|
||||
|
||||
var pips = function() {
|
||||
if (stripData.range=='db') {
|
||||
return [-70,-60,-50,-40,-30,-20,-10,-6,-3,0,3,6];
|
||||
} else {
|
||||
var autopips = [];
|
||||
var i=0;
|
||||
for (key in range) {
|
||||
//alert(range.key)
|
||||
autopips[i]=range[key];
|
||||
i=i+1;
|
||||
}
|
||||
autopips.push((range.max-range.min)/2);
|
||||
autopips.push((range.max-range.min)/4);
|
||||
autopips.push((range.max-range.min)*.75);
|
||||
return autopips;
|
||||
}
|
||||
}
|
||||
var pips = pips();
|
||||
$.each(tabData.widgets,function(widgetId,widgetData){// parse widgets
|
||||
|
||||
var color = widgetData.color?'style="background-color:'+widgetData.color+'"':'';
|
||||
var title = widgetData.title || widgetId;
|
||||
|
||||
switch(widgetData.type) {
|
||||
|
||||
case 'button':
|
||||
var $widget = $('\
|
||||
<div class="widget button">\
|
||||
<div class="title" '+color+'>'+title+'</div>\
|
||||
<div class="button-inner-wrapper"><div class="push"></div></div>\
|
||||
<input value="OFF"></input>\
|
||||
</div>\
|
||||
');
|
||||
|
||||
$strip.find('.fader')
|
||||
.noUiSlider({
|
||||
orientation:'vertical',
|
||||
direction: "rtl",
|
||||
behaviour: "none-drag",
|
||||
connect: "lower",
|
||||
//animate:false,
|
||||
start: 0,
|
||||
range: range
|
||||
})
|
||||
.noUiSlider_pips({
|
||||
mode: 'values',
|
||||
density: 1,
|
||||
filter:function(v,t){return v==0?1:2;},
|
||||
values: pips,
|
||||
format: wNumb({})
|
||||
})
|
||||
.Link('lower').to($strip.find('input'))
|
||||
.on('slide',function(){
|
||||
if ($(this).hasClass('locked')) return;
|
||||
var p = stripData.path,
|
||||
n = stripData.args,
|
||||
t = stripData.target?stripData.target:defaultTarget,
|
||||
v = stripData.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]);
|
||||
})
|
||||
.on('set',function(){
|
||||
if ($(this).hasClass('locked')) return;
|
||||
var p = stripData.path,
|
||||
t = stripData.target?stripData.target:defaultTarget,
|
||||
a = stripData.args,
|
||||
v = stripData.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,a,v]);
|
||||
});
|
||||
break
|
||||
|
||||
|
||||
// store reference for state saving/loading
|
||||
__strips__.push($strip)
|
||||
|
||||
$tabContent.append($strip);
|
||||
});// strips parsed
|
||||
|
||||
case 'strip':
|
||||
default:
|
||||
|
||||
var $widget = $('\
|
||||
<div class="widget strip">\
|
||||
<div class="title" '+color+'>'+title+'</div>\
|
||||
<div class="strip-inner-wrapper">\
|
||||
<div class="fader locked" path="'+widgetData.path+'" name="'+widgetId+'"></div>\
|
||||
</div>\
|
||||
<input value="0"></input>\
|
||||
</div>\
|
||||
');
|
||||
$widget.fader = $widget.find('.fader')
|
||||
|
||||
var range = (widgetData.range=='db'||!widgetData.range)?{'min': -70,'20%': -40,'45%': -20,'60%': -10,'max': 6}:widgetData.range;
|
||||
|
||||
|
||||
var pips = function() {
|
||||
if (widgetData.range=='db'||!widgetData.range) {
|
||||
return [-70,-60,-50,-40,-30,-20,-10,-6,-3,0,3,6];
|
||||
} else {
|
||||
var autopips = [];
|
||||
var i=0;
|
||||
for (key in range) {
|
||||
//alert(range.key)
|
||||
autopips[i]=range[key];
|
||||
i=i+1;
|
||||
}
|
||||
if (range.min<0<range.max){
|
||||
autopips.push(0);
|
||||
}
|
||||
autopips.push((range.max-range.min)/2);
|
||||
autopips.push((range.max-range.min)/4);
|
||||
autopips.push((range.max-range.min)*.75);
|
||||
return autopips;
|
||||
}
|
||||
}
|
||||
var pips = pips();
|
||||
|
||||
|
||||
$widget.find('.fader')
|
||||
.noUiSlider({
|
||||
orientation:'vertical',
|
||||
direction: "rtl",
|
||||
behaviour: "none-drag",
|
||||
connect: "lower",
|
||||
//animate:false,
|
||||
start: 0,
|
||||
range: range
|
||||
})
|
||||
.noUiSlider_pips({
|
||||
mode: 'values',
|
||||
density: 1,
|
||||
filter:function(v,t){return v==0?1:2;},
|
||||
values: pips,
|
||||
format: wNumb({})
|
||||
})
|
||||
.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,
|
||||
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]);
|
||||
})
|
||||
.on('set',function(){
|
||||
if ($(this).hasClass('locked')) return;
|
||||
var p = widgetData.path,
|
||||
t = widgetData.target?widgetData.target:defaultTarget,
|
||||
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,a,v]);
|
||||
});
|
||||
// store reference for state saving/loading
|
||||
__strips__.push($widget)
|
||||
|
||||
|
||||
}
|
||||
|
||||
$tabContent.append($widget);
|
||||
});// widgets parsed
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +179,7 @@ function parsetabs(TABS,parent,sub) {
|
|||
|
||||
|
||||
|
||||
// Synchronize strips that share the same name
|
||||
// Synchronize faders that share the same name
|
||||
$(".fader").each(function(){
|
||||
$(".fader[name='"+$(this).attr('name')+"']").not(this).Link('lower').to($(this), crossUpdate);
|
||||
}).removeClass('locked');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue