- auto iterated tab/widget unique ids if not set in session file

- docs, wip
This commit is contained in:
jean-emmanuel 2015-09-17 13:58:01 +02:00 • committed by bordun
parent a93e8dc9c8
commit 60967e0e89
8 changed files with 124 additions and 53 deletions

View file

@ -0,0 +1,69 @@
## Open Stage Control
### Session file structure
A valid session file is just a javascript file that defines the global variable `TABS` as an array of tab objects :
```
TABS = [
{
id:"my_tab_id", // [string] optional, default unique tab id
label:"My tab", // [string] default to id
stack:false, // [bool] set to true to stack widgets vertically
widgets: [], // [array] of widget objects
tabs: [] // [array] of tab objects
// A tab cannot contain widgets and tabs simultaneously
},
{
etc...
}
]
```
### Widgets
```
{
id:"my_widget_id", // [string] widgets with same id will be synchronized
label:"My widget", // [string] default to id
widget_option:value // each widget type has specific options
}
```
#### Strip
```
horizontal:false, // [bool] set to true to display widgets horizontally
widgets: [] // [array] of widget objects
```
#### Fader
```
horizontal:false, // [bool] set to true to display fader horizontally
range: {min:0,max:1}, // [object] defining the breakpoints of the fader
// keys can be percentages or 'min' / 'max'
unit: false, // [string] value suffix
```
#### Knob
```
range: {min:0,max:1}, // [object] minimum and maximum values
unit: false, // [string] value suffix
```
#### Toggle
```
on: 1,
off:0
```
#### Switch
```
values:[] // [array] of values (string or number)
```
#### XY pad
```
range:{ // [object] minimum and maximum values for x and y axis
x:{min:0,max:1},
y:{min:0,max:1}
}
```
#### RGB pad
```
no option
```

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,16 @@
__widgets__ = {}
__widgetsIds__ = {}
var iterator = {
tab: 0,
widget: 0
},
getIterator = function(type){
iterator[type] += 1
return iterator[type]
}
parsetabs = function(tabs,parent,sub){
if (!sub) {
var nav = $(document.createElement('div')).addClass('main navigation'),
@ -15,16 +28,18 @@ parsetabs = function(tabs,parent,sub){
}
for (i in tabs) {
var tabData = tabs[i];
tabData.id = tabData.id.replace(' ','_')
var id = parent?parent.attr('id')+tabData.id:tabData.id
label= tabData.label||tabData.id
var tabData = tabs[i]
tabData.id = tabData.id?tabData.id.replace(' ','_'):'tab_'+getIterator('tab')
var id = tabData.id,
label= tabData.label||id
navtabs.append('<li><a data-tab="#'+id+'"><span>'+label+'</span></a></li>');
var tabContent = $(document.createElement('div')).addClass('tab').attr('id',id);
var tabContent = $('<div></div>').addClass('tab').attr('id',id);
if (tabData.mode=='stack') tabContent.addClass('stack')
if (tabData.stack) tabContent.addClass('stack')
if (tabData.tabs) {
parsetabs(tabData.tabs,parent=tabContent,sub=true);
@ -37,14 +52,16 @@ parsetabs = function(tabs,parent,sub){
}
}
__widgets__ = {}
__widgetsIds__ = {}
parsewidgets = function(widgets,parent) {
for (i in widgets) {
var widgetData = widgets[i],
id = widgetData.id,
var widgetData = widgets[i]
widgetData.id = widgetData.id?widgetData.id.replace(' ','_'):'widget_'+getIterator('widget')
var id = widgetData.id,
label = widgetData.label || id,
type = widgetData.type || 'fader',
path = widgetData.path || '/' + id,
@ -53,12 +70,6 @@ parsewidgets = function(widgets,parent) {
widgetData.path = path
if (widgetData.color && widgetData.color=='accent') {
accentclass = 'accent'
} else if (widgetData.color) {
color = 'style="color:'+widgetData.color+'"'
}
var widgetContainer = $('\
<div class="widget '+type+'-container" widgetType="'+type+'" widgetId="'+id+'" path="'+path+'">\
<div class="label">'+label+'</div>\

View file

@ -6,7 +6,7 @@ createWidget.strip = function(widgetData) {
<div class="strip">\
</div>\
');
if (widgetData.mode=='horizontal') widget.addClass('horizontal')
if (widgetData.horizontal) widget.addClass('horizontal')
parsewidgets(widgetData.widgets,widget)
widget.getValue = function(){return}
widget.setValue = function(){return}
@ -86,8 +86,6 @@ createWidget.toggle = createWidget.button = function(widgetData) {
createWidget.switch = function(widgetData) {
widgetData.on = widgetData.on || 1
widgetData.off = widgetData.off || 0
var widget = $('\
<div class="switch">\
@ -402,9 +400,9 @@ createWidget.fader = function(widgetData,container){
pips = widget.find('.pips'),
input = widget.find('input'),
unit = widgetData.unit?' '+widgetData.unit.trim(): '',
dimension = widgetData.mode=='horizontal'?'width':'height';
dimension = widgetData.horizontal?'width':'height';
if (widgetData.mode=='horizontal') container.addClass('horizontal')
if (widgetData.horizontal) container.addClass('horizontal')
handle.size = 0
fader.size = dimension=='height'?fader.height():fader.width()

View file

@ -321,7 +321,7 @@ a {
&.main {
padding-right:55rem;
right:0;
background: linear-gradient($color-border,$color-bg);
// background: linear-gradient($color-border,$color-bg);
}
ul {
@ -643,7 +643,8 @@ form {
&.horizontal {
flex-direction: row;
> .widget {
border-bottom: 0;
border-bottom-width: 0;
border-right-width:6rem;
}
}
height: 100%;
@ -652,10 +653,10 @@ form {
> .widget {
display: block;
border-left:0;
border-right:0;
border-left-width:0;
border-right-width:0;
&:not(:last-child) {
border-bottom:0;
border-bottom-width:0;
}
}

View file

@ -26,9 +26,7 @@ compileScss = function(){
});
}
}
if (args.indexOf('-c')!=-1) {
compileScss()
}
dialog.showErrorBox = function(title,err) {
console.log(title + ': ' + err)
@ -101,6 +99,11 @@ app.on('window-all-closed', function() {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
if (args.indexOf('-c')!=-1) {
compileScss()
}
// Create the browser window.
window = new BrowserWindow({
width: 810,
@ -128,9 +131,9 @@ app.on('ready', function() {
label: 'View',
submenu: [
{
label: 'Reload',
label: 'Restart',
accelerator: 'CmdOrCtrl+R',
click: function() { window.reload(); }
click: function() { window.reload(); }//restartApp
},
{
label: 'Toggle DevTools',
@ -141,10 +144,6 @@ app.on('ready', function() {
label: 'Toggle Fullscreen',
accelerator: 'F11',
click: function() { window.setFullScreen(!window.isFullScreen()); }
},
{
label:'Restart App',
click:restartApp
}
]
},

View file

@ -5,34 +5,27 @@ TABS = function(){
var tabs = new Array()
tabs.push(function(){
var tab = {}
tab.id = 'Audio Surface'
tab.widgets = new Array()
for (i in [0,1,2,3,4,5,6,7,8,9]) {
tab.widgets.push({
id:'strip_'+i,
type:'strip',
widgets: [
{
id:'w0'+i,
type:"knob",
target:target
},
{
id:'w1'+i,
type:"switch",
values:['ozehfozeizadz',1,2],
values:[0,1,2],
target:target
},
{
id:'w2'+i,
type:"fader",
target:target
},
{
id:'w3'+i,
type:"toggle",
mode:"horizontal",
target:target
// color:'orange'
}

View file

@ -1727,13 +1727,13 @@ TABS =
},
{
id: "Gates",
mode:"stack",
stack:true,
widgets: [
{
id: "Gate_Kick",
label: "Kick",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Kick",
@ -1810,7 +1810,7 @@ TABS =
id: "Gate_Snare",
label: "Snare",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Snare",
@ -1887,7 +1887,7 @@ TABS =
id: "Gate_Tom1",
label: "Tom1",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Tom1",
@ -1964,7 +1964,7 @@ TABS =
id: "Gate_Tom2",
label: "Tom2",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Tom2",
@ -2041,7 +2041,7 @@ TABS =
id: "Gate_Tom3",
label: "Tom3",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Tom3",
@ -3905,13 +3905,13 @@ TABS =
},
{
id: "Gates",
mode:"stack",
stack:true,
widgets: [
{
id: "Gate_Vx_Dag",
label: "Vx_Dag",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Vx_Dag",
@ -3988,7 +3988,7 @@ TABS =
id: "Gate_Vx_ORL",
label: "Vx_ORL",
type: "strip",
mode:"horizontal",
horizontal:true,
widgets: [
{
id: "Gate_LF_Vx_ORL",