mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibGUI: Add TabWidget::on_tab_count_change hook
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
void set_bar_visible(bool bar_visible);
|
||||
bool is_bar_visible() const { return m_bar_visible; };
|
||||
|
||||
Function<void(size_t)> on_tab_count_change;
|
||||
Function<void(Widget&)> on_change;
|
||||
Function<void(Widget&)> on_middle_click;
|
||||
Function<void(Widget&, const ContextMenuEvent&)> on_context_menu_request;
|
||||
|
||||
Reference in New Issue
Block a user