summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-12-30 17:26:47 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2018-12-30 17:26:47 +0100
commit621e62b3f342a12299e2451adc3ae850f54857c8 (patch)
tree54bc6bba9460ae083ad9648af2b8d7cecc21f33f /src
parent7c22cf3cc88a1f2f62d0cb8bc26f1e8f4c33c06f (diff)
Fix dragging.
Diffstat (limited to 'src')
-rw-r--r--src/outputwindow.cc11
-rw-r--r--src/outputwindow.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/outputwindow.cc b/src/outputwindow.cc
index 95c3c7b..6bb963d 100644
--- a/src/outputwindow.cc
+++ b/src/outputwindow.cc
@@ -159,6 +159,7 @@ void OutputWindow::reset()
r = 0;
colour = QColor(150, 0, 0, 150);
stop = false;
+ offset = { width() / 2.0, height() / 2.0 };
while(sem.tryAcquire())
{
}
@@ -174,7 +175,7 @@ void OutputWindow::mouseMoveEvent(QMouseEvent* event)
void OutputWindow::mousePressEvent(QMouseEvent* event)
{
- if(event->buttons() & Qt::MiddleButton)
+ if(event->button() == Qt::MiddleButton)
{
dragging = true;
dragOffsetOrigo = event->pos();
@@ -184,10 +185,10 @@ void OutputWindow::mousePressEvent(QMouseEvent* event)
void OutputWindow::mouseReleaseEvent(QMouseEvent* event)
{
- if(event->buttons() & Qt::MiddleButton)
+ if(event->button() == Qt::MiddleButton)
{
dragging = false;
- offset = dragOffsetOrigo - event->pos();
+ offset += dragOffset;
dragOffset = dragOffsetOrigo = {};
}
}
@@ -207,8 +208,8 @@ void OutputWindow::paintEvent(QPaintEvent *)
//sem.acquire();
QPainter painter(this);
paint(painter,
- { width() / 2.0 + offset.x() + dragOffset.x(),
- height() / 2.0 + offset.y() + dragOffset.y() }, true, scale);
+ { offset.x() + dragOffset.x(),
+ offset.y() + dragOffset.y() }, true, scale);
sem.release();
}
diff --git a/src/outputwindow.h b/src/outputwindow.h
index 182499a..bc50c90 100644
--- a/src/outputwindow.h
+++ b/src/outputwindow.h
@@ -99,5 +99,5 @@ private:
bool dragging{false};
QPoint dragOffsetOrigo{0, 0};
QPoint dragOffset{0, 0};
- QPoint offset{0, 0};
+ QPointF offset{0.0, 0.0};
};