mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add scroll region parameter to disable right margin
In case that a margin on the right side already exists, this allows creating a symmetric margin around the scrollbar.
This commit is contained in:
parent
f16974d1a9
commit
09835ed342
|
@ -34,11 +34,16 @@ void CScrollRegion::Begin(CUIRect *pClipRect, vec2 *pOutOffset, const CScrollReg
|
|||
const bool ContentOverflows = m_ContentH > pClipRect->h;
|
||||
const bool ForceShowScrollbar = m_Params.m_Flags & CScrollRegionParams::FLAG_CONTENT_STATIC_WIDTH;
|
||||
|
||||
const bool HasScrollBar = ContentOverflows || ForceShowScrollbar;
|
||||
CUIRect ScrollBarBg;
|
||||
bool HasScrollBar = ContentOverflows || ForceShowScrollbar;
|
||||
CUIRect *pModifyRect = HasScrollBar ? pClipRect : nullptr;
|
||||
pClipRect->VSplitRight(m_Params.m_ScrollbarWidth, pModifyRect, &ScrollBarBg);
|
||||
ScrollBarBg.Margin(m_Params.m_ScrollbarMargin, &m_RailRect);
|
||||
pClipRect->VSplitRight(m_Params.m_ScrollbarWidth, HasScrollBar ? pClipRect : nullptr, &ScrollBarBg);
|
||||
if(m_Params.m_ScrollbarNoMarginRight)
|
||||
{
|
||||
ScrollBarBg.HMargin(m_Params.m_ScrollbarMargin, &m_RailRect);
|
||||
m_RailRect.VSplitLeft(m_Params.m_ScrollbarMargin, nullptr, &m_RailRect);
|
||||
}
|
||||
else
|
||||
ScrollBarBg.Margin(m_Params.m_ScrollbarMargin, &m_RailRect);
|
||||
|
||||
// only show scrollbar if required
|
||||
if(HasScrollBar)
|
||||
|
|
|
@ -10,6 +10,7 @@ struct CScrollRegionParams
|
|||
bool m_Active;
|
||||
float m_ScrollbarWidth;
|
||||
float m_ScrollbarMargin;
|
||||
bool m_ScrollbarNoMarginRight;
|
||||
float m_SliderMinHeight;
|
||||
float m_ScrollUnit;
|
||||
ColorRGBA m_ClipBgColor;
|
||||
|
@ -30,6 +31,7 @@ struct CScrollRegionParams
|
|||
m_Active = true;
|
||||
m_ScrollbarWidth = 20.0f;
|
||||
m_ScrollbarMargin = 5.0f;
|
||||
m_ScrollbarNoMarginRight = false;
|
||||
m_SliderMinHeight = 25.0f;
|
||||
m_ScrollUnit = 10.0f;
|
||||
m_ClipBgColor = ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
|
Loading…
Reference in a new issue