From f4073cfa0eefcbbc797a1ee7d40841cda0c5cee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 24 Oct 2025 01:18:38 +0200 Subject: [PATCH] Convert TouchControlVisibilityScreen to use Tabbed... --- UI/TouchControlVisibilityScreen.cpp | 40 ++++++++++++++--------------- UI/TouchControlVisibilityScreen.h | 12 +++++---- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 161f287b5a..bb04391d4f 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Common/UI/TabHolder.h" +#include "Common/System/Display.h" #include "Common/Render/TextureAtlas.h" #include "Common/Data/Text/I18n.h" #include "Common/StringUtils.h" @@ -44,32 +45,38 @@ private: UI::CheckBox *checkbox_; }; -void TouchControlVisibilityScreen::CreateViews() { +void TouchControlVisibilityScreen::CreateTabs() { + auto co = GetI18NCategory(I18NCat::CONTROLS); + + AddTab("Visibility", co->T("Visibility"), [this](UI::LinearLayout *contents) { + CreateVisibilityTab(contents); + }); +} + +void TouchControlVisibilityScreen::CreateVisibilityTab(UI::LinearLayout *vert) { using namespace UI; using namespace CustomKeyData; auto di = GetI18NCategory(I18NCat::DIALOG); auto co = GetI18NCategory(I18NCat::CONTROLS); - root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + const bool portrait = UsePortraitLayout(); - 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); 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, TabHolderFlags::Default, nullptr, new AnchorLayoutParams(10, 0, 10, 0, false)); - tabHolder->SetTag("TouchControlVisibility"); - root_->Add(tabHolder); - ScrollView *rightPanel = new ScrollView(ORIENT_VERTICAL); - tabHolder->AddTab(co->T("Visibility"), rightPanel); - - LinearLayout *vert = rightPanel->Add(new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT))); vert->SetSpacing(0); + vert->Add(toggleAll)->OnClick.Add([this](UI::EventParams &e) { + // TODO: Is this a meaningful operation to support? + for (auto toggle : toggles_) { + *toggle.show = nextToggleAll_; + } + nextToggleAll_ = !nextToggleAll_; + }); + vert->Add(new ItemHeader(co->T("Touch Control Visibility"))); - const int cellSize = 380; + const int cellSize = portrait ? std::min((g_display.dp_xres / 2 - 10), 290) : 380; UI::GridLayoutSettings gridsettings(cellSize, 64, 5); gridsettings.fillCells = true; @@ -170,13 +177,6 @@ void RightAnalogMappingScreen::CreateViews() { rightAnalogPress->SetEnabledPtr(&g_Config.bRightAnalogCustom); } -void TouchControlVisibilityScreen::OnToggleAll(UI::EventParams &e) { - for (auto toggle : toggles_) { - *toggle.show = nextToggleAll_; - } - nextToggleAll_ = !nextToggleAll_; -} - void CheckBoxChoice::HandleClick(UI::EventParams &e) { checkbox_->Toggle(); }; diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h index ff163c4a46..3bb5199844 100644 --- a/UI/TouchControlVisibilityScreen.h +++ b/UI/TouchControlVisibilityScreen.h @@ -18,7 +18,8 @@ #pragma once #include "Common/Render/TextureAtlas.h" -#include "MiscScreens.h" +#include "UI/MiscScreens.h" +#include "UI/TabbedDialogScreen.h" namespace UI { class CheckBox; @@ -31,16 +32,17 @@ struct TouchButtonToggle { std::function handle; }; -class TouchControlVisibilityScreen : public UIDialogScreenWithGameBackground { +class TouchControlVisibilityScreen : public TabbedUIDialogScreenWithGameBackground { public: - TouchControlVisibilityScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} - void CreateViews() override; + TouchControlVisibilityScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + void CreateTabs() override; void onFinish(DialogResult result) override; const char *tag() const override { return "TouchControlVisibility"; } protected: - void OnToggleAll(UI::EventParams &e); + bool ShowSearchControls() const override { return false; } + void CreateVisibilityTab(UI::LinearLayout *contents); private: std::vector toggles_;