Add support for changing the tab labels

This commit is contained in:
Magnus Norddahl 2024-01-10 23:28:26 +01:00 committed by Christoph Oelckers
parent 53c6002746
commit 63f1326e62
3 changed files with 46 additions and 0 deletions

View file

@ -21,6 +21,11 @@ public:
int AddTab(Widget* page, const std::string& label);
int AddTab(Widget* page, const std::shared_ptr<Image>& icon, const std::string& label);
void SetTabText(int index, const std::string& text);
void SetTabText(Widget* page, const std::string& text);
void SetTabIcon(int index, const std::shared_ptr<Image>& icon);
void SetTabIcon(Widget* page, const std::shared_ptr<Image>& icon);
int GetCurrentIndex() const;
Widget* GetCurrentWidget() const;
@ -51,6 +56,9 @@ public:
int AddTab(const std::string& label);
int AddTab(const std::shared_ptr<Image>& icon, const std::string& label);
void SetTabText(int index, const std::string& text);
void SetTabIcon(int index, const std::shared_ptr<Image>& icon);
int GetCurrentIndex() const;
void SetCurrentIndex(int pageIndex);

View file

@ -30,6 +30,30 @@ int TabWidget::AddTab(Widget* page, const std::shared_ptr<Image>& icon, const st
return pageIndex;
}
void TabWidget::SetTabText(int index, const std::string& text)
{
Bar->SetTabText(index, text);
}
void TabWidget::SetTabText(Widget* page, const std::string& text)
{
int index = GetPageIndex(page);
if (index != -1)
SetTabText(index, text);
}
void TabWidget::SetTabIcon(int index, const std::shared_ptr<Image>& icon)
{
Bar->SetTabIcon(index, icon);
}
void TabWidget::SetTabIcon(Widget* page, const std::shared_ptr<Image>& icon)
{
int index = GetPageIndex(page);
if (index != -1)
SetTabIcon(index, icon);
}
int TabWidget::GetCurrentIndex() const
{
return Bar->GetCurrentIndex();
@ -113,6 +137,18 @@ int TabBar::AddTab(const std::shared_ptr<Image>& icon, const std::string& label)
return pageIndex;
}
void TabBar::SetTabText(int index, const std::string& text)
{
Tabs[index]->SetText(text);
OnGeometryChanged();
}
void TabBar::SetTabIcon(int index, const std::shared_ptr<Image>& icon)
{
Tabs[index]->SetIcon(icon);
OnGeometryChanged();
}
int TabBar::GetCurrentIndex() const
{
return CurrentIndex;

View file

@ -72,6 +72,8 @@ void LauncherWindow::Exit()
void LauncherWindow::UpdateLanguage()
{
// Pages->SetTabText(PlayGame, GStrings("PICKER_TAB_PLAY"));
// Pages->SetTabText(Settings, GStrings("PICKER_TAB_SETTINGS"));
Banner->UpdateLanguage();
PlayGame->UpdateLanguage();
Settings->UpdateLanguage();