Commit a147b75e authored by Tao Guo's avatar Tao Guo Committed by Henrik Fehlauer

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
parent 8701d6e8
......@@ -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();
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment