From c91510039ef06e8a88ed09e9fa483d8fb67e9e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 25 Feb 2026 02:02:42 +0100 Subject: [PATCH] Code cleanup on mainscreen --- UI/MainScreen.cpp | 29 +++++++++++++++-------------- UI/MainScreen.h | 2 -- UI/RemoteISOScreen.cpp | 2 -- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index a4dee96819..2f2c089f3d 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1437,20 +1437,22 @@ void MainScreen::CreateViews() { rootLayout->Add(header); rootLayout->Add(leftColumn); root_ = rootLayout; + + // no space for a fullscreen button! } else { const Margins actionMenuMargins(0, 10, 10, 0); - ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(320, FILL_PARENT, actionMenuMargins)); LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); rightColumnItems->SetSpacing(0.0f); ViewGroup *logo = new LogoView(false, new LinearLayoutParams(FILL_PARENT, 80.0f)); #if !defined(MOBILE_DEVICE) auto gr = GetI18NCategory(I18NCat::GRAPHICS); ImageID icon(g_Config.bFullScreen ? "I_RESTORE" : "I_FULLSCREEN"); - fullscreenButton_ = logo->Add(new Button("", icon, new AnchorLayoutParams(48, 48, NONE, 0, 0, NONE, Centering::None))); - fullscreenButton_->SetIgnoreText(true); - fullscreenButton_->OnClick.Add([this](UI::EventParams &e) { - if (fullscreenButton_) { - fullscreenButton_->SetImageID(ImageID(!g_Config.bFullScreen ? "I_RESTORE" : "I_FULLSCREEN")); + UI::Button *fullscreenButton = logo->Add(new Button("", icon, new AnchorLayoutParams(48, 48, NONE, 0, 0, NONE, Centering::None))); + fullscreenButton->SetIgnoreText(true); + fullscreenButton->OnClick.Add([fullscreenButton](UI::EventParams &e) { + if (fullscreenButton) { + fullscreenButton->SetImageID(ImageID(!g_Config.bFullScreen ? "I_RESTORE" : "I_FULLSCREEN")); } g_Config.bFullScreen = !g_Config.bFullScreen; System_ApplyFullscreenState(); @@ -1476,28 +1478,27 @@ void MainScreen::CreateViews() { root_->SetTag("mainroot"); - upgradeBar_ = nullptr; if (!g_Config.sUpgradeMessage.empty()) { auto di = GetI18NCategory(I18NCat::DIALOG); Margins margins(0, 0); if (vertical) { margins.bottom = ITEM_HEIGHT; } - upgradeBar_ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, margins)); + UI::LinearLayout *upgradeBar = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, margins)); UI::Margins textMargins(10, 5); UI::Margins buttonMargins(5, 0); UI::Drawable solid(0xFFbd9939); - upgradeBar_->SetSpacing(5.0f); - upgradeBar_->SetBG(solid); + upgradeBar->SetSpacing(5.0f); + upgradeBar->SetBG(solid); std::string upgradeMessage(di->T("New version of PPSSPP available")); if (!vertical) { // The version only really fits in the horizontal layout. upgradeMessage += ": " + g_Config.sUpgradeVersion; } - upgradeBar_->Add(new TextView(upgradeMessage, new LinearLayoutParams(1.0f, UI::Gravity::G_VCENTER, textMargins))); - upgradeBar_->Add(new Choice(di->T("Download"), new LinearLayoutParams(buttonMargins)))->OnClick.Handle(this, &MainScreen::OnDownloadUpgrade); - Choice *dismiss = upgradeBar_->Add(new Choice("", ImageID("I_CROSS"), new LinearLayoutParams(buttonMargins))); + upgradeBar->Add(new TextView(upgradeMessage, new LinearLayoutParams(1.0f, UI::Gravity::G_VCENTER, textMargins))); + upgradeBar->Add(new Choice(di->T("Download"), new LinearLayoutParams(buttonMargins)))->OnClick.Handle(this, &MainScreen::OnDownloadUpgrade); + Choice *dismiss = upgradeBar->Add(new Choice("", ImageID("I_CROSS"), new LinearLayoutParams(buttonMargins))); dismiss->OnClick.Add([this](UI::EventParams &e) { g_Config.DismissUpgrade(); g_Config.Save("dismissupgrade"); @@ -1507,7 +1508,7 @@ void MainScreen::CreateViews() { // Slip in under root_ LinearLayout *newRoot = new LinearLayout(ORIENT_VERTICAL); newRoot->Add(root_); - newRoot->Add(upgradeBar_); + newRoot->Add(upgradeBar); root_->ReplaceLayoutParams(new LinearLayoutParams(1.0)); root_ = newRoot; } diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 7dd316a6c6..66673841a1 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -162,9 +162,7 @@ protected: void OnDownloadUpgrade(UI::EventParams &e); void OnAllowStorage(UI::EventParams &e); - UI::LinearLayout *upgradeBar_ = nullptr; UI::TabHolder *tabHolder_ = nullptr; - UI::Button *fullscreenButton_ = nullptr; Path restoreFocusGamePath_; std::vector gameBrowsers_; diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 8342e8af16..a4ce24d843 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -624,6 +624,4 @@ void RemoteISOBrowseScreen::CreateViews() { } root_->SetDefaultFocusView(tabHolder_); - - upgradeBar_ = 0; }