From 0ba92081ed112c9cf0bc7d642efda0244d663b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Mar 2025 21:16:31 +0100 Subject: [PATCH] Add banner support to tab holders --- Common/UI/ViewGroup.cpp | 12 +++++++++--- Common/UI/ViewGroup.h | 5 +++-- UI/DevScreens.cpp | 4 ++-- UI/GPUDriverTestScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- UI/MainScreen.cpp | 4 ++-- UI/RemoteISOScreen.cpp | 2 +- UI/TabbedDialogScreen.cpp | 4 ++-- UI/TouchControlVisibilityScreen.cpp | 4 ++-- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index e6270e7606..59288e98bf 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -957,7 +957,7 @@ std::string GridLayoutList::DescribeText() const { return DescribeListOrdered(u->T("List:")); } -TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *layoutParams) +TabHolder::TabHolder(Orientation orientation, float stripSize, View *bannerView, LayoutParams *layoutParams) : LinearLayout(Opposite(orientation), layoutParams) { SetSpacing(0.0f); if (orientation == ORIENT_HORIZONTAL) { @@ -979,8 +979,14 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay Add(new Spacer(4.0f))->SetSeparator(); - contents_ = new AnchorLayout(new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f)); - Add(contents_)->SetClip(true); + ViewGroup *contentHolder_ = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f)); + if (bannerView) { + contentHolder_->Add(bannerView); + bannerView_ = bannerView; + } + contents_ = contentHolder_->Add(new AnchorLayout(new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f))); + contents_->SetClip(true); + Add(contentHolder_); } void TabHolder::AddBack(UIScreen *parent) { diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index 8890f85710..bfd2dd61e7 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -291,7 +291,7 @@ private: class TabHolder : public LinearLayout { public: - TabHolder(Orientation orientation, float stripSize, LayoutParams *layoutParams = 0); + TabHolder(Orientation orientation, float stripSize, View *bannerView, LayoutParams *layoutParams = 0); template T *AddTab(std::string_view title, T *tabContents) { @@ -317,10 +317,11 @@ private: void AddTabContents(std::string_view title, View *tabContents); EventReturn OnTabClick(EventParams &e); + View *bannerView_ = nullptr; LinearLayout *tabContainer_ = nullptr; ChoiceStrip *tabStrip_ = nullptr; ScrollView *tabScroll_ = nullptr; - AnchorLayout *contents_ = nullptr; + ViewGroup *contents_ = nullptr; int currentTab_ = 0; std::vector tabs_; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index d822642e69..23d39ef3eb 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -1007,7 +1007,7 @@ void ShaderListScreen::CreateViews() { LinearLayout *layout = new LinearLayout(ORIENT_VERTICAL); root_ = layout; - tabs_ = new TabHolder(ORIENT_HORIZONTAL, 40, new LinearLayoutParams(1.0)); + tabs_ = new TabHolder(ORIENT_HORIZONTAL, 40, nullptr, new LinearLayoutParams(1.0)); tabs_->SetTag("DevShaderList"); layout->Add(tabs_); layout->Add(new Button(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); @@ -1083,7 +1083,7 @@ void FrameDumpTestScreen::CreateViews() { auto di = GetI18NCategory(I18NCat::DIALOG); TabHolder *tabHolder; - tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false)); + tabHolder = new TabHolder(ORIENT_VERTICAL, 200, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false)); root_->Add(tabHolder); AddStandardBack(root_); tabHolder->SetTag("DumpTypes"); diff --git a/UI/GPUDriverTestScreen.cpp b/UI/GPUDriverTestScreen.cpp index 694a28bb13..e5e7f5b8a9 100644 --- a/UI/GPUDriverTestScreen.cpp +++ b/UI/GPUDriverTestScreen.cpp @@ -301,7 +301,7 @@ void GPUDriverTestScreen::CreateViews() { AnchorLayout *anchor = new AnchorLayout(); root_ = anchor; - tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 30.0f, new AnchorLayoutParams(FILL_PARENT, FILL_PARENT, false)); + tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 30.0f, nullptr, new AnchorLayoutParams(FILL_PARENT, FILL_PARENT, false)); anchor->Add(tabHolder_); tabHolder_->AddTab("Discard", new LinearLayout(ORIENT_VERTICAL)); tabHolder_->AddTab("Shader", new LinearLayout(ORIENT_VERTICAL)); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index ce94fe7dcd..e96aa06bc1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -2538,7 +2538,7 @@ void GestureMappingScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); AddStandardBack(root_); - TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false)); + TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false)); root_->Add(tabHolder); ScrollView *rightPanel = new ScrollView(ORIENT_VERTICAL); tabHolder->AddTab(co->T("Gesture"), rightPanel); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 1dc7f1c61b..c4a4f00ca3 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1105,7 +1105,7 @@ void MainScreen::CreateViews() { auto mm = GetI18NCategory(I18NCat::MAINMENU); - tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)); + tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 64, nullptr, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)); ViewGroup *leftColumn = tabHolder_; tabHolder_->SetTag("MainScreenGames"); gameBrowsers_.clear(); @@ -1653,7 +1653,7 @@ void UmdReplaceScreen::CreateViews() { auto mm = GetI18NCategory(I18NCat::MAINMENU); auto di = GetI18NCategory(I18NCat::DIALOG); - TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0)); + TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, nullptr, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0)); leftColumn->SetTag("UmdReplace"); leftColumn->SetClip(true); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index c0209c83b4..702de9f37f 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -592,7 +592,7 @@ void RemoteISOBrowseScreen::CreateViews() { bool vertical = UseVerticalLayout(); - TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, nullptr, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); tabHolder_ = leftColumn; tabHolder_->SetTag("RemoteGames"); gameBrowsers_.clear(); diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 134ffb965f..98005e0a9a 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -43,13 +43,13 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() { if (vertical) { auto di = GetI18NCategory(I18NCat::DIALOG); LinearLayout *verticalLayout = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); - tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, new LinearLayoutParams(1.0f)); + tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, nullptr, new LinearLayoutParams(1.0f)); verticalLayout->Add(tabHolder_); CreateExtraButtons(verticalLayout, 0); verticalLayout->Add(new Choice(di->T("Back"), "", false, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 0.0f, Margins(0))))->OnClick.Handle(this, &UIScreen::OnBack); root_->Add(verticalLayout); } else { - tabHolder_ = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false)); + tabHolder_ = new TabHolder(ORIENT_VERTICAL, 200, new TextView("I am a banner"), new AnchorLayoutParams(10, 0, 10, 0, false)); CreateExtraButtons(tabHolder_->Container(), 10); tabHolder_->AddBack(this); root_->Add(tabHolder_); diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 34b8c620b5..87f448b96a 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -57,7 +57,7 @@ void TouchControlVisibilityScreen::CreateViews() { Choice *toggleAll = new Choice(di->T("Toggle All"), "", false, new AnchorLayoutParams(leftColumnWidth - 10, WRAP_CONTENT, 10, NONE, NONE, 84)); root_->Add(toggleAll)->OnClick.Handle(this, &TouchControlVisibilityScreen::OnToggleAll); - TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, new AnchorLayoutParams(10, 0, 10, 0, false)); + TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false)); tabHolder->SetTag("TouchControlVisibility"); root_->Add(tabHolder); ScrollView *rightPanel = new ScrollView(ORIENT_VERTICAL); @@ -144,7 +144,7 @@ void RightAnalogMappingScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth - 10, WRAP_CONTENT, 10, NONE, NONE, 10)); root_->Add(back)->OnClick.Handle(this, &UIScreen::OnBack); - TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, new AnchorLayoutParams(10, 0, 10, 0, false)); + TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, leftColumnWidth, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false)); root_->Add(tabHolder); ScrollView *rightPanel = new ScrollView(ORIENT_VERTICAL); tabHolder->AddTab(co->T("Binds"), rightPanel);