Made some improvements to the layout when running on a vertically oriented screen.

This commit is contained in:
Leon Styhre 2023-02-10 17:29:48 +01:00
parent e663a717f0
commit 4dc4b9ef02
10 changed files with 59 additions and 35 deletions

View file

@ -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 // somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9
// reference. // reference.
float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; 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}; float maxWidth {Renderer::getScreenWidth() * maxWidthModifier};
// Set the width of the selector window to the menu width, unless the system full name is // Set the width of the selector window to the menu width, unless the system full name is

View file

@ -245,7 +245,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
row.addElement(deleteCollection, true); row.addElement(deleteCollection, true);
row.addElement(bracketDeleteCollection, false); row.addElement(bracketDeleteCollection, false);
row.makeAcceptInputHandler([this, customSystems] { row.makeAcceptInputHandler([this, customSystems] {
auto ss = new GuiSettings("SELECT COLLECTION TO DELETE"); auto ss = new GuiSettings("COLLECTION TO DELETE");
std::shared_ptr<OptionListComponent<std::string>> customCollections { std::shared_ptr<OptionListComponent<std::string>> customCollections {
std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "", true)}; std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "", true)};
for (std::map<std::string, CollectionSystemData, StringComparator>::const_iterator it = for (std::map<std::string, CollectionSystemData, StringComparator>::const_iterator it =
@ -304,11 +304,8 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
row.addElement(customCollection, true); row.addElement(customCollection, true);
ss->addRow(row); ss->addRow(row);
} }
// Make the menu slightly wider to fit the scroll indicators.
glm::vec2 menuSize {ss->getMenuSize()}; glm::vec2 menuSize {ss->getMenuSize()};
glm::vec3 menuPos {ss->getMenuPosition()}; 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; menuPos.x = (mRenderer->getScreenWidth() - ss->getMenuSize().x) / 2.0f;
ss->setMenuPosition(menuPos); ss->setMenuPosition(menuPos);
mWindow->pushGui(ss); mWindow->pushGui(ss);

View file

@ -260,7 +260,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
} }
const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; 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}; const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier};
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); 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 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}; const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier};
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});

View file

@ -14,6 +14,7 @@
GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue) GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
: mGameQueue {gameQueue} : mGameQueue {gameQueue}
, mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"} , mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {6, 13}} , mGrid {glm::ivec2 {6, 13}}
{ {
@ -77,8 +78,10 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1});
// Skipping label. // Skipping label.
mSkippedLbl = std::make_shared<TextComponent>("Skipped (existing):", Font::get(FONT_SIZE_SMALL), const std::string skipLabel {mRenderer->getIsVerticalOrientation() ? "Skipped:" :
0x888888FF, ALIGN_LEFT); "Skipped (existing):"};
mSkippedLbl = std::make_shared<TextComponent>(skipLabel, Font::get(FONT_SIZE_SMALL), 0x888888FF,
ALIGN_LEFT);
mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
// Skipping value/counter. // Skipping value/counter.
@ -175,12 +178,13 @@ GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
// For narrower displays (e.g. in 4:3 ratio), allow the window to fill 95% of the screen // 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. // width rather than the 85% allowed for wider displays.
float width {Renderer::getScreenWidth() * float width {mRenderer->getScreenWidth() *
((Renderer::getScreenAspectRatio() < 1.4f) ? 0.95f : 0.85f)}; ((mRenderer->getScreenAspectRatio() < 1.4f) ? 0.95f : 0.85f)};
setSize(width, Renderer::getScreenHeight() * 0.75f); setSize(width,
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, mRenderer->getScreenHeight() * (mRenderer->getIsVerticalOrientation() ? 0.52f : 0.75f));
(Renderer::getScreenHeight() - mSize.y) / 2.0f); setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
} }
GuiOfflineGenerator::~GuiOfflineGenerator() GuiOfflineGenerator::~GuiOfflineGenerator()
@ -221,9 +225,11 @@ void GuiOfflineGenerator::onSizeChanged()
// Adjust the width slightly depending on the aspect ratio of the screen to make sure // Adjust the width slightly depending on the aspect ratio of the screen to make sure
// that the label does not get abbreviated. // that the label does not get abbreviated.
if (Renderer::getScreenAspectRatio() <= 1.4f) if (mRenderer->getIsVerticalOrientation())
mGrid.setColWidthPerc(3, 0.13f); mGrid.setColWidthPerc(3, 0.17f);
else if (Renderer::getScreenAspectRatio() <= 1.6f) else if (mRenderer->getScreenAspectRatio() <= 1.4f)
mGrid.setColWidthPerc(3, 0.14f);
else if (mRenderer->getScreenAspectRatio() <= 1.6f)
mGrid.setColWidthPerc(3, 0.12f); mGrid.setColWidthPerc(3, 0.12f);
else else
mGrid.setColWidthPerc(3, 0.113f); mGrid.setColWidthPerc(3, 0.113f);

View file

@ -54,6 +54,7 @@ private:
unsigned int mGamesSkipped; unsigned int mGamesSkipped;
unsigned int mGamesFailed; unsigned int mGamesFailed;
Renderer* mRenderer;
NinePatchComponent mBackground; NinePatchComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;

View file

