From 7d8fd30bbf997d99cafc1cceb4aacd5d9ad559ea Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Wed, 2 Jul 2025 09:21:47 +0200 Subject: [PATCH] =?UTF-8?q?Add=20snap-to-5=C2=B0=20rotation=20with=20Shift?= =?UTF-8?q?+Ctrl+Mouse=20Wheel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a new shortcut (Shift + Ctrl + Mouse Wheel) to snap layer rotation to the nearest 5° increment. Updates the CanvasView help table to document this new functionality and clarifies the description for existing rotation shortcuts. --- js/CanvasInteractions.js | 14 +++++++++++++- js/CanvasView.js | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/js/CanvasInteractions.js b/js/CanvasInteractions.js index 03b97e3..6c04ce5 100644 --- a/js/CanvasInteractions.js +++ b/js/CanvasInteractions.js @@ -224,10 +224,22 @@ export class CanvasInteractions { this.canvas.viewport.y = worldCoords.y - (mouseBufferY / this.canvas.viewport.zoom); } else if (this.canvas.selectedLayer) { const rotationStep = 5 * (e.deltaY > 0 ? -1 : 1); + const direction = e.deltaY < 0 ? 1 : -1; // 1 = up/right, -1 = down/left this.canvas.selectedLayers.forEach(layer => { if (e.shiftKey) { - layer.rotation += rotationStep; + // Nowy skrót: Shift + Ctrl + Kółko do przyciągania do absolutnych wartości + if (e.ctrlKey) { + const snapAngle = 5; + if (direction > 0) { // Obrót w górę/prawo + layer.rotation = Math.ceil((layer.rotation + 0.1) / snapAngle) * snapAngle; + } else { // Obrót w dół/lewo + layer.rotation = Math.floor((layer.rotation - 0.1) / snapAngle) * snapAngle; + } + } else { + // Stara funkcjonalność: Shift + Kółko obraca o stały krok + layer.rotation += rotationStep; + } } else { const oldWidth = layer.width; const oldHeight = layer.height; diff --git a/js/CanvasView.js b/js/CanvasView.js index c0f30a0..3bd1e77 100644 --- a/js/CanvasView.js +++ b/js/CanvasView.js @@ -447,7 +447,8 @@ async function createCanvasWidget(node, widget, app) { Right ClickShow blend mode & opacity menu Mouse WheelScale layer (snaps to grid) Ctrl + Mouse WheelFine-scale layer - Shift + Mouse WheelRotate layer by 5° + Shift + Mouse WheelRotate layer by 5° steps + Shift + Ctrl + Mouse WheelSnap rotation to 5° increments Arrow KeysNudge layer by 1px Shift + Arrow KeysNudge layer by 10px [ or ]Rotate by 1°