From 385c52f7326aa9b664abc086ff41a77de010b206 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 20 Aug 2015 14:46:57 +0200 Subject: [PATCH] - git add missing stuff... - js code cleaning - session loading and history, last used path stored in config file --- index.js | 106 +- lib-dev/config/config.json | 1 + lib-dev/css/style.scss | 165 +- lib-dev/index.html | 108 +- lib-dev/js/demo-full.js | 2765 +++++++++++++++++++++++++ lib-dev/js/demo.js | 11 +- lib-dev/js/jquery-ui.draggable.min.js | 6 + lib-dev/js/oschtmlgui.js | 127 +- package.json | 4 +- 9 files changed, 3117 insertions(+), 176 deletions(-) create mode 100644 lib-dev/config/config.json create mode 100644 lib-dev/js/demo-full.js create mode 100644 lib-dev/js/jquery-ui.draggable.min.js diff --git a/index.js b/index.js index 59d3c291..dc1f5ef6 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,10 @@ +var defaultConfig = { + presetPath : __dirname, + sessionPath: __dirname, + recentSessions: [] +} + + // dependencies var app = require('app') , BrowserWindow = require('browser-window') @@ -6,7 +13,8 @@ var app = require('app') , osc = require("osc") , fs = require("fs") , ipc = require('ipc') - , renderProcess = [] + , renderProcess = {} + , config = require(__dirname + '/lib-dev/config/config.json') // static files serving @@ -37,15 +45,11 @@ app.on('ready', function() { width: 800, height: 600, 'auto-hide-menu-bar':true, - }); // and load the index.html of the app. window.loadUrl('file://' + __dirname + '/lib-dev/index.html'); - // Open the devtools. - //window.openDevTools(); - // Emitted when the window is closed. window.on('closed', function() { // Dereference the window object, usually you would store windows @@ -85,15 +89,52 @@ renderProcess.send = function(name,data) { } -ipc.on('init',function(event, data){ - fs.readFile(__dirname + '/lib-dev/js/demo.js','utf-8', function read(err, data) { - if (err) { - throw err; - } - renderProcess.send('init',data); - }) +ipc.on('loadSession',function(event, data){ + var sessionlist = readConfig('recentSessions') + + if (data == 'browse') { + + dialog.showOpenDialog(window,{title:'Load session file',defaultPath:readConfig('sessionPath'),filters: [ { name: 'OSC Session file', extensions: ['js'] }]},function(file){ + if (file==undefined) {return} + writeConfig({sessionPath:file[0].replace(file[0].split('/').pop(),'')}) + + renderProcess.send('openSession',file[0]); + sessionlist.unshift(file[0]) + + sessionlist = sessionlist.filter(function(elem, index, self) { + return index == self.indexOf(elem); + }) + + writeConfig({recentSessions:sessionlist}) + + }) + + } else { + + renderProcess.send('openSession',sessionlist[data]); + sessionlist.unshift(sessionlist[data]) + sessionlist = sessionlist.filter(function(elem, index, self) { + return index == self.indexOf(elem); + }) + writeConfig({recentSessions:sessionlist}) + } + + }) +ipc.on('removeSessionFromHistory',function(event, data){ + var sessionlist = readConfig('recentSessions') + sessionlist.splice(data,1) + writeConfig({recentSessions:sessionlist}) +}) +ipc.on('ready',function(){ + var recentSessions = readConfig('recentSessions') + renderProcess.send('listSessions',recentSessions) +}) + + + + ipc.on('sendOsc', function (event,data) { @@ -110,30 +151,51 @@ ipc.on('sendOsc', function (event,data) { ipc.on('save', function(event, data){ - dialog.showSaveDialog(window,{title:'Save current state to preset file',defaultPath:__dirname,filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){ + 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(),'')}) + if (file.indexOf('.preset')==-1){file+='.preset'} fs.writeFile(file,data, function (err, data) { - if (err) { - throw err; - } + if (err) throw err; console.log("The current state was saved in "+file); }); }) }) ipc.on('load', function(event, data){ - dialog.showOpenDialog(window,{title:'Load preset file',defaultPath:__dirname,filters: [ { name: 'OSC Preset', extensions: ['preset'] }]},function(file){ + dialog.showOpenDialog(window,{title:'Load 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(),'')}) + fs.readFile(file[0],'utf-8', function read(err, data) { - if (err) { - throw err; - } + if (err) throw err; + renderProcess.send('load',data); }); }) }) -ipc.on('fullscreen', function(event, data){ - window.setFullScreen(data) + +ipc.on('fullscreen', function(event){ + window.setFullScreen(!window.isFullScreen()) + }) + + + +writeConfig = function(newconfig) { + for (i in newconfig) { + config[i] = newconfig[i] + } + fs.writeFile(__dirname + '/lib-dev/config/config.json',JSON.stringify(config), function (err, data) { + if (err) throw err; + }); + +} + +readConfig = function(key) { + return config[key] || defaultConfig[key] +} diff --git a/lib-dev/config/config.json b/lib-dev/config/config.json new file mode 100644 index 00000000..46df6735 --- /dev/null +++ b/lib-dev/config/config.json @@ -0,0 +1 @@ +{"presetPath":"/home/bordun/oscwork/oschtmlgui/lib-dev/presets/","sessionPath":"/home/bordun/oscwork/oschtmlgui/lib-dev/js/","recentSessions":["/home/bordun/oscwork/oschtmlgui/lib-dev/js/demo.js"]} \ No newline at end of file diff --git a/lib-dev/css/style.scss b/lib-dev/css/style.scss index 214df9f9..8171170f 100644 --- a/lib-dev/css/style.scss +++ b/lib-dev/css/style.scss @@ -3,7 +3,7 @@ $color-text:rgba(white,.9); $color-text-fade:transparentize($color-text,.4); -$color-title:rgba(white,.05); + $color-fg:#282c34; $color-bg:mix($color-fg,black,85); @@ -11,6 +11,20 @@ $color-accent:#528bff; $color-border:mix($color-fg,black,55); $nav-height:50px; +$bg-title:rgba(white,.05); +$bg-button:linear-gradient(#3a3f4b, #353b45); + +$sidepanel-size:300px; + + +@mixin layer { + position: absolute; + top:0; + left:0; + right: 0; + bottom:0; +} + ///////////// @@ -43,7 +57,6 @@ html, body { height:100%; overflow:hidden; position:relative; - background:$color-bg; } body { @@ -52,19 +65,60 @@ body { font-family:'Open Sans'; color:$color-text; white-space:nowrap; -} -.content { - background:$color-fg; + opacity:1 } -$sidepanel-size:300px; + + + + +#lobby { + background: $color-bg; + @include layer(); + z-index: 2; + border:1px solid $color-border; + display: flex; + align-items: center; + justify-content: center; + .main { + width:600px; + } + .header { + background: $bg-button; + padding:20px; + font-weight:bold; + box-shadow: 0 0 0 1px $color-border inset; + } + a { + display: block; + padding:10px; + padding-right:25px; + overflow: hidden; + background: $bg-button; + margin-top:10px; + box-shadow: 0 0 0 1px $color-border inset; + position: relative; + + span { + position: absolute; + right:1px; + top:1px; + bottom:1px; + + padding:9px; + background: $bg-button; + } + } +} + + + + + #container { - position:absolute; - top:0; - left:0; - right:0; - bottom:0; + background: $color-bg; + @include layer(); overflow:hidden; transition:right .3s; &.sidepanel-open { @@ -148,7 +202,7 @@ $sidepanel-size:300px; li { display:block; margin-bottom:15px; - background:$color-title; + background:$bg-button; border:1px solid $color-border; > div { padding:10px; @@ -218,7 +272,7 @@ a { list-style:none; display: flex; padding-left:5px; - li.on + li {border:0;} + li.on + li {border-image:none;border-left:1px solid transparent;} li { display:block; max-width:250px; @@ -227,7 +281,8 @@ a { border-width:0 0 0 1px; border-image: linear-gradient($color-bg, $color-border 20px) 0 0 0 1 stretch; &:first-child, &.on { - border:0; + border-image:none; + border-left:1px solid transparent; } @@ -251,6 +306,7 @@ a { border:1px solid $color-border; border-bottom-color:$color-fg; color:$color-text; + &:before { content:""; position: absolute; @@ -258,6 +314,7 @@ a { left:0; right:0; bottom:0; + box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.06); background:linear-gradient(rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)) } &:after { @@ -287,6 +344,7 @@ a { bottom:0; padding:10px 5px 5px; border-top:1px solid $color-border; + background:$color-fg; .tab { //height:100%; @@ -307,6 +365,7 @@ a { height:0px; width: 0px; overflow: hidden; + position: relative; &.on { height:100%; width:auto; @@ -341,6 +400,9 @@ a { vertical-align:top; overflow: hidden; margin-right: 10px; + &:last-child { + margin-right: 0 + } .title { padding:10px 10px; @@ -351,8 +413,8 @@ a { text-overflow:ellipsis; overflow:hidden; height:35px; - border-radius:2px 2px 0 0 ; - background:linear-gradient(#3a3f4b, #353b45); + //border-radius:2px 2px 0 0 ; + background:$bg-button; box-shadow: 0 0 0 1px $color-bg inset; } input { @@ -387,15 +449,17 @@ a { $button-size:20px; .button-wrapper { height:100%; + width:95px; overflow:hidden; - padding-left: 10px; + padding: 10px 0 40px; + position: relative; .button { width:100%; height:100%; position:relative; outline:1px solid $color-bg; outline-offset: -10px; - background:linear-gradient(#3a3f4b, #353b45); + background:$bg-button; box-shadow: 0 0 0 1px $color-bg inset; &:after{ content:""; @@ -415,6 +479,7 @@ $button-size:20px; input { position:absolute; bottom:0; + box-shadow: 0 0 1px 0 $color-border inset; } } @@ -467,6 +532,8 @@ width:400px; float:right; width:70%; height:70px; + padding: 0 0 0 10px; + position: static; } .stack .widget .title { width:30%; @@ -487,6 +554,7 @@ width:400px; width:70%; height:300px; padding-top:0; + padding-left:10px; } /* STRIP (vertical fader) */ @@ -519,11 +587,11 @@ width:400px; .xy-wrapper { width:400px; - padding: 10px 10px 140px; + padding: 10px 0px 140px; height:540px; overflow: hidden; .value { - margin-top:30px; + margin-top:10px; width:100%; } input { @@ -541,7 +609,7 @@ width:400px; width:100%; height: 100%; border:1px solid $color-border; - background: $color-bg; + //background: $color-bg; overflow: hidden; .handle { position:absolute; @@ -553,12 +621,13 @@ width:400px; position:absolute; top:-.5px; left:-1px; - box-shadow:0 0 10px 0px #aaa inset,0 0 1px 1px rgba(0,0,0,.5),0 0 0 3px rgba(255,255,255,.2)!important; + //box-shadow:0 0 10px 0px #aaa inset,0 0 1px 1px rgba(0,0,0,.5),0 0 0 3px rgba(255,255,255,.2)!important; border-radius:100%!important; - background:$color-accent!important; - width: 11px; - height: 11px; - margin:-5px 0 0 -5px; + //background:$color-accent!important; + width: 20px; + height: 20px; + margin:-10px 0 0 -10px; + box-shadow: 0 0 0 1000px rgba(black,.5), 0 0 0 1px rgba(white,.2); } span { @@ -568,24 +637,8 @@ width:400px; width:2000px; height:2000px; margin:-1000px 0 0 -1000px; - opacity:.5; - &:after { - content:""; - position: absolute; - width:100%; - height:1px; - top:50%; - background: $color-accent - } - &:before { - content:""; - position: absolute; - height:100%; - width:1px; - top:0; - left:50%; - background: $color-accent - } + -webkit-mask: radial-gradient(circle,rgba(black,0) 0px , rgba(black,1) 1%); + opacity:.2; } } } @@ -614,6 +667,11 @@ width:400px; &:after { background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%); /* W3C */ } + .handle { + span { + //background: rgba(black,.35) + } + } } .hue { width:100%; @@ -621,7 +679,7 @@ width:400px; border:1px solid $color-border; margin-top:10px; background:transparent linear-gradient(to left, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%; - + overflow: hidden; .handle { position:absolute; height:100%; @@ -630,23 +688,13 @@ width:400px; &:after { content:""; position:absolute; - top:100%; + top:50%; left:-1px; - box-shadow:0 0 10px 0px #aaa inset,0 0 1px 1px rgba(0,0,0,.5),0 0 0 3px rgba(255,255,255,.2)!important; + box-shadow: 0 0 0 1000px rgba(black,.5), 0 0 0 1px rgba(white,.2); border-radius:100%!important; - background:$color-accent!important; width: 11px; height: 11px; - margin:4px 0 0 -5px; - } - &:before { - content:""; - position:absolute; - top:0; - bottom:0; - left:0; - width:1px; - background:$color-accent; + margin:-5px 0 0 -4px; } span { position:absolute; @@ -655,7 +703,6 @@ width:400px; width:2000px; height:100%; margin-left:-1000px; - opacity:.5; } } diff --git a/lib-dev/index.html b/lib-dev/index.html index de713048..ce076be5 100644 --- a/lib-dev/index.html +++ b/lib-dev/index.html @@ -23,28 +23,6 @@ var fs = require('fs'); // jquery window.$ = window.jQuery = require( __dirname + "/js/jquery.min.js") -// Sass (add stylesheets to var styles) -var Sass = require( __dirname + "/js/sass.js") - Sass.setWorkerUrl(__dirname + "/js/sass.worker.js"); - var sass = new Sass() - sass.options({style: Sass.style.compact}) - -var styles = ["/css/style.scss","/css/jquery.nouislider.scss"] - , stylesdata = '' - , done = 0; - -for (i in styles) { - fs.readFile(__dirname + styles[i], 'utf8', function (err,data) { - if (err) {return console.log(err);} - stylesdata += "\n" + data; - done += 1; - if (done==styles.length) { - sass.compile(stylesdata,function(d){ - $('head').append('