From 4dc4b9ef0285a9904c5dfbf83cc0fe487f7f54b8 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 10 Feb 2023 17:29:48 +0100 Subject: [PATCH] Made some improvements to the layout when running on a vertically oriented screen. --- es-app/src/guis/GuiAlternativeEmulators.cpp | 3 ++- .../src/guis/GuiCollectionSystemsOptions.cpp | 5 +--- es-app/src/guis/GuiMetaDataEd.cpp | 8 ++++-- es-app/src/guis/GuiOfflineGenerator.cpp | 26 ++++++++++++------- es-app/src/guis/GuiOfflineGenerator.h | 1 + es-app/src/views/ViewController.cpp | 12 ++++++--- es-core/src/components/ComponentList.cpp | 6 ++--- es-core/src/components/MenuComponent.cpp | 5 ++-- es-core/src/guis/GuiMsgBox.cpp | 22 ++++++++++------ es-core/src/guis/GuiMsgBox.h | 6 +++-- 10 files changed, 59 insertions(+), 35 deletions(-) diff --git a/es-app/src/guis/GuiAlternativeEmulators.cpp b/es-app/src/guis/GuiAlternativeEmulators.cpp index dc128bfd6..453bfb038 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.cpp +++ b/es-app/src/guis/GuiAlternativeEmulators.cpp @@ -203,7 +203,8 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system) // somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 // reference. float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; - float maxWidthModifier {glm::clamp(0.77f * aspectValue, 0.50f, 0.92f)}; + float maxWidthModifier {glm::clamp(0.77f * aspectValue, 0.50f, + (Renderer::getIsVerticalOrientation() ? 0.94f : 0.92f))}; float maxWidth {Renderer::getScreenWidth() * maxWidthModifier}; // Set the width of the selector window to the menu width, unless the system full name is diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index a3533469c..f632509aa 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -245,7 +245,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title) row.addElement(deleteCollection, true); row.addElement(bracketDeleteCollection, false); row.makeAcceptInputHandler([this, customSystems] { - auto ss = new GuiSettings("SELECT COLLECTION TO DELETE"); + auto ss = new GuiSettings("COLLECTION TO DELETE"); std::shared_ptr> customCollections { std::make_shared>(getHelpStyle(), "", true)}; for (std::map::const_iterator it = @@ -304,11 +304,8 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title) row.addElement(customCollection, true); ss->addRow(row); } - // Make the menu slightly wider to fit the scroll indicators. glm::vec2 menuSize {ss->getMenuSize()}; glm::vec3 menuPos {ss->getMenuPosition()}; - const float maxWidthModifier {mRenderer->getIsVerticalOrientation() ? 1.0f : 1.08f}; - ss->setMenuSize(glm::vec2 {menuSize.x * maxWidthModifier, menuSize.y}); menuPos.x = (mRenderer->getScreenWidth() - ss->getMenuSize().x) / 2.0f; ss->setMenuPosition(menuPos); mWindow->pushGui(ss); diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index a2cde562a..abee44a84 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -260,7 +260,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md, } const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; - const float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)}; + const float maxWidthModifier { + glm::clamp(0.64f * aspectValue, 0.42f, + (mRenderer->getIsVerticalOrientation() ? 0.95f : 0.92f))}; const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier}; s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); @@ -512,7 +514,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md, } const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; - const float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)}; + const float maxWidthModifier { + glm::clamp(0.64f * aspectValue, 0.42f, + (mRenderer->getIsVerticalOrientation() ? 0.95f : 0.92f))}; const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier}; s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); diff --git a/es-app/src/guis/GuiOfflineGenerator.cpp b/es-app/src/guis/GuiOfflineGenerator.cpp index de712f4d5..cfc4b941a 100644 --- a/es-app/src/guis/GuiOfflineGenerator.cpp +++ b/es-app/src/guis/GuiOfflineGenerator.cpp @@ -14,6 +14,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue& gameQueue) : mGameQueue {gameQueue} + , mRenderer {Renderer::getInstance()} , mBackground {":/graphics/frame.svg"} , mGrid {glm::ivec2 {6, 13}} { @@ -77,8 +78,10 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue& gameQueue) mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1}); // Skipping label. - mSkippedLbl = std::make_shared("Skipped (existing):", Font::get(FONT_SIZE_SMALL), - 0x888888FF, ALIGN_LEFT); + const std::string skipLabel {mRenderer->getIsVerticalOrientation() ? "Skipped:" : + "Skipped (existing):"}; + mSkippedLbl = std::make_shared(skipLabel, Font::get(FONT_SIZE_SMALL), 0x888888FF, + ALIGN_LEFT); mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); // Skipping value/counter. @@ -175,12 +178,13 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue& gameQueue) // For narrower displays (e.g. in 4:3 ratio), allow the window to fill 95% of the screen // width rather than the 85% allowed for wider displays. - float width {Renderer::getScreenWidth() * - ((Renderer::getScreenAspectRatio() < 1.4f) ? 0.95f : 0.85f)}; + float width {mRenderer->getScreenWidth() * + ((mRenderer->getScreenAspectRatio() < 1.4f) ? 0.95f : 0.85f)}; - setSize(width, Renderer::getScreenHeight() * 0.75f); - setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, - (Renderer::getScreenHeight() - mSize.y) / 2.0f); + setSize(width, + mRenderer->getScreenHeight() * (mRenderer->getIsVerticalOrientation() ? 0.52f : 0.75f)); + setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f, + (mRenderer->getScreenHeight() - mSize.y) / 2.0f); } GuiOfflineGenerator::~GuiOfflineGenerator() @@ -221,9 +225,11 @@ void GuiOfflineGenerator::onSizeChanged() // Adjust the width slightly depending on the aspect ratio of the screen to make sure // that the label does not get abbreviated. - if (Renderer::getScreenAspectRatio() <= 1.4f) - mGrid.setColWidthPerc(3, 0.13f); - else if (Renderer::getScreenAspectRatio() <= 1.6f) + if (mRenderer->getIsVerticalOrientation()) + mGrid.setColWidthPerc(3, 0.17f); + else if (mRenderer->getScreenAspectRatio() <= 1.4f) + mGrid.setColWidthPerc(3, 0.14f); + else if (mRenderer->getScreenAspectRatio() <= 1.6f) mGrid.setColWidthPerc(3, 0.12f); else mGrid.setColWidthPerc(3, 0.113f); diff --git a/es-app/src/guis/GuiOfflineGenerator.h b/es-app/src/guis/GuiOfflineGenerator.h index e62d245a9..ff65e2dfc 100644 --- a/es-app/src/guis/GuiOfflineGenerator.h +++ b/es-app/src/guis/GuiOfflineGenerator.h @@ -54,6 +54,7 @@ private: unsigned int mGamesSkipped; unsigned int mGamesFailed; + Renderer* mRenderer; NinePatchComponent mBackground; ComponentGrid mGrid; diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index b2b640f31..32e31a877 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -74,7 +74,10 @@ void ViewController::invalidSystemsFileDialog() quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, - "", nullptr, "", nullptr, true)); + "", nullptr, "", nullptr, true, true, + (mRenderer->getIsVerticalOrientation() ? + 0.85f : + 0.55f * (1.778f / mRenderer->getScreenAspectRatio())))); } void ViewController::noGamesDialog() @@ -120,7 +123,7 @@ void ViewController::noGamesDialog() "ROM DIRECTORY SETTING SAVED, RESTART\n" "THE APPLICATION TO RESCAN THE SYSTEMS", "OK", nullptr, "", nullptr, "", nullptr, - true)); + true, true)); }, false, "SAVE", "SAVE CHANGES?", "Currently configured path:", currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH", @@ -187,7 +190,10 @@ void ViewController::noGamesDialog() quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, - true, false); + true, false, + (mRenderer->getIsVerticalOrientation() ? + 0.90f : + 0.62f * (1.778f / mRenderer->getScreenAspectRatio()))); mWindow->pushGui(mNoGamesMessageBox); } diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 96e1b6f87..cedc136fe 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -412,13 +412,13 @@ void ComponentList::render(const glm::mat4& parentTrans) // Draw separators. float y {0.0f}; for (unsigned int i {0}; i < mEntries.size(); ++i) { - mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(), + mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenResolutionModifier(), 0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming); y += getRowHeight(mEntries.at(i).data); } - mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(), 0xC6C7C6FF, - 0xC6C7C6FF, false, mOpacity, mDimming); + mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenResolutionModifier(), + 0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming); mRenderer->popClipRect(); } diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index c47c8c431..fb9b197c4 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -112,8 +112,9 @@ void MenuComponent::updateSize() } } - float width { - std::min(mRenderer->getScreenHeight() * 1.05f, mRenderer->getScreenWidth() * 0.90f)}; + float width {std::min(mRenderer->getScreenHeight() * 1.05f, + mRenderer->getScreenWidth() * + (mRenderer->getIsVerticalOrientation() ? 0.94f : 0.90f))}; setSize(width, height); } diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 0077fcf95..497b92dc5 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -23,22 +23,26 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle, const std::function& func2, const std::string& name3, const std::function& func3, - bool disableBackButton, - bool deleteOnButtonPress) + const bool disableBackButton, + const bool deleteOnButtonPress, + const float maxWidthMultiplier) : mRenderer {Renderer::getInstance()} , mBackground {":/graphics/frame.svg"} , mGrid {glm::ivec2 {1, 2}} , mHelpStyle {helpstyle} , mDisableBackButton {disableBackButton} , mDeleteOnButtonPress {deleteOnButtonPress} + , mMaxWidthMultiplier {maxWidthMultiplier} { // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; - const float maxWidthMultiplier {mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f}; - float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, maxWidthMultiplier) * - mRenderer->getScreenWidth())}; + if (mMaxWidthMultiplier == 0.0f) + mMaxWidthMultiplier = mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f; + + float width {std::floor(glm::clamp(0.60f * aspectValue, 0.60f, mMaxWidthMultiplier) * + mRenderer->getScreenWidth())}; const float minWidth { floorf(glm::clamp(0.30f * aspectValue, 0.10f, 0.50f) * mRenderer->getScreenWidth())}; @@ -110,10 +114,12 @@ void GuiMsgBox::changeText(const std::string& newText) // Adjust the width depending on the aspect ratio of the screen, to make the screen look // somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 // reference. - float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; + const float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; - const float maxWidthMultiplier {mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f}; - float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, maxWidthMultiplier) * + if (mMaxWidthMultiplier == 0.0f) + mMaxWidthMultiplier = mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f; + + float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, mMaxWidthMultiplier) * mRenderer->getScreenWidth())}; const float minWidth {mRenderer->getScreenWidth() * 0.3f}; diff --git a/es-core/src/guis/GuiMsgBox.h b/es-core/src/guis/GuiMsgBox.h index a39451f0a..edf1a4938 100644 --- a/es-core/src/guis/GuiMsgBox.h +++ b/es-core/src/guis/GuiMsgBox.h @@ -28,8 +28,9 @@ public: const std::function& func2 = nullptr, const std::string& name3 = "", const std::function& func3 = nullptr, - bool disableBackButton = false, - bool deleteOnButtonPress = true); + const bool disableBackButton = false, + const bool deleteOnButtonPress = true, + const float maxWidthMultiplier = 0.0f); void changeText(const std::string& newText); @@ -53,6 +54,7 @@ private: std::function mAcceleratorFunc; bool mDisableBackButton; bool mDeleteOnButtonPress; + float mMaxWidthMultiplier; }; #endif // ES_CORE_GUIS_GUI_MSG_BOX_H