mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Fixed a text artifact issue caused by a missing rounding in TextComponent.
Also forced vertical center alignment if the text field is smaller than the font height.
This commit is contained in:
parent
63e7b58ec0
commit
79c61b2d8a
|
@ -171,31 +171,37 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
const glm::vec2& textSize {mTextCache->metrics.size};
|
const glm::vec2& textSize {mTextCache->metrics.size};
|
||||||
float yOff = 0.0f;
|
float yOff {0.0f};
|
||||||
switch (mVerticalAlignment) {
|
|
||||||
case ALIGN_TOP: {
|
if (mSize.y > textSize.y) {
|
||||||
yOff = 0.0f;
|
switch (mVerticalAlignment) {
|
||||||
break;
|
case ALIGN_TOP: {
|
||||||
}
|
yOff = 0.0f;
|
||||||
case ALIGN_BOTTOM: {
|
break;
|
||||||
yOff = (getSize().y - textSize.y);
|
}
|
||||||
break;
|
case ALIGN_BOTTOM: {
|
||||||
}
|
yOff = (getSize().y - textSize.y);
|
||||||
case ALIGN_CENTER: {
|
break;
|
||||||
yOff = (getSize().y - textSize.y) / 2.0f;
|
}
|
||||||
break;
|
case ALIGN_CENTER: {
|
||||||
}
|
yOff = (getSize().y - textSize.y) / 2.0f;
|
||||||
default: {
|
break;
|
||||||
break;
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glm::vec3 off {0.0f, yOff, 0.0f};
|
else {
|
||||||
|
// If height is smaller than the font height, then always center vertically.
|
||||||
|
yOff = (getSize().y - textSize.y) / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the "textbox" area, what we are aligned within.
|
// Draw the "textbox" area, what we are aligned within.
|
||||||
if (Settings::getInstance()->getBool("DebugText"))
|
if (Settings::getInstance()->getBool("DebugText"))
|
||||||
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x0000FF33, 0x0000FF33);
|
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x0000FF33, 0x0000FF33);
|
||||||
|
|
||||||
trans = glm::translate(trans, off);
|
trans = glm::translate(trans, glm::vec3 {0.0f, std::round(yOff), 0.0f});
|
||||||
mRenderer->setMatrix(trans);
|
mRenderer->setMatrix(trans);
|
||||||
|
|
||||||
// Draw the text area, where the text actually is located.
|
// Draw the text area, where the text actually is located.
|
||||||
|
|
Loading…
Reference in a new issue