From e8f108e18dbdff88b3b9bae85f9a6dc6b4c75e2c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 18 Jun 2016 13:33:21 -0400 Subject: [PATCH] Mandelbrot: Implement mouse wheel zooming. --- src/apps/mandelbrot/Mandelbrot.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/apps/mandelbrot/Mandelbrot.cpp b/src/apps/mandelbrot/Mandelbrot.cpp index 7fa9032803..794c065b88 100644 --- a/src/apps/mandelbrot/Mandelbrot.cpp +++ b/src/apps/mandelbrot/Mandelbrot.cpp @@ -198,6 +198,21 @@ void FractalView::MouseUp(BPoint where) void FractalView::MessageReceived(BMessage* msg) { switch (msg->what) { + case B_MOUSE_WHEEL_CHANGED: { + float change = msg->FindFloat("be:wheel_delta_y"); + BPoint where; + GetMouse(&where, NULL); + BRect frame = Frame(); + fLocationX = ((where.x - frame.Width() / 2) * fSize + fLocationX); + fLocationY = ((where.y - frame.Height() / 2) * -fSize + fLocationY); + if (change < 0) + fSize /= 1.5; + else + fSize *= 1.5; + RedrawFractal(); + break; + } + case FractalEngine::MSG_RENDER_COMPLETE: if (fOwnBitmap) { fOwnBitmap = false;