mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:07:45 +00:00
LibGUI: Add TabWidget::on_tab_count_change hook
This commit is contained in:
parent
2aaf12e9cd
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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue