fader/knob/xy/range/multixy: remove touchAddress property; expose touch state in script property (touchAddress usages will be converted automatically)

This commit is contained in:
bordun 2020-10-01 15:07:04 +02:00
parent a492904708
commit e95816c806
11 changed files with 70 additions and 69 deletions

View file

@ -213,7 +213,11 @@ class Widget extends EventEmitter {
this.on('change', (e)=>{
if (e.widget === this && this.mounted && !e.options.fromEdit) this.script.setValue(this.value, {...e.options, id: e.options.id || e.id})
})
if (String(this.getProp('script')).includes('touch')) {
this.on('touch', (e)=>{
this.script.setValue(this.value, {id: this.getProp('id'), touch: e.touch, sync: false, send: true})
})
}
}
this.container = html`

View file

@ -1,18 +1,13 @@
module.exports = (self, options)=>{
var sendTouchState = self.getProp('touchAddress') && self.getProp('touchAddress').length
self.touched = 0
self.setValueTouchedQueue = undefined
self.on('draginit',(e)=>{
self.touched += 1
if (self.touched == 1 && sendTouchState)
self.sendValue({
address:self.getProp('touchAddress'),
v:1,
split:false
})
if (self.touched == 1) {
self.trigger('touch', {stopPropagation :0, touch: 1})
}
}, options)
self.on('dragend', (e)=>{
@ -24,13 +19,7 @@ module.exports = (self, options)=>{
self.setValueTouchedQueue = undefined
}
if (sendTouchState) {
self.sendValue({
address:self.getProp('touchAddress'),
v:0,
split:false
})
}
self.trigger('touch', {stopPropagation :true, touch: 0})
} else if (self.touched > 1){
self.touched -= 1
@ -38,12 +27,8 @@ module.exports = (self, options)=>{
}, options)
self.onRemove = ()=>{
if (sendTouchState && self.touched > 0) {
self.sendValue({
address:self.getProp('touchAddress'),
v:0,
split:false
})
if (self.touched > 0) {
self.trigger('touch', {stopPropagation :true, touch: 0})
}
self.__proto__.onRemove.call(self)
}

View file

@ -43,11 +43,7 @@ module.exports = class MultiXy extends Pad {
logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'},
sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '},
}, [], {
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'},
})
}, [], {})
}
@ -120,12 +116,7 @@ module.exports = class MultiXy extends Pad {
e.stopPropagation = true
if (this.getProp('touchAddress')) {
this.sendValue({
address: this.getProp('touchAddress'),
v: [parseInt(id), 1],
})
}
this.trigger('touch', {stopPropagation: true, touch: [parseInt(id), 1]})
this.pads[id].trigger('draginit', e)
@ -151,12 +142,7 @@ module.exports = class MultiXy extends Pad {
this.pads[i].trigger('dragend', e)
if (this.getProp('touchAddress')) {
this.sendValue({
address: this.getProp('touchAddress'),
v: [parseInt(this.touchMap[e.pointerId]), 0],
})
}
this.trigger('touch', {stopPropagation: true, touch: [parseInt(this.touchMap[e.pointerId]), 0]})
delete this.touchMap[e.pointerId]

View file

@ -37,11 +37,7 @@ module.exports = class Xy extends Pad {
]},
sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '},
}, [], {
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`)'},
})
}, [], {})
}

View file

@ -56,7 +56,8 @@ class Script extends Widget {
this.compile({
id: '',
value: 0
value: 0,
touch: undefined
})
} else if (this.getProp('event') === 'keyboard' && this.getProp('keyBinding')) {
@ -128,6 +129,7 @@ class Script extends Widget {
this.run({
value: v,
id: options.id,
touch: options.touch
})
scriptVm.setValueOptions(options)

View file

@ -49,11 +49,7 @@ class Fader extends Slider {
]},
origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'},
}, [], {
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'},
}, Fader)
}, [], {}, Fader)
}

View file

@ -48,11 +48,7 @@ module.exports = class Knob extends Slider {
]},
origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the knob\'s gauge'},
}, [], {
touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'},
}, Knob)
}, [], {}, Knob)
}

View file

@ -141,12 +141,7 @@ class Range extends Fader {
if (!i) return
if (this.getProp('touchAddress')) {
this.sendValue({
address: this.getProp('touchAddress'),
v: [parseInt(i), 1],
})
}
this.trigger('touch', {stopPropagation: true, touch: [parseInt(i), 1]})
if (e.shiftKey) {
this.faders[0].trigger('drag', e)
@ -167,12 +162,7 @@ class Range extends Fader {
this.faders[i].trigger('dragend', e)
if (this.getProp('touchAddress')) {
this.sendValue({
address: this.getProp('touchAddress'),
v: [parseInt(i), 0],
})
}
this.trigger('touch', {stopPropagation: true, touch: [parseInt(i), 0]})
delete this.touchMap[e.pointerId]