mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:58:14 +00:00
LibGUI: Add helper for constructing new TabWidget tabs
This patch adds the following convenience helper: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = tab_widget->add_tab<GUI::Widget>("My tab", ...); The above is equivalent to: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = GUI::Widget::construct(...); tab_widget->add_widget("My tab", my_widget);
This commit is contained in:
parent
bbc02af090
commit
6c5100b644
8 changed files with 42 additions and 53 deletions
|
@ -52,7 +52,15 @@ public:
|
|||
int bar_height() const { return 21; }
|
||||
int container_padding() const { return 2; }
|
||||
|
||||
void add_widget(const StringView&, Widget*);
|
||||
void add_widget(const StringView&, Widget&);
|
||||
|
||||
template<class T, class... Args>
|
||||
inline NonnullRefPtr<T> add_tab(const StringView& title, Args&&... args)
|
||||
{
|
||||
auto t = T::construct(forward<Args>(args)...);
|
||||
add_widget(title, *t);
|
||||
return t;
|
||||
}
|
||||
|
||||
protected:
|
||||
TabWidget();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue