mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Fixed an issue with international characters getting clipped in ScrollableContainer.
This commit is contained in:
parent
52b516b9ca
commit
050dccb6b8
|
@ -82,10 +82,12 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
float lineSpacing{mChildren.front()->getLineSpacing()};
|
float lineSpacing{mChildren.front()->getLineSpacing()};
|
||||||
float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)};
|
float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)};
|
||||||
|
|
||||||
// Calculate the line spacing which will be used to clip the container.
|
// Calculate the spacing which will be used to clip the container.
|
||||||
if (mClipSpacing == 0.0f)
|
if (lineSpacing > 1.2f && mClipSpacing == 0.0f) {
|
||||||
mClipSpacing =
|
const float minimumSpacing = mChildren.front()->getFont()->getHeight(1.2f);
|
||||||
std::round((combinedHeight - mChildren.front()->getFont()->getLetterHeight()) / 2.0f);
|
const float currentSpacing = mChildren.front()->getFont()->getHeight(lineSpacing);
|
||||||
|
mClipSpacing = std::round((currentSpacing - minimumSpacing) / 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// Resize container to font height boundary to avoid rendering a fraction of the last line.
|
// Resize container to font height boundary to avoid rendering a fraction of the last line.
|
||||||
if (!mUpdatedSize && contentSize.y > mSize.y) {
|
if (!mUpdatedSize && contentSize.y > mSize.y) {
|
||||||
|
@ -176,13 +178,13 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
|
||||||
dimScaled.x = std::fabs(trans[3].x + mSize.x);
|
dimScaled.x = std::fabs(trans[3].x + mSize.x);
|
||||||
dimScaled.y = std::fabs(trans[3].y + mSize.y);
|
dimScaled.y = std::fabs(trans[3].y + mSize.y);
|
||||||
|
|
||||||
glm::ivec2 clipDim{static_cast<int>(dimScaled.x - trans[3].x),
|
glm::ivec2 clipDim{static_cast<int>(ceilf(dimScaled.x - trans[3].x)),
|
||||||
static_cast<int>(dimScaled.y - trans[3].y)};
|
static_cast<int>(ceilf(dimScaled.y - trans[3].y))};
|
||||||
|
|
||||||
// By effectively clipping the upper and lower boundaries of the container we mostly avoid
|
// By effectively clipping the upper and lower boundaries of the container we mostly avoid
|
||||||
// scrolling outside the vertical starting and ending positions.
|
// scrolling outside the vertical starting and ending positions.
|
||||||
clipPos.y += mClipSpacing;
|
clipPos.y += static_cast<int>(mClipSpacing);
|
||||||
clipDim.y -= mClipSpacing * 0.9f;
|
clipDim.y -= static_cast<int>(mClipSpacing);
|
||||||
|
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue