- added font-awesome icons
- solved widget cross-sync (removed previous hack) : closure is the key !
This commit is contained in:
parent
cd24f7290d
commit
e5b7f63f08
9 changed files with 200 additions and 139 deletions
|
|
@ -41,6 +41,7 @@ $sidepanel-size:300px;
|
|||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
$scrollbar-margin:5px;
|
||||
|
|
@ -172,6 +173,20 @@ a.btn {
|
|||
&.sidepanel-open {
|
||||
right:$sidepanel-size;
|
||||
}
|
||||
#open-toggle {
|
||||
position:absolute;
|
||||
top:7px;
|
||||
right:0;
|
||||
width:60px;
|
||||
height:40px;
|
||||
padding:0 10px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
color:$color-text-fade;
|
||||
&.sidepanel-open {
|
||||
color:$color-text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#sidepanel {
|
||||
|
|
@ -186,60 +201,13 @@ a.btn {
|
|||
border-left:1px solid $color-border;
|
||||
//box-shadow: 0 0 10px 0 $color-border;
|
||||
transition:right .3s;
|
||||
overflow-y: auto;
|
||||
overflow-x: visible;
|
||||
|
||||
&.sidepanel-open {
|
||||
right:$sidepanel-size;
|
||||
}
|
||||
.open-toggle {
|
||||
position:absolute;
|
||||
top:7px;
|
||||
left:-53px;
|
||||
width:47px;
|
||||
height:40px;
|
||||
padding:11px 9px;
|
||||
border:1px solid transparent;
|
||||
border-bottom:0;
|
||||
//box-shadow: 0 0 10px 0 $color-border;
|
||||
border-radius:3px 3px 0 0;
|
||||
|
||||
.bars {
|
||||
display:block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
height:2px;
|
||||
background: $color-text;
|
||||
&:after, &:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height:100%;
|
||||
top:7px;
|
||||
left:0;
|
||||
background: $color-text;
|
||||
}
|
||||
&::after {
|
||||
top:14px;
|
||||
}
|
||||
&, &:after, &:before {
|
||||
//transition:all .3s;
|
||||
}
|
||||
&.sidepanel-open {
|
||||
background:transparent,
|
||||
}
|
||||
&.sidepanel-open:before {
|
||||
background:$color-accent;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
&.sidepanel-open:after {
|
||||
background:$color-accent;
|
||||
transform: rotate(-45deg);
|
||||
top:8px;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#options {
|
||||
position:absolute;
|
||||
left:0;top:2px;
|
||||
|
|
@ -321,7 +289,7 @@ a {
|
|||
|
||||
|
||||
&.main {
|
||||
right:80px;
|
||||
right:60px;
|
||||
}
|
||||
ul {
|
||||
list-style:none;
|
||||
|
|
@ -339,7 +307,9 @@ a {
|
|||
border-image:none;
|
||||
border-left:1px solid transparent;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-left:0;
|
||||
}
|
||||
|
||||
a {
|
||||
display:block;
|
||||
|
|
@ -1013,6 +983,10 @@ a {
|
|||
position: relative;
|
||||
background: $color-bg;
|
||||
box-shadow: 0 0 0 2px $color-border;
|
||||
cursor: -webkit-grab;
|
||||
&:active {
|
||||
cursor: -webkit-grabbing;
|
||||
}
|
||||
&:after {
|
||||
content:"";
|
||||
position:absolute;
|
||||
|
|
|
|||
4
browser/fonts/font-awesome.min.css
vendored
Normal file
4
browser/fonts/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
browser/fonts/fontawesome-webfont.woff2
Normal file
BIN
browser/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
|
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>OSCGUI</title>
|
||||
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
|
||||
<style>
|
||||
/* Preloading style */
|
||||
html {
|
||||
|
|
|
|||
|
|
@ -12,24 +12,23 @@ init = function(callback) {
|
|||
$.each(__widgets__,function(i,widget) {
|
||||
if (widget.length>1) {
|
||||
var script ='';
|
||||
for (j in widget) {
|
||||
|
||||
// Oh dear this looks hacky
|
||||
// I didn't manage to cross-bind all widgets together the usual way
|
||||
// ( getValue() always returns the last element's value, maybe a scope problem)
|
||||
|
||||
script += ' \n\
|
||||
widget['+j+'].on(\'sync\',function(){ \n\
|
||||
var v = widget['+j+'].getValue() \n\
|
||||
for (k=0;k<widget.length;k++) { \n\
|
||||
if ('+j+'!=k) { \n\
|
||||
widget[k].setValue(v,false,false) \n\
|
||||
} \n\
|
||||
} \n\
|
||||
}) \n\
|
||||
';
|
||||
var closureSync = function(x) {
|
||||
return function() {
|
||||
var v = widget[x].getValue()
|
||||
for (k=0;k<widget.length;k++) {
|
||||
if (x!=k) {
|
||||
widget[k].setValue(v,false,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
eval(script)
|
||||
|
||||
for (j in widget) {
|
||||
widget[j].on('sync',closureSync(j))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -75,27 +74,50 @@ init = function(callback) {
|
|||
// sidepanel
|
||||
|
||||
|
||||
$('#sidepanel').append('\
|
||||
<a class="open-toggle">\
|
||||
<span class="bars"></span>\
|
||||
</a>\
|
||||
<ul id="options">\
|
||||
<li><a class="saveState btn">Save</a></li>\
|
||||
<li><a href="#" class="loadState btn">Load</a></li>\
|
||||
<li><a href="#" class="sendState btn">Send ALL</a></li>\
|
||||
<li><a href="#" class="goFullscreen btn">Fullscreen</a></li>\
|
||||
<li>\
|
||||
<div class="inspector">\
|
||||
Inspector\
|
||||
<div class="result"><em>Click on a widges\'s title to inspect</em></div>\
|
||||
</div>\
|
||||
</li>\
|
||||
</ul>\
|
||||
$('#container').append('\
|
||||
<a id="open-toggle">'+icon('navicon')+'</a>\
|
||||
')
|
||||
|
||||
$('#sidepanel .open-toggle').click(function(){
|
||||
$('#sidepanel .open-toggle, #sidepanel .open-toggle .bars, #sidepanel, #container').toggleClass('sidepanel-open');
|
||||
})
|
||||
|
||||
$('#sidepanel').append(createMenu([
|
||||
{
|
||||
label:'Save',
|
||||
click:saveState,
|
||||
icon:'save'
|
||||
},
|
||||
{
|
||||
label:'Load',
|
||||
click:loadState,
|
||||
icon:'folder-open'
|
||||
},
|
||||
{
|
||||
label:'Send all',
|
||||
click:sendState,
|
||||
icon:'feed'
|
||||
|
||||
},
|
||||
{
|
||||
label:'Fullscreen',
|
||||
click:function(){ipc.send('fullscreen')},
|
||||
icon:'tv'
|
||||
},
|
||||
{
|
||||
label:'Config',
|
||||
icon:'gears'
|
||||
},
|
||||
{
|
||||
html:'<div class="inspector">\
|
||||
Inspector\
|
||||
<div class="result"><em>Click on a widges\'s title to inspect</em></div>\
|
||||
</div>',
|
||||
icon:'terminal'
|
||||
}
|
||||
]))
|
||||
|
||||
|
||||
$('#open-toggle').click(function(){
|
||||
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open');
|
||||
}).click()
|
||||
|
||||
$('.title').click(function(){
|
||||
if (!$('#sidepanel').hasClass('sidepanel-open')){return}
|
||||
|
|
@ -105,28 +127,6 @@ init = function(callback) {
|
|||
})
|
||||
|
||||
|
||||
// Options menu
|
||||
$('.showOptions a').click(function(e){
|
||||
e.preventDefault();
|
||||
$('#options').toggleClass('open');
|
||||
})
|
||||
$('.goFullscreen').click(function(e){
|
||||
e.preventDefault();
|
||||
ipc.send('fullscreen')
|
||||
})
|
||||
|
||||
$('.saveState').click(function(e){
|
||||
e.preventDefault();
|
||||
saveState();
|
||||
})
|
||||
$('.loadState').click(function(e){
|
||||
e.preventDefault();
|
||||
loadState();
|
||||
})
|
||||
$('.sendState').click(function(e){
|
||||
e.preventDefault();
|
||||
sendState();
|
||||
})
|
||||
|
||||
if (callback) callback()
|
||||
|
||||
|
|
|
|||
|
|
@ -49,3 +49,42 @@ findNode = function(searchID, searchObject) {
|
|||
})
|
||||
return result
|
||||
}
|
||||
|
||||
icon = function(i) {
|
||||
return '<i class="fa fa-fw fa-'+i+'"></i>'
|
||||
}
|
||||
|
||||
createMenu = function(template) {
|
||||
var menu = $('<ul id="options"></ul>')
|
||||
|
||||
var closureClick = function(item) {
|
||||
return function() {
|
||||
item.click();
|
||||
return false
|
||||
};
|
||||
}
|
||||
|
||||
for (i in template) {
|
||||
var item = template[i],
|
||||
label = item.label || 'undefined',
|
||||
classname = item.class || '',
|
||||
wrapper = $('<li></li>'),
|
||||
html
|
||||
|
||||
if (!item.html) {
|
||||
html = $('<a href="" class="'+classname+' btn">'+label+'</a>')
|
||||
} else {
|
||||
html = $(item.html)
|
||||
}
|
||||
|
||||
if (item.icon) html.prepend(icon(item.icon)+' ')
|
||||
|
||||
if (item.click) html.on('click',closureClick(item))
|
||||
|
||||
wrapper.append(html)
|
||||
menu.append(wrapper)
|
||||
}
|
||||
|
||||
return menu
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ createWidget.fader = function(widgetData,parent){
|
|||
|
||||
|
||||
var rangeKeys = Object.keys(range).map(function (key) {return parseInt(key)}),
|
||||
rangeVals = Object.keys(range).map(function (key) {return parseInt(range[key])})
|
||||
rangeVals = Object.keys(range).map(function (key) {return parseFloat(range[key])})
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
"sessionPath": "/home/bordun/oscwork/oschtmlgui/sessions/",
|
||||
"recentSessions": [
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/demo.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/knob.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/xy.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/sebkhachott.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/fadertest.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/monitorsjeannot.js",
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/sebkhachott.js"
|
||||
"/home/bordun/oscwork/oschtmlgui/sessions/monitorsjeannot.js"
|
||||
]
|
||||
}
|
||||
95
main/main.js
95
main/main.js
|
|
@ -12,18 +12,27 @@ var app = require('app')
|
|||
, ipc = require('ipc')
|
||||
, configPath = __dirname + '/config.json'
|
||||
, config = require(configPath)
|
||||
, args = process.argv.slice(2);
|
||||
|
||||
, args = process.argv.slice(1);
|
||||
|
||||
dialog.showErrorBox = function(title,err) {
|
||||
console.log(title + ': ' + err)
|
||||
}
|
||||
// config file handling
|
||||
|
||||
var defaultConfig = {
|
||||
presetPath : __dirname,
|
||||
sessionPath: __dirname,
|
||||
recentSessions: [],
|
||||
syncTargets: [],
|
||||
syncTargets: "",
|
||||
oscInPort:5555
|
||||
}
|
||||
var editableConfig = {
|
||||
syncTargets: "List of target host (ip:port pairs), separeted by spaces. Every OSC message sent by the app will be sent to these hosts too.",
|
||||
oscInPort: "Port on which the app listens to synchronise with other apps."
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
writeConfig = function(newconfig) {
|
||||
for (i in newconfig) {
|
||||
|
|
@ -66,23 +75,54 @@ 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() {
|
||||
// Create the browser window.
|
||||
window = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
'auto-hide-menu-bar':true
|
||||
});
|
||||
// Create the browser window.
|
||||
window = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
'auto-hide-menu-bar':true
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
window.loadUrl('file://' + __dirname + '/../browser/index.html');
|
||||
// and load the index.html of the app.
|
||||
window.loadUrl('file://' + __dirname + '/../browser/index.html');
|
||||
|
||||
// Emitted when the window is closed.
|
||||
window.on('closed', function() {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
window = null;
|
||||
});
|
||||
// Emitted when the window is closed.
|
||||
window.on('closed', function() {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
window = null;
|
||||
});
|
||||
|
||||
|
||||
var Menu = require('menu');
|
||||
var MenuItem = require('menu-item');
|
||||
|
||||
var menu = new Menu();
|
||||
|
||||
var template = [
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click: function() { window.reload(); }
|
||||
},
|
||||
{
|
||||
label: 'Toggle DevTools',
|
||||
accelerator: 'F12',
|
||||
click: function() { window.toggleDevTools(); }
|
||||
},
|
||||
{
|
||||
label: 'Toggle Fullscreen',
|
||||
accelerator: 'F11',
|
||||
click: function() { window.setFullScreen(!window.isFullScreen()); }
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -170,7 +210,7 @@ ipc.on('ready',function(){
|
|||
var recentSessions = readConfig('recentSessions')
|
||||
renderProcess.send('listSessions',recentSessions)
|
||||
|
||||
if ('testing'==args[0]) {
|
||||
if (args.indexOf('-l')!=-1) {
|
||||
var sessionlist = readConfig('recentSessions')
|
||||
renderProcess.send('openSession',sessionlist[0]);
|
||||
}
|
||||
|
|
@ -184,17 +224,21 @@ ipc.on('sendOsc', function (event,data) {
|
|||
|
||||
var targets = []
|
||||
Array.prototype.push.apply(targets, data.target.split(' '));
|
||||
Array.prototype.push.apply(targets, readConfig('syncTargets'));
|
||||
Array.prototype.push.apply(targets, readConfig('syncTargets').split(' '));
|
||||
|
||||
for (i in targets) {
|
||||
|
||||
var host = targets[i].split(':')[0],
|
||||
port = targets[i].split(':')[1];
|
||||
|
||||
udpPort.send({
|
||||
address: data.path,
|
||||
args: data.args
|
||||
}, host, port);
|
||||
try {
|
||||
udpPort.send({
|
||||
address: data.path,
|
||||
args: data.args
|
||||
}, host, port);
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -205,7 +249,7 @@ ipc.on('save', function(event, data){
|
|||
dialog.showSaveDialog(window,{title:'Save current state to preset file',defaultPath:readConfig('presetPath'),filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){
|
||||
|
||||
if (file==undefined) {return}
|
||||
writeConfig({presetPath:file[0].replace(file[0].split('/').pop(),'')})
|
||||
writeConfig({presetPath:file.replace(file.split('/').pop(),'')})
|
||||
|
||||
if (file.indexOf('.preset')==-1){file+='.preset'}
|
||||
fs.writeFile(file,data, function (err, data) {
|
||||
|
|
@ -223,7 +267,6 @@ ipc.on('load', function(event, data){
|
|||
|
||||
fs.readFile(file[0],'utf-8', function read(err, data) {
|
||||
if (err) throw err;
|
||||
|
||||
renderProcess.send('load',data);
|
||||
});
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue