mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +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)
|
bool CScrollRegion::AddRect(const CUIRect &Rect, bool ShouldScrollHere)
|
||||||
{
|
{
|
||||||
m_LastAddedRect = Rect;
|
m_LastAddedRect = Rect;
|
||||||
// Round up and add 1 to fix pixel clipping at the end of the scrolling area
|
// 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)) + 1.0f, m_ContentH);
|
m_ContentH = maximum(std::ceil(Rect.y + Rect.h - (m_ClipRect.y + m_ContentScrollOff.y)) + HEIGHT_MAGIC_FIX, m_ContentH);
|
||||||
if(ShouldScrollHere)
|
if(ShouldScrollHere)
|
||||||
ScrollHere();
|
ScrollHere();
|
||||||
return !IsRectClipped(Rect);
|
return !IsRectClipped(Rect);
|
||||||
|
|
|
@ -89,6 +89,10 @@ Usage:
|
||||||
class CScrollRegion : private CUIElementBase
|
class CScrollRegion : private CUIElementBase
|
||||||
{
|
{
|
||||||
public:
|
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
|
enum EScrollRelative
|
||||||
{
|
{
|
||||||
SCROLLRELATIVE_UP = -1,
|
SCROLLRELATIVE_UP = -1,
|
||||||
|
|
Loading…
Reference in a new issue