mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
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. :^)
This commit is contained in:
parent
37af1d74cc
commit
2463a285ee
6 changed files with 41 additions and 41 deletions
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue