Mandelbrot: Reset position when changing sets.

This commit is contained in:
Augustin Cavalier 2016-06-18 13:22:15 -04:00
parent fb292a367a
commit d4bca23f9b

View File

@ -42,6 +42,7 @@ public:
virtual void MessageReceived(BMessage* msg);
virtual void Draw(BRect updateRect);
void ResetPosition();
void RedrawFractal();
FractalEngine* fFractalEngine;
@ -87,6 +88,14 @@ FractalView::~FractalView()
}
void FractalView::ResetPosition()
{
fLocationX = 0;
fLocationY = 0;
fSize = 0.005;
}
void FractalView::AttachedToWindow()
{
fFractalEngine = new FractalEngine(this, Window());
@ -119,6 +128,7 @@ void FractalView::Pulse()
RedrawFractal();
}
BRect FractalView::GetDragFrame()
{
BRect dragZone = BRect(std::min(fSelectStart.x, fSelectEnd.x),
@ -336,6 +346,7 @@ MandelbrotWindow::MandelbrotWindow(BRect frame)
BMessage msg(FractalEngine::MSG_CHANGE_SET); \
msg.AddUInt8("set", id); \
fFractalView->fFractalEngine->PostMessage(&msg); \
fFractalView->ResetPosition(); \
fFractalView->RedrawFractal(); \
break; \
}