@ -74,7 +74,10 @@ void ViewController::invalidSystemsFileDialog()
quit.type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(&quit); SDL_PushEvent(&quit);
}, },
"", nullptr, "", nullptr, true)); "", nullptr, "", nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ?
0.85f :
0.55f * (1.778f / mRenderer->getScreenAspectRatio()))));
} }
void ViewController::noGamesDialog() void ViewController::noGamesDialog()
@ -120,7 +123,7 @@ void ViewController::noGamesDialog()
"ROM DIRECTORY SETTING SAVED, RESTART\n" "ROM DIRECTORY SETTING SAVED, RESTART\n"
"THE APPLICATION TO RESCAN THE SYSTEMS", "THE APPLICATION TO RESCAN THE SYSTEMS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
true)); true, true));
}, },
false, "SAVE", "SAVE CHANGES?", "Currently configured path:", false, "SAVE", "SAVE CHANGES?", "Currently configured path:",
currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH", currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH",
@ -187,7 +190,10 @@ void ViewController::noGamesDialog()
quit.type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(&quit); SDL_PushEvent(&quit);
}, },
true, false); true, false,
(mRenderer->getIsVerticalOrientation() ?
0.90f :
0.62f * (1.778f / mRenderer->getScreenAspectRatio())));
mWindow->pushGui(mNoGamesMessageBox); mWindow->pushGui(mNoGamesMessageBox);
} }

View file

@ -412,13 +412,13 @@ void ComponentList::render(const glm::mat4& parentTrans)
// Draw separators. // Draw separators.
float y {0.0f}; float y {0.0f};
for (unsigned int i {0}; i < mEntries.size(); ++i) { 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); 0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming);
y += getRowHeight(mEntries.at(i).data); y += getRowHeight(mEntries.at(i).data);
} }
mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(), 0xC6C7C6FF, mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenResolutionModifier(),
0xC6C7C6FF, false, mOpacity, mDimming); 0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming);
mRenderer->popClipRect(); mRenderer->popClipRect();
} }

View file

@ -112,8 +112,9 @@ void MenuComponent::updateSize()
} }
} }
float width { float width {std::min(mRenderer->getScreenHeight() * 1.05f,
std::min(mRenderer->getScreenHeight() * 1.05f, mRenderer->getScreenWidth() * 0.90f)}; mRenderer->getScreenWidth() *
(mRenderer->getIsVerticalOrientation() ? 0.94f : 0.90f))};
setSize(width, height); setSize(width, height);
} }

View file

@ -23,22 +23,26 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle,
const std::function<void()>& func2, const std::function<void()>& func2,
const std::string& name3, const std::string& name3,
const std::function<void()>& func3, const std::function<void()>& func3,
bool disableBackButton, const bool disableBackButton,
bool deleteOnButtonPress) const bool deleteOnButtonPress,
const float maxWidthMultiplier)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"} , mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {1, 2}} , mGrid {glm::ivec2 {1, 2}}
, mHelpStyle {helpstyle} , mHelpStyle {helpstyle}
, mDisableBackButton {disableBackButton} , mDisableBackButton {disableBackButton}
, mDeleteOnButtonPress {deleteOnButtonPress} , mDeleteOnButtonPress {deleteOnButtonPress}
, mMaxWidthMultiplier {maxWidthMultiplier}
{ {
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // 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. // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
const float maxWidthMultiplier {mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f}; if (mMaxWidthMultiplier == 0.0f)
float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, maxWidthMultiplier) * mMaxWidthMultiplier = mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f;
mRenderer->getScreenWidth())};
float width {std::floor(glm::clamp(0.60f * aspectValue, 0.60f, mMaxWidthMultiplier) *
mRenderer->getScreenWidth())};
const float minWidth { const float minWidth {
floorf(glm::clamp(0.30f * aspectValue, 0.10f, 0.50f) * mRenderer->getScreenWidth())}; 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 // 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 // somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9
// reference. // reference.
float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; const float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
const float maxWidthMultiplier {mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f}; if (mMaxWidthMultiplier == 0.0f)
float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, maxWidthMultiplier) * mMaxWidthMultiplier = mRenderer->getIsVerticalOrientation() ? 0.90f : 0.80f;
float width {floorf(glm::clamp(0.60f * aspectValue, 0.60f, mMaxWidthMultiplier) *
mRenderer->getScreenWidth())}; mRenderer->getScreenWidth())};
const float minWidth {mRenderer->getScreenWidth() * 0.3f}; const float minWidth {mRenderer->getScreenWidth() * 0.3f};

View file

@ -28,8 +28,9 @@ public:
const std::function<void()>& func2 = nullptr, const std::function<void()>& func2 = nullptr,
const std::string& name3 = "", const std::string& name3 = "",
const std::function<void()>& func3 = nullptr, const std::function<void()>& func3 = nullptr,
bool disableBackButton = false, const bool disableBackButton = false,
bool deleteOnButtonPress = true); const bool deleteOnButtonPress = true,
const float maxWidthMultiplier = 0.0f);
void changeText(const std::string& newText); void changeText(const std::string& newText);
@ -53,6 +54,7 @@ private:
std::function<void()> mAcceleratorFunc; std::function<void()> mAcceleratorFunc;
bool mDisableBackButton; bool mDisableBackButton;
bool mDeleteOnButtonPress; bool mDeleteOnButtonPress;
float mMaxWidthMultiplier;
}; };
#endif // ES_CORE_GUIS_GUI_MSG_BOX_H #endif // ES_CORE_GUIS_GUI_MSG_BOX_H