diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-09 22:23:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-09 22:23:14 +0200 |
commit | c8ff507534fba8ce22b140d0d9c516ca2271d17f (patch) | |
tree | 63bca0d8789a3f74578e4606eac6e726774c4f09 /Userland/Libraries/LibGUI/TabWidget.cpp | |
parent | 2aaf12e9cded2d73b023c735a37c9aff27e9fe3f (diff) | |
download | serenity-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.cpp | 5 |
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() |