summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-04 11:10:07 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-04 11:10:07 +0200
commit2463a285ee26813c86865268e499972e923691c2 (patch)
tree8dabeeef4bb1f266c3ce437ba864429f772c6c2b /Libraries/LibGUI
parent37af1d74cc32166c8bcbd971eb3065b9b6ca5ed7 (diff)
downloadserenity-2463a285ee26813c86865268e499972e923691c2.zip
LibGUI: Make GUI::TabWidget::add_tab<T>() return a T&
Since the newly constructed sub-widget is owned by the TabWidget, we can simply return a T& here. :^)
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/ColorPicker.cpp24
-rw-r--r--Libraries/LibGUI/TabWidget.h4
2 files changed, 14 insertions, 14 deletions
diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp
index 1d7fb7a93f..2b4ee5ab2e 100644
--- a/Libraries/LibGUI/ColorPicker.cpp
+++ b/Libraries/LibGUI/ColorPicker.cpp
@@ -107,21 +107,21 @@ void ColorPicker::build_ui()
auto& tab_widget = root_container.add<GUI::TabWidget>();
- auto tab_palette = tab_widget.add_tab<Widget>("Palette");
- tab_palette->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
- tab_palette->set_layout<VerticalBoxLayout>();
- tab_palette->layout()->set_margins({ 4, 4, 4, 4 });
- tab_palette->layout()->set_spacing(4);
+ auto& tab_palette = tab_widget.add_tab<Widget>("Palette");
+ tab_palette.set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
+ tab_palette.set_layout<VerticalBoxLayout>();
+ tab_palette.layout()->set_margins({ 4, 4, 4, 4 });
+ tab_palette.layout()->set_spacing(4);
- build_ui_palette(*tab_palette);
+ build_ui_palette(tab_palette);
- auto tab_custom_color = tab_widget.add_tab<Widget>("Custom Color");
- tab_custom_color->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
- tab_custom_color->set_layout<VerticalBoxLayout>();
- tab_custom_color->layout()->set_margins({ 4, 4, 4, 4 });
- tab_custom_color->layout()->set_spacing(4);
+ auto& tab_custom_color = tab_widget.add_tab<Widget>("Custom Color");
+ tab_custom_color.set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
+ tab_custom_color.set_layout<VerticalBoxLayout>();
+ tab_custom_color.layout()->set_margins({ 4, 4, 4, 4 });
+ tab_custom_color.layout()->set_spacing(4);
- build_ui_custom(*tab_custom_color);
+ build_ui_custom(tab_custom_color);
auto& button_container = root_container.add<Widget>();
button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
diff --git a/Libraries/LibGUI/TabWidget.h b/Libraries/LibGUI/TabWidget.h
index e711001d1d..1e9333f155 100644
--- a/Libraries/LibGUI/TabWidget.h
+++ b/Libraries/LibGUI/TabWidget.h
@@ -55,11 +55,11 @@ public:
void add_widget(const StringView&, Widget&);
template<class T, class... Args>
- inline NonnullRefPtr<T> add_tab(const StringView& title, Args&&... args)
+ T& add_tab(const StringView& title, Args&&... args)
{
auto t = T::construct(forward<Args>(args)...);
add_widget(title, *t);
- return t;
+ return *t;
}
protected: