From 79e0eee7210e48d57c56799aaecef80f1fe6052b Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 12 Mar 2025 09:42:50 +0100 Subject: [PATCH] sliders/pads: `doubleTap` can now be `"script"`, in which case `onTouch` will be called with `event.type` set to `doubleTap` --- CHANGELOG.md | 1 + src/client/widgets/pads/multixy.js | 18 ++++++++++++++---- src/client/widgets/pads/xy.js | 17 ++++++++++++++--- src/client/widgets/sliders/fader.js | 7 ++++--- src/client/widgets/sliders/knob.js | 5 +++-- src/client/widgets/sliders/slider.js | 11 +++++++++++ 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 808c23f5..457ee28b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - xy/multixy: add `auto` choice to to `axisLock` (locks on the first moved axis) - file: `extension` can now be an array of strings - plot/eq: smoother curves + - sliders/pads: `doubleTap` can now be `"stript"`, in which case `onTouch` will be called with `event.type` set to `doubleTap` ## 1.27.5 diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 624706f2..3bb56312 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -44,9 +44,10 @@ module.exports = class MultiXy extends Pad { 'Restrict movements to one of the axes only.', 'When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.' ]}, - doubleTap: {type: 'boolean|string', value: false, help: [ - 'Set to `true` to make the fader reset to its default value when receiving a double tap.', - 'Can also be an osc address, which case the widget will just send an osc message: `/ `' + doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [ + 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.', + 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).', + 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. ' ]}, sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, } @@ -195,7 +196,16 @@ module.exports = class MultiXy extends Pad { } var pad = this.pads[id] - pad.setValue([pad.faders.x.getSpringValue(), pad.faders.y.getSpringValue()], { sync: true, send: true, spring: true, doubleTap: true }) + + if (this.getProp('doubleTap') == 'script') { + this.scripts.onTouch.run({ + event: {type: 'doubleTap', handle: id}, + value: this.value + }, {sync: true, send: true}) + } else { + pad.setValue([pad.faders.x.getSpringValue(), pad.faders.y.getSpringValue()], { sync: true, send: true, spring: true, doubleTap: true }) + } + }, { element: this.widget}) } diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index bc0a6888..2aab17b7 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -36,9 +36,10 @@ module.exports = class Xy extends Pad { 'Restrict movements to one of the axes only unless `Shift` is held.', 'When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.' ]}, - doubleTap: {type: 'boolean|string', value: false, help: [ - 'Set to `true` to make the fader reset to its default value when receiving a double tap.', - 'Can also be an osc address, which case the widget will just send an osc message: `/ `' + doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [ + 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.', + 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).', + 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. ' ]}, sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, } @@ -143,6 +144,16 @@ module.exports = class Xy extends Pad { this.sendValue({v:null, address: this.getProp('doubleTap')}) }, {element: this.widget}) + } else if (this.getProp('doubleTap') == 'script') { + + doubleTap(this, ()=>{ + this.scripts.onTouch.run({ + event: {type: 'doubleTap'}, + value: this.value + }, {sync: true, send: true}) + }, {element: this.widget}) + + } else { doubleTap(this, ()=>{ diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 054fa438..3d837937 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -38,9 +38,10 @@ class Fader extends Slider { 'This setting is ignored in containers with `traversing` set to `true`' ]}, spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, - doubleTap: {type: 'boolean', value: false, help: [ - 'Set to `true` to make the fader reset to its `default` value when receiving a double tap.', - 'Can also be an osc address, in which case the widget will just send an osc message (`/ `)' + doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [ + 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.', + 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).', + 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. ' ]}, range: {type: 'object', value: {min:0,max:1}, help: [ 'Defines the breakpoints of the fader\'s scale:', diff --git a/src/client/widgets/sliders/knob.js b/src/client/widgets/sliders/knob.js index 6d9276d3..1a89901e 100644 --- a/src/client/widgets/sliders/knob.js +++ b/src/client/widgets/sliders/knob.js @@ -31,9 +31,10 @@ class Knob extends Slider { '- `snap-alt`: alternative snap mode that allow jumping from `range.min` to `range.max`. `sensitivity` is ignored with this mode.', ]}, spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, - doubleTap: {type: 'boolean', value: false, help: [ + doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [ 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.', - 'Can also be an osc address, in which case the widget will just send an osc message (`/ `)' + 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).', + 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. ' ]}, range: {type: 'object', value: {min:0,max:1}, help: [ 'Defines the breakpoints of the fader\'s scale:', diff --git a/src/client/widgets/sliders/slider.js b/src/client/widgets/sliders/slider.js index a3acd39b..289372a2 100644 --- a/src/client/widgets/sliders/slider.js +++ b/src/client/widgets/sliders/slider.js @@ -61,6 +61,17 @@ class Slider extends Canvas { this.sendValue({v:null, address: this.getProp('doubleTap')}) }, {element: this.widget}) + } + if (this.getProp('doubleTap') == 'script') { + + doubleTap(this, ()=>{ + this.scripts.onTouch.run({ + event: {type: 'doubleTap'}, + value: this.value + }, {sync: true, send: true}) + }, {element: this.widget}) + + } else { doubleTap(this, ()=>{