sliders/pads: add sensitivity property (#548)

This commit is contained in:
bordun 2019-09-12 17:10:47 +02:00
parent 0523c19b2a
commit da13ef9852
7 changed files with 18 additions and 6 deletions

View file

@ -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

View file

@ -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 = ()=>{}

View file

@ -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: `/<doubleTap> <preArgs>`'
]},
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}),
}

View file

@ -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})

View file

@ -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

View file

@ -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})
]

View file

@ -303,6 +303,7 @@ Slider.dynamicProps = Slider.prototype.constructor.dynamicProps
.concat([
'steps',
'spring',
'sensitivity',
'default',
])