diff --git a/Common/Data/Encoding/Utf8.cpp b/Common/Data/Encoding/Utf8.cpp index a6324a78fc..3ec3fc6ac6 100644 --- a/Common/Data/Encoding/Utf8.cpp +++ b/Common/Data/Encoding/Utf8.cpp @@ -438,7 +438,7 @@ std::wstring ConvertUTF8ToWString(const std::string_view source) { std::wstring str; str.resize(size); if (size > 0) { - MultiByteToWideChar(CP_UTF8, 0, source.data(), source.size(), &str[0], size); + MultiByteToWideChar(CP_UTF8, 0, source.data(), (int)source.size(), &str[0], size); } return str; } diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 6e6afda28c..8a240c11df 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -14,6 +14,7 @@ #include "Common/UI/Tween.h" #include "Common/UI/Root.h" #include "Common/UI/View.h" +#include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "Common/Render/DrawBuffer.h" @@ -949,9 +950,13 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay tabScroll_->Add(tabStrip_); Add(tabScroll_); } else { - tabStrip_ = new ChoiceStrip(orientation, new LayoutParams(stripSize, WRAP_CONTENT)); + tabContainer_ = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(stripSize, FILL_PARENT)); + tabStrip_ = new ChoiceStrip(orientation, new LayoutParams(FILL_PARENT, FILL_PARENT)); tabStrip_->SetTopTabs(true); - Add(tabStrip_); + tabScroll_ = new ScrollView(orientation, new LinearLayoutParams(1.0f)); + tabScroll_->Add(tabStrip_); + tabContainer_->Add(tabScroll_); + Add(tabContainer_); } tabStrip_->OnChoice.Handle(this, &TabHolder::OnTabClick); @@ -959,6 +964,13 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay Add(contents_)->SetClip(true); } +void TabHolder::AddBack(UIScreen *parent) { + if (tabContainer_) { + auto di = GetI18NCategory(I18NCat::DIALOG); + tabContainer_->Add(new Choice(di->T("Back"), "", false, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 0.0f, Margins(0, 0, 10, 10))))->OnClick.Handle(parent, &UIScreen::OnBack); + } +} + void TabHolder::AddTabContents(const std::string &title, View *tabContents) { tabContents->ReplaceLayoutParams(new AnchorLayoutParams(FILL_PARENT, FILL_PARENT)); tabs_.push_back(tabContents); diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index 7d19525844..f20779d398 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -9,6 +9,8 @@ #include "Common/Input/GestureDetector.h" #include "Common/UI/View.h" +class UIScreen; + namespace UI { class AnchorTranslateTween; @@ -298,6 +300,8 @@ public: tabStrip_->EnableChoice(tab, enabled); } + void AddBack(UIScreen *parent); + void SetCurrentTab(int tab, bool skipTween = false); int GetCurrentTab() const { return currentTab_; } @@ -309,6 +313,7 @@ private: void AddTabContents(const std::string &title, View *tabContents); EventReturn OnTabClick(EventParams &e); + LinearLayout *tabContainer_ = nullptr; ChoiceStrip *tabStrip_ = nullptr; ScrollView *tabScroll_ = nullptr; AnchorLayout *contents_ = nullptr; diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 88a7fe8afe..87f27b9fba 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -49,8 +49,8 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() { root_->Add(verticalLayout); } else { tabHolder_ = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false)); + tabHolder_->AddBack(this); root_->Add(tabHolder_); - AddStandardBack(root_); } tabHolder_->SetTag(tag()); // take the tag from the screen. root_->SetDefaultFocusView(tabHolder_);