diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/EditorRoot.qml --- a/src/QuickEditor/EditorRoot.qml +++ b/src/QuickEditor/EditorRoot.qml @@ -29,6 +29,11 @@ property var selection: undefined; property color maskColour: Qt.rgba(0, 0, 0, 0.15); property color strokeColour: Qt.rgba(0.114, 0.6, 0.953, 1); + property color crossColour: Qt.rgba(0.114, 0.6, 0.953, 0.5); + property var magZoom: 5; + property var magPixels: 16; + property var magOffset: 16; + SystemPalette { id: systemPalette; } @@ -188,9 +193,37 @@ ctx.strokeRect(selectionBoxX - 4, selectionBoxY - selectionTextRect.height - 2, selectionTextRect.width + 10, selectionTextRect.height + 8); ctx.fillStyle = systemPalette.windowText; ctx.fillText(selectionText, selectionBoxX, selectionBoxY); + if (selection.zx >= 0 && selection.zy >= 0) { + var offsetX = magOffset; + var offsetY = magOffset; + var magX = selection.zx; + var magY = selection.zy; + var magWidth = (magPixels * 2 + 1) * magZoom; + var magHeight = (magPixels * 2 + 1) * magZoom; + + if (magX + offsetX + magWidth >= Window.width / Screen.devicePixelRatio) { + offsetX -= offsetX * 2 + magWidth; + } + + if (magY + offsetY + magHeight >= Window.height / Screen.devicePixelRatio) { + offsetY -= offsetY * 2 + magHeight; + } + + magX += offsetX; + magY += offsetY; + crossMagnifier.visible = true; + crossMagnifier.x = magX; + crossMagnifier.y = magY; + crossBackground.x = -selection.zx * Screen.devicePixelRatio * magZoom + magPixels * magZoom; + crossBackground.y = -selection.zy * Screen.devicePixelRatio * magZoom + magPixels * magZoom; + ctx.strokeRect(magX, magY, magWidth, magHeight); + } else { + crossMagnifier.visible = false; + } } else { midHelpText.visible = true; bottomHelpText.visible = false; + crossMagnifier.visible = false; } } @@ -229,6 +262,7 @@ border.width: 1; border.color: Qt.rgba(0, 0, 0, 1); color: Qt.rgba(1, 1, 1, 0.85); + visible: false; anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; @@ -241,6 +275,61 @@ anchors.centerIn: parent; } } + + Rectangle { + id: crossMagnifier; + objectName: "crossMagnifier"; + + height: ( magPixels * 2 + 1) * magZoom; + width: ( magPixels * 2 + 1) * magZoom; + border.width: 0; + visible: false; + clip: true + + Image { + id: crossBackground; + objectName: "crossBackground"; + source: "image://snapshot/rawimage"; + cache: false; + smooth: false; + height: Window.height * magZoom; + width: Window.width * magZoom; + fillMode: Image.PreserveAspectCrop; + } + + Rectangle { + x: magPixels * magZoom; + y: 0; + width: magZoom; + height: magPixels * magZoom; + color: crossColour; + } + + Rectangle { + x: magPixels * magZoom; + y: (magPixels + 1) * magZoom; + width: magZoom; + height: magPixels * magZoom; + color: crossColour; + } + + Rectangle { + x: 0; + y: magPixels * magZoom; + width: magPixels * magZoom; + height: magZoom; + color: crossColour; + } + + Rectangle { + x: (magPixels + 1) * magZoom; + y: magPixels * magZoom; + width: magPixels * magZoom; + height: magZoom; + color: crossColour; + } + } + } MouseArea { @@ -273,7 +362,8 @@ selection.y = Math.min(starty, mouse.y); selection.width = Math.abs(startx - mouse.x) + 1; selection.height = Math.abs(starty - mouse.y) + 1; - + selection.zx = mouse.x; + selection.zy = mouse.y; cropDisplayCanvas.requestPaint(); } @@ -283,6 +373,12 @@ cropDisplayCanvas.requestPaint(); } } + + onReleased: { + selection.zx = -1; + selection.zy = -1; + cropDisplayCanvas.requestPaint(); + } } Component { diff --git a/src/QuickEditor/SelectionRectangle.qml b/src/QuickEditor/SelectionRectangle.qml --- a/src/QuickEditor/SelectionRectangle.qml +++ b/src/QuickEditor/SelectionRectangle.qml @@ -27,6 +27,14 @@ property var imageElement: null; property int minRectSize: 20; property int mouseAreaSize: 20; + property var zx: -1; + property var zy: -1; + + function resetZxZy() { + zx = -1; + zy = -1; + drawCanvas.requestPaint(); + } signal doubleClicked(); @@ -77,21 +85,29 @@ onPressed: { brxLimit = (parent.x + parent.width) - minRectSize; bryLimit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + mouse.y) < bryLimit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -110,20 +126,28 @@ onPressed: { brxLimit = parent.x + mouseAreaSize + minRectSize; bryLimit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } if ((parent.y + mouse.y) < bryLimit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -142,20 +166,28 @@ onPressed: { brxLimit = (parent.x + parent.width) - minRectSize; bryLimit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + parent.height + mouse.y) > bryLimit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -174,18 +206,26 @@ onPressed: { brxLimit = parent.x + mouseAreaSize + minRectSize; bryLimit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } if ((parent.y + parent.height + mouse.y) > bryLimit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -202,16 +242,23 @@ onPressed: { limit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2; + parent.zy = parent.y; } onPositionChanged: { if ((parent.y + mouse.y) < limit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } - + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2 + mouse.x + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -228,15 +275,22 @@ onPressed: { limit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.y + parent.height + mouse.y) > limit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } - + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2 + mouse.x + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -253,16 +307,23 @@ onPressed: { limit = (parent.x + parent.width) - minRectSize; + parent.zx = parent.x; + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2; } onPositionChanged: { if ((parent.x + mouse.x) < limit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } - + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2 + mouse.y + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -279,14 +340,21 @@ onPressed: { limit = parent.x + mouseAreaSize + minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > limit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } - + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2 + mouse.y + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } }