From bdfe6f6bb99db5221f26c1e8af35d253d8b7d467 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 22 Dec 2017 13:16:56 +0100 Subject: [PATCH] sliders/pads: holding `Ctrl` now enables high precision dragging with the mouse and bypasses the `snap` option --- CHANGELOG.md | 2 +- resources/docs/interface.md | 4 +++- src/browser/js/app/widgets/matrices/multifader.js | 2 +- src/browser/js/app/widgets/sliders/fader.js | 2 +- src/browser/js/app/widgets/sliders/knob.js | 4 ++-- src/browser/js/libs/jquery.drag.js | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc61fe91..8503e84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,9 @@ - downgraded to the latest *stable* electron release - main - added `zeroconf` / `bonjour` publishing for the app's http and osc input ports -- cli - added `--instance-name` option to differenciate mulitple instances in zeroconf networks - widgets + - sliders/pads: holding `Ctrl` now enables high precision dragging with the mouse and bypasses the `snap` option - inputs: renamed `input`'s property `horizontal` to `vertical` to match how the widget actually displays - sliders: **new** `range` widget - plots: **new** `image` widget diff --git a/resources/docs/interface.md b/resources/docs/interface.md index 614d542a..a79e0f55 100644 --- a/resources/docs/interface.md +++ b/resources/docs/interface.md @@ -30,4 +30,6 @@ See [Editing sessions](editing-sessions.md). | Click | Tap | Handled at pressing time, not releasing. | | Double Click | Double Tap | Some widgets handle double click / tap events. | | Right-click | Long touch | Widgets that have only one value input will give focus to it when receiving this event. When the editor is enabled, Right-click / Long touch spawns the editor's context menu. | -| Drag | | The widgets respond to mouse and touch drag gestures with a 1:1 precision ratio. By using two or more fingers, one can obtain higher precision gestures : each finger that touches the widget without moving will slow down the moving one. | +| Drag | Drag | The widgets respond to mouse and touch drag gestures with a 1:1 precision ratio. | +| `Ctrl` + Drag | | Holding the `Ctrl` key while dragging with the mouse increases the gesture's precision by 8.| +| | Multi-finger drag (single target) | Using two or more fingers on a single-touch target increases the gesture's precision by the squared number of fingers. | diff --git a/src/browser/js/app/widgets/matrices/multifader.js b/src/browser/js/app/widgets/matrices/multifader.js index 7447fdd9..32fb5445 100644 --- a/src/browser/js/app/widgets/matrices/multifader.js +++ b/src/browser/js/app/widgets/matrices/multifader.js @@ -96,7 +96,7 @@ module.exports = class Multifader extends _matrices_base { } - if (this.getProp('traversing')) this.widget.enableTraversingGestures() + if (this.getProp('traversing')) this.widget.enableTraversingGestures({ctrlKeyCancel:true}) this.registerHashes() diff --git a/src/browser/js/app/widgets/sliders/fader.js b/src/browser/js/app/widgets/sliders/fader.js index 58cedfe7..6e3890b9 100644 --- a/src/browser/js/app/widgets/sliders/fader.js +++ b/src/browser/js/app/widgets/sliders/fader.js @@ -130,7 +130,7 @@ module.exports = class Fader extends _sliders_base { this.percent = clip(this.percent,[0,100]) - if (!(traversing || this.getProp('snap'))) return + if (!(traversing || this.getProp('snap')) || data.ctrlKey) return this.percent = this.getProp('horizontal')? (data.offsetX - this.margin * PXSCALE) / (this.width - (this.margin * PXSCALE * 2)) * 100: diff --git a/src/browser/js/app/widgets/sliders/knob.js b/src/browser/js/app/widgets/sliders/knob.js index b1cfb5cc..418fd07b 100644 --- a/src/browser/js/app/widgets/sliders/knob.js +++ b/src/browser/js/app/widgets/sliders/knob.js @@ -76,7 +76,7 @@ module.exports = class Knob extends _sliders_base { this.lastOffsetX = data.offsetX this.lastOffsetY = data.offsetY - if (!(traversing || this.getProp('snap'))) return + if (!(traversing || this.getProp('snap')) || data.ctrlKey) return this.percent = this.angleToPercent(this.coordsToAngle(data.offsetX, data.offsetY)) @@ -86,7 +86,7 @@ module.exports = class Knob extends _sliders_base { dragHandle(e, data, traversing) { - if (!(traversing || this.getProp('snap'))) { + if (!(traversing || this.getProp('snap')) || data.ctrlKey) { this.percent = -100*data.speedY/this.height + this.percent diff --git a/src/browser/js/libs/jquery.drag.js b/src/browser/js/libs/jquery.drag.js index c665ba07..1d8f3fd8 100644 --- a/src/browser/js/libs/jquery.drag.js +++ b/src/browser/js/libs/jquery.drag.js @@ -297,11 +297,12 @@ } - $.fn.enableTraversingGestures = function() { + $.fn.enableTraversingGestures = function(options={}) { var self = this[0] var down = function(e){ + if (e.ctrlKey && options.ctrlKeyCancel) return makeEventTraversing(e) self.addEventListener("mousemove", makeEventTraversing, true) self.addEventListener("touchmove", makeEventTraversing, true)