1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibGUI: Add TabWidget functions to activate next/previous tab

This commit is contained in:
Andreas Kling 2020-04-23 21:43:08 +02:00
parent 312501f309
commit 4087e3cfb9
2 changed files with 25 additions and 0 deletions

View file

@ -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);
}
}