diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index 51f33f917..5568d0f63 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -82,10 +82,12 @@ void ScrollableContainer::update(int deltaTime) float lineSpacing{mChildren.front()->getLineSpacing()}; float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)}; - // Calculate the line spacing which will be used to clip the container. - if (mClipSpacing == 0.0f) - mClipSpacing = - std::round((combinedHeight - mChildren.front()->getFont()->getLetterHeight()) / 2.0f); + // Calculate the spacing which will be used to clip the container. + if (lineSpacing > 1.2f && mClipSpacing == 0.0f) { + const float minimumSpacing = mChildren.front()->getFont()->getHeight(1.2f); + 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. 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.y = std::fabs(trans[3].y + mSize.y); - glm::ivec2 clipDim{static_cast(dimScaled.x - trans[3].x), - static_cast(dimScaled.y - trans[3].y)}; + glm::ivec2 clipDim{static_cast(ceilf(dimScaled.x - trans[3].x)), + static_cast(ceilf(dimScaled.y - trans[3].y))}; // By effectively clipping the upper and lower boundaries of the container we mostly avoid // scrolling outside the vertical starting and ending positions. - clipPos.y += mClipSpacing; - clipDim.y -= mClipSpacing * 0.9f; + clipPos.y += static_cast(mClipSpacing); + clipDim.y -= static_cast(mClipSpacing); Renderer::pushClipRect(clipPos, clipDim);