1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:28:12 +00:00

LibGUI: Fully support TabWidget in GML

TabWidgets couldn't be used in GML properly, as the GML creation
routines didn't actually call the necessary functions in the TabWidget
to get a new tab added. This commit fixes that by making the name of the
tab a normal property, the previously introduced "title", which can be
trivially set from GML. Therefore, try_add_widget() loses an argument
(while try_add_tab doesn't, because it newly constructs the widget).
This allows us to get rid of the silly "fixing my widget tree after the
fact" code in Help and will make it super easy to use TabWidget in
future GML. :^)
This commit is contained in:
kleines Filmröllchen 2022-03-18 22:57:05 +01:00 committed by Andreas Kling
parent 0410414455
commit 7e34b88ed4
7 changed files with 34 additions and 17 deletions

View file

@ -41,9 +41,9 @@ TabWidget::TabWidget()
});
}
ErrorOr<void> TabWidget::try_add_widget(String title, Widget& widget)
ErrorOr<void> TabWidget::try_add_widget(Widget& widget)
{
m_tabs.append({ move(title), nullptr, &widget });
m_tabs.append({ widget.title(), nullptr, &widget });
add_child(widget);
update_focus_policy();
if (on_tab_count_change)
@ -51,9 +51,9 @@ ErrorOr<void> TabWidget::try_add_widget(String title, Widget& widget)
return {};
}
void TabWidget::add_widget(String title, Widget& widget)
void TabWidget::add_widget(Widget& widget)
{
MUST(try_add_widget(move(title), widget));
MUST(try_add_widget(widget));
}
void TabWidget::remove_widget(Widget& widget)