From 2d9ceb8ccf26453dd76bd138e2d90eafe700bc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 5 Nov 2025 00:15:05 +0100 Subject: [PATCH] Display layout: Add orientation indicator. Also, the stretch option was inconsistent between UI and actual application --- GPU/Common/PresentationCommon.cpp | 5 ++--- UI/DisplayLayoutScreen.cpp | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index d01df25f5f..cdfdd4a64e 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -108,9 +108,8 @@ void CalculateDisplayOutputRect(const DisplayLayoutConfig &config, FRect *rc, fl if (stretch) { // Automatically set aspect ratio to match the display, IF the rotation matches the output display ratio! Otherwise, just - // sets standard aspect ratio because actually stretching will just look silly. - bool globalRotated = g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270; - if (rotated == (g_display.dp_yres > g_display.dp_xres)) { + // ignore it because actually stretching will just look silly. + if (rotated == (g_display.GetDeviceOrientation() == DeviceOrientation::Portrait)) { origRatio = frameRatio; } else { origRatio *= aspectRatioAdjust; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index b58e5fba1d..4e407a7138 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -210,6 +210,12 @@ void DisplayLayoutScreen::CreateViews() { // impossible. root_->SetExclusiveTouch(true); + // Add indicator of the current mode we're editing. Not sure why these strings are in Controls. + root_->Add(new TextView(portrait ? co->T("Portrait") : co->T("Landscape"), new AnchorLayoutParams(portrait ? 10.0f : NONE, 10.0f, NONE, NONE))); + + DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()); + bool internalPortrait = config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180; + LinearLayout *leftColumn; if (!portrait) { ScrollView *leftScrollView = new ScrollView(ORIENT_VERTICAL, new AnchorLayoutParams(420.0f, FILL_PARENT, 0.f, 0.f, NONE, 0.f, false)); @@ -242,12 +248,14 @@ void DisplayLayoutScreen::CreateViews() { leftColumn->SetBG(backgroundWithAlpha); rightColumn->SetBG(backgroundWithAlpha); - DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()); if (!IsVREnabled()) { - - auto stretch = new CheckBox(&config.bDisplayStretch, gr->T("Stretch")); - stretch->SetDisabledPtr(&config.bDisplayIntegerScale); - rightColumn->Add(stretch); + if (portrait == internalPortrait) { + // Stretch doesn't make sense in portrait mode (looks crazy), so we only show it in landscape mode. + // Vice versa if internal is portrait. + auto stretch = new CheckBox(&config.bDisplayStretch, gr->T("Stretch")); + stretch->SetDisabledPtr(&config.bDisplayIntegerScale); + rightColumn->Add(stretch); + } PopupSliderChoiceFloat *aspectRatio = new PopupSliderChoiceFloat(&config.fDisplayAspectRatio, 0.1f, 2.0f, 1.0f, gr->T("Aspect Ratio"), screenManager()); rightColumn->Add(aspectRatio); @@ -282,6 +290,10 @@ void DisplayLayoutScreen::CreateViews() { static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" }; auto rotation = new PopupMultiChoice(&config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), I18NCat::CONTROLS, screenManager()); + rotation->OnChoice.Add([this](UI::EventParams &) { + // Affects the presence of the Stretch checkbox. + RecreateViews(); + }); rotation->SetEnabledFunc([] { return !g_Config.bSkipBufferEffects || g_Config.bSoftwareRendering; }); @@ -300,7 +312,7 @@ void DisplayLayoutScreen::CreateViews() { rightColumn->Add(new Spacer(12.0f)); } - Choice *back = new Choice(di->T("Back"), "", false); + Choice *back = new Choice(di->T("Back"), ImageID("I_NAVIGATE_BACK")); back->OnClick.Handle(this, &UIScreen::OnBack); rightColumn->Add(back);