widgets: props inheritance feature working
This commit is contained in:
parent
e7a3bdba41
commit
342c9ebe02
39 changed files with 147 additions and 163 deletions
|
|
@ -15,6 +15,7 @@
|
|||
"electron-packager": "8.7.0",
|
||||
"babelify": "7.3.0",
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "6.23.0",
|
||||
"uglifyify": "3.0.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ var browserify = require('browserify'),
|
|||
|
||||
var b = browserify(path.resolve(__dirname + '/../src/browser/js/browser.js'), {debug:true});
|
||||
|
||||
b.transform(babelify, {presets: ["es2015"]})
|
||||
b.transform(babelify, {presets: ["es2015"], plugins: ["transform-object-rest-spread"]})
|
||||
.transform('uglifyify')
|
||||
.bundle()
|
||||
.pipe(exorcist(path.resolve(__dirname + '/../app/browser/scripts.js.map')))
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ var updateDom = function(container,data, remote) {
|
|||
|
||||
if (container.hasClass('widget')) {
|
||||
// widget
|
||||
var newContainer = parsewidgets([data],container.parent())
|
||||
var newContainer = parsewidgets([data],container.parent(), container[0].abstract.parent)
|
||||
container.replaceWith(newContainer)
|
||||
|
||||
if (!remote) editObject(newContainer,data,true)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var {getObjectData, updateDom, incrementWidget} = require('./data-workers'),
|
||||
{editObject, editSession, editClean} = require('./edit-objects'),
|
||||
createPopup = require('../utils').createPopup,
|
||||
{widgets, widgetCategories} = require('../widgets'),
|
||||
{widgets, categories} = require('../widgets'),
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
|
@ -102,10 +102,10 @@ var init = function(){
|
|||
}
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add widget'] = {}
|
||||
for (let category in widgetCategories) {
|
||||
for (let category in categories) {
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category] = {}
|
||||
for (let t in widgetCategories[category]) {
|
||||
let wtype = widgetCategories[category][t]
|
||||
for (let t in categories[category]) {
|
||||
let wtype = categories[category][t]
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][category][wtype] = function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = {type:wtype}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ module.exports.tabs = function(data,parent,main,parentLabel){
|
|||
|
||||
|
||||
|
||||
module.exports.widgets = function(data,parent) {
|
||||
module.exports.widgets = function(data, parentNode, parentWidget) {
|
||||
|
||||
for (let i in data) {
|
||||
var props = data[i]
|
||||
|
|
@ -133,7 +133,7 @@ module.exports.widgets = function(data,parent) {
|
|||
if (defaults[i]===undefined && i!='type') {delete props[i]}
|
||||
}
|
||||
|
||||
if (parent.hasClass('strip')) {
|
||||
if (parentNode.hasClass('strip')) {
|
||||
delete props.top
|
||||
delete props.left
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ module.exports.widgets = function(data,parent) {
|
|||
`)
|
||||
|
||||
// create widget
|
||||
var widgetInner = new widgets[props.type](props, widgetContainer)
|
||||
var widgetInner = new widgets[props.type]({props:props, container:widgetContainer, parent:parentWidget})
|
||||
|
||||
widgetContainer[0].appendChild(widgetInner.widget[0])
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ module.exports.widgets = function(data,parent) {
|
|||
}
|
||||
|
||||
// Append the widget to its parent
|
||||
parent[0].appendChild(widgetContainer[0])
|
||||
parentNode[0].appendChild(widgetContainer[0])
|
||||
}
|
||||
|
||||
// Editor needs to get the container object
|
||||
|
|
|
|||
|
|
@ -33,13 +33,9 @@ module.exports = class Push extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="light"></div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: '<div class="light"></div>'})
|
||||
|
||||
this.state = 0
|
||||
this.active = 0
|
||||
|
|
|
|||
|
|
@ -34,13 +34,10 @@ module.exports = class Switch extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="switch"></div>
|
||||
`
|
||||
super({...options, html: '<div class="switch"></div>'})
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,9 @@ module.exports = class Toggle extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="light"></div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: '<div class="light"></div>'})
|
||||
|
||||
this.widget.value = this.widget.find('span')
|
||||
this.widget.state = 0
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ var _widgets_base = require('./_widgets_base')
|
|||
|
||||
module.exports = class _canvas_base extends _widgets_base {
|
||||
|
||||
constructor() {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.canvas = this.widget.find('canvas')
|
||||
this.ctx = this.canvas[0].getContext('2d')
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ module.exports = class _widgets_base {
|
|||
return shortid.generate()
|
||||
}
|
||||
|
||||
constructor(props, widgetContainer, widgetHtml) {
|
||||
constructor(options={}) {
|
||||
|
||||
this.container = widgetContainer
|
||||
this.widget = $(widgetHtml)
|
||||
this.props = props
|
||||
this.container = options.container
|
||||
this.widget = $(options.html)
|
||||
this.props = options.props
|
||||
this.parent = options.parent
|
||||
this.hash = _widgets_base.createHash()
|
||||
|
||||
|
||||
}
|
||||
|
||||
sendValue(overrides) {
|
||||
|
|
@ -78,7 +78,9 @@ module.exports = class _widgets_base {
|
|||
k = id.pop()
|
||||
id = id.join('.')
|
||||
|
||||
var widgets = widgetManager.getWidgetById(id)
|
||||
var widgets = id == 'parent' && this.parent ?
|
||||
[this.parent] : widgetManager.getWidgetById(id)
|
||||
|
||||
for (var i in widgets) {
|
||||
if (widgets[i].props.hasOwnProperty(k)) {
|
||||
return widgets[i].getProp(k)
|
||||
|
|
|
|||
|
|
@ -37,15 +37,13 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
}
|
||||
|
||||
constructor(props, container) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.widget.removeClass('noscroll')
|
||||
this.container = container
|
||||
|
||||
container.append('<div class="light"></div>')
|
||||
this.light = container.find('.light').first()
|
||||
this.light = $('<div class="light"></div>').appendTo(this.container)
|
||||
|
||||
this.modal = this.widget.detach()
|
||||
|
||||
|
|
|
|||
|
|
@ -35,20 +35,14 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="panel">
|
||||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: '<div class="panel"></div>'})
|
||||
|
||||
if (!this.getProp('scroll')) this.widget.addClass('noscroll')
|
||||
if (this.getProp('tabs').length) this.widget.addClass('has-tabs')
|
||||
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets,
|
||||
parsetabs = parsers.tabs
|
||||
|
|
@ -56,7 +50,7 @@ module.exports = class Panel extends _widgets_base {
|
|||
if (this.getProp('tabs').length) {
|
||||
parsetabs(this.getProp('tabs'),this.widget)
|
||||
} else {
|
||||
parsewidgets(this.getProp('widgets'),this.widget)
|
||||
parsewidgets(this.getProp('widgets'),this.widget, this)
|
||||
}
|
||||
|
||||
this.children = this.widget.find('> .widget')
|
||||
|
|
|
|||
|
|
@ -26,23 +26,20 @@ module.exports = class Strip extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props, container) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="strip"></div>
|
||||
`
|
||||
super({...options, html: '<div class="strip"></div>'})
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
container.addClass('horizontal')
|
||||
this.container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
this.container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(this.getProp('widgets'),this.widget)
|
||||
parsewidgets(this.getProp('widgets'),this.widget, this)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ module.exports = class Formula extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="formula">
|
||||
<div class="input"></div>
|
||||
</div>
|
||||
`
|
||||
super({...options, html: html})
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
this.formula = String(this.getProp('formula'))
|
||||
this.condition = String(this.getProp('condition'))
|
||||
|
|
|
|||
|
|
@ -2,14 +2,9 @@ var _widgets_base = require('../common/_widgets_base')
|
|||
|
||||
module.exports = class _matrices_base extends _widgets_base {
|
||||
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="matrix"></div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: '<div class="matrix"></div>'})
|
||||
|
||||
this.value = []
|
||||
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.keys = parseInt(this.getProp('keys'))
|
||||
|
||||
var strData = JSON.stringify(props),
|
||||
var strData = JSON.stringify(options.props),
|
||||
pattern = 'wbwbwwbwbwbw',
|
||||
wCount = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ module.exports = class Multifader extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.strips = parseInt(this.getProp('strips'))
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ module.exports = class Multifader extends _matrices_base {
|
|||
this.widget.addClass('horizontal')
|
||||
}
|
||||
|
||||
var strData = JSON.stringify(props)
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ module.exports = class Multipush extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
var strData = JSON.stringify(props)
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ module.exports = class Multitoggle extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
var strData = JSON.stringify(props)
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ var Fader = require('../sliders/fader')
|
|||
|
||||
module.exports = class _fake_fader extends Fader {
|
||||
|
||||
constructor(props, cancelDraw) {
|
||||
constructor(options) {
|
||||
|
||||
super(props, false)
|
||||
super(options)
|
||||
|
||||
if (cancelDraw) this.noDraw = true
|
||||
if (arguments.cancelDraw) this.noDraw = true
|
||||
}
|
||||
|
||||
sendValue() {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ var _canvas_base = require('../common/_canvas_base'),
|
|||
|
||||
module.exports = class _pads_base extends _canvas_base {
|
||||
|
||||
constructor() {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="pad">
|
||||
<div class="wrapper">
|
||||
<canvas></canvas>
|
||||
|
|
@ -13,7 +13,7 @@ module.exports = class _pads_base extends _canvas_base {
|
|||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ var _pads_base = require('./_pads_base'),
|
|||
Xy = require('./xy'),
|
||||
{clip} = require('../utils')
|
||||
|
||||
var xyDefaults = Xy.defaults()
|
||||
|
||||
|
||||
module.exports = class MultiXy extends _pads_base {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -45,9 +48,9 @@ module.exports = class MultiXy extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.npoints = typeof this.getProp('points') == 'object' ? this.getProp('points').length : this.getProp('points')
|
||||
this.labels = typeof this.getProp('points') == 'object'
|
||||
|
|
@ -76,7 +79,8 @@ module.exports = class MultiXy extends _pads_base {
|
|||
this.pads = []
|
||||
|
||||
for (var i=this.npoints-1;i>=0;i--) {
|
||||
this.pads[i] = new Xy({
|
||||
this.pads[i] = new Xy({props:{
|
||||
...xyDefaults,
|
||||
snap:this.getProp('snap'),
|
||||
spring:this.getProp('spring'),
|
||||
value:this.getProp('value').length == this.getProp('points') * 2 ? [this.getProp('value')[i*2], this.getProp('value')[i*2 + 1]] : '',
|
||||
|
|
@ -85,7 +89,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
precision:this.getProp('precision'),
|
||||
logScaleX:this.getProp('logScaleX'),
|
||||
logScaleY:this.getProp('logScaleY')
|
||||
}, false)
|
||||
}})
|
||||
this.pads[i].sendValue = ()=>{}
|
||||
this.pads[i].draw = ()=>{}
|
||||
this.wrapper.append(this.pads[i].widget)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ var _pads_base = require('./_pads_base'),
|
|||
Fader = require('./_fake_fader'),
|
||||
{clip, hsbToRgb, rgbToHsb} = require('../utils')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
module.exports = class Rgb extends _pads_base {
|
||||
|
||||
|
|
@ -38,9 +39,9 @@ module.exports = class Rgb extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 3 ?
|
||||
|
|
@ -65,7 +66,8 @@ module.exports = class Rgb extends _pads_base {
|
|||
this.hueWrapper = this.widget.find('.hue-wrapper')
|
||||
|
||||
this.faders = {
|
||||
h: new Fader({
|
||||
h: new Fader({props:{
|
||||
...faderDefaults,
|
||||
id:'h',
|
||||
compact:false,
|
||||
noPip:true,
|
||||
|
|
@ -73,24 +75,25 @@ module.exports = class Rgb extends _pads_base {
|
|||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:360},
|
||||
precision:2
|
||||
}, false),
|
||||
s: new Fader({
|
||||
}, cancelDraw: false}),
|
||||
s: new Fader({props:{
|
||||
...faderDefaults,
|
||||
id:'s',
|
||||
compact:true,
|
||||
horizontal:true,
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
precision:2
|
||||
|
||||
}, true),
|
||||
b: new Fader({
|
||||
}, cancelDraw: true}),
|
||||
b: new Fader({props:{
|
||||
...faderDefaults,
|
||||
id:'b',
|
||||
compact:true,
|
||||
horizontal:false,
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
precision:2
|
||||
}, true)
|
||||
}, cancelDraw: true})
|
||||
}
|
||||
|
||||
this.inputs = [
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ var _pads_base = require('./_pads_base'),
|
|||
Fader = require('./_fake_fader'),
|
||||
{clip} = require('../utils')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
module.exports = class Xy extends _pads_base {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -43,9 +45,9 @@ module.exports = class Xy extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 ?
|
||||
|
|
@ -65,7 +67,8 @@ module.exports = class Xy extends _pads_base {
|
|||
`)
|
||||
|
||||
this.faders = {
|
||||
x: new Fader({
|
||||
x: new Fader({props:{
|
||||
...faderDefaults,
|
||||
id:0,
|
||||
compact:true,
|
||||
horizontal:true,
|
||||
|
|
@ -77,8 +80,9 @@ module.exports = class Xy extends _pads_base {
|
|||
origin:'auto',
|
||||
precision:this.getProp('precision'),
|
||||
logScale:this.getProp('logScaleX')
|
||||
}, true),
|
||||
y: new Fader({
|
||||
}, cancelDraw: true}),
|
||||
y: new Fader({props:{
|
||||
...faderDefaults,
|
||||
id:1,
|
||||
compact:true,
|
||||
horizontal:false,
|
||||
|
|
@ -90,8 +94,7 @@ module.exports = class Xy extends _pads_base {
|
|||
origin:'auto',
|
||||
precision:this.getProp('precision'),
|
||||
logScale:this.getProp('logScaleY')
|
||||
|
||||
}, true)
|
||||
}, cancelDraw: true}),
|
||||
}
|
||||
|
||||
this.inputs = [
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ var {mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class _plots_base extends _canvas_base {
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="plot">
|
||||
<canvas></canvas>
|
||||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: html})
|
||||
|
||||
this.data = []
|
||||
this.linkedWidgets = []
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ module.exports = class Eq extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.rangeX = {min:20,max:22050}
|
||||
this.pips.x.min = '20'
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="led">
|
||||
<div><span></span></div>
|
||||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: html})
|
||||
|
||||
this.led = this.widget.find('span')
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ module.exports = class Meter extends Fader {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
props.compact = true
|
||||
options.props.compact = true
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.input.hide()
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ module.exports = class Plot extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
if (typeof this.getProp('points')=='string') {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,15 +34,15 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="led">
|
||||
<div><span></span></div>
|
||||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: html})
|
||||
|
||||
this.led = this.widget.find('span')
|
||||
|
||||
|
|
|
|||
|
|
@ -34,14 +34,9 @@ module.exports = class Text extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="text">
|
||||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: '<div class="text"></div>'})
|
||||
|
||||
if (this.getProp('vertical')) this.widget.addClass('vertical')
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ module.exports = class Visualizer extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.pips.y.min = Math.abs(this.getProp('range').min) >= 1000? this.getProp('range').min/1000+'k' : this.getProp('range').min
|
||||
this.pips.y.max = Math.abs(this.getProp('range').max) >= 1000? this.getProp('range').max/1000+'k' : this.getProp('range').max
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ var {clip, mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class _sliders_base extends _canvas_base {
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
var html = `
|
||||
<div class="slider">
|
||||
<div class="wrapper">
|
||||
<canvas></canvas>
|
||||
|
|
@ -15,7 +15,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
</div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.input = this.widget.find('.input').fakeInput({align:'center'})
|
||||
|
|
|
|||
|
|
@ -79,36 +79,37 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments, `
|
||||
var html = `
|
||||
<div class="encoder">
|
||||
<div class="wrapper">
|
||||
</div>
|
||||
</div>
|
||||
`)
|
||||
`
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.ticks = Math.abs(parseInt(this.getProp('ticks')))
|
||||
|
||||
this.knob = new EncoderKnob({
|
||||
this.knob = new EncoderKnob({props:{
|
||||
label:false,
|
||||
angle:360,
|
||||
snap:true,
|
||||
range:{min:0,max:this.ticks},
|
||||
noPip:true,
|
||||
}, true)
|
||||
}})
|
||||
|
||||
this.knob.noDraw = true
|
||||
|
||||
this.display = new DisplayKnob({
|
||||
this.display = new DisplayKnob({props:{
|
||||
label:false,
|
||||
angle:360,
|
||||
range:{min:0,max:this.ticks},
|
||||
compact:this.getProp('compact'),
|
||||
origin:this.ticks/2,
|
||||
noPip:true,
|
||||
}, true)
|
||||
}})
|
||||
|
||||
this.wrapper.append(this.knob.widget.addClass('drag-knob'))
|
||||
this.wrapper.append(this.display.widget.addClass('display-knob'))
|
||||
|
|
|
|||
|
|
@ -48,16 +48,16 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props, widgetContainer) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('fader')
|
||||
this.margin = 15
|
||||
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.add(widgetContainer).addClass('horizontal')
|
||||
this.widget.add(this.container).addClass('horizontal')
|
||||
if (this.getProp('width') == 'auto' && this.getProp('left') != 'auto') {
|
||||
this.container.css({'width':'auto', 'right':'0'})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('knob')
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class _switchers_base extends _widgets_base {
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this._isSwitcher = true
|
||||
this.value = {_selected:false}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ var Switcher = require('./switcher'),
|
|||
Fader = require('../sliders/fader'),
|
||||
{mapToScale, clip} = require('../utils')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
|
||||
module.exports = class Crossfader extends Switcher {
|
||||
|
||||
static defaults(){
|
||||
|
|
@ -14,18 +17,18 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
props.values = props.horizontal ? ['A', 'B'] : ['B', 'A']
|
||||
options.props.values = options.props.horizontal ? ['A', 'B'] : ['B', 'A']
|
||||
|
||||
super(...arguments)
|
||||
super(options)
|
||||
|
||||
this.fader = new Fader({props:{
|
||||
...faderDefaults,
|
||||
horizontal: this.getProp('horizontal'),
|
||||
range: {min:{'A':0}, '50%':{" ":0.5},max:{'B':1}}
|
||||
}})
|
||||
|
||||
var o = Fader.defaults()
|
||||
o.horizontal = this.getProp('horizontal')
|
||||
o.range = {min:{'A':0}, '50%':{" ":0.5},max:{'B':1}}
|
||||
|
||||
this.fader = new Fader(o, 0)
|
||||
this.fader.sendValue = ()=>{}
|
||||
|
||||
this.widget.append($('<div class="fader-container"></div>').append(this.fader.widget))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
var _switchers_base = require('./_switchers_base'),
|
||||
Switch = require('../buttons/switch')
|
||||
|
||||
var switchDefaults = Switch.defaults()
|
||||
|
||||
module.exports = class Switcher extends _switchers_base {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -36,22 +38,19 @@ module.exports = class Switcher extends _switchers_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(options) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="switcher switch-container"></div>
|
||||
`
|
||||
|
||||
super(...arguments, widgetHtml)
|
||||
super({...options, html: '<div class="switcher switch-container"></div>'})
|
||||
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
|
||||
this.switch = new Switch({
|
||||
this.switch = new Switch({props:{
|
||||
...switchDefaults,
|
||||
label:false,
|
||||
values:this.getProp('values'),
|
||||
value: this.getProp('value'),
|
||||
horizontal:this.getProp('horizontal')
|
||||
},0)
|
||||
}})
|
||||
|
||||
this.switch.sendValue = ()=>{}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue