From b1c08a49b0ae34941d1fe483d962e46e40033166 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 3 Oct 2016 18:26:11 +0200 Subject: [PATCH] widgets: oop/prototype rewrite matrices --- app/browser/js/app/widgets.js | 6 +- .../js/app/widgets/matrices/_matrices_base.js | 36 ++++++++ .../js/app/widgets/matrices/multifader.js | 72 ++++++++++++++++ .../app/widgets/{ => matrices}/multipush.js | 44 ++++------ .../app/widgets/{ => matrices}/multitoggle.js | 44 ++++------ app/browser/js/app/widgets/multifader.js | 85 ------------------- 6 files changed, 143 insertions(+), 144 deletions(-) create mode 100644 app/browser/js/app/widgets/matrices/_matrices_base.js create mode 100644 app/browser/js/app/widgets/matrices/multifader.js rename app/browser/js/app/widgets/{ => matrices}/multipush.js (51%) rename app/browser/js/app/widgets/{ => matrices}/multitoggle.js (50%) delete mode 100644 app/browser/js/app/widgets/multifader.js diff --git a/app/browser/js/app/widgets.js b/app/browser/js/app/widgets.js index f2f60c15..138163da 100644 --- a/app/browser/js/app/widgets.js +++ b/app/browser/js/app/widgets.js @@ -13,9 +13,9 @@ var widgets = { rgb: require('./widgets/rgb'), // matrices - multitoggle: require('./widgets/multitoggle'), - multipush: require('./widgets/multipush'), - multifader: require('./widgets/multifader'), + multitoggle: require('./widgets/matrices/multitoggle'), + multipush: require('./widgets/matrices/multipush'), + multifader: require('./widgets/matrices/multifader'), // plots led: require('./widgets/plots/led'), diff --git a/app/browser/js/app/widgets/matrices/_matrices_base.js b/app/browser/js/app/widgets/matrices/_matrices_base.js new file mode 100644 index 00000000..9cd995ea --- /dev/null +++ b/app/browser/js/app/widgets/matrices/_matrices_base.js @@ -0,0 +1,36 @@ +var _widgets_base = require('../common/_widgets_base') + +var _matrices_base = module.exports = function(widgetData){ + + _widgets_base.apply(this,arguments) + + this.widget = $(` +
+
\ + `) + this.value = [] + + this.widget.getValue = function(){ + console.log(this.value) + return this.value + }.bind(this) + + this.widget.on('sync',function(e){ + if (e.id==this.widgetData.id) return + this.value[e.widget.parent().index()] = e.widget.getValue() + this.widget.trigger({type:'sync',id:this.widgetData.id,widget:this.widget}) + }.bind(this)) + + this.widget.enableTraversingGestures() + +} + + + +_matrices_base.prototype = Object.create(_widgets_base.prototype) + +_matrices_base.prototype.constructor = _matrices_base + +_matrices_base.prototype.getValue = function(){ + return this.value +} diff --git a/app/browser/js/app/widgets/matrices/multifader.js b/app/browser/js/app/widgets/matrices/multifader.js new file mode 100644 index 00000000..38207ef4 --- /dev/null +++ b/app/browser/js/app/widgets/matrices/multifader.js @@ -0,0 +1,72 @@ +var _matrices_base = require('./_matrices_base') + +module.exports.options = { + type:'multifader', + id:'auto', + + separator0:'Matrix', + + strips:2, + + separator1:'style', + + label:'auto', + unit:'', + left:'auto', + top:'auto', + width:'auto', + height:'auto', + color:'auto', + compact:false, + css:'', + + + separator2:'osc', + + range:{min:0,max:1}, + logScale:false, + precision:2, + path:'auto', + preArgs:[], + target:[] +} + + +var Multifader = function(widgetData) { + + _matrices_base.apply(this,arguments) + + for (var i=0;i - \ - `), - $document = $(document) +var Multipush = function(widgetData) { - widget.value = [] + _matrices_base.apply(this,arguments) - for (var i=0;i - \ - `), - $document = $(document) + _matrices_base.apply(this,arguments) - widget.value = [] - - for (var i=0;i - \ - `), - $document = $(document) - - widget.value = [] - - for (var i=0;i