summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTao Guo <[email protected]>2018-03-26 22:36:02 +0200
committerHenrik Fehlauer <[email protected]>2018-03-26 22:37:57 +0200
commita147b75ef3371b8c261913f67c9af3ed2f70b8af (patch)
treefa08f54c2c26aca27d64cc19b0c6c02096891618
parent8701d6e8b707881d0be2ab54b8e8926ce50040d2 (diff)
Fix rectangle selection edge not follow mouse
Summary: 1. In rectangle mode, when to adjust selection, the right, bottom edge not follow mouse 2. Fix wrong rectangle size Test Plan: 1. In rectangle mode, adjust the ( topright, right, bottom right, bottom, bottom left) selection and check mouse and edge position. 2 select full screen and check size 3 save image and check image size Reviewers: #spectacle, rkflx, ngraham Reviewed By: #spectacle, rkflx, ngraham Subscribers: rkflx, ngraham Differential Revision: https://phabricator.kde.org/D11598
-rw-r--r--src/QuickEditor/EditorRoot.qml4
-rw-r--r--src/QuickEditor/SelectionRectangle.qml71
2 files changed, 38 insertions, 37 deletions
diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/EditorRoot.qml
index 84c117b..4fc1318 100644
--- a/src/QuickEditor/EditorRoot.qml
+++ b/src/QuickEditor/EditorRoot.qml
@@ -271,8 +271,8 @@ Item {
onPositionChanged: {
selection.x = Math.min(startx, mouse.x);
selection.y = Math.min(starty, mouse.y);
- selection.width = Math.abs(startx - mouse.x);
- selection.height = Math.abs(starty - mouse.y);
+ selection.width = Math.abs(startx - mouse.x) + 1;
+ selection.height = Math.abs(starty - mouse.y) + 1;
cropDisplayCanvas.requestPaint();
}
diff --git a/src/QuickEditor/SelectionRectangle.qml b/src/QuickEditor/SelectionRectangle.qml
index f20f01d..c428556 100644
--- a/src/QuickEditor/SelectionRectangle.qml
+++ b/src/QuickEditor/SelectionRectangle.qml
@@ -25,6 +25,8 @@ Item {
property var drawCanvas: null;
property var imageElement: null;
+ property int minRectSize: 20;
+ property int mouseAreaSize: 20;
signal doubleClicked();
@@ -68,13 +70,13 @@ Item {
anchors.top: parent.top;
anchors.left: parent.left;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeFDiagCursor;
onPressed: {
- brxLimit = (parent.x + parent.width) - 20;
- bryLimit = (parent.y + parent.height) - 20;
+ brxLimit = (parent.x + parent.width) - minRectSize;
+ bryLimit = (parent.y + parent.height) - minRectSize;
}
onPositionChanged: {
@@ -101,18 +103,18 @@ Item {
anchors.top: parent.top;
anchors.right: parent.right;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeBDiagCursor;
onPressed: {
- brxLimit = parent.x + 20;
- bryLimit = (parent.y + parent.height) - 20;
+ brxLimit = parent.x + mouseAreaSize + minRectSize;
+ bryLimit = (parent.y + parent.height) - minRectSize;
}
onPositionChanged: {
if ((parent.x + parent.width + mouse.x) > brxLimit) {
- parent.width = parent.width + mouse.x;
+ parent.width = parent.width + mouse.x - mouseAreaSize + 1;
}
if ((parent.y + mouse.y) < bryLimit) {
@@ -133,13 +135,13 @@ Item {
anchors.bottom: parent.bottom;
anchors.left: parent.left;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeBDiagCursor;
onPressed: {
- brxLimit = (parent.x + parent.width) - 20;
- bryLimit = parent.y + 20;
+ brxLimit = (parent.x + parent.width) - minRectSize;
+ bryLimit = parent.y + mouseAreaSize + minRectSize;
}
onPositionChanged: {
@@ -149,7 +151,7 @@ Item {
}
if ((parent.y + parent.height + mouse.y) > bryLimit) {
- parent.height = parent.height + mouse.y;
+ parent.height = parent.height + mouse.y - mouseAreaSize + 1;
}
drawCanvas.requestPaint();
@@ -165,24 +167,23 @@ Item {
anchors.bottom: parent.bottom;
anchors.right: parent.right;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeFDiagCursor;
onPressed: {
- brxLimit = parent.x + 20;
- bryLimit = parent.y + 20;
+ brxLimit = parent.x + mouseAreaSize + minRectSize;
+ bryLimit = parent.y + mouseAreaSize + minRectSize;
}
onPositionChanged: {
if ((parent.x + parent.width + mouse.x) > brxLimit) {
- parent.width = parent.width + mouse.x;
+ parent.width = parent.width + mouse.x - mouseAreaSize + 1;
}
if ((parent.y + parent.height + mouse.y) > bryLimit) {
- parent.height = parent.height + mouse.y;
+ parent.height = parent.height + mouse.y - mouseAreaSize + 1;
}
-
drawCanvas.requestPaint();
}
}
@@ -195,12 +196,12 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: parent.top;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeVerCursor;
onPressed: {
- limit = (parent.y + parent.height) - 20;
+ limit = (parent.y + parent.height) - minRectSize;
}
onPositionChanged: {
@@ -221,17 +222,17 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter;
anchors.bottom: parent.bottom;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeVerCursor;
onPressed: {
- limit = parent.y + 20;
+ limit = parent.y + mouseAreaSize + minRectSize;
}
onPositionChanged: {
if ((parent.y + parent.height + mouse.y) > limit) {
- parent.height = parent.height + mouse.y;
+ parent.height = parent.height + mouse.y - mouseAreaSize + 1;
}
drawCanvas.requestPaint();
@@ -246,12 +247,12 @@ Item {
anchors.verticalCenter: parent.verticalCenter;
anchors.left: parent.left;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeHorCursor;
onPressed: {
- limit = (parent.x + parent.width) - 20;
+ limit = (parent.x + parent.width) - minRectSize;
}
onPositionChanged: {
@@ -272,17 +273,17 @@ Item {
anchors.verticalCenter: parent.verticalCenter;
anchors.right: parent.right;
- width: 20;
- height: 20;
+ width: mouseAreaSize;
+ height: mouseAreaSize;
cursorShape: Qt.SizeHorCursor;
onPressed: {
- limit = parent.x + 20;
+ limit = parent.x + mouseAreaSize + minRectSize;
}
onPositionChanged: {
if ((parent.x + parent.width + mouse.x) > limit) {
- parent.width = parent.width + mouse.x;
+ parent.width = parent.width + mouse.x - mouseAreaSize + 1;
}
drawCanvas.requestPaint();