mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibGUI: Add TabWidget functions to activate next/previous tab
This commit is contained in:
parent
312501f309
commit
4087e3cfb9
2 changed files with 25 additions and 0 deletions
|
@ -273,4 +273,26 @@ void TabWidget::set_tab_title(Widget& tab, const StringView& title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabWidget::activate_next_tab()
|
||||||
|
{
|
||||||
|
if (m_tabs.size() <= 1)
|
||||||
|
return;
|
||||||
|
int index = active_tab_index();
|
||||||
|
++index;
|
||||||
|
if (index >= (int)m_tabs.size())
|
||||||
|
index = 0;
|
||||||
|
set_active_widget(m_tabs.at(index).widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabWidget::activate_previous_tab()
|
||||||
|
{
|
||||||
|
if (m_tabs.size() <= 1)
|
||||||
|
return;
|
||||||
|
int index = active_tab_index();
|
||||||
|
--index;
|
||||||
|
if (index < 0)
|
||||||
|
index = m_tabs.size() - 1;
|
||||||
|
set_active_widget(m_tabs.at(index).widget);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ public:
|
||||||
|
|
||||||
void set_tab_title(Widget& tab, const StringView& title);
|
void set_tab_title(Widget& tab, const StringView& title);
|
||||||
|
|
||||||
|
void activate_next_tab();
|
||||||
|
void activate_previous_tab();
|
||||||
|
|
||||||
Function<void(Widget&)> on_change;
|
Function<void(Widget&)> on_change;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue