This commit is contained in:
jean-emmanuel 2015-09-26 10:44:07 +02:00
parent 5c2b620239
commit c24b64d991
6 changed files with 34 additions and 34 deletions

View file

@ -1,5 +1,5 @@
require(__dirname + '/parser.js') // session file parser
require(__dirname + '/utils.js') // state managing & inspector
require(__dirname + '/widgets.js') // widgets types and behaviour definition
require(__dirname + '/callbacks.js')// calls from mainProcess
require(__dirname + '/init.js') // ...
require('./parser.js') // session file parser
require('./utils.js') // state managing & inspector
require('./widgets.js') // widgets types and behaviour definition
require('./callbacks.js')// calls from mainProcess
require('./init.js') // ...

View file

@ -78,7 +78,7 @@ init = function(session,callback) {
} else {
var h = $('#container').innerHeight()-scrollbarHeight-$(this).parents('.tab').length*5
if ($(this).get(0).scrollHeight+scrollbarHeight == $(this).height()) {
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
$(this).scrollLeft($(this).scrollLeft()+scroll)
e.preventDefault()
} else if (e.pageY>=h) {
@ -92,7 +92,7 @@ init = function(session,callback) {
var h = $(this).parent().innerHeight()-scrollbarHeight-$(this).parents('.tab').length*5
if ($(this).get(0).scrollHeight+scrollbarHeight == $(this).parent().height()) {
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
var scroll = e.originalEvent.deltaY || e.originalEvent.deltaX
$(this).scrollLeft($(this).scrollLeft()+scroll)
e.preventDefault()
}

View file

@ -63,7 +63,7 @@ parsewidgets = function(widgets,parent) {
var id = widgetData.id,
label = widgetData.label || id,
path = widgetData.path || '/' + id,
path = widgetData.path || '/' + id,
width = clip(parseInt(widgetData.width),[100,2000]),
style= widgetData.width?`width:${width}rem;min-width:${width}rem`:''

View file

@ -50,7 +50,7 @@ createWidget.led = function(widgetData) {
</div>
`),
led = widget.find('span'),
range = widgetData.range || {min:0,max:1}
range = widgetData.range || {min:0,max:1}
if (widgetData.color) led.css('background-color',widgetData.color)
@ -84,7 +84,7 @@ createWidget.toggle = createWidget.button = function(widgetData) {
})
widget.getValue = function() {
widget.getValue = function() {
return widget.hasClass('on')?widgetData.on:widgetData.off
}
widget.setValue = function(v,send,sync) {
@ -133,7 +133,7 @@ createWidget.switch = function(widgetData) {
})
widget.getValue = function() {
widget.getValue = function() {
return widget.find('.on').data('value')
}
widget.setValue = function(v,send,sync) {
@ -225,13 +225,13 @@ createWidget.xy = function(widgetData) {
widget.getValue = function() {
widget.getValue = function() {
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) {
widget.setValue = function(v,send,sync) {
if (v[1]==undefined) var v = [v,v]
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]),
@ -244,7 +244,7 @@ createWidget.xy = function(widgetData) {
if (sync) widget.trigger('sync')
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v])
@ -399,14 +399,14 @@ createWidget.rgb = function(widgetData) {
widget.getValue = function() {
widget.getValue = function() {
var s = clip(rgbHandle.width,[0,100]),
l = clip(rgbHandle.height,[0,100]),
h = mapToScale(hueHandle.width,[0,100],[0,360]),
rgb = hsbToRgb({h:h,s:s,b:l})
return [rgb.r,rgb.g,rgb.b]
}
widget.setValue = function(v,send,sync) {
widget.setValue = function(v,send,sync) {
if (v[1]==undefined && v[2]==undefined) var v = [v,v,v]
if (v[2]==undefined) var v = [v[0],v[1],v[1]]
@ -439,7 +439,7 @@ createWidget.rgb = function(widgetData) {
if (sync) widget.trigger('sync')
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v])
@ -447,7 +447,7 @@ createWidget.rgb = function(widgetData) {
widget.showValue = function(v) {
widget.showValue = function(v) {
value.r.val(v[0])
value.g.val(v[1])
value.b.val(v[2])
@ -589,7 +589,7 @@ createWidget.fader = function(widgetData,container){
}
}
widget.setValue = function(v,send,sync) {
widget.setValue = function(v,send,sync) {
var h,
v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
for (var i=0;i<rangeVals.length-1;i++) {
@ -608,7 +608,7 @@ createWidget.fader = function(widgetData,container){
if (send) widget.sendValue(v)
}
widget.sendValue = function(v) {
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v])
@ -679,7 +679,7 @@ createWidget.knob = function(widgetData) {
knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
knob.rotation = r
if (r>180) {knob.addClass('d3')}
if (r>180) {knob.addClass('d3')}
else if (r>90) {knob.removeClass('d3').addClass('d2')}
else {knob.removeClass('d3 d2')}
@ -718,7 +718,7 @@ createWidget.knob = function(widgetData) {
knob.rotation = r
if (r>180) {knob.addClass('d3')}
if (r>180) {knob.addClass('d3')}
else if (r>90) {knob.removeClass('d3').addClass('d2')}
else {knob.removeClass('d3 d2')}
@ -737,16 +737,16 @@ createWidget.knob = function(widgetData) {
widget.showValue = function(v) {
input.val(v+unit)
}
widget.sendValue = function(v) {
widget.sendValue = function(v) {
var t = widgetData.target,
p = widgetData.path
sendOsc([t,p,v])
}
widget.setValue = function(v,send,sync) {
widget.setValue = function(v,send,sync) {
var r = mapToScale(v,[range.min,range.max],[0,270])
knob.rotation = r
if (r>180) {
if (r>180) {
knob.addClass('d3')
} else if (r>90) {
knob.removeClass('d3').addClass('d2')

View file

@ -6,15 +6,15 @@ ipc = require('ipc')
fs = require('fs')
// jquery
window.$ = window.jQuery = require( __dirname + "/jquery/jquery.min.js")
window.$ = window.jQuery = require('./jquery/jquery.min.js')
// third-party js libraries
require( __dirname + "/jquery/jquery.event.drag-2.2.js")
require( __dirname + "/jquery/jquery.ba-resize.js")
require('./jquery/jquery.event.drag-2.2.js')
require('./jquery/jquery.ba-resize.js')
// main js
require( __dirname + "/app/app.js")
require('./app/app.js')
ipc.send('ready')

View file

@ -18,8 +18,8 @@ var app = require('app')
'l':{alias:'load',type:'string',describe:'session file to load'},
'p':{alias:'port',describe:'osc input port (for synchronization)'}
})
.check(function(a,x){if(a.port==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.host==undefined || a.h.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Hosts must ne ip:port pairs & port must be >= 1024'}})
.check(function(a,x){if(a.port==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}})
.check(function(a,x){if(a.host==undefined || a.h.join(' ').match('^([^:\s]*:[0-9]{4,5}[\s]*)*$')!=null){return true}else{throw 'Error: Hosts must ne ip:port pairs & port must be >= 1024'}})
.strict()
.argv
@ -29,16 +29,16 @@ var app = require('app')
recentSessions: [],
appName: argv.n || 'Controller',
syncTargets: argv.h || false,
syncTargets: argv.h || false,
oscInPort: argv.p || false,
compileScss: argv.c || false,
sessionFile: argv.l || false,
persistent: function(){var c = {};try {c=require( __dirname + '/config.json')} finally {return c}}(),
persistent: function(){var c = {};try {c=require( __dirname + '/config.json')} finally {return c}}(),
read:function(key){
var x = this.persistent[key] || this[key]
var x = this.persistent[key] || this[key]
return x
},
write:function(key,value) {