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

LibGUI: Add TabWidget::on_tab_count_change hook

This commit is contained in:
Andreas Kling 2021-04-09 22:23:14 +02:00
parent 2aaf12e9cd
commit c8ff507534
2 changed files with 6 additions and 0 deletions

View file

@ -68,15 +68,20 @@ void TabWidget::add_widget(const StringView& title, Widget& widget)
m_tabs.append({ title, nullptr, &widget });
add_child(widget);
update_focus_policy();
if (on_tab_count_change)
on_tab_count_change(m_tabs.size());
}
void TabWidget::remove_widget(Widget& widget)
{
VERIFY(widget.parent() == this);
if (active_widget() == &widget)
activate_next_tab();
m_tabs.remove_first_matching([&widget](auto& entry) { return &widget == entry.widget; });
remove_child(widget);
update_focus_policy();
if (on_tab_count_change)
on_tab_count_change(m_tabs.size());
}
void TabWidget::update_focus_policy()