1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +00:00

GameOfLife: Don't enable rotate button if a pattern isn't selected

This commit is contained in:
Musab Kılıç 2021-08-28 22:31:35 +03:00 committed by Linus Groh
parent fac0bbe739
commit 1179d5d921
3 changed files with 11 additions and 2 deletions

View file

@ -127,9 +127,9 @@ int main(int argc, char** argv)
main_toolbar.add_action(randomize_cells_action);
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"), [&](auto&) {
if (board_widget.selected_pattern() != nullptr)
board_widget.selected_pattern()->rotate_clockwise();
board_widget.selected_pattern()->rotate_clockwise();
});
rotate_pattern_action->set_enabled(false);
main_toolbar.add_action(rotate_pattern_action);
auto& game_menu = window->add_menu("&Game");
@ -180,6 +180,10 @@ int main(int argc, char** argv)
statusbar.set_text(click_tip);
};
board_widget.on_pattern_selection_state_change = [&] {
rotate_pattern_action->set_enabled(board_widget.selected_pattern() != nullptr);
};
window->resize(500, 420);
window->show();