diff options
Diffstat (limited to 'desktop/island')
| -rw-r--r-- | desktop/island/Controls.js | 9 | ||||
| -rw-r--r-- | desktop/island/ControlsPanel.qml | 4 | ||||
| -rw-r--r-- | desktop/island/test_controls.js | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/desktop/island/Controls.js b/desktop/island/Controls.js index 39865b2..0ca2f6c 100644 --- a/desktop/island/Controls.js +++ b/desktop/island/Controls.js @@ -88,9 +88,14 @@ function fill(volume) { } // One scroll step, rounded to the percent so repeated steps do not drift. +// The cap only stops a step up: a level already above it (set elsewhere, +// e.g. a mic at 120% from pavucontrol) is left alone by up and stepped from +// by down, never snapped to the cap. function step(volume, delta, max) { - const v = Math.round(((volume > 0 ? volume : 0) + delta) * 100) / 100; - return Math.max(0, Math.min(max, v)); + const cur = volume > 0 ? volume : 0; + const v = Math.round((cur + delta) * 100) / 100; + if (delta < 0) return Math.max(0, v); + return Math.max(cur, Math.min(max, v)); } // The slot a dragged tile lands in, from its centre in grid coordinates. diff --git a/desktop/island/ControlsPanel.qml b/desktop/island/ControlsPanel.qml index a21b892..a7872d7 100644 --- a/desktop/island/ControlsPanel.qml +++ b/desktop/island/ControlsPanel.qml @@ -98,6 +98,10 @@ Column { anchors.fill: parent enabled: panel.editing preventStealing: true + // Both buttons and the wheel, so in edit mode nothing + // reaches the tile: no drawer page, no volume change. + acceptedButtons: Qt.LeftButton | Qt.RightButton + onWheel: wheel => wheel.accepted = true cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor property real sx: 0 property real sy: 0 diff --git a/desktop/island/test_controls.js b/desktop/island/test_controls.js index f84e472..b2db873 100644 --- a/desktop/island/test_controls.js +++ b/desktop/island/test_controls.js @@ -82,6 +82,9 @@ assert.strictEqual(C.step(1.48, 0.05, 1.5), 1.5); assert.strictEqual(C.step(0.98, 0.05, 1.0), 1); assert.strictEqual(C.step(0.1 + 0.2, 0.05, 1), 0.35); assert.strictEqual(C.step(undefined, 0.05, 1), 0.05); +// Above the cap (set elsewhere): up leaves it, down steps from where it is. +assert.strictEqual(C.step(1.2, 0.05, 1.0), 1.2); +assert.strictEqual(C.step(1.2, -0.05, 1.0), 1.15); // slotAt: pitch 70, 4 columns, 7 tiles. assert.strictEqual(C.slotAt(35, 35, 70, 4, 7), 0); |
