diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/outputwindow.cc | 11 | ||||
-rw-r--r-- | src/outputwindow.h | 2 |
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}; }; |