summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TabWidget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-09 22:23:14 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-09 22:23:14 +0200
commitc8ff507534fba8ce22b140d0d9c516ca2271d17f (patch)
tree63bca0d8789a3f74578e4606eac6e726774c4f09 /Userland/Libraries/LibGUI/TabWidget.cpp
parent2aaf12e9cded2d73b023c735a37c9aff27e9fe3f (diff)
downloadserenity-c8ff507534fba8ce22b140d0d9c516ca2271d17f.zip
LibGUI: Add TabWidget::on_tab_count_change hook
Diffstat (limited to 'Userland/Libraries/LibGUI/TabWidget.cpp')
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp
index a5d2f000b3..6e680b38ff 100644
--- a/Userland/Libraries/LibGUI/TabWidget.cpp
+++ b/Userland/Libraries/LibGUI/TabWidget.cpp
@@ -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()