Skip to content

Commit e923f39

Browse files
committed
selection tool fix geometry tool
1 parent 5820a17 commit e923f39

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/DrawingWidget.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ void DrawingWidget::mousePressEvent(QMouseEvent *event) {
284284
if(floatingSettings->isVisible()){
285285
floatingSettings->hide();
286286
}
287+
geo.clear(-1);
288+
geo.addValue(-1,event->position());
287289
if(penMode != DRAW) {
288290
return;
289291
}
@@ -296,8 +298,6 @@ void DrawingWidget::mousePressEvent(QMouseEvent *event) {
296298
}
297299
curs.setCursor(-1, penSize[ev_pen]);
298300
curEventButtons = event->buttons();
299-
geo.clear(-1);
300-
geo.addValue(-1,event->position());
301301
isMoved = false;
302302

303303
}
@@ -353,6 +353,7 @@ void DrawingWidget::mouseReleaseEvent(QMouseEvent *event) {
353353
drawing = false;
354354
}
355355
if(penMode == SELECTION) {
356+
geo.addValue(-1, event->position());
356357
createSelection();
357358
update();
358359
return;

src/Selection.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ MovableWidget::MovableWidget(QWidget *parent) : QWidget(parent) {
88
extern float scale;
99
#define nearEdge 10*scale
1010

11+
#define startPoint geo.first(-1)
12+
#define endPoint geo.last(-1)
13+
1114
void MovableWidget::mousePressEvent(QMouseEvent *event) {
1215
lastMousePosition = event->pos();
1316
int xx = width() - event->pos().x();
@@ -44,8 +47,9 @@ static bool hasSelection = false;
4447

4548
void DrawingWidget::createSelection() {
4649
hasSelection = true;
47-
QPoint topLeft(qMin(geo.first(-1).x(), geo.last(-1).x()), qMin(geo.first(-1).y(), geo.last(-1).y()));
48-
QPoint bottomRight(qMax(geo.first(-1).x(), geo.last(-1).x()), qMax(geo.first(-1).y(), geo.last(-1).y()));
50+
printf("%f %f %f %f\n", startPoint.x(), endPoint.x(), startPoint.y(), endPoint.y());
51+
QPoint topLeft(qMin(startPoint.x(), endPoint.x()), qMin(startPoint.y(), endPoint.y()));
52+
QPoint bottomRight(qMax(startPoint.x(), endPoint.x()), qMax(startPoint.y(), endPoint.y()));
4953
QRect cropRect(topLeft, bottomRight);
5054

5155
cropWidget->image = imageBackup.copy(cropRect);

0 commit comments

Comments
 (0)