Mandelbrot: Extract reset() method

This commit is contained in:
Nico Weber 2021-08-14 12:32:44 -04:00 committed by Gunnar Beutner
parent ad7bfe017f
commit 19068945de
Notes: sideshowbarker 2024-07-18 06:54:49 +09:00

View File

@ -215,6 +215,8 @@ class Mandelbrot : public GUI::Frame {
};
void zoom(Zoom in_out, const Gfx::IntPoint& center);
void reset();
private:
virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent& event) override;
@ -260,6 +262,12 @@ void Mandelbrot::zoom(Zoom in_out, const Gfx::IntPoint& center)
update();
}
void Mandelbrot::reset()
{
m_set.reset();
update();
}
void Mandelbrot::paint_event(GUI::PaintEvent& event)
{
Frame::paint_event(event);
@ -330,8 +338,7 @@ void Mandelbrot::mouseup_event(GUI::MouseEvent& event)
m_panning = false;
update();
} else if (event.button() == GUI::MouseButton::Right) {
m_set.reset();
update();
reset();
}
return GUI::Widget::mouseup_event(event);