- not much to say... prepare for mergiiiiing
This commit is contained in:
parent
d527a02e0a
commit
d427d83586
7 changed files with 32 additions and 25 deletions
|
|
@ -7,7 +7,7 @@ A valid session file is a javascript file that returns, when eval'd, an array of
|
|||
```
|
||||
[
|
||||
{
|
||||
id:"my_tab_id", // [string] optional, default unique tab id
|
||||
id:"my_tab_id", // [string] optional, default to unique 'tab_n'
|
||||
label:"My tab", // [string] default to id
|
||||
stack:false, // [bool] set to true to stack widgets vertically
|
||||
widgets: [], // [array] of widget objects
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -30,10 +30,12 @@ parsetabs = function(tabs,parent,sub){
|
|||
for (i in tabs) {
|
||||
var tabData = tabs[i]
|
||||
|
||||
|
||||
tabData.id = tabData.id?tabData.id.replace(' ','_'):'tab_'+getIterator('tab')
|
||||
|
||||
var id = tabData.id,
|
||||
label= tabData.label||id
|
||||
var id = 'tab_'+getIterator('tab')
|
||||
label= tabData.label||tabData.id
|
||||
|
||||
|
||||
navtabs.append('<li><a data-tab="#'+id+'"><span>'+label+'</span></a></li>');
|
||||
|
||||
|
|
@ -81,13 +83,15 @@ parsewidgets = function(widgets,parent) {
|
|||
widgetInner.type = type
|
||||
widgetContainer.find('.label').data('papers',widgetData)
|
||||
|
||||
// store widget reference for cross widget sync
|
||||
widgetContainer.append(widgetInner)
|
||||
|
||||
// store widget reference for cross widget sync
|
||||
if (__widgets__[id]==undefined) {
|
||||
__widgets__[id] = []
|
||||
}
|
||||
__widgets__[id].push(widgetInner)
|
||||
|
||||
|
||||
// store path vs widget id for faster cross-app sync
|
||||
__widgetsIds__[widgetData.path ] = id
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ saveState = function () {
|
|||
getState = function (){
|
||||
var data = []
|
||||
$.each(__widgets__,function(i,widget) {
|
||||
data.push(widget[0].type+':'+i+':'+widget[0].getValue())
|
||||
var v = widget[0].getValue()
|
||||
if (v!=undefined) data.push(i+' '+widget[0].getValue())
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
|
@ -32,7 +33,8 @@ setState = function(preset){
|
|||
|
||||
setTimeout(function(){
|
||||
if (__widgets__[data[1]]!=undefined) {
|
||||
__widgets__[data[1]][0].setValue(data[2].split(','),true,true)
|
||||
__widgets__[data[1]][0].setValue(data[
|
||||
console.log(value)].split(','),true,true)
|
||||
}
|
||||
},i)
|
||||
})
|
||||
|
|
@ -43,11 +45,12 @@ setState = function(preset){
|
|||
openSession = function(path){
|
||||
var fs = require('fs'),
|
||||
data = fs.readFileSync(path,'utf8'),
|
||||
vm = require('vm'),
|
||||
session,
|
||||
error
|
||||
|
||||
try {
|
||||
session = eval(data)
|
||||
session = vm.runInNewContext(data)
|
||||
} catch(err) {
|
||||
error = err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,10 +141,11 @@ createWidget.xy = function(widgetData) {
|
|||
'),
|
||||
handle = widget.find('.handle'),
|
||||
pad = widget.find('.xy'),
|
||||
value = {x:widget.find('.x'),y:widget.find('.y')}
|
||||
value = {x:widget.find('.x'),y:widget.find('.y')},
|
||||
range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
|
||||
|
||||
|
||||
widgetData.range = widgetData.range || {x:{min:0,max:1},y:{min:0,max:1}}
|
||||
widgetData.range = range
|
||||
|
||||
|
||||
pad.width = pad.innerWidth()
|
||||
|
|
@ -179,15 +180,15 @@ createWidget.xy = function(widgetData) {
|
|||
|
||||
|
||||
widget.getValue = function() {
|
||||
var x = mapToScale(handle.width,[0,100],[widgetData.range.x.min,widgetData.range.x.max]),
|
||||
y = mapToScale(handle.height,[0,100],[widgetData.range.y.min,widgetData.range.y.max])
|
||||
var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max]),
|
||||
y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max])
|
||||
|
||||
return [x,y]
|
||||
}
|
||||
widget.setValue = function(v,send,sync) {
|
||||
if (v[1]==undefined) var v = [v,v]
|
||||
var w = mapToScale(v[0],[widgetData.range.x.min,widgetData.range.x.max],[0,100])
|
||||
h = mapToScale(v[1],[widgetData.range.y.min,widgetData.range.y.max],[0,100]),
|
||||
var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100])
|
||||
h = mapToScale(v[1],[range.y.min,range.y.max],[0,100]),
|
||||
|
||||
handle[0].setAttribute('style','height:'+h+'%;width:'+w+'%')
|
||||
handle.height = h
|
||||
|
|
@ -210,16 +211,16 @@ createWidget.xy = function(widgetData) {
|
|||
|
||||
value.x.change(function(){
|
||||
var v = widget.getValue();
|
||||
v[0] = clip(value.x.val(),[widgetData.range.x.min,widgetData.range.x.max])
|
||||
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(),[widgetData.range.y.min,widgetData.range.y.max])
|
||||
v[1] = clip(value.y.val(),[range.y.min,range.y.max])
|
||||
widget.setValue(v,true,true)
|
||||
})
|
||||
|
||||
widget.setValue(widgetData.range.x.min,widgetData.range.y.min)
|
||||
widget.setValue(range.x.min,range.y.min)
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -559,16 +559,17 @@ form {
|
|||
padding:35rem 1px 0;
|
||||
vertical-align:top;
|
||||
border: 6rem solid $color-fg;
|
||||
border-width:6rem 3rem;
|
||||
border-width:6rem 0;
|
||||
margin:0 3rem;
|
||||
|
||||
box-shadow: 0 0 0 1px $color-bg inset;
|
||||
background:$bg-3d;
|
||||
|
||||
&:first-child {
|
||||
border-left-width:6rem;
|
||||
margin-left:6rem;
|
||||
}
|
||||
&:last-child {
|
||||
border-right-width:6rem;
|
||||
margin-right:6rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
|
|
@ -653,8 +654,7 @@ form {
|
|||
|
||||
> .widget {
|
||||
display: block;
|
||||
border-left-width:0;
|
||||
border-right-width:0;
|
||||
margin: 0;
|
||||
&:not(:last-child) {
|
||||
border-bottom-width:0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
type:'strip',
|
||||
widgets: [
|
||||
{
|
||||
"type":"knob",
|
||||
type:"knob",
|
||||
target:target
|
||||
},
|
||||
{
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
},
|
||||
{
|
||||
type:"fader",
|
||||
range:db,
|
||||
target:target,
|
||||
range:db
|
||||
},
|
||||
{
|
||||
type:"toggle",
|
||||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
return tab
|
||||
}())
|
||||
tabs.push({id:'test'})
|
||||
|
||||
return tabs
|
||||
})()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue