summaryrefslogtreecommitdiff
path: root/src/outputwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-12-29 21:30:28 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2018-12-30 11:42:13 +0100
commit6f2c3b90ce29a20e14cc769841056d4b36c42d50 (patch)
tree41c555a7363bdb248d3306698d83692a0c89262b /src/outputwindow.cc
parent58183c47c2b3235f8f56dc6492bb41b775dd6f26 (diff)
Implement drag'n'move.
Diffstat (limited to 'src/outputwindow.cc')
-rw-r--r--src/outputwindow.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/outputwindow.cc b/src/outputwindow.cc
index 8c4cb7b..95c3c7b 100644
--- a/src/outputwindow.cc
+++ b/src/outputwindow.cc
@@ -164,6 +164,34 @@ void OutputWindow::reset()
}
}
+void OutputWindow::mouseMoveEvent(QMouseEvent* event)
+{
+ if(dragging)
+ {
+ dragOffset = event->pos() - dragOffsetOrigo;
+ }
+}
+
+void OutputWindow::mousePressEvent(QMouseEvent* event)
+{
+ if(event->buttons() & Qt::MiddleButton)
+ {
+ dragging = true;
+ dragOffsetOrigo = event->pos();
+ dragOffset = {};
+ }
+}
+
+void OutputWindow::mouseReleaseEvent(QMouseEvent* event)
+{
+ if(event->buttons() & Qt::MiddleButton)
+ {
+ dragging = false;
+ offset = dragOffsetOrigo - event->pos();
+ dragOffset = dragOffsetOrigo = {};
+ }
+}
+
void OutputWindow::wheelEvent(QWheelEvent* event)
{
double delta = event->delta() / 120.0 * scale;
@@ -178,7 +206,9 @@ void OutputWindow::paintEvent(QPaintEvent *)
{
//sem.acquire();
QPainter painter(this);
- paint(painter, {width() / 2.0, height() / 2.0}, true, scale);
+ paint(painter,
+ { width() / 2.0 + offset.x() + dragOffset.x(),
+ height() / 2.0 + offset.y() + dragOffset.y() }, true, scale);
sem.release();
}