mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +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
|
@ -57,12 +57,11 @@ int main(int argc, char** argv)
|
|||
window->set_title("Minesweeper");
|
||||
window->set_rect(100, 100, 139, 175);
|
||||
|
||||
auto widget = GUI::Widget::construct();
|
||||
window->set_main_widget(widget);
|
||||
widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
widget->layout()->set_spacing(0);
|
||||
auto& widget = window->set_main_widget<GUI::Widget>();
|
||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
widget.layout()->set_spacing(0);
|
||||
|
||||
auto container = widget->add<GUI::Widget>();
|
||||
auto container = widget.add<GUI::Widget>();
|
||||
container->set_fill_with_background_color(true);
|
||||
container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
container->set_preferred_size(0, 36);
|
||||
|
@ -77,7 +76,7 @@ int main(int argc, char** argv)
|
|||
auto time_icon_label = container->add<GUI::Label>();
|
||||
time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
||||
auto time_label = container->add<GUI::Label>();
|
||||
auto field = widget->add<Field>(*flag_label, *time_label, *face_button, [&](auto size) {
|
||||
auto field = widget.add<Field>(*flag_label, *time_label, *face_button, [&](auto size) {
|
||||
size.set_height(size.height() + container->preferred_size().height());
|
||||
window->resize(size);
|
||||
});
|
||||
|
|
|
@ -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