mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 14:55:07 +00:00
LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients
This commit is contained in:
parent
4697195645
commit
0f3e57a6fb
37 changed files with 203 additions and 246 deletions
|
@ -55,15 +55,14 @@ int main(int argc, char** argv)
|
|||
window->set_title("Snake");
|
||||
window->set_rect(100, 100, 320, 320);
|
||||
|
||||
auto game = SnakeGame::construct();
|
||||
window->set_main_widget(game);
|
||||
auto& game = window->set_main_widget<SnakeGame>();
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
||||
auto app_menu = GUI::Menu::construct("Snake");
|
||||
|
||||
app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) {
|
||||
game->reset();
|
||||
game.reset();
|
||||
}));
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue