code: rename widgetData to props, options() to defaults(), clean
This commit is contained in:
parent
bb5b8b2dbc
commit
e7a3bdba41
42 changed files with 416 additions and 439 deletions
|
|
@ -32,7 +32,7 @@ module.exports = {
|
|||
if (widget.setValue && widget.getValue) {
|
||||
var v = widget.getValue()
|
||||
if (v!=undefined) {
|
||||
data.push([widget.widgetData.id,v])
|
||||
data.push([widget.getProp('id'),v])
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
{widgets} = require('../widgets')
|
||||
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ var editObject = function(container, data, refresh){
|
|||
var form = $('<div class="form"></div>').appendTo('.editor-container')
|
||||
|
||||
|
||||
var params = isWidget?widgetOptions[data.type]:{label:'', id:''}
|
||||
var params = isWidget ? widgets[data.type].defaults() : {label:'', id:''}
|
||||
|
||||
$(`<div class="separator"><span>${isWidget?'Widget':'Tab'}</span></div>`).appendTo(form)
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ var editObject = function(container, data, refresh){
|
|||
|
||||
input = $(`<select class="input" data-type="${type}" title="${i}"/>`)
|
||||
|
||||
for (let t in widgetOptions) {
|
||||
for (let t in widgets) {
|
||||
input.append(`<option ${t==value?'selected=':''} value="${t}">${t}</option>`)
|
||||
}
|
||||
let select = $('<div class="select-wrapper"></div>').append(input)
|
||||
|
|
@ -117,7 +117,7 @@ var editObject = function(container, data, refresh){
|
|||
}
|
||||
|
||||
// widget list edit
|
||||
if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
|
||||
if (((isWidget && params.widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
$(`<div class="separator"><span>Widgets</span></div>`).appendTo(form)
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ var editObject = function(container, data, refresh){
|
|||
}
|
||||
|
||||
// tab list edit
|
||||
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
if (((isWidget && params.tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
|
||||
$(`<div class="separator"><span>Tabs</span></div>`).appendTo(form)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
var {getObjectData, updateDom, incrementWidget} = require('./data-workers'),
|
||||
{editObject, editSession, editClean} = require('./edit-objects'),
|
||||
createPopup = require('../utils').createPopup,
|
||||
widgetOptions = require('../widgets').widgetOptions,
|
||||
widgetCategories = require('../widgets').categories,
|
||||
{widgets, widgetCategories} = require('../widgets'),
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ var init = function(){
|
|||
updateDom(parentContainer,parentData)
|
||||
}
|
||||
|
||||
if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
|
||||
if (((type=='widget' && widgets[data.type].defaults().widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
if (CLIPBOARD!=null) {
|
||||
actions['<i class="fa fa-paste"></i> Paste'] = {
|
||||
|
|
@ -122,7 +121,7 @@ var init = function(){
|
|||
}
|
||||
|
||||
}
|
||||
if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
|
||||
if (((type=='widget' && widgets[data.type].defaults().tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add tab'] = function(){
|
||||
data.tabs = data.tabs || []
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ var WidgetManager = function(){
|
|||
ipc.send('addWidget', {
|
||||
hash:hash,
|
||||
data:{
|
||||
precision: this.widgets[hash].getOption('precision'),
|
||||
preArgs: this.widgets[hash].getOption('preArgs'),
|
||||
precision: this.widgets[hash].getProp('precision'),
|
||||
preArgs: this.widgets[hash].getProp('preArgs'),
|
||||
split: this.widgets[hash].split,
|
||||
target: this.widgets[hash].getOption('target'),
|
||||
address: this.widgets[hash].getOption('address'),
|
||||
target: this.widgets[hash].getProp('target'),
|
||||
address: this.widgets[hash].getProp('address'),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -61,8 +61,8 @@ var WidgetManager = function(){
|
|||
|
||||
|
||||
WidgetManager.prototype.createAddressRef = function(widget, preArgs, address) {
|
||||
var preArgs = preArgs || widget.getOption('preArgs'),
|
||||
address = address || widget.getOption('address')
|
||||
var preArgs = preArgs || widget.getProp('preArgs'),
|
||||
address = address || widget.getProp('address')
|
||||
|
||||
return preArgs && preArgs.length ?
|
||||
address + this.preArgsSeparator + preArgs.join(this.preArgsSeparator)
|
||||
|
|
@ -74,8 +74,8 @@ WidgetManager.prototype.addWidget = function(widget) {
|
|||
|
||||
var hash = widget.hash,
|
||||
address = this.createAddressRef(widget),
|
||||
id = widget.getOption('id'),
|
||||
linkId = widget.getOption('linkId')
|
||||
id = widget.getProp('id'),
|
||||
linkId = widget.getProp('linkId')
|
||||
|
||||
|
||||
this.widgets[hash] = widget
|
||||
|
|
@ -99,11 +99,11 @@ WidgetManager.prototype.addWidget = function(widget) {
|
|||
ipc.send('addWidget', {
|
||||
hash:hash,
|
||||
data:{
|
||||
precision: widget.getOption('precision'),
|
||||
preArgs: widget.getOption('preArgs'),
|
||||
precision: widget.getProp('precision'),
|
||||
preArgs: widget.getProp('preArgs'),
|
||||
split: widget.split,
|
||||
target: widget.getOption('target'),
|
||||
address: widget.getOption('address'),
|
||||
target: widget.getProp('target'),
|
||||
address: widget.getProp('address'),
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -113,8 +113,8 @@ WidgetManager.prototype.removeWidget = function(hash) {
|
|||
|
||||
var widget = this.widgets[hash],
|
||||
address = this.createAddressRef(widget),
|
||||
linkId = widget.getOption('linkId'),
|
||||
id = widget.getOption('id')
|
||||
linkId = widget.getProp('linkId'),
|
||||
id = widget.getProp('id')
|
||||
|
||||
if (this.widgets[hash]) {
|
||||
if (this.widgets[hash].onRemove) this.widgets[hash].onRemove()
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ Osc.prototype.receive = function(data){
|
|||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
// compare arrays using > and < operators (both false = equality)
|
||||
if (!target || !(widget[i].widgetData.target < target || widget[i].widgetData.target > target)) {
|
||||
if (!target || !(widget[i].getProp('target') < target || widget[i].getProp('target') > target)) {
|
||||
// update matching widgets
|
||||
if (widget[i] && widget[i].setValue) widget[i].setValue(args,{send:false,sync:true,fromExternal:!target})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
var {widgetManager} = require('./managers')
|
||||
|
||||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
createWidget = widgets.createWidget,
|
||||
var {widgets} = require('./widgets'),
|
||||
{iconify} = require('./utils')
|
||||
|
||||
var iterators = {
|
||||
|
|
@ -102,67 +100,67 @@ module.exports.tabs = function(data,parent,main,parentLabel){
|
|||
module.exports.widgets = function(data,parent) {
|
||||
|
||||
for (let i in data) {
|
||||
var widgetData = data[i]
|
||||
var props = data[i]
|
||||
|
||||
// Set default widget type
|
||||
widgetData.type = widgetData.type || 'fader'
|
||||
props.type = props.type || 'fader'
|
||||
|
||||
// Safe copy widget's options
|
||||
var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
|
||||
let defaults = widgets[props.type].defaults()
|
||||
|
||||
// Set widget's undefined options to default
|
||||
for (let i in tmpWidgetOptions[widgetData.type]) {
|
||||
if (i.indexOf('_')!=0 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
|
||||
for (let i in defaults) {
|
||||
if (i.indexOf('_')!=0 && props[i]===undefined) props[i] = defaults[i]
|
||||
}
|
||||
|
||||
// Genrate widget's id, based on its type
|
||||
if (widgetData.id=='auto') {
|
||||
if (props.id=='auto') {
|
||||
var id
|
||||
while (!id || widgetManager.getWidgetById(id).length) {
|
||||
id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
|
||||
id=props.type+'_'+getIterator(props.type,'widget')
|
||||
}
|
||||
widgetData.id = id
|
||||
props.id = id
|
||||
}
|
||||
|
||||
// Backward compatibility patch: path -> address
|
||||
if (widgetData.path) widgetData.address = widgetData.path
|
||||
if (props.path) props.address = props.path
|
||||
|
||||
// Genrate default address
|
||||
widgetData.address = widgetData.address=='auto'?'/' + widgetData.id:widgetData.address
|
||||
props.address = props.address=='auto'?'/' + props.id:props.address
|
||||
|
||||
// Delete unrecognized options
|
||||
for (let i in widgetData) {
|
||||
if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
|
||||
for (let i in props) {
|
||||
if (defaults[i]===undefined && i!='type') {delete props[i]}
|
||||
}
|
||||
|
||||
if (parent.hasClass('strip')) {
|
||||
delete widgetData.top
|
||||
delete widgetData.left
|
||||
delete props.top
|
||||
delete props.left
|
||||
}
|
||||
|
||||
// Turn preArgs into array
|
||||
if (widgetData.preArgs!=undefined) {
|
||||
widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
|
||||
if (props.preArgs!=undefined) {
|
||||
props.preArgs = Array.isArray(props.preArgs)?props.preArgs:[props.preArgs]
|
||||
}
|
||||
|
||||
// Turn preArgs into array
|
||||
if (widgetData.target!=undefined) {
|
||||
widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
|
||||
if (props.target!=undefined) {
|
||||
props.target = Array.isArray(props.target)?props.target:[props.target]
|
||||
}
|
||||
|
||||
if (widgetData.precision) {
|
||||
widgetData.precision = Math.min(20,Math.max(widgetData.precision,0))
|
||||
if (props.precision) {
|
||||
props.precision = Math.min(20,Math.max(props.precision,0))
|
||||
}
|
||||
|
||||
// create container
|
||||
var widgetContainer = $(`
|
||||
<div class="widget ${widgetData.type}-container">
|
||||
<div class="widget ${props.type}-container">
|
||||
<div class="label"><span></span></div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
// create widget
|
||||
var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
|
||||
var widgetInner = new widgets[props.type](props, widgetContainer)
|
||||
|
||||
widgetContainer[0].appendChild(widgetInner.widget[0])
|
||||
|
||||
|
|
@ -170,45 +168,45 @@ module.exports.widgets = function(data,parent) {
|
|||
|
||||
// dimensions / coordinates can't be < 0
|
||||
for (let t in {width:'',height:'',top:'',left:''}) {
|
||||
widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
|
||||
props[t] = `${props[t]}`.indexOf('-')!=-1?0:props[t]
|
||||
}
|
||||
|
||||
// convert dimensions / coordinates to rem
|
||||
var width = parseFloat(widgetInner.getOption('width'))==widgetInner.getOption('width')?parseFloat(widgetInner.getOption('width'))+'rem' : widgetInner.getOption('width'),
|
||||
height = parseFloat(widgetInner.getOption('height'))==widgetInner.getOption('height')?parseFloat(widgetInner.getOption('height'))+'rem' : widgetInner.getOption('height'),
|
||||
left = parseFloat(widgetInner.getOption('left'))==widgetInner.getOption('left')?parseFloat(widgetInner.getOption('left'))+'rem' : widgetInner.getOption('left'),
|
||||
top = parseFloat(widgetInner.getOption('top'))==widgetInner.getOption('top')?parseFloat(widgetInner.getOption('top'))+'rem' : widgetInner.getOption('top')
|
||||
var width = parseFloat(widgetInner.getProp('width'))==widgetInner.getProp('width')?parseFloat(widgetInner.getProp('width'))+'rem' : widgetInner.getProp('width'),
|
||||
height = parseFloat(widgetInner.getProp('height'))==widgetInner.getProp('height')?parseFloat(widgetInner.getProp('height'))+'rem' : widgetInner.getProp('height'),
|
||||
left = parseFloat(widgetInner.getProp('left'))==widgetInner.getProp('left')?parseFloat(widgetInner.getProp('left'))+'rem' : widgetInner.getProp('left'),
|
||||
top = parseFloat(widgetInner.getProp('top'))==widgetInner.getProp('top')?parseFloat(widgetInner.getProp('top'))+'rem' : widgetInner.getProp('top')
|
||||
|
||||
var geometry = {}
|
||||
for (var d of ['width', 'height', 'left', 'top']){
|
||||
if (widgetData[d])
|
||||
geometry[d] = `${widgetData[d]}`.indexOf('-') != -1 ? 0 :
|
||||
parseFloat(widgetData[d]) == widgetData[d] ?
|
||||
parseFloat(widgetData[d])+'rem' : widgetData[d]
|
||||
if (props[d]!==undefined)
|
||||
geometry[d] = `${props[d]}`.indexOf('-') != -1 ? 0 :
|
||||
parseFloat(props[d]) == props[d] ?
|
||||
parseFloat(props[d])+'rem' : props[d]
|
||||
}
|
||||
|
||||
// dimensions / coordinates css
|
||||
var styleW = widgetInner.getOption('width') && widgetInner.getOption('width') != 'auto' ? `width: ${geometry.width}; min-width:auto;` : '',
|
||||
styleH = widgetInner.getOption('height') && widgetInner.getOption('height') != 'auto' ? `height: ${geometry.height}; min-height:auto;` : '',
|
||||
styleL = widgetInner.getOption('left') && widgetInner.getOption('left') != 'auto'|| widgetInner.getOption('left') == 0 ?`left: ${geometry.left};` : '',
|
||||
styleT = widgetInner.getOption('top') && widgetInner.getOption('top') != 'auto'|| widgetInner.getOption('top') == 0 ? `top: ${geometry.top};` : ''
|
||||
var styleW = widgetInner.getProp('width') && widgetInner.getProp('width') != 'auto' ? `width: ${geometry.width}; min-width:auto;` : '',
|
||||
styleH = widgetInner.getProp('height') && widgetInner.getProp('height') != 'auto' ? `height: ${geometry.height}; min-height:auto;` : '',
|
||||
styleL = widgetInner.getProp('left') && widgetInner.getProp('left') != 'auto'|| widgetInner.getProp('left') == 0 ?`left: ${geometry.left};` : '',
|
||||
styleT = widgetInner.getProp('top') && widgetInner.getProp('top') != 'auto'|| widgetInner.getProp('top') == 0 ? `top: ${geometry.top};` : ''
|
||||
|
||||
if (styleL.length || styleT.length) widgetContainer.addClass('absolute-position')
|
||||
|
||||
// Hide label if false
|
||||
if (widgetInner.getOption('label')===false) {
|
||||
if (widgetInner.getProp('label')===false) {
|
||||
widgetContainer.addClass('nolabel')
|
||||
} else {
|
||||
// Generate label, iconify if starting with "icon:"
|
||||
var label = widgetInner.getOption('label') == 'auto'?
|
||||
widgetInner.getOption('id'):
|
||||
iconify(widgetInner.getOption('label'))
|
||||
var label = widgetInner.getProp('label') == 'auto'?
|
||||
widgetInner.getProp('id'):
|
||||
iconify(widgetInner.getProp('label'))
|
||||
|
||||
widgetContainer.find('> .label span').html(label)
|
||||
}
|
||||
|
||||
// parse scoped css
|
||||
var css = ';' + widgetInner.getOption('css'),
|
||||
var css = ';' + widgetInner.getProp('css'),
|
||||
scopedCss = ''
|
||||
|
||||
css = css.replace(/[;\}\s]*([^;\{]*\{[^\}]*\})/g, (m)=>{
|
||||
|
|
@ -232,11 +230,11 @@ module.exports.widgets = function(data,parent) {
|
|||
}
|
||||
|
||||
// Set custom css color variable
|
||||
if (widgetInner.getOption('color') && widgetInner.getOption('color')!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetInner.getOption('color'))
|
||||
if (widgetInner.getProp('color') && widgetInner.getProp('color')!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetInner.getProp('color'))
|
||||
|
||||
// set widget's initial state
|
||||
if (widgetInner.getOption('value') !== '' && widgetInner.setValue) {
|
||||
widgetInner.setValue(widgetInner.getOption('value'))
|
||||
if (widgetInner.getProp('value') !== '' && widgetInner.setValue) {
|
||||
widgetInner.setValue(widgetInner.getProp('value'))
|
||||
}
|
||||
|
||||
// Append the widget to its parent
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ var callbacks = {
|
|||
if (!containers.length) return
|
||||
for (var i=containers.length-1;i>=0;i--) {
|
||||
var container = containers[i].widget.parent(),
|
||||
data = containers[i].widgetData
|
||||
data = containers[i].props
|
||||
|
||||
for (var k in newdata) {
|
||||
data[k] = newdata[k]
|
||||
|
|
@ -38,7 +38,7 @@ var callbacks = {
|
|||
if (!containers.length) return
|
||||
for (var i=containers.length-1;i>=0;i--) {
|
||||
var container = containers[i].widget.parent(),
|
||||
data = containers[i].widgetData
|
||||
data = containers[i].props
|
||||
|
||||
$.extend(true,data,newdata)
|
||||
updateDom(container,data,true)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var widgets = {
|
||||
module.exports.widgets = {
|
||||
// sliders
|
||||
fader: require('./widgets/sliders/fader'),
|
||||
knob: require('./widgets/sliders/knob'),
|
||||
|
|
@ -52,23 +52,3 @@ module.exports.categories = {
|
|||
'Switchers':['switcher','crossfader'],
|
||||
'Maths':['formula']
|
||||
}
|
||||
|
||||
module.exports.widgetOptions = function(){
|
||||
var r = {}
|
||||
for (let i in widgets) {
|
||||
r[i] = widgets[i].options()
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
||||
module.exports.createWidget = function(){
|
||||
var r = {}
|
||||
for (let i in widgets) {
|
||||
let x = i,
|
||||
f = function(){
|
||||
return new widgets[x](...arguments)
|
||||
}
|
||||
r[i] = f
|
||||
}
|
||||
return r
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class Push extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'push',
|
||||
|
|
@ -33,7 +33,7 @@ module.exports = class Push extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="light"></div>
|
||||
|
|
@ -51,24 +51,24 @@ module.exports = class Push extends _widgets_base {
|
|||
this.fakeclick()
|
||||
})
|
||||
|
||||
this.value = this.getOption('off')
|
||||
this.value = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
updateValue(){
|
||||
|
||||
this.value = this[this.lastChanged] ?
|
||||
this.getOption('on') != null && this.getOption('on').value !== undefined ? this.getOption('on').value : this.getOption('on')
|
||||
this.getProp('on') != null && this.getProp('on').value !== undefined ? this.getProp('on').value : this.getProp('on')
|
||||
:
|
||||
this.getOption('off') != null && this.getOption('off').value !== undefined ? this.getOption('off').value : this.getOption('off')
|
||||
this.getProp('off') != null && this.getProp('off').value !== undefined ? this.getProp('off').value : this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
fakeclick(){
|
||||
|
||||
if (!this.active) this.setValuePrivate(this.getOption('on'),{send:true,sync:true})
|
||||
if (!this.active) this.setValuePrivate(this.getProp('on'),{send:true,sync:true})
|
||||
this.widget.on('dragend.push',()=>{
|
||||
this.setValuePrivate(this.getOption('off'),{send:true,sync:true})
|
||||
this.setValuePrivate(this.getProp('off'),{send:true,sync:true})
|
||||
this.widget.off('dragend.push')
|
||||
this.widget.on('draginit.push',()=>{
|
||||
this.widget.off('draginit.push')
|
||||
|
|
@ -81,20 +81,20 @@ module.exports = class Push extends _widgets_base {
|
|||
setValuePrivate(v,options={}) {
|
||||
|
||||
if (typeof v == 'object' && v !== null) v = v.value
|
||||
if (v===this.getOption('on') || (this.getOption('on') != null && v === this.getOption('on').value && v !== undefined)) {
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.widget.addClass('active')
|
||||
this.active = 1
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(v)
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
} else if (v===this.getOption('off') || (this.getOption('off') != null && v === this.getOption('off').value && v !== undefined)) {
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.widget.removeClass('active')
|
||||
this.active = 0
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(v, this.getOption('norelease'))
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.send) this.sendValue(v, this.getProp('norelease'))
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -106,18 +106,18 @@ module.exports = class Push extends _widgets_base {
|
|||
return
|
||||
}
|
||||
if (typeof v == 'object' && v !== null) v = v.value
|
||||
if (v===this.getOption('on') || (this.getOption('on') != null && v === this.getOption('on').value && v !== undefined)) {
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.widget.addClass('on')
|
||||
this.state = 1
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'),options:options})
|
||||
} else if (v===this.getOption('off') || (this.getOption('off') != null && v === this.getOption('off').value && v !== undefined)) {
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'),options:options})
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.widget.removeClass('on')
|
||||
this.state = 0
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'),options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'),options:options})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class Switch extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'switch',
|
||||
|
|
@ -34,7 +34,7 @@ module.exports = class Switch extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="switch"></div>
|
||||
|
|
@ -42,13 +42,13 @@ module.exports = class Switch extends _widgets_base {
|
|||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
if (this.getOption('horizontal')) this.widget.addClass('horizontal')
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
|
||||
this.values = []
|
||||
|
||||
for (var k in this.getOption('values')) {
|
||||
this.values.push(this.getOption('values')[k])
|
||||
$(`<div class="value">${iconify(parseFloat(k) != k ? k : this.getOption("values")[k])}</div>`).data({value:this.getOption('values')[k]}).appendTo(this.widget)
|
||||
for (var k in this.getProp('values')) {
|
||||
this.values.push(this.getProp('values')[k])
|
||||
$(`<div class="value">${iconify(parseFloat(k) != k ? k : this.getProp("values")[k])}</div>`).data({value:this.getProp('values')[k]}).appendTo(this.widget)
|
||||
}
|
||||
|
||||
this.value = undefined
|
||||
|
|
@ -78,11 +78,11 @@ module.exports = class Switch extends _widgets_base {
|
|||
this.widget.find('.on').removeClass('on')
|
||||
this.widget.find('.value').eq(i).addClass('on')
|
||||
if (options.send) this.sendValue(this.value)
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
} else {
|
||||
this.widget.find('.on').removeClass('on')
|
||||
this.value = undefined
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _widgets_base = require('../common/_widgets_base')
|
|||
|
||||
module.exports = class Toggle extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'toggle',
|
||||
|
|
@ -32,7 +32,7 @@ module.exports = class Toggle extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="light"></div>
|
||||
|
|
@ -50,13 +50,13 @@ module.exports = class Toggle extends _widgets_base {
|
|||
})
|
||||
|
||||
|
||||
this.value = this.getOption('off')
|
||||
this.value = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
fakeclick() {
|
||||
|
||||
var newVal = this.widget.state?this.getOption('off'):this.getOption('on')
|
||||
var newVal = this.widget.state?this.getProp('off'):this.getProp('on')
|
||||
this.setValue(newVal,{sync:true,send:true})
|
||||
this.widget.on('dragend.toggle',()=>{
|
||||
this.widget.off('dragend.toggle')
|
||||
|
|
@ -71,19 +71,19 @@ module.exports = class Toggle extends _widgets_base {
|
|||
|
||||
setValue(v,options={}) {
|
||||
|
||||
if (v===this.getOption('on') || (this.getOption('on') != null && v.value === this.getOption('on').value && v.value !== undefined)) {
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v.value === this.getProp('on').value && v.value !== undefined)) {
|
||||
this.widget.addClass('on')
|
||||
this.widget.state = 1
|
||||
this.value = this.getOption('on')
|
||||
this.value = this.getProp('on')
|
||||
if (options.send) this.sendValue()
|
||||
} else if (v===this.getOption('off') || (this.getOption('off') != null && v.value === this.getOption('off').value && v.value !== undefined)) {
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v.value === this.getProp('off').value && v.value !== undefined)) {
|
||||
this.widget.removeClass('on')
|
||||
this.widget.state = 0
|
||||
this.value = this.getOption('off')
|
||||
this.value = this.getProp('off')
|
||||
if (options.send) this.sendValue()
|
||||
}
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ var osc = require('../../osc'),
|
|||
|
||||
module.exports = class _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
throw 'Calling unimplemented static options() method'
|
||||
throw 'Calling unimplemented static defaults() method'
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -15,11 +15,11 @@ module.exports = class _widgets_base {
|
|||
return shortid.generate()
|
||||
}
|
||||
|
||||
constructor(widgetData, widgetContainer, widgetHtml) {
|
||||
constructor(props, widgetContainer, widgetHtml) {
|
||||
|
||||
this.container = widgetContainer
|
||||
this.widget = $(widgetHtml)
|
||||
this.widgetData = widgetData
|
||||
this.props = props
|
||||
this.hash = _widgets_base.createHash()
|
||||
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ module.exports = class _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
getOption(key) {
|
||||
getProp(key) {
|
||||
|
||||
var opt = this.widgetData[key]
|
||||
var opt = this.props[key]
|
||||
|
||||
if (typeof opt == 'string' && opt.indexOf('@{') != -1) {
|
||||
opt = opt.replace(/@\{([^\}]+)\}/g, (m)=>{
|
||||
|
|
@ -80,8 +80,8 @@ module.exports = class _widgets_base {
|
|||
|
||||
var widgets = widgetManager.getWidgetById(id)
|
||||
for (var i in widgets) {
|
||||
if (widgets[i].widgetData.hasOwnProperty(k)) {
|
||||
return widgets[i].widgetData[k]
|
||||
if (widgets[i].props.hasOwnProperty(k)) {
|
||||
return widgets[i].getProp(k)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var Panel = require('./panel'),
|
|||
|
||||
module.exports = class Modal extends Panel {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'modal',
|
||||
|
|
@ -37,7 +37,7 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData, container) {
|
||||
constructor(props, container) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class Panel extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'panel',
|
||||
|
|
@ -35,7 +35,7 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
|
||||
var widgetHtml = `
|
||||
|
|
@ -45,32 +45,32 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
if (!this.getOption('scroll')) this.widget.addClass('noscroll')
|
||||
if (this.getOption('tabs').length) this.widget.addClass('has-tabs')
|
||||
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
|
||||
|
||||
if (this.getOption('tabs').length) {
|
||||
parsetabs(this.getOption('tabs'),this.widget)
|
||||
if (this.getProp('tabs').length) {
|
||||
parsetabs(this.getProp('tabs'),this.widget)
|
||||
} else {
|
||||
parsewidgets(this.getOption('widgets'),this.widget)
|
||||
parsewidgets(this.getProp('widgets'),this.widget)
|
||||
}
|
||||
|
||||
this.children = this.widget.find('> .widget')
|
||||
|
||||
if (this.getOption('layout') != '') {
|
||||
if (this.getProp('layout') != '') {
|
||||
try {
|
||||
|
||||
var layout = this.getOption('layout').replace(/\$([0-9])+/g, (m)=>{
|
||||
return this.children[m.replace('$','')].abstract.this.getOption('id')
|
||||
var layout = this.getProp('layout').replace(/\$([0-9])+/g, (m)=>{
|
||||
return this.children[m.replace('$','')].abstract.this.getProp('id')
|
||||
})
|
||||
|
||||
this.layout = new autolayout.View({
|
||||
constraints: autolayout.VisualFormat.parse(layout.split('\\n').join('\n').split(' ').join(''), {extended: true}),
|
||||
spacing: this.getOption('spacing')
|
||||
spacing: this.getProp('spacing')
|
||||
});
|
||||
|
||||
this.widget.on('resize',(e, w, h)=>{
|
||||
|
|
@ -83,21 +83,21 @@ module.exports = class Panel extends _widgets_base {
|
|||
})
|
||||
|
||||
} catch(err) {
|
||||
throw `Visual Format Language error in ${this.getOption('id')}.layout: ${err.message} (line ${err.line})`
|
||||
throw `Visual Format Language error in ${this.getProp('id')}.layout: ${err.message} (line ${err.line})`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
applyLayout(){
|
||||
this.widget.find('> .widget').each((i,widget)=>{
|
||||
var id = widget.abstract.this.getOption('id')
|
||||
var id = widget.abstract.this.getProp('id')
|
||||
if (!this.layout.subViews[id]) return
|
||||
var $widget = $(widget).addClass('absolute-position').css({'min-height':'auto','min-width':'auto'})
|
||||
for (var prop of ['height', 'width', 'top', 'left']) {
|
||||
delete widget.abstract.widgetData[prop]
|
||||
delete widget.abstract.props[prop]
|
||||
$widget.css(prop, this.layout.subViews[id][prop] + 'px')
|
||||
}
|
||||
if ($widget.hasClass('editing')) editObject($widget,widget.abstract.widgetData,true)
|
||||
if ($widget.hasClass('editing')) editObject($widget,widget.abstract.props,true)
|
||||
$(window).resize()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _widgets_base = require('../common/_widgets_base')
|
|||
|
||||
module.exports = class Strip extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'strip',
|
||||
|
|
@ -26,7 +26,7 @@ module.exports = class Strip extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData, container) {
|
||||
constructor(props, container) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="strip"></div>
|
||||
|
|
@ -36,13 +36,13 @@ module.exports = class Strip extends _widgets_base {
|
|||
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
|
||||
parsewidgets(this.getOption('widgets'),this.widget)
|
||||
parsewidgets(this.getProp('widgets'),this.widget)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class Formula extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'formula',
|
||||
|
|
@ -38,7 +38,7 @@ module.exports = class Formula extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="formula">
|
||||
|
|
@ -48,10 +48,10 @@ module.exports = class Formula extends _widgets_base {
|
|||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
this.formula = String(this.getOption('formula'))
|
||||
this.condition = String(this.getOption('condition'))
|
||||
this.formula = String(this.getProp('formula'))
|
||||
this.condition = String(this.getProp('condition'))
|
||||
|
||||
this.split = typeof this.getOption('split') == 'object' && this.getOption('split').length ? this.getOption('split') : false
|
||||
this.split = typeof this.getProp('split') == 'object' && this.getProp('split').length ? this.getProp('split') : false
|
||||
|
||||
this.input = this.widget.find('.input').fakeInput({align:'center', disabled:true})
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ module.exports = class Formula extends _widgets_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.getOption('condition').length) {
|
||||
if (this.getProp('condition').length) {
|
||||
|
||||
try {
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ module.exports = class Formula extends _widgets_base {
|
|||
|
||||
this.showValue()
|
||||
|
||||
if (e.options.sync && this.conditionState) this.widget.trigger({type: 'sync',id: this.getOption('id'),widget: this.widget, linkId: this.getOption('linkId'), options: e.options})
|
||||
if (e.options.sync && this.conditionState) this.widget.trigger({type: 'sync',id: this.getProp('id'),widget: this.widget, linkId: this.getProp('linkId'), options: e.options})
|
||||
if (e.options.send && this.conditionState) this.sendValue()
|
||||
|
||||
} catch(err) {
|
||||
|
|
@ -163,8 +163,8 @@ module.exports = class Formula extends _widgets_base {
|
|||
showValue() {
|
||||
|
||||
this.input.val(
|
||||
(this.getOption('condition').length && !this.conditionState ? '* ' : '') +
|
||||
JSON.stringify(Formula.deepCopyWithPrecision(this.value, this.getOption('precision')))
|
||||
(this.getProp('condition').length && !this.conditionState ? '* ' : '') +
|
||||
JSON.stringify(Formula.deepCopyWithPrecision(this.value, this.getProp('precision')))
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _widgets_base = require('../common/_widgets_base')
|
|||
|
||||
module.exports = class _matrices_base extends _widgets_base {
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="matrix"></div>
|
||||
|
|
@ -13,13 +13,13 @@ module.exports = class _matrices_base extends _widgets_base {
|
|||
|
||||
this.value = []
|
||||
|
||||
this.start = parseInt(this.getOption('start'))
|
||||
this.start = parseInt(this.getProp('start'))
|
||||
|
||||
this.widget.on('sync',(e)=>{
|
||||
|
||||
if (e.id==this.getOption('id')) return
|
||||
if (e.id==this.getProp('id')) return
|
||||
this.value[e.widget.parent().index()] = e.widget.abstract.getValue()
|
||||
this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget,options:e.options})
|
||||
this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget,options:e.options})
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _matrices_base = require('./_matrices_base')
|
|||
|
||||
module.exports = class Keyboard extends _matrices_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'keyboard',
|
||||
|
|
@ -40,13 +40,13 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.keys = parseInt(this.getOption('keys'))
|
||||
this.keys = parseInt(this.getProp('keys'))
|
||||
|
||||
var strData = JSON.stringify(widgetData),
|
||||
var strData = JSON.stringify(props),
|
||||
pattern = 'wbwbwwbwbwbw',
|
||||
wCount = 0
|
||||
|
||||
|
|
@ -60,10 +60,10 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'push'
|
||||
data.id = this.getOption('id') + '/' + i
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = false
|
||||
data.address = this.getOption('split') ? this.getOption('address') + '/' + i : this.getOption('address')
|
||||
data.preArgs = this.getOption('split') ? this.getOption('preArgs') : [].concat(this.getOption('preArgs'), i)
|
||||
data.address = this.getProp('split') ? this.getProp('address') + '/' + i : this.getProp('address')
|
||||
data.preArgs = this.getProp('split') ? this.getProp('preArgs') : [].concat(this.getProp('preArgs'), i)
|
||||
data.css = ''
|
||||
|
||||
var element = parsewidgets([data],this.widget)
|
||||
|
|
@ -77,7 +77,7 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
this.value[i-this.start] = this.getOption('off')
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
})
|
||||
|
||||
if (this.getOption('traversing')) this.widget.enableTraversingGestures()
|
||||
if (this.getProp('traversing')) this.widget.enableTraversingGestures()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _matrices_base = require('./_matrices_base')
|
|||
|
||||
module.exports = class Multifader extends _matrices_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'multifader',
|
||||
|
|
@ -49,17 +49,17 @@ module.exports = class Multifader extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.strips = parseInt(this.getOption('strips'))
|
||||
this.strips = parseInt(this.getProp('strips'))
|
||||
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.addClass('horizontal')
|
||||
}
|
||||
|
||||
var strData = JSON.stringify(widgetData)
|
||||
var strData = JSON.stringify(props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
|
@ -70,24 +70,24 @@ module.exports = class Multifader extends _matrices_base {
|
|||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'fader'
|
||||
data.id = this.getOption('id') + '/' + i
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.address = this.getOption('split') ? this.getOption('address') + '/' + i : this.getOption('address')
|
||||
data.preArgs = this.getOption('split') ? this.getOption('preArgs') : [].concat(this.getOption('preArgs'), i)
|
||||
data.color = typeof this.getOption('color') == 'object' ? '' + this.getOption('color')[i % this.getOption('color').length] : this.getOption('color')
|
||||
data.address = this.getProp('split') ? this.getProp('address') + '/' + i : this.getProp('address')
|
||||
data.preArgs = this.getProp('split') ? this.getProp('preArgs') : [].concat(this.getProp('preArgs'), i)
|
||||
data.color = typeof this.getProp('color') == 'object' ? '' + this.getProp('color')[i % this.getProp('color').length] : this.getProp('color')
|
||||
data.css = ''
|
||||
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].style.setProperty(this.getOption('horizontal')?'height':'width', 100/this.strips + '%')
|
||||
element[0].style.setProperty(this.getProp('horizontal')?'height':'width', 100/this.strips + '%')
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
if (this.getOption('traversing')) element.find('canvas').off('drag')
|
||||
if (this.getProp('traversing')) element.find('canvas').off('drag')
|
||||
|
||||
this.value[i-this.start] = this.getOption('range').min
|
||||
this.value[i-this.start] = this.getProp('range').min
|
||||
|
||||
}
|
||||
|
||||
if (this.getOption('traversing')) this.widget.enableTraversingGestures()
|
||||
if (this.getProp('traversing')) this.widget.enableTraversingGestures()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _matrices_base = require('./_matrices_base')
|
|||
|
||||
module.exports = class Multipush extends _matrices_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'multipush',
|
||||
|
|
@ -42,37 +42,37 @@ module.exports = class Multipush extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
var strData = JSON.stringify(widgetData)
|
||||
var strData = JSON.stringify(props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
||||
for (var i = this.start; i < this.getOption('matrix')[0] * this.getOption('matrix')[1] + this.start; i++) {
|
||||
for (var i = this.start; i < this.getProp('matrix')[0] * this.getProp('matrix')[1] + this.start; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'push'
|
||||
data.id = this.getOption('id') + '/' + i
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.address = this.getOption('split') ? this.getOption('address') + '/' + i : this.getOption('address')
|
||||
data.preArgs = this.getOption('split') ? this.getOption('preArgs') : [].concat(this.getOption('preArgs'), i)
|
||||
data.color = typeof this.getOption('color') == 'object' ? '' + this.getOption('color')[i % this.getOption('color').length] : this.getOption('color')
|
||||
data.address = this.getProp('split') ? this.getProp('address') + '/' + i : this.getProp('address')
|
||||
data.preArgs = this.getProp('split') ? this.getProp('preArgs') : [].concat(this.getProp('preArgs'), i)
|
||||
data.color = typeof this.getProp('color') == 'object' ? '' + this.getProp('color')[i % this.getProp('color').length] : this.getProp('color')
|
||||
data.css = ''
|
||||
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].style.setProperty('width', 100/this.getOption('matrix')[0] + '%')
|
||||
element[0].style.setProperty('width', 100/this.getProp('matrix')[0] + '%')
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
this.value[i-this.start] = this.getOption('off')
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
if (this.getOption('traversing')) this.widget.enableTraversingGestures()
|
||||
if (this.getProp('traversing')) this.widget.enableTraversingGestures()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _matrices_base = require('./_matrices_base')
|
|||
|
||||
module.exports = class Multitoggle extends _matrices_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'multitoggle',
|
||||
|
|
@ -41,37 +41,37 @@ module.exports = class Multitoggle extends _matrices_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
var strData = JSON.stringify(widgetData)
|
||||
var strData = JSON.stringify(props)
|
||||
|
||||
var parsers = require('../../parser'),
|
||||
parsewidgets = parsers.widgets
|
||||
|
||||
for (var i = this.start; i < this.getOption('matrix')[0] * this.getOption('matrix')[1] + this.start; i++) {
|
||||
for (var i = this.start; i < this.getProp('matrix')[0] * this.getProp('matrix')[1] + this.start; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'toggle'
|
||||
data.id = this.getOption('id') + '/' + i
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = i
|
||||
data.address = this.getOption('split') ? this.getOption('address') + '/' + i : this.getOption('address')
|
||||
data.preArgs = this.getOption('split') ? this.getOption('preArgs') : [].concat(this.getOption('preArgs'), i)
|
||||
data.color = typeof this.getOption('color') == 'object' ? '' + this.getOption('color')[i % this.getOption('color').length] : this.getOption('color')
|
||||
data.address = this.getProp('split') ? this.getProp('address') + '/' + i : this.getProp('address')
|
||||
data.preArgs = this.getProp('split') ? this.getProp('preArgs') : [].concat(this.getProp('preArgs'), i)
|
||||
data.color = typeof this.getProp('color') == 'object' ? '' + this.getProp('color')[i % this.getProp('color').length] : this.getProp('color')
|
||||
data.css = ''
|
||||
|
||||
var element = parsewidgets([data],this.widget)
|
||||
element[0].style.setProperty('width', 100/this.getOption('matrix')[0] + '%')
|
||||
element[0].style.setProperty('width', 100/this.getProp('matrix')[0] + '%')
|
||||
element[0].classList.add('not-editable')
|
||||
|
||||
this.value[i-this.start] = this.getOption('off')
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
if (this.getOption('traversing')) this.widget.enableTraversingGestures()
|
||||
if (this.getProp('traversing')) this.widget.enableTraversingGestures()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,17 @@ module.exports = (self, element)=>{
|
|||
self._touched += 1
|
||||
if (self._touched == 1)
|
||||
self.sendValue({
|
||||
address:self.widgetData.touchAddress,
|
||||
address:self.getProp('touchAddress'),
|
||||
v:1,
|
||||
split:false
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
element.on('dragend', (e, data, traversing)=>{
|
||||
if (self._touched == 1) {
|
||||
self._touched = 0
|
||||
self.sendValue({
|
||||
address:self.widgetData.touchAddress,
|
||||
address:self.getProp('touchAddress'),
|
||||
v:0,
|
||||
split:false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ var Fader = require('../sliders/fader')
|
|||
|
||||
module.exports = class _fake_fader extends Fader {
|
||||
|
||||
constructor(widgetData, cancelDraw) {
|
||||
constructor(props, cancelDraw) {
|
||||
|
||||
super(widgetData, false)
|
||||
super(props, false)
|
||||
|
||||
if (cancelDraw) this.noDraw = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module.exports = class _pads_base extends _canvas_base {
|
|||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
|
||||
if (this.getOption('touchAddress') && this.getOption('touchAddress').length)
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length)
|
||||
osctouchstate(this, this.wrapper)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var _pads_base = require('./_pads_base'),
|
|||
|
||||
module.exports = class MultiXy extends _pads_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'xy',
|
||||
|
|
@ -45,25 +45,25 @@ module.exports = class MultiXy extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.npoints = typeof this.getOption('points') == 'object' ? this.getOption('points').length : this.getOption('points')
|
||||
this.labels = typeof this.getOption('points') == 'object'
|
||||
this.pointSize = parseInt(this.getOption('pointSize'))
|
||||
this.npoints = typeof this.getProp('points') == 'object' ? this.getProp('points').length : this.getProp('points')
|
||||
this.labels = typeof this.getProp('points') == 'object'
|
||||
this.pointSize = parseInt(this.getProp('pointSize'))
|
||||
this.widget[0].style.setProperty("--point-size",this.pointSize + 'rem')
|
||||
|
||||
this.split = this.getOption('split')?
|
||||
typeof this.getOption('split') == 'object' && this.getOption('split').length == 2 * this.npoints ?
|
||||
this.getOption('split')
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 * this.npoints ?
|
||||
this.getProp('split')
|
||||
: (()=>{
|
||||
var s={},
|
||||
t
|
||||
for (var i=0; i<this.npoints * 2;i=i+2) {
|
||||
t = this.labels ? this.getOption('points')[i/2] : i/2
|
||||
s[i]=this.getOption('address') + '/' + t + '/x'
|
||||
s[i+1]=this.getOption('address') + '/' + t + '/y'
|
||||
t = this.labels ? this.getProp('points')[i/2] : i/2
|
||||
s[i]=this.getProp('address') + '/' + t + '/x'
|
||||
s[i+1]=this.getProp('address') + '/' + t + '/y'
|
||||
};
|
||||
return s
|
||||
})()
|
||||
|
|
@ -77,14 +77,14 @@ module.exports = class MultiXy extends _pads_base {
|
|||
|
||||
for (var i=this.npoints-1;i>=0;i--) {
|
||||
this.pads[i] = new Xy({
|
||||
snap:this.getOption('snap'),
|
||||
spring:this.getOption('spring'),
|
||||
value:this.getOption('value').length == this.getOption('points') * 2 ? [this.getOption('value')[i*2], this.getOption('value')[i*2 + 1]] : '',
|
||||
rangeX:this.getOption('rangeX'),
|
||||
rangeY:this.getOption('rangeY'),
|
||||
precision:this.getOption('precision'),
|
||||
logScaleX:this.getOption('logScaleX'),
|
||||
logScaleY:this.getOption('logScaleY')
|
||||
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]] : '',
|
||||
rangeX:this.getProp('rangeX'),
|
||||
rangeY:this.getProp('rangeY'),
|
||||
precision:this.getProp('precision'),
|
||||
logScaleX:this.getProp('logScaleX'),
|
||||
logScaleY:this.getProp('logScaleY')
|
||||
}, false)
|
||||
this.pads[i].sendValue = ()=>{}
|
||||
this.pads[i].draw = ()=>{}
|
||||
|
|
@ -185,7 +185,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
for (var i=0;i<this.npoints;i++) {
|
||||
var x = clip(this.pads[i].faders.x.percent,[0,100]) / 100 * (this.width - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE,
|
||||
y = (100 - clip(this.pads[i].faders.y.percent,[0,100])) / 100 * (this.height - (this.pointSize * 2 + 2) * PXSCALE) + (this.pointSize + 1) * PXSCALE,
|
||||
t = this.labels ? this.getOption('points')[i] : i
|
||||
t = this.labels ? this.getProp('points')[i] : i
|
||||
|
||||
this.ctx.strokeStyle = this.colors.custom
|
||||
this.ctx.fillStyle = this.colors.custom
|
||||
|
|
@ -243,7 +243,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
}
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var _pads_base = require('./_pads_base'),
|
|||
|
||||
module.exports = class Rgb extends _pads_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'rgb',
|
||||
|
|
@ -38,14 +38,14 @@ module.exports = class Rgb extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.split = this.getOption('split')?
|
||||
typeof this.getOption('split') == 'object' && this.getOption('split').length == 3 ?
|
||||
this.getOption('split')
|
||||
: [this.getOption('address') + '/r', this.getOption('address') + '/g', this.getOption('address') + '/b']
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 3 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/r', this.getProp('address') + '/g', this.getProp('address') + '/b']
|
||||
: false
|
||||
|
||||
this.widget.append(`
|
||||
|
|
@ -70,7 +70,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
compact:false,
|
||||
noPip:true,
|
||||
horizontal:true,
|
||||
snap:this.getOption('snap'),
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:360},
|
||||
precision:2
|
||||
}, false),
|
||||
|
|
@ -78,7 +78,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
id:'s',
|
||||
compact:true,
|
||||
horizontal:true,
|
||||
snap:this.getOption('snap'),
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
precision:2
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
id:'b',
|
||||
compact:true,
|
||||
horizontal:false,
|
||||
snap:this.getOption('snap'),
|
||||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:100},
|
||||
precision:2
|
||||
}, true)
|
||||
|
|
@ -180,7 +180,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
this.value = v
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
this.update({dragged:options.dragged, nohue:options.nohue || (v[0]==v[1]&&v[1]==v[2])})
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
}
|
||||
|
||||
for (let i in this.inputs) [
|
||||
this.inputs[i].val(this.value[i].toFixed(this.getOption('precision')))
|
||||
this.inputs[i].val(this.value[i].toFixed(this.getProp('precision')))
|
||||
]
|
||||
|
||||
this.draw()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var _pads_base = require('./_pads_base'),
|
|||
|
||||
module.exports = class Xy extends _pads_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'xy',
|
||||
|
|
@ -43,14 +43,14 @@ module.exports = class Xy extends _pads_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.split = this.getOption('split')?
|
||||
typeof this.getOption('split') == 'object' && this.getOption('split').length == 2 ?
|
||||
this.getOption('split')
|
||||
: [this.getOption('address') + '/x', this.getOption('address') + '/y']
|
||||
this.split = this.getProp('split')?
|
||||
typeof this.getProp('split') == 'object' && this.getProp('split').length == 2 ?
|
||||
this.getProp('split')
|
||||
: [this.getProp('address') + '/x', this.getProp('address') + '/y']
|
||||
: false
|
||||
|
||||
this.widget.append(`
|
||||
|
|
@ -71,12 +71,12 @@ module.exports = class Xy extends _pads_base {
|
|||
horizontal:true,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getOption('value').length==2?this.getOption('value')[0]:'',
|
||||
snap:this.getOption('snap'),
|
||||
range:this.getOption('rangeX'),
|
||||
value:this.getProp('value').length==2?this.getProp('value')[0]:'',
|
||||
snap:this.getProp('snap'),
|
||||
range:this.getProp('rangeX'),
|
||||
origin:'auto',
|
||||
precision:this.getOption('precision'),
|
||||
logScale:this.getOption('logScaleX')
|
||||
precision:this.getProp('precision'),
|
||||
logScale:this.getProp('logScaleX')
|
||||
}, true),
|
||||
y: new Fader({
|
||||
id:1,
|
||||
|
|
@ -84,12 +84,12 @@ module.exports = class Xy extends _pads_base {
|
|||
horizontal:false,
|
||||
height:'100%',
|
||||
width:'100%',
|
||||
value:this.getOption('value').length==2?this.getOption('value')[1]:'',
|
||||
snap:this.getOption('snap'),
|
||||
range:this.getOption('rangeY'),
|
||||
value:this.getProp('value').length==2?this.getProp('value')[1]:'',
|
||||
snap:this.getProp('snap'),
|
||||
range:this.getProp('rangeY'),
|
||||
origin:'auto',
|
||||
precision:this.getOption('precision'),
|
||||
logScale:this.getOption('logScaleY')
|
||||
precision:this.getProp('precision'),
|
||||
logScale:this.getProp('logScaleY')
|
||||
|
||||
}, true)
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ module.exports = class Xy extends _pads_base {
|
|||
this.dragHandle()
|
||||
})
|
||||
|
||||
if (this.getOption('spring')) {
|
||||
if (this.getProp('spring')) {
|
||||
this.wrapper.on('dragend', ()=>{
|
||||
this.setValue([this.faders.x.springValue,this.faders.y.springValue],{sync:true,send:true,fromLocal:true})
|
||||
})
|
||||
|
|
@ -164,7 +164,7 @@ module.exports = class Xy extends _pads_base {
|
|||
]
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
this.draw()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class _plots_base extends _canvas_base {
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="plot">
|
||||
|
|
@ -16,8 +16,8 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
this.data = []
|
||||
this.linkedWidgets = []
|
||||
this.rangeX = this.getOption('rangeX') || {min:0,max:1}
|
||||
this.rangeY = this.getOption('rangeY') || {min:0,max:1}
|
||||
this.rangeX = this.getProp('rangeX') || {min:0,max:1}
|
||||
this.rangeY = this.getProp('rangeY') || {min:0,max:1}
|
||||
this.pips = {
|
||||
x : {
|
||||
min: Math.abs(this.rangeX.min)>=1000?this.rangeY.min/1000+'k':this.rangeX.min,
|
||||
|
|
@ -75,9 +75,9 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
|
||||
|
||||
if (this.getOption('origin') !== false) {
|
||||
if (this.getProp('origin') !== false) {
|
||||
|
||||
var origin = mapToScale(this.getOption('origin') || this.rangeY.min,[this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getOption('logScaleY'),true)
|
||||
var origin = mapToScale(this.getProp('origin') || this.rangeY.min,[this.rangeY.min,this.rangeY.max],[this.height,0],0,this.getProp('logScaleY'),true)
|
||||
|
||||
this.ctx.globalAlpha = 0.1
|
||||
this.ctx.fillStyle = this.colors.custom
|
||||
|
|
@ -132,13 +132,13 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
|
||||
var newpoint = this.data[i].length?
|
||||
[
|
||||
mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[0,this.width],0,this.getOption('logScaleX'),true),
|
||||
mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getOption('logScaleY'),true),
|
||||
mapToScale(this.data[i][0],[this.rangeX.min,this.rangeX.max],[0,this.width],0,this.getProp('logScaleX'),true),
|
||||
mapToScale(this.data[i][1],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true),
|
||||
]
|
||||
:
|
||||
[
|
||||
mapToScale(i,[0,this.data.length-1],[0,this.width],0,this.getOption('logScaleX'),true),
|
||||
mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getOption('logScaleY'),true),
|
||||
mapToScale(i,[0,this.data.length-1],[0,this.width],0,this.getProp('logScaleX'),true),
|
||||
mapToScale(this.data[i],[this.rangeY.min,this.rangeY.max],[this.height-PXSCALE,PXSCALE],0,this.getProp('logScaleY'),true),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var {mapToScale, clip} = require('../utils'),
|
|||
|
||||
module.exports = class Eq extends _plots_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'eq',
|
||||
|
|
@ -38,7 +38,7 @@ module.exports = class Eq extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ module.exports = class Eq extends _plots_base {
|
|||
this.pips.x.min = '20'
|
||||
this.pips.x.max = '22k'
|
||||
|
||||
this.resolution = clip(this.getOption('resolution'),[64,1024])
|
||||
this.resolution = clip(this.getProp('resolution'),[64,1024])
|
||||
|
||||
for (let i in this.getOption('filters')) {
|
||||
for (let i in this.getProp('filters')) {
|
||||
|
||||
for (let j in this.getOption('filters')[i]) {
|
||||
if (typeof this.getOption('filters')[i][j]=='string' && !(j=='type' && this.getOption('filters')[i][j].match(/peak|notch|highpass|highshelf|lowpass|lowshelf/))) {
|
||||
this.linkedWidgets.push(this.getOption('filters')[i][j])
|
||||
for (let j in this.getProp('filters')[i]) {
|
||||
if (typeof this.getProp('filters')[i][j]=='string' && !(j=='type' && this.getProp('filters')[i][j].match(/peak|notch|highpass|highshelf|lowpass|lowshelf/))) {
|
||||
this.linkedWidgets.push(this.getProp('filters')[i][j])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,8 +66,8 @@ module.exports = class Eq extends _plots_base {
|
|||
eqResponse = []
|
||||
|
||||
|
||||
for (let i in this.getOption('filters')) {
|
||||
var filter = this.getOption('filters')[i]
|
||||
for (let i in this.getProp('filters')) {
|
||||
var filter = this.getProp('filters')[i]
|
||||
|
||||
filters[i] = {}
|
||||
|
||||
|
|
@ -95,9 +95,9 @@ module.exports = class Eq extends _plots_base {
|
|||
if (!filters[i].type) filters[i].type = "peak"
|
||||
|
||||
if (!filters[i].on) {
|
||||
filterResponse = _biquad_response({type:"peak",freq:1,gain:0,q:1},!this.getOption('logScaleX'), this.resolution)
|
||||
filterResponse = _biquad_response({type:"peak",freq:1,gain:0,q:1},!this.getProp('logScaleX'), this.resolution)
|
||||
} else {
|
||||
filterResponse = _biquad_response(filters[i],!this.getOption('logScaleX'), this.resolution)
|
||||
filterResponse = _biquad_response(filters[i],!this.getProp('logScaleX'), this.resolution)
|
||||
}
|
||||
|
||||
for (var k in filterResponse) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class Led extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'led',
|
||||
|
|
@ -36,7 +36,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="led">
|
||||
|
|
@ -48,9 +48,9 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
this.led = this.widget.find('span')
|
||||
|
||||
if (this.getOption('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
|
||||
this.setValue(this.getOption('range').min)
|
||||
this.setValue(this.getProp('range').min)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.getOption('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
var widget = widgetManager.getWidgetById(e.id),
|
||||
value
|
||||
for (var i=widget.length-1; i>=0; i--) {
|
||||
|
|
@ -76,7 +76,7 @@ module.exports = class Led extends _widgets_base {
|
|||
setValue(v) {
|
||||
|
||||
if (typeof v != 'number') return
|
||||
this.led.css('opacity',mapToScale(v,[this.getOption('range').min,this.getOption('range').max],[0,1],false,this.getOption('logScale'),true))
|
||||
this.led.css('opacity',mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var Fader = require('../sliders/fader'),
|
|||
|
||||
module.exports = class Meter extends Fader {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'fader',
|
||||
|
|
@ -39,9 +39,9 @@ module.exports = class Meter extends Fader {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
widgetData.compact = true
|
||||
props.compact = true
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ module.exports = class Meter extends Fader {
|
|||
|
||||
this.canvas.off('draginit drag')
|
||||
|
||||
if (this.getOption('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ module.exports = class Meter extends Fader {
|
|||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.getOption('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
var widget = widgetManager.getWidgetById(e.id),
|
||||
value
|
||||
for (var i=widget.length-1; i>=0; i--) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class Plot extends _plots_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'plot',
|
||||
|
|
@ -38,20 +38,20 @@ module.exports = class Plot extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
if (typeof this.getOption('points')=='string') {
|
||||
if (typeof this.getProp('points')=='string') {
|
||||
|
||||
this.linkedWidgets.push(this.getOption('points'))
|
||||
this.linkedWidgets.push(this.getProp('points'))
|
||||
|
||||
} else if (typeof this.getOption('points')=='object') {
|
||||
} else if (typeof this.getProp('points')=='object') {
|
||||
|
||||
for (let i in this.getOption('points')) {
|
||||
for (let j in this.getOption('points')[i]) {
|
||||
if (typeof this.getOption('points')[i][j] == 'string') {
|
||||
this.linkedWidgets.push(this.getOption('points')[i][j])
|
||||
for (let i in this.getProp('points')) {
|
||||
for (let j in this.getProp('points')[i]) {
|
||||
if (typeof this.getProp('points')[i][j] == 'string') {
|
||||
this.linkedWidgets.push(this.getProp('points')[i][j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ module.exports = class Plot extends _plots_base {
|
|||
updateData() {
|
||||
|
||||
var data = [],
|
||||
points = this.getOption('points'),
|
||||
points = this.getProp('points'),
|
||||
widget = widgetManager.getWidgetById(points)
|
||||
|
||||
if (typeof points=='string' && widget.length) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ var {mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class Led extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'rgbled',
|
||||
|
|
@ -34,7 +34,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="led">
|
||||
|
|
@ -46,7 +46,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
this.led = this.widget.find('span')
|
||||
|
||||
if (this.getOption('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
|
||||
this.setValue([0,0,0])
|
||||
|
||||
|
|
@ -60,11 +60,11 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.getOption('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
|
||||
var widget = widgetManager.getWidgetById(e.id),
|
||||
value
|
||||
|
||||
|
||||
for (var i=widget.length-1; i>=0; i--) {
|
||||
if (widget[i].getValue) {
|
||||
this.setValue(widget[i].getValue())
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {iconify} = require('../../utils'),
|
|||
|
||||
module.exports = class Text extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'text',
|
||||
|
|
@ -34,7 +34,7 @@ module.exports = class Text extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="text">
|
||||
|
|
@ -43,17 +43,17 @@ module.exports = class Text extends _widgets_base {
|
|||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
if (this.getOption('vertical')) this.widget.addClass('vertical')
|
||||
if (this.getProp('vertical')) this.widget.addClass('vertical')
|
||||
|
||||
this.defaultValue = this.getOption('label')===false?
|
||||
this.getOption('id'):
|
||||
this.getOption('label')=='auto'?
|
||||
this.getOption('id'):
|
||||
this.getOption('label')
|
||||
this.defaultValue = this.getProp('label')===false?
|
||||
this.getProp('id'):
|
||||
this.getProp('label')=='auto'?
|
||||
this.getProp('id'):
|
||||
this.getProp('label')
|
||||
|
||||
this.value = this.defaultValue
|
||||
|
||||
if (this.getOption('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
if (this.getProp('widgetId').length) $('body').on(`sync.${this.hash}`,this.syncHandle.bind(this))
|
||||
|
||||
this.setValue(this.value)
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ module.exports = class Text extends _widgets_base {
|
|||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.getOption('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
var widget = widgetManager.getWidgetById(e.id),
|
||||
value
|
||||
for (var i=widget.length-1; i>=0; i--) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {mapToScale, clip} = require('../utils'),
|
|||
|
||||
module.exports = class Visualizer extends _plots_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'visualizer',
|
||||
|
|
@ -37,16 +37,16 @@ module.exports = class Visualizer extends _plots_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this.pips.y.min = Math.abs(this.getOption('range').min) >= 1000? this.getOption('range').min/1000+'k' : this.getOption('range').min
|
||||
this.pips.y.max = Math.abs(this.getOption('range').max) >= 1000? this.getOption('range').max/1000+'k' : this.getOption('range').max
|
||||
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
|
||||
this.pips.x = false
|
||||
this.length = Math.round(clip(60 * this.getOption('duration'), [8, 4096]))
|
||||
this.length = Math.round(clip(60 * this.getProp('duration'), [8, 4096]))
|
||||
this.data = new Array(this.length)
|
||||
this.value = this.getOption('range').min
|
||||
this.value = this.getProp('range').min
|
||||
this.cancel = false
|
||||
this.loop = false
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
|
||||
syncHandle(e) {
|
||||
|
||||
if (this.getOption('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
|
||||
this.startLoop()
|
||||
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
clearInterval(this.loop)
|
||||
this.loop = false
|
||||
this.cancel = false
|
||||
},1000*this.getOption('duration'))
|
||||
},1000*this.getProp('duration'))
|
||||
|
||||
if (this.loop) return
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
this.updateData()
|
||||
this.draw()
|
||||
|
||||
},1000*this.getOption('duration') / this.length)
|
||||
},1000*this.getProp('duration') / this.length)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -89,13 +89,13 @@ module.exports = class Visualizer extends _plots_base {
|
|||
for (var i=0;i<this.length;i++) {
|
||||
var newpoint = [
|
||||
mapToScale(i,[0,this.length-1],[0,this.width],1),
|
||||
mapToScale(this.data[i],[this.getOption('range').min,this.getOption('range').max],[this.height-PXSCALE,PXSCALE],1,this.getOption('logScale'),true),
|
||||
mapToScale(this.data[i],[this.getProp('range').min,this.getProp('range').max],[this.height-PXSCALE,PXSCALE],1,this.getProp('logScale'),true),
|
||||
]
|
||||
if (first) {
|
||||
this.ctx.moveTo(newpoint[0],newpoint[1])
|
||||
first = false
|
||||
} else {
|
||||
if (this.getOption('logScale')) {
|
||||
if (this.getProp('logScale')) {
|
||||
this.ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
|
||||
} else {
|
||||
this.ctx.lineTo(newpoint[0],newpoint[1])
|
||||
|
|
@ -110,7 +110,7 @@ module.exports = class Visualizer extends _plots_base {
|
|||
|
||||
updateData() {
|
||||
|
||||
var id = this.getOption('widgetId'),
|
||||
var id = this.getProp('widgetId'),
|
||||
widget = widgetManager.getWidgetById(id)
|
||||
|
||||
if (typeof id == 'string' && widget.length) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {clip, mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class _sliders_base extends _canvas_base {
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="slider">
|
||||
|
|
@ -22,20 +22,20 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
this.unit = this.getOption('unit') ? ' ' + this.getOption('unit') : ''
|
||||
this.unit = this.getProp('unit') ? ' ' + this.getProp('unit') : ''
|
||||
|
||||
|
||||
this.rangeKeys = []
|
||||
this.rangeVals = []
|
||||
this.rangeLabels = []
|
||||
|
||||
for (var k in this.getOption('range')) {
|
||||
for (var k in this.getProp('range')) {
|
||||
var key = k=='min'?0:k=='max'?100:parseInt(k),
|
||||
val = typeof this.getOption('range')[k] == 'object'?
|
||||
this.getOption('range')[k][Object.keys(this.getOption('range')[k])[0]]:
|
||||
this.getOption('range')[k],
|
||||
label = typeof this.getOption('range')[k] == 'object'?
|
||||
Object.keys(this.getOption('range')[k])[0]:
|
||||
val = typeof this.getProp('range')[k] == 'object'?
|
||||
this.getProp('range')[k][Object.keys(this.getProp('range')[k])[0]]:
|
||||
this.getProp('range')[k],
|
||||
label = typeof this.getProp('range')[k] == 'object'?
|
||||
Object.keys(this.getProp('range')[k])[0]:
|
||||
val
|
||||
|
||||
this.rangeKeys.push(key)
|
||||
|
|
@ -45,10 +45,10 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
this.rangeValsMax = Math.max(...this.rangeVals),
|
||||
this.rangeValsMin = Math.min(...this.rangeVals)
|
||||
|
||||
this.originValue = this.getOption('origin')=='auto'?
|
||||
this.originValue = this.getProp('origin')=='auto'?
|
||||
this.rangeValsMin:
|
||||
clip(this.getOption('origin'), [this.rangeValsMin,this.rangeValsMax])
|
||||
this.springValue = this.getOption('value') != '' ? this.getOption('value') : this.originValue
|
||||
clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
|
||||
this.springValue = this.getProp('value') != '' ? this.getProp('value') : this.originValue
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
|
|
@ -58,7 +58,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
}
|
||||
}.bind(this))
|
||||
|
||||
if (this.getOption('touchAddress') && this.getOption('touchAddress').length)
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length)
|
||||
osctouchstate(this, this.canvas)
|
||||
|
||||
this.widget.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
|
|
@ -110,7 +110,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
var direction = e.originalEvent.wheelDelta / Math.abs(e.originalEvent.wheelDelta),
|
||||
increment = e.ctrlKey?0.25:1
|
||||
|
||||
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.getOption('precision') + 1)) * direction, [0,100])
|
||||
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.getProp('precision') + 1)) * direction, [0,100])
|
||||
|
||||
this.setValue(this.percentToValue(this.percent), {sync:true,send:true,dragged:true})
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
dragendHandle(e, data, traversing) {
|
||||
|
||||
if (this.getOption('spring'))
|
||||
if (this.getProp('spring'))
|
||||
this.setValue(this.springValue,{sync:true,send:true,fromLocal:true})
|
||||
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
var h = clip(percent,[0,100])
|
||||
for (var i=0;i<this.rangeKeys.length-1;i++) {
|
||||
if (h <= this.rangeKeys[i+1] && h >= this.rangeKeys[i]) {
|
||||
return mapToScale(h,[this.rangeKeys[i],this.rangeKeys[i+1]],[this.rangeVals[i],this.rangeVals[i+1]],false,this.getOption('logScale'))
|
||||
return mapToScale(h,[this.rangeKeys[i],this.rangeKeys[i+1]],[this.rangeVals[i],this.rangeVals[i+1]],false,this.getProp('logScale'))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
for (var i=0;i<this.rangeVals.length-1;i++) {
|
||||
if (value <= this.rangeVals[i+1] && value >= this.rangeVals[i]) {
|
||||
return mapToScale(value,[this.rangeVals[i],this.rangeVals[i+1]],[this.rangeKeys[i],this.rangeKeys[i+1]],false,this.getOption('logScale'),true)
|
||||
return mapToScale(value,[this.rangeVals[i],this.rangeVals[i+1]],[this.rangeKeys[i],this.rangeKeys[i+1]],false,this.getProp('logScale'),true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
var value = clip(v,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
if ((options.dragged || options.fromLocal) && this.value.toFixed(this.getOption('precision')) == value.toFixed(this.getOption('precision'))) options.send = false
|
||||
if ((options.dragged || options.fromLocal) && this.value.toFixed(this.getProp('precision')) == value.toFixed(this.getProp('precision'))) options.send = false
|
||||
|
||||
this.value = value
|
||||
|
||||
|
|
@ -182,14 +182,14 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
this.showValue()
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send) this.sendValue(v)
|
||||
|
||||
}
|
||||
|
||||
showValue() {
|
||||
|
||||
this.input.val(this.value.toFixed(this.getOption('precision')) + this.unit)
|
||||
this.input.val(this.value.toFixed(this.getProp('precision')) + this.unit)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ var EncoderKnob = class extends Knob {
|
|||
this.lastOffsetX = data.offsetX
|
||||
this.lastOffsetY = data.offsetY
|
||||
|
||||
if (!(traversing || this.getOption('snap'))) return
|
||||
if (!(traversing || this.getProp('snap'))) return
|
||||
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(data.offsetX, data.offsetY))
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ var DisplayKnob = class extends Knob {
|
|||
draw(){
|
||||
super.draw()
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
this.ctx.beginPath()
|
||||
this.ctx.fillStyle = this.colors.raised
|
||||
this.ctx.strokeStyle = this.colors.raised
|
||||
|
|
@ -42,7 +42,7 @@ var DisplayKnob = class extends Knob {
|
|||
|
||||
module.exports = class Encoder extends _widgets_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'encoder',
|
||||
|
|
@ -79,7 +79,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments, `
|
||||
<div class="encoder">
|
||||
|
|
@ -89,7 +89,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
`)
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.ticks = Math.abs(parseInt(this.getOption('ticks')))
|
||||
this.ticks = Math.abs(parseInt(this.getProp('ticks')))
|
||||
|
||||
this.knob = new EncoderKnob({
|
||||
label:false,
|
||||
|
|
@ -105,7 +105,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
label:false,
|
||||
angle:360,
|
||||
range:{min:0,max:this.ticks},
|
||||
compact:this.getOption('compact'),
|
||||
compact:this.getProp('compact'),
|
||||
origin:this.ticks/2,
|
||||
noPip:true,
|
||||
}, true)
|
||||
|
|
@ -126,14 +126,14 @@ module.exports = class Encoder extends _widgets_base {
|
|||
var direction
|
||||
|
||||
if (value < this.previousValue)
|
||||
direction = this.getOption('back')
|
||||
direction = this.getProp('back')
|
||||
if (value > this.previousValue)
|
||||
direction = this.getOption('forth')
|
||||
direction = this.getProp('forth')
|
||||
|
||||
if ((this.ticks * .75 < value && value < this.ticks) && (0 < this.previousValue && this.previousValue < this.ticks / 4))
|
||||
direction = this.getOption('back')
|
||||
direction = this.getProp('back')
|
||||
if ((0 < value && value < this.ticks / 4) && (this.ticks * .75 < this.previousValue && this.previousValue < this.ticks))
|
||||
direction = this.getOption('forth')
|
||||
direction = this.getProp('forth')
|
||||
|
||||
|
||||
if (direction && (Math.round(value) != Math.round(this.previousValue))) this.setValue(direction, {sync:true, send:true, dragged: e.options.dragged, draginit: e.options.draginit})
|
||||
|
|
@ -142,24 +142,24 @@ module.exports = class Encoder extends _widgets_base {
|
|||
})
|
||||
|
||||
this.wrapper.on('draginit', (e)=>{
|
||||
if (this.getOption('touchAddress') && this.getOption('touchAddress').length
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length
|
||||
&& e.target == this.wrapper[0])
|
||||
this.sendValue({
|
||||
address:this.getOption('touchAddress'),
|
||||
address:this.getProp('touchAddress'),
|
||||
v:1
|
||||
})
|
||||
})
|
||||
|
||||
this.wrapper.on('dragend', (e)=>{
|
||||
if (this.getOption('release') !== '' && this.value !== this.getOption('release')) {
|
||||
if (this.getProp('release') !== '' && this.value !== this.getProp('release')) {
|
||||
this.knob.setValue(this.ticks/2)
|
||||
this.display.setValue(this.ticks/2)
|
||||
this.setValue(this.getOption('release'), {sync:true, send:true, dragged:false})
|
||||
this.setValue(this.getProp('release'), {sync:true, send:true, dragged:false})
|
||||
}
|
||||
if (this.getOption('touchAddress') && this.getOption('touchAddress').length
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length
|
||||
&& e.target == this.wrapper[0])
|
||||
this.sendValue({
|
||||
address:this.getOption('touchAddress'),
|
||||
address:this.getProp('touchAddress'),
|
||||
v:0
|
||||
})
|
||||
})
|
||||
|
|
@ -168,24 +168,24 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
setValue(v,options={}) {
|
||||
|
||||
if (this.getOption('snap') || (!this.getOption('snap') && !options.draginit)) {
|
||||
if (this.getProp('snap') || (!this.getProp('snap') && !options.draginit)) {
|
||||
|
||||
var match = true
|
||||
|
||||
if (v === this.getOption('back')) {
|
||||
this.value = this.getOption('back')
|
||||
} else if (v === this.getOption('forth')) {
|
||||
this.value = this.getOption('forth')
|
||||
} else if (v === this.getOption('release') && this.getOption('release') !== '') {
|
||||
this.value = this.getOption('release')
|
||||
if (v === this.getProp('back')) {
|
||||
this.value = this.getProp('back')
|
||||
} else if (v === this.getProp('forth')) {
|
||||
this.value = this.getProp('forth')
|
||||
} else if (v === this.getProp('release') && this.getProp('release') !== '') {
|
||||
this.value = this.getProp('release')
|
||||
} else {
|
||||
match = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (options.sync && match) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.send && match && !(!this.getOption('snap') && options.draginit)) this.sendValue()
|
||||
if (options.sync && match) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send && match && !(!this.getProp('snap') && options.draginit)) this.sendValue()
|
||||
|
||||
if (options.dragged || options.draginit) this.updateDisplay(options.draginit)
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
updateDisplay(init){
|
||||
|
||||
if (this.getOption('snap')) {
|
||||
if (this.getProp('snap')) {
|
||||
this.display.setValue(this.knob.value)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {clip, mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class Fader extends _sliders_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'fader',
|
||||
|
|
@ -48,7 +48,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData, widgetContainer) {
|
||||
constructor(props, widgetContainer) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
|
@ -56,27 +56,27 @@ module.exports = class Fader extends _sliders_base {
|
|||
this.margin = 15
|
||||
|
||||
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.add(widgetContainer).addClass('horizontal')
|
||||
if (this.getOption('width') == 'auto' && this.getOption('left') != 'auto') {
|
||||
if (this.getProp('width') == 'auto' && this.getProp('left') != 'auto') {
|
||||
this.container.css({'width':'auto', 'right':'0'})
|
||||
}
|
||||
} else {
|
||||
if (this.getOption('height') == 'auto' && this.getOption('top') != 'auto') {
|
||||
if (this.getProp('height') == 'auto' && this.getProp('top') != 'auto') {
|
||||
this.container.css({'height':'auto', 'bottom':'0'})
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
if (this.getOption('alignRight') && !this.getOption('horizontal')) {
|
||||
if (this.getProp('alignRight') && !this.getProp('horizontal')) {
|
||||
this.widget.addClass('align-right')
|
||||
}
|
||||
|
||||
if (!this.getOption('noPip') && !this.getOption('compact')) {
|
||||
if (!this.getProp('noPip') && !this.getProp('compact')) {
|
||||
|
||||
this.widget.addClass('has-pips')
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
for (var i=0;i<=100;i++) {
|
||||
if (pipTexts[i]==undefined) continue
|
||||
|
||||
var pos = this.getOption('horizontal')?'left':'bottom';
|
||||
var pos = this.getProp('horizontal')?'left':'bottom';
|
||||
|
||||
var piptext = `<span>${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]}</span>`
|
||||
|
||||
|
|
@ -103,18 +103,18 @@ module.exports = class Fader extends _sliders_base {
|
|||
}
|
||||
|
||||
|
||||
if (this.getOption('meter')) {
|
||||
if (this.getProp('meter')) {
|
||||
var parsewidgets = require('../../parser').widgets
|
||||
var data = {
|
||||
type:'meter',
|
||||
id: this.getOption('id') + '/meter',
|
||||
id: this.getProp('id') + '/meter',
|
||||
label:false,
|
||||
horizontal:this.getOption('horizontal'),
|
||||
range:this.getOption('range'),
|
||||
logScale:this.getOption('logScale'),
|
||||
address:this.getOption('meterAddress') || this.getOption('address') + '/meter',
|
||||
preArgs:this.getOption('preArgs'),
|
||||
color:this.getOption('color')
|
||||
horizontal:this.getProp('horizontal'),
|
||||
range:this.getProp('range'),
|
||||
logScale:this.getProp('logScale'),
|
||||
address:this.getProp('meterAddress') || this.getProp('address') + '/meter',
|
||||
preArgs:this.getProp('preArgs'),
|
||||
color:this.getProp('color')
|
||||
}
|
||||
var element = parsewidgets([data],this.widget.find('.wrapper'))
|
||||
element[0].classList.add('not-editable')
|
||||
|
|
@ -129,9 +129,9 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
this.percent = clip(this.percent,[0,100])
|
||||
|
||||
if (!(traversing || this.getOption('snap'))) return
|
||||
if (!(traversing || this.getProp('snap'))) return
|
||||
|
||||
this.percent = this.getOption('horizontal')?
|
||||
this.percent = this.getProp('horizontal')?
|
||||
(data.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100:
|
||||
(this.height - data.offsetY - this.margin * PXSCALE) / (this.height - (this.margin * PXSCALE * 2)) * 100
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
super.dragHandle(...arguments)
|
||||
|
||||
this.percent = this.getOption('horizontal')?
|
||||
this.percent = this.getProp('horizontal')?
|
||||
this.percent + ( data.speedX/(this.width - this.margin * PXSCALE * 2)) * 100:
|
||||
this.percent + (-data.speedY/(this.height - this.margin * PXSCALE * 2)) * 100
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
percentToCoord(percent) {
|
||||
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
return clip(percent / 100,[0,1]) * (this.width - 2 * PXSCALE * this.margin)
|
||||
} else {
|
||||
return (this.height - this.margin * PXSCALE) - clip(percent / 100, [0,1]) * (this.height - 2 * PXSCALE * this.margin)
|
||||
|
|
@ -166,8 +166,8 @@ module.exports = class Fader extends _sliders_base {
|
|||
resizeHandle(){
|
||||
super.resizeHandle(...arguments)
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getProp('compact')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
this.canvas[0].setAttribute('height', 1)
|
||||
} else {
|
||||
this.canvas[0].setAttribute('width', 1)
|
||||
|
|
@ -183,14 +183,14 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
var d = Math.round(this.percentToCoord(this.percent)),
|
||||
o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
|
||||
m = Math.round(this.getOption('horizontal') ? this.height / 2 : this.width / 2)
|
||||
m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2)
|
||||
|
||||
this.clear()
|
||||
|
||||
if (this.getOption('horizontal')) {
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
if (!this.getOption('noPip')) {
|
||||
if (!this.getProp('noPip')) {
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
this.ctx.globalAlpha = 1
|
||||
|
||||
|
|
@ -256,9 +256,9 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
} else {
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
if (!this.getOption('noPip')) {
|
||||
if (!this.getProp('noPip')) {
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
this.ctx.globalAlpha = 0.75
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var {clip, mapToScale} = require('../utils'),
|
|||
|
||||
module.exports = class Knob extends _sliders_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'knob',
|
||||
|
|
@ -44,7 +44,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
this.margin = 5
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
if (!this.getOption('noPip')) {
|
||||
if (!this.getProp('noPip')) {
|
||||
this.wrapper.append(`
|
||||
<div class="pips">
|
||||
<div>${this.rangeLabels[0]}</div><div>${this.rangeLabels[this.rangeLabels.length-1]}</div>
|
||||
|
|
@ -69,7 +69,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
this.lastOffsetY = 0
|
||||
this.minDimension = 0
|
||||
|
||||
this.maxAngle = this.getOption('angle')
|
||||
this.maxAngle = this.getProp('angle')
|
||||
|
||||
// calculate lost height factor
|
||||
var a = this.maxAngle <= 180 ?
|
||||
|
|
@ -85,7 +85,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
this.lastOffsetX = data.offsetX
|
||||
this.lastOffsetY = data.offsetY
|
||||
|
||||
if (!(traversing || this.getOption('snap'))) return
|
||||
if (!(traversing || this.getProp('snap'))) return
|
||||
|
||||
this.percent = this.angleToPercent(this.coordsToAngle(data.offsetX, data.offsetY))
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
dragHandle(e, data, traversing) {
|
||||
|
||||
if (!(traversing || this.getOption('snap'))) {
|
||||
if (!(traversing || this.getProp('snap'))) {
|
||||
|
||||
this.percent = -100*data.speedY/this.height + this.percent
|
||||
|
||||
|
|
@ -144,10 +144,10 @@ module.exports = class Knob extends _sliders_base {
|
|||
this.minDimension = Math.min(this.width, this.height)
|
||||
this.gaugeWidth = this.minDimension / 8
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
this.canvas[0].style.top = this.input[0].style.marginTop = (this.minDimension) * this.lostHeightFactor - (this.getOption('label') === false ? 0 : this.gaugeWidth / 4) + 'px'
|
||||
if (this.getProp('compact')) {
|
||||
this.canvas[0].style.top = this.input[0].style.marginTop = (this.minDimension) * this.lostHeightFactor - (this.getProp('label') === false ? 0 : this.gaugeWidth / 4) + 'px'
|
||||
} else {
|
||||
this.canvas[0].style.top = Math.min((this.minDimension) * this.lostHeightFactor - (this.getOption('label') === false ? 0 : this.margin * PXSCALE / 2), this.input.outerHeight() * .5) + 'px'
|
||||
this.canvas[0].style.top = Math.min((this.minDimension) * this.lostHeightFactor - (this.getProp('label') === false ? 0 : this.margin * PXSCALE / 2), this.input.outerHeight() * .5) + 'px'
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
this.ctx.clearRect(0,0,this.width,this.height)
|
||||
|
||||
if (this.getOption('compact')) {
|
||||
if (this.getProp('compact')) {
|
||||
|
||||
this.ctx.lineWidth = this.gaugeWidth
|
||||
this.ctx.globalAlpha = 0.3
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ var _widgets_base = require('../common/_widgets_base'),
|
|||
|
||||
module.exports = class _switchers_base extends _widgets_base {
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
super(...arguments)
|
||||
|
||||
this._isSwitcher = true
|
||||
this.value = {_selected:false}
|
||||
this.linkedWidgets = typeof widgetData.linkedWidgets == 'object' ? widgetData.linkedWidgets : [widgetData.linkedWidgets]
|
||||
this.linkedWidgets = typeof this.getProp('linkedWidgets') == 'object' ? this.getProp('linkedWidgets') : [this.getProp('linkedWidgets')]
|
||||
|
||||
for (var i in widgetData.values) {
|
||||
for (var i in this.getProp('values')) {
|
||||
|
||||
this.value[widgetData.values[i]] = {}
|
||||
this.value[this.getProp('values')[i]] = {}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ module.exports = class _switchers_base extends _widgets_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getOption('id'),widget:this.widget, linkId:this.getOption('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'sync',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send) this.sendValue()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ var Switcher = require('./switcher'),
|
|||
|
||||
module.exports = class Crossfader extends Switcher {
|
||||
|
||||
static options(){
|
||||
static defaults(){
|
||||
|
||||
var o = super.options()
|
||||
var o = super.defaults()
|
||||
o.type = 'crossfader'
|
||||
delete o.values
|
||||
|
||||
|
|
@ -14,15 +14,15 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
widgetData.values = widgetData.horizontal ? ['A', 'B'] : ['B', 'A']
|
||||
props.values = props.horizontal ? ['A', 'B'] : ['B', 'A']
|
||||
|
||||
super(...arguments)
|
||||
|
||||
|
||||
var o = Fader.options()
|
||||
o.horizontal = this.getOption('horizontal')
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var _switchers_base = require('./_switchers_base'),
|
|||
|
||||
module.exports = class Switcher extends _switchers_base {
|
||||
|
||||
static options() {
|
||||
static defaults() {
|
||||
|
||||
return {
|
||||
type:'switcher',
|
||||
|
|
@ -36,7 +36,7 @@ module.exports = class Switcher extends _switchers_base {
|
|||
|
||||
}
|
||||
|
||||
constructor(widgetData) {
|
||||
constructor(props) {
|
||||
|
||||
var widgetHtml = `
|
||||
<div class="switcher switch-container"></div>
|
||||
|
|
@ -44,13 +44,13 @@ module.exports = class Switcher extends _switchers_base {
|
|||
|
||||
super(...arguments, widgetHtml)
|
||||
|
||||
if (this.getOption('horizontal')) this.widget.addClass('horizontal')
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
|
||||
this.switch = new Switch({
|
||||
label:false,
|
||||
values:this.getOption('values'),
|
||||
value: this.getOption('value'),
|
||||
horizontal:this.getOption('horizontal')
|
||||
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