summaryrefslogtreecommitdiff
path: root/src/outputwindow.cc
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/outputwindow.cc
parent7c22cf3cc88a1f2f62d0cb8bc26f1e8f4c33c06f (diff)
Fix dragging.
Diffstat (limited to 'src/outputwindow.cc')
-rw-r--r--src/outputwindow.cc11
1 files changed, 6 insertions, 5 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();
}