Split the display layout config between landscape and portrait orientations

This commit is contained in:
Henrik Rydgård committed 2025-10-31 10:43:44 +01:00
1 parent 174d45279c
commit 4994246c8b
61 files changed
+482 -317

No files matched your search

+9 -8
View File
@@ -16,17 +16,18 @@
static const bool ClickDebug = false;
UIScreen::UIScreen()
: Screen() {
lastPortrait_ = UsePortraitLayout();
UIScreen::UIScreen() : Screen() {
lastOrientation_ = GetDeviceOrientation();
}
UIScreen::~UIScreen() {
delete root_;
}
bool UIScreen::UsePortraitLayout() const {
return g_display.dp_yres > g_display.dp_xres * 1.1f;
// This is the source of truth for orientation for configuration and rendering.
DeviceOrientation UIScreen::GetDeviceOrientation() const {
// TODO: On some platforms, we can do a more sophisticated check.
return g_display.GetDeviceOrientation();
}
void UIScreen::DoRecreateViews() {
@@ -140,10 +141,10 @@ bool UIScreen::UnsyncKey(const KeyInput &key) {
}
void UIScreen::update() {
bool portrait = UsePortraitLayout();
if (portrait != lastPortrait_) {
DeviceOrientation orientation = GetDeviceOrientation();
if (orientation != lastOrientation_) {
RecreateViews();
lastPortrait_ = portrait;
lastOrientation_ = orientation;
}
DoRecreateViews();