From da13ef9852d6f5072b47118e3f3822318d173716 Mon Sep 17 00:00:00 2001 From: bordun Date: Thu, 12 Sep 2019 17:10:47 +0200 Subject: [PATCH] sliders/pads: add sensitivity property (#548) --- CHANGELOG.md | 1 + src/client/app/widgets/pads/multixy.js | 4 +++- src/client/app/widgets/pads/xy.js | 3 +++ src/client/app/widgets/sliders/fader.js | 7 ++++--- src/client/app/widgets/sliders/knob.js | 5 +++-- src/client/app/widgets/sliders/range.js | 3 +++ src/client/app/widgets/sliders/slider.js | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63cbead0..16500c0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - frames: allow loading local html files without requiring a web server to serve them - text: escape html tags characters (`<` & `>`) - input: added `asYouType` property + - sliders/pads: added `sensitivity` property ## 0.47.4 diff --git a/src/client/app/widgets/pads/multixy.js b/src/client/app/widgets/pads/multixy.js index 14249c3a..938daac0 100644 --- a/src/client/app/widgets/pads/multixy.js +++ b/src/client/app/widgets/pads/multixy.js @@ -39,7 +39,8 @@ module.exports = class MultiXy extends Pad { rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'} + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, }, [], { @@ -84,6 +85,7 @@ module.exports = class MultiXy extends Pad { logScaleY:this.getProp('logScaleY'), pointSize: this.getProp('pointSize'), pips: this.getProp('pips') && i == this.npoints-1, + sensitivity: this.getProp('sensitivity'), input:false }, parent: this}) this.pads[i].sendValue = ()=>{} diff --git a/src/client/app/widgets/pads/xy.js b/src/client/app/widgets/pads/xy.js index 8cc1acc4..51ec1da5 100644 --- a/src/client/app/widgets/pads/xy.js +++ b/src/client/app/widgets/pads/xy.js @@ -36,6 +36,7 @@ module.exports = class Xy extends Pad { '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: `/ `' ]}, + sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, }, [], { @@ -76,6 +77,7 @@ module.exports = class Xy extends Pad { origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScaleX'), + sensitivity: this.getProp('sensitivity'), input:false }, cancelDraw: true, parent: this}), y: new Fader({props:{ @@ -92,6 +94,7 @@ module.exports = class Xy extends Pad { origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScaleY'), + sensitivity: this.getProp('sensitivity'), input:false }, cancelDraw: true, parent: this}), } diff --git a/src/client/app/widgets/sliders/fader.js b/src/client/app/widgets/sliders/fader.js index f5c18a2c..fbed1640 100644 --- a/src/client/app/widgets/sliders/fader.js +++ b/src/client/app/widgets/sliders/fader.js @@ -34,13 +34,14 @@ module.exports = class Fader extends Slider { '- values can be `number` or `object` if a custom label is needed', 'Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`)' ]}, + logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the fader\'s sensitivity when `snap` is `false` '}, steps: {type: 'string|number|array', value: '', help: [ 'Restricts the widget\'s value:', '- `auto`: use values defined in `range`', '- `number`: define a number of evenly spaced steps', '- `array`: use arbitrary values', ]}, - logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'}, unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'}, @@ -159,8 +160,8 @@ module.exports = class Fader extends Slider { super.dragHandle(...arguments) this.percent = this.getProp('horizontal')? - this.percent + ( e.movementX/(this.width - this.margin * PXSCALE * 2)) * 100 / e.inertia: - this.percent + (-e.movementY/(this.height - this.margin * PXSCALE * 2)) * 100 / e.inertia + this.percent + ( e.movementX/(this.width - this.margin * PXSCALE * 2)) * 100 / e.inertia * this.getProp('sensitivity'): + this.percent + (-e.movementY/(this.height - this.margin * PXSCALE * 2)) * 100 / e.inertia * this.getProp('sensitivity') this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true}) diff --git a/src/client/app/widgets/sliders/knob.js b/src/client/app/widgets/sliders/knob.js index f9fc5c17..5007a071 100644 --- a/src/client/app/widgets/sliders/knob.js +++ b/src/client/app/widgets/sliders/knob.js @@ -26,13 +26,14 @@ module.exports = class Knob extends Slider { '- values can be `number` or `object` if a custom label is needed', 'Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`)' ]}, + logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the knob\'s sensitivity when `snap` is `false` '}, steps: {type: 'string|number|array', value: '', help: [ 'Restricts the widget\'s value:', '- `auto`: use values defined in `range`', '- `number`: define a number of evenly spaced steps', '- `array`: use arbitrary values', ]}, - logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'}, unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the knob\'s gauge'}, @@ -92,7 +93,7 @@ module.exports = class Knob extends Slider { if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) { // vertical - this.percent = -100 * (e.movementY / e.inertia) / this.height + this.percent + this.percent = -100 * (e.movementY / e.inertia * this.getProp('sensitivity')) / this.height + this.percent } else { //snap diff --git a/src/client/app/widgets/sliders/range.js b/src/client/app/widgets/sliders/range.js index 74c4d846..95834e06 100644 --- a/src/client/app/widgets/sliders/range.js +++ b/src/client/app/widgets/sliders/range.js @@ -195,6 +195,7 @@ class Range extends Widget { snap: {type: 'boolean', value: false, help: 'See fader\'s `snap`'}, spring: {type: 'boolean', value: false, help: 'See fader\'s `spring`'}, logScale: {type: 'boolean', value: false, help: 'See fader\'s `logScale`'}, + sensitivity: {type: 'number', value: 1, help: 'See fader\'s `sensitivity`'}, }, [], { @@ -242,6 +243,7 @@ class Range extends Widget { origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScale'), + sensitivity:this.getProp('sensitivity'), input:false }, cancelDraw: true, parent: this}), new RangeFader({props:{ @@ -259,6 +261,7 @@ class Range extends Widget { origin:'auto', precision:this.getProp('precision'), logScale:this.getProp('logScale'), + sensitivity:this.getProp('sensitivity'), input:false }, cancelDraw: false, parent: this}) ] diff --git a/src/client/app/widgets/sliders/slider.js b/src/client/app/widgets/sliders/slider.js index 5e004fe7..595d9d74 100644 --- a/src/client/app/widgets/sliders/slider.js +++ b/src/client/app/widgets/sliders/slider.js @@ -303,6 +303,7 @@ Slider.dynamicProps = Slider.prototype.constructor.dynamicProps .concat([ 'steps', 'spring', + 'sensitivity', 'default', ])