button widget in progress
This commit is contained in:
parent
a0ac480076
commit
5def76b11b
3 changed files with 66 additions and 31 deletions
|
|
@ -15,7 +15,7 @@ nmPorts = {
|
|||
}
|
||||
|
||||
TABS = {
|
||||
/*
|
||||
|
||||
testingshits: {
|
||||
widgets:{
|
||||
button1: {
|
||||
|
|
@ -31,7 +31,7 @@ TABS = {
|
|||
},
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
MainMix: {
|
||||
|
||||
title:'MainMix',
|
||||
|
|
|
|||
|
|
@ -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 = $('\
|
||||
<div class="widget button">\
|
||||
<div class="widget">\
|
||||
<div class="title" '+color+'>'+title+'</div>\
|
||||
<div class="button-inner-wrapper"><div class="push"></div></div>\
|
||||
<input value="OFF"></input>\
|
||||
<div class="button-wrapper"><div class="button"></div></div>\
|
||||
<input value="'+dv+'"></input>\
|
||||
</div>\
|
||||
');
|
||||
|
||||
$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 = $('\
|
||||
<div class="widget strip">\
|
||||
<div class="widget">\
|
||||
<div class="title" '+color+'>'+title+'</div>\
|
||||
<div class="strip-inner-wrapper">\
|
||||
<div class="fader-wrapper">\
|
||||
<div class="fader locked" path="'+widgetData.path+'" name="'+widgetId+'"></div>\
|
||||
</div>\
|
||||
<input value="0"></input>\
|
||||
|
|
@ -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(';')
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue