mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Add optional Spacing parameter to H/VSplitMid
This commit is contained in:
parent
155a922d47
commit
4fbca828f4
|
@ -216,25 +216,26 @@ void CUI::ClipDisable()
|
||||||
Graphics()->ClipDisable();
|
Graphics()->ClipDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUIRect::HSplitMid(CUIRect *pTop, CUIRect *pBottom) const
|
void CUIRect::HSplitMid(CUIRect *pTop, CUIRect *pBottom, float Spacing) const
|
||||||
{
|
{
|
||||||
CUIRect r = *this;
|
CUIRect r = *this;
|
||||||
float Cut = r.h / 2;
|
const float Cut = r.h / 2;
|
||||||
|
const float HalfSpacing = Spacing / 2;
|
||||||
|
|
||||||
if(pTop)
|
if(pTop)
|
||||||
{
|
{
|
||||||
pTop->x = r.x;
|
pTop->x = r.x;
|
||||||
pTop->y = r.y;
|
pTop->y = r.y;
|
||||||
pTop->w = r.w;
|
pTop->w = r.w;
|
||||||
pTop->h = Cut;
|
pTop->h = Cut - HalfSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pBottom)
|
if(pBottom)
|
||||||
{
|
{
|
||||||
pBottom->x = r.x;
|
pBottom->x = r.x;
|
||||||
pBottom->y = r.y + Cut;
|
pBottom->y = r.y + Cut + HalfSpacing;
|
||||||
pBottom->w = r.w;
|
pBottom->w = r.w;
|
||||||
pBottom->h = r.h - Cut;
|
pBottom->h = r.h - Cut - HalfSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,25 +283,25 @@ void CUIRect::HSplitBottom(float Cut, CUIRect *pTop, CUIRect *pBottom) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUIRect::VSplitMid(CUIRect *pLeft, CUIRect *pRight) const
|
void CUIRect::VSplitMid(CUIRect *pLeft, CUIRect *pRight, float Spacing) const
|
||||||
{
|
{
|
||||||
CUIRect r = *this;
|
CUIRect r = *this;
|
||||||
float Cut = r.w / 2;
|
const float Cut = r.w / 2;
|
||||||
// Cut *= Scale();
|
const float HalfSpacing = Spacing / 2;
|
||||||
|
|
||||||
if(pLeft)
|
if(pLeft)
|
||||||
{
|
{
|
||||||
pLeft->x = r.x;
|
pLeft->x = r.x;
|
||||||
pLeft->y = r.y;
|
pLeft->y = r.y;
|
||||||
pLeft->w = Cut;
|
pLeft->w = Cut - HalfSpacing;
|
||||||
pLeft->h = r.h;
|
pLeft->h = r.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pRight)
|
if(pRight)
|
||||||
{
|
{
|
||||||
pRight->x = r.x + Cut;
|
pRight->x = r.x + Cut + HalfSpacing;
|
||||||
pRight->y = r.y;
|
pRight->y = r.y;
|
||||||
pRight->w = r.w - Cut;
|
pRight->w = r.w - Cut - HalfSpacing;
|
||||||
pRight->h = r.h;
|
pRight->h = r.h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Splits 2 CUIRect inside *this* CUIRect horizontally. You can pass null pointers.
|
* Splits 2 CUIRect inside *this* CUIRect horizontally. You can pass null pointers.
|
||||||
*
|
*
|
||||||
* @param pTop This rect will end up taking the top half of this CUIRect
|
* @param pTop This rect will end up taking the top half of this CUIRect.
|
||||||
* @param pBottom This rect will end up taking the bottom half of this CUIRect
|
* @param pBottom This rect will end up taking the bottom half of this CUIRect.
|
||||||
|
* @param Spacing Total size of margin between split rects.
|
||||||
*/
|
*/
|
||||||
void HSplitMid(CUIRect *pTop, CUIRect *pBottom) const;
|
void HSplitMid(CUIRect *pTop, CUIRect *pBottom, float Spacing = 0.0f) const;
|
||||||
/**
|
/**
|
||||||
* Splits 2 CUIRect inside *this* CUIRect.
|
* Splits 2 CUIRect inside *this* CUIRect.
|
||||||
*
|
*
|
||||||
|
@ -52,8 +53,9 @@ public:
|
||||||
*
|
*
|
||||||
* @param pLeft This rect will take up the left half of *this* CUIRect.
|
* @param pLeft This rect will take up the left half of *this* CUIRect.
|
||||||
* @param pRight This rect will take up the right half of *this* CUIRect.
|
* @param pRight This rect will take up the right half of *this* CUIRect.
|
||||||
|
* @param Spacing Total size of margin between split rects.
|
||||||
*/
|
*/
|
||||||
void VSplitMid(CUIRect *pLeft, CUIRect *pRight) const;
|
void VSplitMid(CUIRect *pLeft, CUIRect *pRight, float Spacing = 0.0f) const;
|
||||||
/**
|
/**
|
||||||
* Splits 2 CUIRect inside *this* CUIRect.
|
* Splits 2 CUIRect inside *this* CUIRect.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue