mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibGUI: Add TabWidget::on_tab_count_change hook
This commit is contained in:
parent
2aaf12e9cd
commit
c8ff507534
Notes:
sideshowbarker
2024-07-18 20:36:56 +09:00
Author: https://github.com/awesomekling
Commit: c8ff507534
2 changed files with 6 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue