1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +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:
Andreas Kling 2020-02-23 12:23:48 +01:00
parent bbc02af090
commit 6c5100b644
8 changed files with 42 additions and 53 deletions

View file

@ -41,10 +41,10 @@ TabWidget::~TabWidget()
{
}
void TabWidget::add_widget(const StringView& title, Widget* widget)
void TabWidget::add_widget(const StringView& title, Widget& widget)
{
m_tabs.append({ title, widget });
add_child(*widget);
m_tabs.append({ title, &widget });
add_child(widget);
}
void TabWidget::set_active_widget(Widget* widget)