mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Extract CScrollRegion::HEIGHT_MAGIC_FIX
Currently this must be added when calculating the required height of a UI rect for a scroll region to get a perfect fit. It is extracted into a constant so it can be used in other parts to get list boxes with the perfect size.
This commit is contained in:
parent
abfafa314a
commit
f16974d1a9
|
@ -184,8 +184,8 @@ void CScrollRegion::End()
|
|||
bool CScrollRegion::AddRect(const CUIRect &Rect, bool ShouldScrollHere)
|
||||
{
|
||||
m_LastAddedRect = Rect;
|
||||
// Round up and add 1 to fix pixel clipping at the end of the scrolling area
|
||||
m_ContentH = maximum(std::ceil(Rect.y + Rect.h - (m_ClipRect.y + m_ContentScrollOff.y)) + 1.0f, m_ContentH);
|
||||
// Round up and add magic to fix pixel clipping at the end of the scrolling area
|
||||
m_ContentH = maximum(std::ceil(Rect.y + Rect.h - (m_ClipRect.y + m_ContentScrollOff.y)) + HEIGHT_MAGIC_FIX, m_ContentH);
|
||||
if(ShouldScrollHere)
|
||||
ScrollHere();
|
||||
return !IsRectClipped(Rect);
|
||||
|
|
|
@ -89,6 +89,10 @@ Usage:
|
|||
class CScrollRegion : private CUIElementBase
|
||||
{
|
||||
public:
|
||||
// TODO: Properly fix whatever is causing the 1-pixel discrepancy in scrolling rect height and remove this magic value.
|
||||
// Currently this must be added when calculating the required height of a UI rect for a scroll region to get a perfect fit.
|
||||
static constexpr float HEIGHT_MAGIC_FIX = 1.0f;
|
||||
|
||||
enum EScrollRelative
|
||||
{
|
||||
SCROLLRELATIVE_UP = -1,
|
||||
|
|
Loading…
Reference in a new issue