Mandelbrot: Implement mouse wheel zooming.

This commit is contained in:
Augustin Cavalier 2016-06-18 13:33:21 -04:00
parent d4bca23f9b
commit e8f108e18d

View File

@ -198,6 +198,21 @@ void FractalView::MouseUp(BPoint where)
void FractalView::MessageReceived(BMessage* msg) void FractalView::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { 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: case FractalEngine::MSG_RENDER_COMPLETE:
if (fOwnBitmap) { if (fOwnBitmap) {
fOwnBitmap = false; fOwnBitmap = false;