mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
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&.
This commit is contained in:
parent
0cafbbf09c
commit
03e0ddce52
10 changed files with 66 additions and 60 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue