android: Original Portrait Layout (#625)
Some checks are pending
citra-build / source (push) Waiting to run
citra-build / linux (appimage) (push) Waiting to run
citra-build / linux (fresh) (push) Waiting to run
citra-build / macos (arm64) (push) Waiting to run
citra-build / macos (x86_64) (push) Waiting to run
citra-build / macos-universal (push) Blocked by required conditions
citra-build / windows (msvc) (push) Waiting to run
citra-build / windows (msys2) (push) Waiting to run
citra-build / android (push) Waiting to run
citra-build / ios (push) Waiting to run
citra-format / clang-format (push) Waiting to run
citra-transifex / transifex (push) Waiting to run

* Original Portrait Layout

Original Portrait Layout

* type conversion fix for win

* Updated license headers

* Applied clang-format

* android: Reordered Portrait Screen Layout menu

Custom Layout is now at the bottom of the list

---------

Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
David Griswold 2025-04-11 14:23:07 -03:00 committed by GitHub
parent 89d2e67459
commit 8e477e35bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 54 additions and 9 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -41,7 +41,8 @@ enum class SmallScreenPosition(val int: Int) {
enum class PortraitScreenLayout(val int: Int) {
// These must match what is defined in src/common/settings.h
TOP_FULL_WIDTH(0),
CUSTOM_PORTRAIT_LAYOUT(1);
CUSTOM_PORTRAIT_LAYOUT(1),
ORIGINAL(2);
companion object {
fun from(int: Int): PortraitScreenLayout {

View file

@ -902,10 +902,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
val layoutOptionMenuItem = when (IntSetting.PORTRAIT_SCREEN_LAYOUT.int) {
PortraitScreenLayout.TOP_FULL_WIDTH.int ->
R.id.menu_portrait_layout_top_full
PortraitScreenLayout.ORIGINAL.int ->
R.id.menu_portrait_layout_original
PortraitScreenLayout.CUSTOM_PORTRAIT_LAYOUT.int ->
R.id.menu_portrait_layout_custom
else ->
R.id.menu_portrait_layout_top_full
@ -920,6 +920,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
true
}
R.id.menu_portrait_layout_original -> {
screenAdjustmentUtil.changePortraitOrientation(PortraitScreenLayout.ORIGINAL.int)
true
}
R.id.menu_portrait_layout_custom -> {
Toast.makeText(
requireContext(),

View file

@ -7,6 +7,10 @@
android:id="@+id/menu_portrait_layout_top_full"
android:title="@string/emulation_portrait_layout_top_full" />
<item
android:id="@+id/menu_portrait_layout_original"
android:title="@string/emulation_screen_layout_original" />
<item
android:id="@+id/menu_portrait_layout_custom"
android:title="@string/emulation_screen_layout_custom" />

View file

@ -31,11 +31,13 @@
<string-array name="portraitLayouts">
<item>@string/emulation_portrait_layout_top_full</item>
<item>@string/emulation_screen_layout_original</item>
<item>@string/emulation_screen_layout_custom</item>
</string-array>
<integer-array name="portraitLayoutValues">
<item>0</item>
<item>2</item>
<item>1</item>
</integer-array>

View file

@ -51,6 +51,7 @@ enum class PortraitLayoutOption : u32 {
// formerly mobile portrait
PortraitTopFullWidth,
PortraitCustomLayout,
PortraitOriginal
};
/** Defines where the small screen will appear relative to the large screen

View file

@ -221,6 +221,10 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
layout = Layout::CustomFrameLayout(
width, height, Settings::values.swap_screen.GetValue(), is_portrait_mode);
break;
case Settings::PortraitLayoutOption::PortraitOriginal:
layout = Layout::PortraitOriginalLayout(width, height,
Settings::values.swap_screen.GetValue());
break;
}
} else {
switch (layout_option) {

View file

@ -51,6 +51,18 @@ FramebufferLayout PortraitTopFullFrameLayout(u32 width, u32 height, bool swapped
return res;
}
FramebufferLayout PortraitOriginalLayout(u32 width, u32 height, bool swapped) {
ASSERT(width > 0);
ASSERT(height > 0);
const float scale_factor = 1;
FramebufferLayout res = LargeFrameLayout(width, height, swapped, false, scale_factor,
Settings::SmallScreenPosition::BelowLarge);
const int shiftY = -(int)(swapped ? res.bottom_screen.top : res.top_screen.top);
res.top_screen = res.top_screen.TranslateY(shiftY);
res.bottom_screen = res.bottom_screen.TranslateY(shiftY);
return res;
}
FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool swapped, bool upright) {
ASSERT(width > 0);
ASSERT(height > 0);
@ -346,7 +358,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary,
bool is_portrait) {
int width, height;
u32 width, height;
if (is_portrait) {
auto layout_option = Settings::values.portrait_layout_option.GetValue();
switch (layout_option) {
@ -363,9 +375,14 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar
Settings::values.swap_screen.GetValue(), is_portrait);
case Settings::PortraitLayoutOption::PortraitTopFullWidth:
width = Core::kScreenTopWidth * res_scale;
height = (Core::kScreenTopHeight + Core::kScreenBottomHeight) * res_scale;
height = static_cast<int>(Core::kScreenTopHeight + Core::kScreenBottomHeight * 1.25) *
res_scale;
return PortraitTopFullFrameLayout(width, height,
Settings::values.swap_screen.GetValue());
case Settings::PortraitLayoutOption::PortraitOriginal:
width = Core::kScreenTopWidth * res_scale;
height = (Core::kScreenTopHeight + Core::kScreenBottomHeight) * res_scale;
return PortraitOriginalLayout(width, height, Settings::values.swap_screen.GetValue());
}
} else {
auto layout_option = Settings::values.layout_option.GetValue();
@ -497,6 +514,7 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) {
if (is_portrait) {
switch (Settings::values.portrait_layout_option.GetValue()) {
case Settings::PortraitLayoutOption::PortraitTopFullWidth:
case Settings::PortraitLayoutOption::PortraitOriginal:
cardboard_screen_width = top_screen_width;
cardboard_screen_height = top_screen_height + bottom_screen_height;
bottom_screen_left += (top_screen_width - bottom_screen_width) / 2;

View file

@ -1,4 +1,4 @@
// Copyright 2016 Citra Emulator Project
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -62,8 +62,8 @@ FramebufferLayout reverseLayout(FramebufferLayout layout);
FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
/**
* Factory method for constructing the mobile Full Width Top layout
* Two screens at top, full width, no gap between them
* Factory method for constructing the mobile Full Width (Default) layout
* Two screens at top, full width (so different heights)
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be displayed above the top screen
@ -71,6 +71,16 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, boo
*/
FramebufferLayout PortraitTopFullFrameLayout(u32 width, u32 height, bool is_swapped);
/**
* Factory method for constructing the mobile Original layout
* Two screens at top, equal heights
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be displayed above the top screen
* @return Newly created FramebufferLayout object with mobile portrait screen regions initialized
*/
FramebufferLayout PortraitOriginalLayout(u32 width, u32 height, bool is_swapped);
/**
* Factory method for constructing a FramebufferLayout with only the top or bottom screen
* @param width Window framebuffer width in pixels