diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index e6641645d..2b05a5e3b 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -1183,8 +1183,8 @@ void SystemView::legacyApplyTheme(const std::shared_ptr& theme) mPrimary->applyTheme(theme, "system", "textlist_gamelist", ThemeFlags::ALL); mLegacySystemInfo->setSize(mSize.x, mLegacySystemInfo->getFont()->getLetterHeight() * 2.2f); - mLegacySystemInfo->setPosition(0.0f, std::round(mPrimary->getPosition().y) + - std::round(mPrimary->getSize().y)); + mLegacySystemInfo->setPosition(0.0f, + std::floor(mPrimary->getPosition().y) + mPrimary->getSize().y); mLegacySystemInfo->setBackgroundColor(0xDDDDDDD8); mLegacySystemInfo->setRenderBackground(true); mLegacySystemInfo->setFont( diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index dae7d2a45..b6178ff46 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -290,10 +290,10 @@ void ComponentList::render(const glm::mat4& parentTrans) dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x; dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y; - const int clipRectPosX {static_cast(std::ceil(trans[3].x))}; - const int clipRectPosY {static_cast(std::ceil(trans[3].y))}; - const int clipRectSizeX {static_cast(std::ceil(dim.x))}; - const int clipRectSizeY {static_cast(std::ceil(dim.y))}; + const int clipRectPosX {static_cast(std::floor(trans[3].x))}; + const int clipRectPosY {static_cast(std::floor(trans[3].y))}; + const int clipRectSizeX {static_cast(std::round(dim.x))}; + const int clipRectSizeY {static_cast(std::ceil(dim.y) + 1.0f)}; mRenderer->pushClipRect(glm::ivec2 {clipRectPosX, clipRectPosY}, glm::ivec2 {clipRectSizeX, clipRectSizeY}); @@ -423,6 +423,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const height = row.elements.at(i).component->getSize().y; } + // We round down to avoid separator single-pixel alignment issues. return std::floor(height); } diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 85736654f..bae9dfc05 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -211,7 +211,11 @@ void HelpComponent::updateGrid() std::vector> labels; float width {0.0f}; - const float height {std::round(font->getLetterHeight() * 1.25f)}; + float height {std::round(font->getLetterHeight() * 1.25f)}; + + // Make sure both text and icons have either odd or equal sizes to avoid alignment issues. + if (static_cast(font->getHeight()) % 2 != static_cast(height) % 2) + --height; // State variable indicating whether the GUI is dimmed. bool isDimmed {mWindow->isBackgroundDimmed()}; @@ -244,8 +248,8 @@ void HelpComponent::updateGrid() mGrid->setSize(width, height); - for (unsigned int i = 0; i < icons.size(); ++i) { - const int col = i * 4; + for (size_t i = 0; i < icons.size(); ++i) { + const size_t col {i * 4}; mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width); mGrid->setColWidthPerc(col + 1, (mStyle.iconTextSpacing * mRenderer->getScreenWidth()) / width); @@ -256,7 +260,6 @@ void HelpComponent::updateGrid() } mGrid->setPosition({mStyle.position.x, mStyle.position.y, 0.0f}); - mGrid->setOrigin(mStyle.origin); } diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index 12336350a..a0cd27c2e 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -11,9 +11,8 @@ #include "Settings.h" #include "components/ButtonComponent.h" -#define BUTTON_GRID_VERT_PADDING std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.915f) -#define BUTTON_GRID_HORIZ_PADDING \ - std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.283f) +#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) @@ -86,7 +85,7 @@ void MenuComponent::setTitle(std::string title, const std::shared_ptr& fon float MenuComponent::getButtonGridHeight() const { return (mButtonGrid ? mButtonGrid->getSize().y : - Font::get(FONT_SIZE_MEDIUM)->getHeight() + BUTTON_GRID_VERT_PADDING); + Font::get(FONT_SIZE_MEDIUM)->getSize() * 1.5f + BUTTON_GRID_VERT_PADDING); } void MenuComponent::updateSize() @@ -186,7 +185,7 @@ std::shared_ptr makeButtonGrid( std::shared_ptr makeArrow() { auto bracket = std::make_shared(); - bracket->setResize(0, std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight())); + bracket->setResize(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); bracket->setImage(":/graphics/arrow.svg"); return bracket; } diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index 615e3a35a..8704e68c5 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -86,11 +86,11 @@ public: mText.getFont()->getHeight()); // Position. - mLeftArrow.setPosition(0.0f, std::round((mSize.y - mLeftArrow.getSize().y) / 2.0f)); + mLeftArrow.setPosition(0.0f, (mSize.y - mLeftArrow.getSize().y) / 2.0f); mText.setPosition(mLeftArrow.getPosition().x + mLeftArrow.getSize().x, (mSize.y - mText.getSize().y) / 2.0f); mRightArrow.setPosition(mText.getPosition().x + mText.getSize().x, - std::round((mSize.y - mRightArrow.getSize().y) / 2.0f)); + (mSize.y - mRightArrow.getSize().y) / 2.0f); } bool input(InputConfig* config, Input input) override diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index 452edc09d..7a9a4aea4 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -97,11 +97,8 @@ void SliderComponent::render(const glm::mat4& parentTrans) if (mTextCache) mFont->renderTextCache(mTextCache.get()); - const float barPosY {mBarHeight == 1.0f ? std::floor(mSize.y / 2.0f - mBarHeight / 2.0f) : - std::round(mSize.y / 2.0f - mBarHeight / 2.0f)}; - // Render bar. - mRenderer->drawRect(mKnob.getSize().x / 2.0f, barPosY, width, mBarHeight, 0x777777FF, + mRenderer->drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f, width, mBarHeight, 0x777777FF, 0x777777FF); // Render knob. @@ -154,7 +151,7 @@ void SliderComponent::onValueChanged() mTextCache->metrics.size.x = textSize.x; // Fudge the width. } - mKnob.setResize(0.0f, std::round(mSize.y * 0.7f)); + mKnob.setResize(0.0f, mSize.y * 0.7f); float barLength { mSize.x - mKnob.getSize().x - @@ -175,11 +172,11 @@ void SliderComponent::onValueChanged() barHeight = 1; // Resize the knob one pixel if necessary to keep the bar centered. - if (barHeight % 2 == 0 && static_cast(mKnob.getSize().y) % 2 != 0) { + if (barHeight % 2 == 0 && static_cast(std::round(mKnob.getSize().y)) % 2 != 0) { mKnob.setResize(mKnob.getSize().x - 1.0f, mKnob.getSize().y - 1.0f); setSize(getSize().x, getSize().y - 1.0f); } - else if (barHeight == 1 && static_cast(mKnob.getSize().y) % 2 == 0) { + else if (barHeight == 1 && static_cast(std::round(mKnob.getSize().y)) % 2 == 0) { mKnob.setResize(mKnob.getSize().x - 1.0f, mKnob.getSize().y - 1); setSize(getSize().x, getSize().y - 1.0f); }