Improved the sizes of some menu GUI elements on 4:3 aspect ratio displays.

This commit is contained in:
Leon Styhre 2021-03-09 17:17:33 +01:00
parent 97568fcb22
commit 6a57a44df9
5 changed files with 22 additions and 3 deletions

View file

@ -77,7 +77,12 @@ GuiDetectDevice::GuiDetectDevice(
Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, ALIGN_CENTER); Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, ALIGN_CENTER);
mGrid.setEntry(mDeviceHeld, Vector2i(0, 4), false, true); mGrid.setEntry(mDeviceHeld, Vector2i(0, 4), false, true);
setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.5f); // For narrower displays (e.g. in 4:3 ratio), allow the window to fill 80% of the screen
// width rather than the 60% allowed for wider displays.
float width = Renderer::getScreenWidth() *
((Renderer::getScreenAspectRatio() < 1.4f) ? 0.8f : 0.6f);
setSize(width, Renderer::getScreenHeight() * 0.5f);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, setPosition((Renderer::getScreenWidth() - mSize.x()) / 2,
(Renderer::getScreenHeight() - mSize.y()) / 2); (Renderer::getScreenHeight() - mSize.y()) / 2);
} }

View file

@ -251,7 +251,12 @@ GuiInputConfig::GuiInputConfig(
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false); mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false);
setSize(Renderer::getScreenWidth() * 0.6f, Renderer::getScreenHeight() * 0.75f); // For narrower displays (e.g. in 4:3 ratio), allow the window to fill 80% of the screen
// width rather than the 60% allowed for wider displays.
float width = Renderer::getScreenWidth() *
((Renderer::getScreenAspectRatio() < 1.4f) ? 0.8f : 0.6f);
setSize(width, Renderer::getScreenHeight() * 0.75f);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, setPosition((Renderer::getScreenWidth() - mSize.x()) / 2,
(Renderer::getScreenHeight() - mSize.y()) / 2); (Renderer::getScreenHeight() - mSize.y()) / 2);
} }

View file

@ -62,7 +62,12 @@ GuiTextEditPopup::GuiTextEditPopup(
textHeight *= 6; textHeight *= 6;
mText->setSize(0, textHeight); mText->setSize(0, textHeight);
setSize(Renderer::getScreenWidth() * 0.5f, mTitle->getFont()->getHeight() + // For narrower displays (e.g. in 4:3 ratio), allow the window to fill 70% of the screen
// width rather than the 50% allowed for wider displays.
float width = Renderer::getScreenWidth() *
((Renderer::getScreenAspectRatio() < 1.4f) ? 0.7f : 0.5f);
setSize(width, mTitle->getFont()->getHeight() +
textHeight + mButtonGrid->getSize().y() + mButtonGrid->getSize().y() / 2); textHeight + mButtonGrid->getSize().y() + mButtonGrid->getSize().y() / 2);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() -
mSize.y()) / 2); mSize.y()) / 2);

View file

@ -38,6 +38,7 @@ namespace Renderer
// Screen resolution modifiers relative to the 1920x1080 reference. // Screen resolution modifiers relative to the 1920x1080 reference.
static float screenHeightModifier; static float screenHeightModifier;
static float screenWidthModifier; static float screenWidthModifier;
static float screenAspectRatio;
static void setIcon() static void setIcon()
{ {
@ -140,6 +141,7 @@ namespace Renderer
screenHeightModifier = static_cast<float>(screenHeight) / 1080.0f; screenHeightModifier = static_cast<float>(screenHeight) / 1080.0f;
screenWidthModifier = static_cast<float>(screenWidth) / 1920.0f; screenWidthModifier = static_cast<float>(screenWidth) / 1920.0f;
screenAspectRatio = static_cast<float>(screenWidth) / static_cast<float>(screenHeight);
// Prevent the application window from minimizing when switching windows (when launching // Prevent the application window from minimizing when switching windows (when launching
// games or when manually switching windows using the task switcher). // games or when manually switching windows using the task switcher).
@ -506,5 +508,6 @@ namespace Renderer
int getScreenRotate() { return screenRotate; } int getScreenRotate() { return screenRotate; }
float getScreenWidthModifier() { return screenWidthModifier; } float getScreenWidthModifier() { return screenWidthModifier; }
float getScreenHeightModifier() { return screenHeightModifier; } float getScreenHeightModifier() { return screenHeightModifier; }
float getScreenAspectRatio() { return screenAspectRatio; }
} // Renderer:: } // Renderer::

View file

@ -158,6 +158,7 @@ namespace Renderer
int getScreenRotate(); int getScreenRotate();
float getScreenWidthModifier(); float getScreenWidthModifier();
float getScreenHeightModifier(); float getScreenHeightModifier();
float getScreenAspectRatio();
unsigned int convertRGBAToABGR(unsigned int color); unsigned int convertRGBAToABGR(unsigned int color);
unsigned int convertABGRToRGBA(unsigned int color); unsigned int convertABGRToRGBA(unsigned int color);