summaryrefslogtreecommitdiff
path: root/Applications/Help/main.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-03 21:42:48 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-03 22:37:48 +0100
commit03e0ddce5237b6ad7b84724ef03039e413944f00 (patch)
treeee45767b85f54584ce6c3f08dd34b7f8e84ef1cd /Applications/Help/main.cpp
parent0cafbbf09c303a51a48b67ef951fa828979cde6e (diff)
downloadserenity-03e0ddce5237b6ad7b84724ef03039e413944f00.zip
LibGUI: Some more convenience functions for constructing widgets
This patch adds two new API's: - WidgetType& GUI::Window::set_main_widget<WidgetType>(); This creates a new main widget for a window, assigns it, and returns it to you as a WidgetType&. - LayoutType& GUI::Widget::set_layout<LayoutType>(); Same basic idea, creates a new layout, assigns it, and returns it to you as a LayoutType&.
Diffstat (limited to 'Applications/Help/main.cpp')
-rw-r--r--Applications/Help/main.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp
index 010a87f0e5..423bc5ef64 100644
--- a/Applications/Help/main.cpp
+++ b/Applications/Help/main.cpp
@@ -78,13 +78,13 @@ int main(int argc, char* argv[])
window->set_title("Help");
window->set_rect(300, 200, 570, 500);
- auto widget = GUI::Widget::construct();
- widget->set_layout(make<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 toolbar = widget->add<GUI::ToolBar>();
+ auto toolbar = widget.add<GUI::ToolBar>();
- auto splitter = widget->add<GUI::HorizontalSplitter>();
+ auto splitter = widget.add<GUI::HorizontalSplitter>();
auto model = ManualModel::create();
@@ -195,7 +195,6 @@ int main(int argc, char* argv[])
app.set_menubar(move(menubar));
- window->set_main_widget(widget);
window->set_focused_widget(tree_view);
window->show();