From 4217f910f6863978863379d6ec3c9cd1e631d331 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 29 Jul 2023 11:31:36 +0200 Subject: [PATCH] Improved the layout for the scraper and theme downloader to look more consistent across different display aspect ratios --- es-app/src/guis/GuiScraperMulti.cpp | 8 +++---- es-app/src/guis/GuiScraperSearch.cpp | 10 ++++++--- es-app/src/guis/GuiScraperSearch.h | 3 ++- es-app/src/guis/GuiScraperSingle.cpp | 2 +- es-app/src/guis/GuiThemeDownloader.cpp | 31 +++++++++++--------------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 3447bf3e8..53930df81 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -62,13 +62,13 @@ GuiScraperMulti::GuiScraperMulti( if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = - std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames); + std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames, 7); else if (mApproveResults && Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = std::make_shared(GuiScraperSearch::ACCEPT_SINGLE_MATCHES, - mTotalGames); + mTotalGames, 7); else if (!mApproveResults) mSearchComp = std::make_shared( - GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames); + GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames, 7); mSearchComp->setAcceptCallback( std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); @@ -162,7 +162,7 @@ GuiScraperMulti::GuiScraperMulti( float height {(mTitle->getFont()->getLetterHeight() + titleHeight) + mSystem->getFont()->getLetterHeight() + - mSubtitle->getFont()->getHeight() * 1.75f + mButtonGrid->getSize().y + + mSubtitle->getFont()->getHeight() * 1.75f + (mButtonGrid->getSize().y * 1.1f) + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 7.0f}; // TODO: Temporary hack, see below. diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 5cfc1d94d..905696035 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -34,10 +34,11 @@ #include "resources/Font.h" #include "utils/StringUtil.h" -GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount) +GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount, int rowCount) : mRenderer {Renderer::getInstance()} , mGrid {glm::ivec2 {5, 3}} , mSearchType {type} + , mRowCount {rowCount} , mScrapeCount {scrapeCount} , mRefinedSearch {false} , mBlockAccept {false} @@ -176,7 +177,7 @@ GuiScraperSearch::~GuiScraperSearch() void GuiScraperSearch::onSizeChanged() { - mGrid.setSize(mSize); + mGrid.setSize(glm::vec2 {mSize.x, (mResultList->getRowHeight() * mRowCount) + 0.0f}); if (mSize.x == 0 || mSize.y == 0) return; @@ -652,7 +653,10 @@ void GuiScraperSearch::render(const glm::mat4& parentTrans) glm::mat4 trans {parentTrans * getTransform()}; renderChildren(trans); - mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, mMenuColorPanelDimmed, mMenuColorPanelDimmed); + mRenderer->drawRect(0.0f, 0.0f, mSize.x, + (mResultList->getRowHeight() * mRowCount) + + mRenderer->getScreenHeightModifier(), + mMenuColorPanelDimmed, mMenuColorPanelDimmed); // Slight adjustment upwards so the busy grid is not rendered precisely at the text edge. trans = glm::translate( diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 3e7340f69..a92862daa 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -42,7 +42,7 @@ public: NEVER_AUTO_ACCEPT // Manual mode. }; - GuiScraperSearch(SearchType searchType, unsigned int scrapeCount = 1); + GuiScraperSearch(SearchType searchType, unsigned int scrapeCount, int rowCount); ~GuiScraperSearch(); void search(ScraperSearchParams& params); @@ -164,6 +164,7 @@ private: std::function mSkipCallback; std::function mCancelCallback; std::function mRefineCallback; + int mRowCount; unsigned int mScrapeCount; bool mRefinedSearch; bool mBlockAccept; diff --git a/es-app/src/guis/GuiScraperSingle.cpp b/es-app/src/guis/GuiScraperSingle.cpp index e9858bce9..a696851ca 100644 --- a/es-app/src/guis/GuiScraperSingle.cpp +++ b/es-app/src/guis/GuiScraperSingle.cpp @@ -60,7 +60,7 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params, // Row 3 is a spacer. // GuiScraperSearch. - mSearch = std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); + mSearch = std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, 1, 8); mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); mResultList = mSearch->getResultList(); diff --git a/es-app/src/guis/GuiThemeDownloader.cpp b/es-app/src/guis/GuiThemeDownloader.cpp index b6a34f900..c3a03c7e3 100644 --- a/es-app/src/guis/GuiThemeDownloader.cpp +++ b/es-app/src/guis/GuiThemeDownloader.cpp @@ -131,11 +131,9 @@ GuiThemeDownloader::GuiThemeDownloader(std::function updateCallback) // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. const float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; - const float width {glm::clamp(0.95f * aspectValue, 0.65f, 0.98f) * mRenderer->getScreenWidth()}; + const float width {glm::clamp(0.95f * aspectValue, 0.45f, 0.98f) * mRenderer->getScreenWidth()}; setSize(width, - mTitle->getSize().y + - (FONT_SIZE_MEDIUM * 1.5f * (mRenderer->getIsVerticalOrientation() ? 10.0f : 9.0f)) + - mButtons->getSize().y); + mTitle->getSize().y + (mList->getRowHeight() * 9.0f) + mButtons->getSize().y * 1.1f); setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f, (mRenderer->getScreenHeight() - mSize.y) / 2.0f); @@ -821,8 +819,7 @@ void GuiThemeDownloader::populateGUI() } mVariantsLabel->setText("VARIANTS:"); - mColorSchemesLabel->setText(mRenderer->getIsVerticalOrientation() ? "COL. SCHEMES:" : - "COLOR SCHEMES:"); + mColorSchemesLabel->setText("COLOR SCHEMES:"); mAspectRatiosLabel->setText("ASPECT RATIOS:"); updateInfoPane(); @@ -1069,22 +1066,20 @@ void GuiThemeDownloader::onSizeChanged() 4.0f); mGrid.setRowHeightPerc(1, (mTitle->getFont()->getLetterHeight() + screenSize * 0.2f) / mSize.y / 4.0f); - mGrid.setRowHeightPerc(3, mButtons->getSize().y / mSize.y); + mGrid.setRowHeightPerc(2, (mList->getRowHeight() * 9.0f) / mSize.y); mCenterGrid->setRowHeightPerc( - 0, (mVariantsLabel->getFont()->getLetterHeight() + screenSize * 0.08f) / mSize.y / 2.0f); + 0, (mVariantsLabel->getFont()->getLetterHeight() + screenSize * 0.115f) / mSize.y / 2.0f); mCenterGrid->setRowHeightPerc( 1, - (mColorSchemesLabel->getFont()->getLetterHeight() + screenSize * 0.06f) / mSize.y / 2.0f); + (mColorSchemesLabel->getFont()->getLetterHeight() + screenSize * 0.09f) / mSize.y / 2.0f); mCenterGrid->setRowHeightPerc( - 2, (mDownloadStatus->getFont()->getLetterHeight() + screenSize * 0.08f) / mSize.y / 2.0f); - mCenterGrid->setRowHeightPerc(3, 0.5f); - mCenterGrid->setRowHeightPerc(4, (mAuthor->getFont()->getLetterHeight() + screenSize * 0.06f) / - mSize.y / 2.0f); + 2, (mDownloadStatus->getFont()->getLetterHeight() + screenSize * 0.115f) / mSize.y / 2.0f); + mCenterGrid->setRowHeightPerc(3, 0.7f); mGrid.setColWidthPerc(1, 0.04f); mCenterGrid->setColWidthPerc(0, 0.01f); - mCenterGrid->setColWidthPerc(1, 0.18f); + mCenterGrid->setColWidthPerc(1, (mRenderer->getScreenAspectRatio() < 1.6f ? 0.21f : 0.18f)); mCenterGrid->setColWidthPerc(2, 0.05f); mCenterGrid->setColWidthPerc(3, 0.18f); mCenterGrid->setColWidthPerc(4, 0.04f); @@ -1092,7 +1087,9 @@ void GuiThemeDownloader::onSizeChanged() mCenterGrid->setColWidthPerc(7, 0.04f); mGrid.setSize(mSize); - mCenterGrid->setSize(glm::vec2 {mSize.x, mSize.y}); + + mCenterGrid->setSize(glm::vec2 {std::round(mSize.x), (mList->getRowHeight() * 9.0f) + + mRenderer->getScreenHeightModifier()}); mCenterGrid->setPosition(glm::vec3 {0.0f, mGrid.getRowHeight(0) + mGrid.getRowHeight(1), 0.0f}); mBackground.fitTo(mSize); mScreenshot->setMaxSize(mCenterGrid->getColWidth(1) + mCenterGrid->getColWidth(2) + @@ -1103,9 +1100,7 @@ void GuiThemeDownloader::onSizeChanged() mGrayRectangleCoords.emplace_back(0.0f); mGrayRectangleCoords.emplace_back(mCenterGrid->getPosition().y); mGrayRectangleCoords.emplace_back(mSize.x); - mGrayRectangleCoords.emplace_back(mCenterGrid->getRowHeight(0) + mCenterGrid->getRowHeight(1) + - mCenterGrid->getRowHeight(2) + mCenterGrid->getRowHeight(3) + - mCenterGrid->getRowHeight(4)); + mGrayRectangleCoords.emplace_back(mList->getRowHeight() * 9.0f); } bool GuiThemeDownloader::input(InputConfig* config, Input input)