mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Made many improvements to GUI sizing and positioning when running in vertical screen resolutions.
This commit is contained in:
parent
cf8ce151dd
commit
33bca1b0d3
|
@ -103,10 +103,11 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
|
||||
float maxWidthModifier {glm::clamp(0.78f * aspectValue, 0.78f, 0.90f)};
|
||||
float minWidthModifier {glm::clamp(0.50f * aspectValue, 0.50f, 0.65f)};
|
||||
float minWidthModifier {glm::clamp(0.50f * aspectValue, 0.50f,
|
||||
(mRenderer->getIsVerticalOrientation() ? 0.80f : 0.65f))};
|
||||
|
||||
float maxWidth {Renderer::getScreenWidth() * maxWidthModifier};
|
||||
float minWidth {Renderer::getScreenWidth() * minWidthModifier};
|
||||
float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier};
|
||||
float minWidth {mRenderer->getScreenWidth() * minWidthModifier};
|
||||
|
||||
float fontWidth {Font::get(gameNameFontSize *
|
||||
std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))
|
||||
|
@ -118,10 +119,18 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
|
||||
float width {glm::clamp(fontWidth, minWidth, maxWidth)};
|
||||
|
||||
if (mImagePath != "")
|
||||
setSize(width, Renderer::getScreenHeight() * 0.60f);
|
||||
else
|
||||
setSize(width, Renderer::getScreenHeight() * 0.38f);
|
||||
if (mImagePath != "") {
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
setSize(width, mRenderer->getScreenWidth() * 0.60f);
|
||||
else
|
||||
setSize(width, mRenderer->getScreenHeight() * 0.60f);
|
||||
}
|
||||
else {
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
setSize(width, mRenderer->getScreenWidth() * 0.38f);
|
||||
else
|
||||
setSize(width, mRenderer->getScreenHeight() * 0.38f);
|
||||
}
|
||||
|
||||
// Set row heights.
|
||||
if (mImagePath != "")
|
||||
|
@ -160,11 +169,13 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
// width so that the sizes look somewhat consistent regardless of the aspect ratio
|
||||
// of the images.
|
||||
if (mImagePath != "") {
|
||||
const float multiplier {mRenderer->getIsVerticalOrientation() ? 0.20f : 0.25f};
|
||||
mMarquee->setLinearInterpolation(true);
|
||||
mMarquee->setImage(game->getMarqueePath(), false);
|
||||
mMarquee->cropTransparentPadding(Renderer::getScreenWidth() *
|
||||
(0.25f * (1.778f / Renderer::getScreenAspectRatio())),
|
||||
mGrid->getRowHeight(3));
|
||||
mMarquee->cropTransparentPadding(
|
||||
mRenderer->getScreenWidth() *
|
||||
(multiplier * (1.778f / mRenderer->getScreenAspectRatio())),
|
||||
mGrid->getRowHeight(3));
|
||||
|
||||
mMarquee->setOrigin(0.5f, 0.5f);
|
||||
glm::vec3 currentPos {mMarquee->getPosition()};
|
||||
|
|
|
@ -31,7 +31,10 @@
|
|||
#include "resources/Font.h"
|
||||
#include "utils/StringUtil.h"
|
||||
|
||||
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.060f)
|
||||
#define TITLE_HEIGHT \
|
||||
(mTitle->getFont()->getLetterHeight() + (Renderer::getIsVerticalOrientation() ? \
|
||||
Renderer::getScreenWidth() * 0.060f : \
|
||||
Renderer::getScreenHeight() * 0.060f))
|
||||
|
||||
GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
||||
const std::vector<MetaDataDecl>& mdd,
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
GuiScraperMulti::GuiScraperMulti(const std::queue<ScraperSearchParams>& searches,
|
||||
bool approveResults)
|
||||
: mBackground {":/graphics/frame.svg"}
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mBackground {":/graphics/frame.svg"}
|
||||
, mGrid {glm::ivec2 {2, 6}}
|
||||
, mSearchQueue {searches}
|
||||
, mApproveResults {approveResults}
|
||||
|
@ -147,20 +148,24 @@ GuiScraperMulti::GuiScraperMulti(const std::queue<ScraperSearchParams>& searches
|
|||
|
||||
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
|
||||
// the 16:9 reference.
|
||||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
float width {glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth()};
|
||||
float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
float width {glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * mRenderer->getScreenWidth()};
|
||||
|
||||
float height {(mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) +
|
||||
const float titleHeight {mRenderer->getIsVerticalOrientation() ?
|
||||
mRenderer->getScreenWidth() * 0.0637f :
|
||||
mRenderer->getScreenHeight() * 0.0637f};
|
||||
|
||||
float height {(mTitle->getFont()->getLetterHeight() + titleHeight) +
|
||||
mSystem->getFont()->getLetterHeight() +
|
||||
mSubtitle->getFont()->getHeight() * 1.75f + mButtonGrid->getSize().y +
|
||||
Font::get(FONT_SIZE_MEDIUM)->getHeight() * 7.0f};
|
||||
|
||||
// TODO: Temporary hack, see below.
|
||||
height -= 7.0f * Renderer::getScreenHeightModifier();
|
||||
height -= 7.0f * mRenderer->getScreenResolutionModifier();
|
||||
|
||||
setSize(width, height);
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
|
||||
doNextSearch();
|
||||
}
|
||||
|
@ -178,12 +183,12 @@ GuiScraperMulti::~GuiScraperMulti()
|
|||
|
||||
void GuiScraperMulti::onSizeChanged()
|
||||
{
|
||||
mGrid.setRowHeightPerc(
|
||||
0, (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
mGrid.setRowHeightPerc(
|
||||
1, (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
const float screenSize {mRenderer->getIsVerticalOrientation() ? mRenderer->getScreenWidth() :
|
||||
mRenderer->getScreenHeight()};
|
||||
mGrid.setRowHeightPerc(0, (mTitle->getFont()->getLetterHeight() + screenSize * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
mGrid.setRowHeightPerc(1, (mTitle->getFont()->getLetterHeight() + screenSize * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
mGrid.setRowHeightPerc(2, (mSystem->getFont()->getLetterHeight()) / mSize.y, false);
|
||||
mGrid.setRowHeightPerc(3, mSubtitle->getFont()->getHeight() * 1.75f / mSize.y, false);
|
||||
mGrid.setRowHeightPerc(4, ((Font::get(FONT_SIZE_MEDIUM)->getHeight() * 7.0f)) / mSize.y, false);
|
||||
|
@ -191,8 +196,8 @@ void GuiScraperMulti::onSizeChanged()
|
|||
// TODO: Replace this temporary hack with a proper solution. There is some kind of rounding
|
||||
// issue somewhere that causes a small alignment error. This code partly compensates for this
|
||||
// at higher resolutions than 1920x1080.
|
||||
if (Renderer::getScreenHeightModifier() > 1.0f)
|
||||
mSize.y -= 3.0f * Renderer::getScreenHeightModifier();
|
||||
if (mRenderer->getScreenResolutionModifier() > 1.0f)
|
||||
mSize.y -= 3.0f * mRenderer->getScreenResolutionModifier();
|
||||
|
||||
mGrid.setColWidthPerc(1, 0.04f);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ private:
|
|||
void doNextSearch();
|
||||
void finish();
|
||||
|
||||
Renderer* mRenderer;
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ void GuiScraperSearch::onSizeChanged()
|
|||
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT)
|
||||
mGrid.setColWidthPerc(2, 0.33f);
|
||||
else
|
||||
mGrid.setColWidthPerc(2, 0.30f);
|
||||
mGrid.setColWidthPerc(2, (mRenderer->getIsVerticalOrientation() ? 0.34f : 0.30f));
|
||||
|
||||
// Row heights.
|
||||
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // Show name.
|
||||
|
@ -250,13 +250,19 @@ void GuiScraperSearch::resizeMetadata()
|
|||
it->first->setFont(fontLbl);
|
||||
it->first->setSize(0, 0);
|
||||
if (it->first->getSize().x > maxLblWidth)
|
||||
maxLblWidth = it->first->getSize().x + (16.0f * Renderer::getScreenWidthModifier());
|
||||
maxLblWidth =
|
||||
it->first->getSize().x + (16.0f * (mRenderer->getIsVerticalOrientation() ?
|
||||
mRenderer->getScreenHeightModifier() :
|
||||
mRenderer->getScreenWidthModifier()));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < mMD_Pairs.size(); ++i)
|
||||
mMD_Grid->setRowHeightPerc(
|
||||
i * 2, (fontLbl->getLetterHeight() + (2.0f * Renderer::getScreenHeightModifier())) /
|
||||
mMD_Grid->getSize().y);
|
||||
i * 2,
|
||||
(fontLbl->getLetterHeight() + (2.0f * (mRenderer->getIsVerticalOrientation() ?
|
||||
mRenderer->getScreenWidthModifier() :
|
||||
mRenderer->getScreenHeightModifier()))) /
|
||||
mMD_Grid->getSize().y);
|
||||
|
||||
// Update component fonts.
|
||||
mMD_ReleaseDate->setFont(fontComp);
|
||||
|
|
|
@ -21,8 +21,9 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
|
|||
std::function<void(const ScraperSearchResult&)> doneFunc,
|
||||
bool& savedMediaAndAborted)
|
||||
: mClose {false}
|
||||
, mGrid {glm::ivec2 {2, 6}}
|
||||
, mRenderer {Renderer::getInstance()}
|
||||
, mBackground {":/graphics/frame.svg"}
|
||||
, mGrid {glm::ivec2 {2, 6}}
|
||||
, mSearchParams {params}
|
||||
, mSavedMediaAndAborted {savedMediaAndAborted}
|
||||
{
|
||||
|
@ -119,17 +120,18 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
|
|||
|
||||
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
|
||||
// the 16:9 reference.
|
||||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
float width {glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth()};
|
||||
const float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
const float width {glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * mRenderer->getScreenWidth()};
|
||||
const float screenSize {mRenderer->getIsVerticalOrientation() ? mRenderer->getScreenWidth() :
|
||||
mRenderer->getScreenHeight()};
|
||||
|
||||
float height {
|
||||
(mGameName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) +
|
||||
mSystemName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.04f +
|
||||
mButtonGrid->getSize().y + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f};
|
||||
const float height {(mGameName->getFont()->getLetterHeight() + screenSize * 0.0637f) +
|
||||
mSystemName->getFont()->getLetterHeight() + screenSize * 0.04f +
|
||||
mButtonGrid->getSize().y + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f};
|
||||
|
||||
setSize(width, height);
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
|
||||
mGrid.resetCursor();
|
||||
mSearch->search(params); // Start the search.
|
||||
|
@ -137,17 +139,22 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
|
|||
|
||||
void GuiScraperSingle::onSizeChanged()
|
||||
{
|
||||
mGrid.setRowHeightPerc(
|
||||
0, (mGameName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
mGrid.setRowHeightPerc(
|
||||
1, (mGameName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) /
|
||||
mSize.y / 2.0f);
|
||||
const float gameNameHeight {mRenderer->getIsVerticalOrientation() ?
|
||||
mRenderer->getScreenWidth() * 0.0637f :
|
||||
mRenderer->getScreenHeight() * 0.0637f};
|
||||
|
||||
mGrid.setRowHeightPerc(0, (mGameName->getFont()->getLetterHeight() + gameNameHeight) / mSize.y /
|
||||
2.0f);
|
||||
mGrid.setRowHeightPerc(1, (mGameName->getFont()->getLetterHeight() + gameNameHeight) / mSize.y /
|
||||
2.0f);
|
||||
mGrid.setRowHeightPerc(2, mSystemName->getFont()->getLetterHeight() / mSize.y, false);
|
||||
mGrid.setRowHeightPerc(3, 0.04f, false);
|
||||
mGrid.setRowHeightPerc(4, (Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f) / mSize.y, false);
|
||||
|
||||
mGrid.setColWidthPerc(1, 0.04f);
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
mGrid.setColWidthPerc(1, 0.05f);
|
||||
else
|
||||
mGrid.setColWidthPerc(1, 0.04f);
|
||||
|
||||
mGrid.setSize(glm::round(mSize));
|
||||
mBackground.fitTo(mSize, glm::vec3 {0.0f, 0.0f, 0.0f}, glm::vec2 {-32.0f, -32.0f});
|
||||
|
|
|
@ -36,8 +36,9 @@ private:
|
|||
bool mClose;
|
||||
void close();
|
||||
|
||||
ComponentGrid mGrid;
|
||||
Renderer* mRenderer;
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
|
||||
std::shared_ptr<TextComponent> mGameName;
|
||||
std::shared_ptr<ImageComponent> mScrollUp;
|
||||
|
|
|
@ -123,11 +123,11 @@ bool Window::init()
|
|||
mDefaultFonts.push_back(Font::get(FONT_SIZE_LARGE));
|
||||
}
|
||||
|
||||
if (mRenderer->getScreenWidth() > mRenderer->getScreenHeight())
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
mSplash->setResize(mRenderer->getScreenWidth() * 0.8f, 0.0f);
|
||||
else
|
||||
mSplash->setResize(0.0f, glm::clamp(mRenderer->getScreenHeight() * 0.62f, 0.0f,
|
||||
mRenderer->getScreenWidth() * 0.42f));
|
||||
else
|
||||
mSplash->setResize(mRenderer->getScreenWidth() * 0.8f, 0.0f);
|
||||
|
||||
mSplash->setImage(":/graphics/splash.svg");
|
||||
mSplash->setPosition((mRenderer->getScreenWidth() - mSplash->getSize().x) / 2.0f,
|
||||
|
@ -146,13 +146,15 @@ bool Window::init()
|
|||
(mRenderer->getScreenWidth() - mSplashTextPopulating->metrics.size.x) / 2.0f;
|
||||
mSplashTextPositions.w =
|
||||
(mRenderer->getScreenWidth() - mSplashTextReloading->metrics.size.x) / 2.0f;
|
||||
mSplashTextPositions.y = mRenderer->getScreenHeight() * 0.745f;
|
||||
mSplashTextPositions.y =
|
||||
mRenderer->getScreenHeight() * (mRenderer->getIsVerticalOrientation() ? 0.620f : 0.745f);
|
||||
|
||||
ProgressBarRectangle progressBarRect;
|
||||
if (mRenderer->getScreenWidth() > mRenderer->getScreenHeight())
|
||||
progressBarRect.barWidth = mRenderer->getScreenHeight() * 0.53f;
|
||||
else
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
progressBarRect.barWidth = mRenderer->getScreenWidth() * 0.53f;
|
||||
else
|
||||
progressBarRect.barWidth = mRenderer->getScreenHeight() * 0.53f;
|
||||
|
||||
progressBarRect.barHeight = mDefaultFonts.at(1)->getLetterHeight() * 1.1f;
|
||||
progressBarRect.barPosX =
|
||||
(mRenderer->getScreenWidth() / 2.0f) - (progressBarRect.barWidth / 2.0f);
|
||||
|
|
|
@ -56,10 +56,10 @@ void BusyComponent::onSizeChanged()
|
|||
|
||||
mGrid.setRowHeightPerc(1, textHeight / std::round(mSize.y));
|
||||
|
||||
mBackground.setCornerSize(
|
||||
{16.0f * Renderer::getScreenWidthModifier(), 16.0f * Renderer::getScreenHeightModifier()});
|
||||
mBackground.setCornerSize({16.0f * Renderer::getScreenResolutionModifier(),
|
||||
16.0f * Renderer::getScreenResolutionModifier()});
|
||||
mBackground.fitTo(glm::vec2 {mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
|
||||
textHeight + (2.0f * Renderer::getScreenHeightModifier())},
|
||||
textHeight + (2.0f * Renderer::getScreenResolutionModifier())},
|
||||
mAnimation->getPosition(), glm::vec2 {});
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,12 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
|
|||
mTextCache =
|
||||
std::unique_ptr<TextCache>(mFont->buildTextCache(mText, 0.0f, 0.0f, getCurTextColor()));
|
||||
|
||||
float minWidth = mFont->sizeText("DELETE").x + (12.0f * Renderer::getScreenWidthModifier());
|
||||
setSize(std::max(mTextCache->metrics.size.x + (12.0f * Renderer::getScreenWidthModifier()),
|
||||
minWidth),
|
||||
mTextCache->metrics.size.y);
|
||||
const float minWidth {mFont->sizeText("DELETE").x +
|
||||
(12.0f * mRenderer->getScreenResolutionModifier())};
|
||||
setSize(
|
||||
std::max(mTextCache->metrics.size.x + (12.0f * mRenderer->getScreenResolutionModifier()),
|
||||
minWidth),
|
||||
mTextCache->metrics.size.y);
|
||||
|
||||
updateHelpPrompts();
|
||||
}
|
||||
|
|
|
@ -30,9 +30,12 @@ ComponentList::ComponentList()
|
|||
{
|
||||
// Adjust the padding relative to the aspect ratio and screen resolution to make it look
|
||||
// coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
mHorizontalPadding =
|
||||
TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier();
|
||||
TOTAL_HORIZONTAL_PADDING_PX * aspectValue * mRenderer->getScreenWidthModifier();
|
||||
|
||||
if (mRenderer->getIsVerticalOrientation())
|
||||
mHorizontalPadding *= 0.7f;
|
||||
}
|
||||
|
||||
void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
|
||||
|
@ -403,12 +406,12 @@ 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 * Renderer::getScreenHeightModifier(),
|
||||
mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(),
|
||||
0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming);
|
||||
y += getRowHeight(mEntries.at(i).data);
|
||||
}
|
||||
|
||||
mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * Renderer::getScreenHeightModifier(), 0xC6C7C6FF,
|
||||
mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(), 0xC6C7C6FF,
|
||||
0xC6C7C6FF, false, mOpacity, mDimming);
|
||||
mRenderer->popClipRect();
|
||||
}
|
||||
|
|
|
@ -14,10 +14,14 @@
|
|||
#define BUTTON_GRID_VERT_PADDING Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.915f
|
||||
#define BUTTON_GRID_HORIZ_PADDING Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.283f
|
||||
|
||||
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f)
|
||||
#define TITLE_HEIGHT \
|
||||
(mTitle->getFont()->getLetterHeight() + (Renderer::getIsVerticalOrientation() ? \
|
||||
Renderer::getScreenWidth() * 0.0637f : \
|
||||
Renderer::getScreenHeight() * 0.0637f))
|
||||
|
||||
MenuComponent::MenuComponent(std::string title, const std::shared_ptr<Font>& titleFont)
|
||||
: mGrid {glm::ivec2 {2, 4}}
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mGrid {glm::ivec2 {2, 4}}
|
||||
, mNeedsSaving {false}
|
||||
{
|
||||
addChild(&mBackground);
|
||||
|
@ -90,15 +94,16 @@ float MenuComponent::getButtonGridHeight() const
|
|||
|
||||
void MenuComponent::updateSize()
|
||||
{
|
||||
const float maxHeight {Renderer::getScreenHeight() * 0.80f};
|
||||
const float maxHeight {mRenderer->getScreenHeight() *
|
||||
(mRenderer->getIsVerticalOrientation() ? 0.70f : 0.80f)};
|
||||
float height {TITLE_HEIGHT + mList->getTotalRowHeight() + getButtonGridHeight() +
|
||||
(2.0f * Renderer::getScreenHeightModifier())};
|
||||
(2.0f * mRenderer->getScreenResolutionModifier())};
|
||||
if (height > maxHeight) {
|
||||
height = TITLE_HEIGHT + getButtonGridHeight();
|
||||
int i {0};
|
||||
while (i < mList->size()) {
|
||||
// Add the separator height to the row height so that it also gets properly rendered.
|
||||
float rowHeight {mList->getRowHeight(i) + (1.0f * Renderer::getScreenHeightModifier())};
|
||||
float rowHeight {mList->getRowHeight(i) + mRenderer->getScreenResolutionModifier()};
|
||||
if (height + rowHeight < maxHeight)
|
||||
height += rowHeight;
|
||||
else
|
||||
|
@ -107,7 +112,8 @@ void MenuComponent::updateSize()
|
|||
}
|
||||
}
|
||||
|
||||
float width {std::min(Renderer::getScreenHeight() * 1.05f, Renderer::getScreenWidth() * 0.90f)};
|
||||
float width {
|
||||
std::min(mRenderer->getScreenHeight() * 1.05f, mRenderer->getScreenWidth() * 0.90f)};
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ private:
|
|||
void updateGrid();
|
||||
float getButtonGridHeight() const;
|
||||
|
||||
Renderer* mRenderer;
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ ScrollableContainer::ScrollableContainer()
|
|||
, mUpdatedSize {false}
|
||||
{
|
||||
// Set the modifier to get equivalent scrolling speed regardless of screen resolution.
|
||||
mResolutionModifier = Renderer::getScreenHeightModifier();
|
||||
mResolutionModifier = mRenderer->getScreenResolutionModifier();
|
||||
|
||||
mAutoScrollResetDelayConstant = AUTO_SCROLL_RESET_DELAY;
|
||||
mAutoScrollDelayConstant = AUTO_SCROLL_DELAY;
|
||||
|
|
|
@ -34,7 +34,7 @@ TextEditComponent::TextEditComponent()
|
|||
mBox.setSharpCorners(true);
|
||||
addChild(&mBox);
|
||||
onFocusLost();
|
||||
setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()));
|
||||
setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * mRenderer->getScreenHeightModifier()));
|
||||
}
|
||||
|
||||
void TextEditComponent::onFocusGained()
|
||||
|
@ -57,7 +57,7 @@ void TextEditComponent::onSizeChanged()
|
|||
|
||||
mBox.fitTo(
|
||||
mSize, glm::vec3 {},
|
||||
glm::vec2 {-34.0f, -32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())});
|
||||
glm::vec2 {-34.0f, -32.0f - (TEXT_PADDING_VERT * mRenderer->getScreenHeightModifier())});
|
||||
onTextChanged(); // Wrap point probably changed.
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
|
|||
|
||||
glm::ivec2 clipPos {static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
|
||||
// Use "text area" size for clipping.
|
||||
glm::vec3 dimScaled {};
|
||||
glm::vec3 dimScaled {0.0f, 0.0f, 0.0f};
|
||||
dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x);
|
||||
dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y);
|
||||
|
||||
|
@ -329,31 +329,31 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
|
|||
mRenderer->popClipRect();
|
||||
|
||||
// Draw cursor.
|
||||
float cursorHeight {mFont->getHeight() * 0.8f};
|
||||
const float cursorHeight {mFont->getHeight() * 0.8f};
|
||||
|
||||
if (!mEditing) {
|
||||
mRenderer->drawRect(mCursorPos.x, mCursorPos.y + (mFont->getHeight() - cursorHeight) / 2.0f,
|
||||
2.0f * Renderer::getScreenWidthModifier(), cursorHeight, 0xC7C7C7FF,
|
||||
0xC7C7C7FF);
|
||||
2.0f * mRenderer->getScreenResolutionModifier(), cursorHeight,
|
||||
0xC7C7C7FF, 0xC7C7C7FF);
|
||||
}
|
||||
|
||||
if (mEditing && mBlinkTime < BLINKTIME / 2) {
|
||||
mRenderer->drawRect(mCursorPos.x, mCursorPos.y + (mFont->getHeight() - cursorHeight) / 2.0f,
|
||||
2.0f * Renderer::getScreenWidthModifier(), cursorHeight, 0x777777FF,
|
||||
0x777777FF);
|
||||
2.0f * mRenderer->getScreenResolutionModifier(), cursorHeight,
|
||||
0x777777FF, 0x777777FF);
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec2 TextEditComponent::getTextAreaPos() const
|
||||
{
|
||||
return glm::vec2 {(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()) / 2.0f,
|
||||
(TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()) / 2.0f};
|
||||
return glm::vec2 {(TEXT_PADDING_HORIZ * mRenderer->getScreenResolutionModifier()) / 2.0f,
|
||||
(TEXT_PADDING_VERT * mRenderer->getScreenResolutionModifier()) / 2.0f};
|
||||
}
|
||||
|
||||
glm::vec2 TextEditComponent::getTextAreaSize() const
|
||||
{
|
||||
return glm::vec2 {mSize.x - (TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()),
|
||||
mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())};
|
||||
return glm::vec2 {mSize.x - (TEXT_PADDING_HORIZ * mRenderer->getScreenResolutionModifier()),
|
||||
mSize.y - (TEXT_PADDING_VERT * mRenderer->getScreenResolutionModifier())};
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> TextEditComponent::getHelpPrompts()
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
// Has a default mode and a complex mode, both with various options passed as arguments.
|
||||
//
|
||||
|
||||
#define KEYBOARD_HEIGHT Renderer::getScreenHeight() * 0.60f
|
||||
#define KEYBOARD_HEIGHT \
|
||||
(Renderer::getIsVerticalOrientation() ? Renderer::getScreenWidth() * 0.60f : \
|
||||
Renderer::getScreenHeight() * 0.60f)
|
||||
|
||||
#define KEYBOARD_PADDINGX (Renderer::getScreenWidth() * 0.02f)
|
||||
#define KEYBOARD_PADDINGY (Renderer::getScreenWidth() * 0.01f)
|
||||
|
||||
#define BUTTON_GRID_HORIZ_PADDING (10.0f * Renderer::getScreenHeightModifier())
|
||||
#define BUTTON_GRID_HORIZ_PADDING (10.0f * Renderer::getScreenResolutionModifier())
|
||||
|
||||
#define NAVIGATION_REPEAT_START_DELAY 400
|
||||
#define NAVIGATION_REPEAT_SPEED 70 // Lower is faster.
|
||||
|
@ -86,7 +88,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
const std::string& loadBtnHelpText,
|
||||
const std::string& clearBtnHelpText,
|
||||
const std::string& cancelBtnHelpText)
|
||||
: mBackground {":/graphics/frame.svg"}
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mBackground {":/graphics/frame.svg"}
|
||||
, mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}}
|
||||
, mHelpStyle {helpstyle}
|
||||
, mInitValue {initValue}
|
||||
|
@ -241,7 +244,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
// If the multiLine option has been set, then include three lines of text on screen.
|
||||
if (multiLine) {
|
||||
textHeight *= 3.0f;
|
||||
textHeight += 2.0f * Renderer::getScreenHeightModifier();
|
||||
textHeight += 2.0f * mRenderer->getScreenResolutionModifier();
|
||||
}
|
||||
|
||||
mText->setSize(0.0f, textHeight);
|
||||
|
@ -264,16 +267,16 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
});
|
||||
|
||||
// Adapt width to the geometry of the display. The 1.778 aspect ratio is the 16:9 reference.
|
||||
float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
|
||||
float width = glm::clamp(0.78f * aspectValue, 0.35f, 0.90f) * Renderer::getScreenWidth();
|
||||
float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
float width {glm::clamp(0.78f * aspectValue, 0.35f, 0.90f) * mRenderer->getScreenWidth()};
|
||||
|
||||
// The combination of multiLine and complex mode is not supported as there is currently
|
||||
// no need for that.
|
||||
if (mMultiLine) {
|
||||
setSize(width, KEYBOARD_HEIGHT + textHeight - mText->getFont()->getHeight());
|
||||
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
}
|
||||
else {
|
||||
if (mComplexMode)
|
||||
|
@ -281,8 +284,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
else
|
||||
setSize(width, KEYBOARD_HEIGHT);
|
||||
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
}
|
||||
|
||||
if (!multiLine)
|
||||
|
@ -313,7 +316,8 @@ void GuiTextEditKeyboardPopup::onSizeChanged()
|
|||
|
||||
// Add a small margin between buttons.
|
||||
mKeyboardGrid->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX,
|
||||
sz.y - KEYBOARD_PADDINGY + 70.0f * Renderer::getScreenHeightModifier());
|
||||
sz.y - KEYBOARD_PADDINGY +
|
||||
70.0f * mRenderer->getScreenResolutionModifier());
|
||||
mKeyboardGrid->setPosition(KEYBOARD_PADDINGX, pos.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
std::shared_ptr<ButtonComponent> mShiftButton;
|
||||
std::shared_ptr<ButtonComponent> mAltButton;
|
||||
|
||||
Renderer* mRenderer;
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
HelpStyle mHelpStyle;
|
||||
|
|
|
@ -160,9 +160,9 @@ public:
|
|||
const glm::mat4& getProjectionMatrixNormal() { return mProjectionMatrixNormal; }
|
||||
SDL_Window* getSDLWindow() { return mSDLWindow; }
|
||||
const int getScreenRotation() { return mScreenRotation; }
|
||||
const bool getIsVerticalOrientation() { return sIsVerticalOrientation; }
|
||||
const float getWindowWidth() { return static_cast<float>(mWindowWidth); }
|
||||
const float getWindowHeight() { return static_cast<float>(mWindowHeight); }
|
||||
static const bool getIsVerticalOrientation() { return sIsVerticalOrientation; }
|
||||
static const float getScreenWidth() { return static_cast<float>(sScreenWidth); }
|
||||
static const float getScreenHeight() { return static_cast<float>(sScreenHeight); }
|
||||
static const float getScreenWidthModifier() { return sScreenWidthModifier; }
|
||||
|
|
Loading…
Reference in a new issue