Mandelbrot: Add a View menu with zoom actions

This commit is contained in:
Nico Weber 2021-08-14 12:33:43 -04:00 committed by Gunnar Beutner
parent 19068945de
commit 5c3440c5db
Notes: sideshowbarker 2024-07-18 06:54:46 +09:00

View File

@ -407,6 +407,31 @@ int main(int argc, char** argv)
}));
file_menu.add_separator();
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
auto zoom_in_action = GUI::CommonActions::make_zoom_in_action(
[&](auto&) {
mandelbrot.zoom(Mandelbrot::Zoom::In, mandelbrot.relative_rect().center());
},
window);
auto reset_zoom_action = GUI::CommonActions::make_reset_zoom_action(
[&](auto&) {
// FIXME: Ideally, this would only reset zoom. Currently, it resets pan too.
mandelbrot.reset();
},
window);
auto zoom_out_action = GUI::CommonActions::make_zoom_out_action(
[&](auto&) {
mandelbrot.zoom(Mandelbrot::Zoom::Out, mandelbrot.relative_rect().center());
},
window);
auto& view_menu = window->add_menu("&View");
view_menu.add_action(zoom_in_action);
view_menu.add_action(reset_zoom_action);
view_menu.add_action(zoom_out_action);
window->show();
auto app_icon = GUI::Icon::default_icon("app-mandelbrot");