diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-29 14:32:13 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-29 14:32:13 +0100 |
commit | 9f33eb49ccb7fa8fb80f00865819beb499e70025 (patch) | |
tree | 65e1f8fcbdd09780bf23a27eb01ca5ef72ab3c1f /src/outputwindow.cc | |
parent | 16beb55484c20b8b1e92afdf5720fa3860d77309 (diff) |
Zoom canvas using scroll-wheel.
Diffstat (limited to 'src/outputwindow.cc')
-rw-r--r-- | src/outputwindow.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/outputwindow.cc b/src/outputwindow.cc index 815da8c..b7b1a51 100644 --- a/src/outputwindow.cc +++ b/src/outputwindow.cc @@ -29,6 +29,7 @@ #include <QPixmap> #include <QPainter> +#include <QWheelEvent> #include <math.h> @@ -72,7 +73,11 @@ void OutputWindow::loadPen(QString file) void OutputWindow::setScale(double s) { scale = s; - sem.acquire(); +} + +double OutputWindow::getScale() const +{ + return scale; } void OutputWindow::setSpeed(int s) @@ -107,11 +112,22 @@ void OutputWindow::timeout() timer.start(25); } + +void OutputWindow::wheelEvent(QWheelEvent* event) +{ + double delta = event->delta() / 120.0 * scale; + scale += delta / 10.0; + printf("%f\n", scale); + if(scale < 0.3) + { + scale = 0.3; + } +} + void OutputWindow::paintEvent(QPaintEvent *) { //sem.acquire(); QPainter p(this); - //QTransform tp; tp.scale(3, 3); p.setTransform(tp); if(loadpen) { @@ -180,7 +196,6 @@ void OutputWindow::paintEvent(QPaintEvent *) void OutputWindow::reset() { - scale = 2.0; speed = 50; penfile = "gfx/kaiman.png"; loadpen = true; |