dynamic props: handle undeclared children case for color prop update
This commit is contained in:
parent
453f2b6f0f
commit
ba8d2b476d
10 changed files with 141 additions and 4 deletions
|
|
@ -357,6 +357,9 @@ class Widget extends EventEmitter {
|
|||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (!this.constructor.dynamicProps.includes(propName)) return true
|
||||
|
||||
|
||||
switch(propName) {
|
||||
|
||||
case 'value':
|
||||
|
|
@ -380,9 +383,6 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
return this.constructor.dynamicProps.indexOf(propName) == -1
|
||||
|
||||
|
||||
}
|
||||
|
||||
reCreateWidget(){
|
||||
|
|
|
|||
|
|
@ -174,6 +174,20 @@ module.exports = class Formula extends Widget {
|
|||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
if (this.input) this.input.onPropChanged('color')
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.input.onRemove()
|
||||
super.onRemove()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
var Widget = require('../common/widget'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
{enableTraversingGestures} = require('../../events/drag')
|
||||
|
||||
|
||||
module.exports = class Matrix extends Widget {
|
||||
class Matrix extends Widget {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
|
|
@ -26,3 +27,9 @@ module.exports = class Matrix extends Widget {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Matrix.dynamicProps = Matrix.prototype.constructor.dynamicProps.filter(
|
||||
item => !['address', 'preArgs', 'color'].includes(item)
|
||||
)
|
||||
|
||||
module.exports = Matrix
|
||||
|
|
|
|||
|
|
@ -250,6 +250,22 @@ module.exports = class MultiXy extends Pad {
|
|||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of this.pads) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
for (var i in this.pads) {
|
||||
this.pads[i].onRemove()
|
||||
|
|
|
|||
|
|
@ -190,6 +190,23 @@ module.exports = class Rgb extends Pad {
|
|||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of [this.hue, this.pad]) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
if (this.input) this.input.onPropChanged('color')
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.hue.onRemove()
|
||||
this.pad.onRemove()
|
||||
|
|
|
|||
|
|
@ -266,6 +266,24 @@ module.exports = class Xy extends Pad {
|
|||
|
||||
}
|
||||
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of [this.faders.x, this.faders.y]) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
if (this.input) this.input.onPropChanged('color')
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.faders.x.onRemove()
|
||||
this.faders.y.onRemove()
|
||||
|
|
|
|||
|
|
@ -259,6 +259,23 @@ module.exports = class Encoder extends Widget {
|
|||
|
||||
}
|
||||
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of [this.knob, this.display]) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.knob.onRemove()
|
||||
this.display.onRemove()
|
||||
|
|
|
|||
|
|
@ -440,6 +440,23 @@ module.exports = class Range extends Widget {
|
|||
|
||||
}
|
||||
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of this.faders) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.faders[0].onRemove()
|
||||
this.faders[1].onRemove()
|
||||
|
|
|
|||
|
|
@ -223,6 +223,21 @@ class Slider extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
if (this.input) this.input.onPropChanged('color')
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
if (this.input) this.input.onRemove()
|
||||
super.onRemove()
|
||||
|
|
|
|||
|
|
@ -121,6 +121,22 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options) {
|
||||
|
||||
if (super.onPropChanged(propName, options)) return true
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'color':
|
||||
for (var w of [this.fader]) {
|
||||
w.onPropChanged('color')
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.fader.onRemove()
|
||||
super.onRemove()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue