mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Overload ui SplitMid functions with tripple split
This commit is contained in:
parent
96889c8d41
commit
7b464b9465
|
@ -29,6 +29,38 @@ void CUIRect::HSplitMid(CUIRect *pTop, CUIRect *pBottom, float Spacing) const
|
|||
}
|
||||
}
|
||||
|
||||
void CUIRect::HSpaceAround(CUIRect *pTop, CUIRect *pMiddle, CUIRect *pBottom, float Spacing) const
|
||||
{
|
||||
CUIRect r = *this;
|
||||
const float Cut = r.h / 3;
|
||||
const float HalfSpacing = Spacing / 2;
|
||||
const float Height = Cut - Spacing;
|
||||
|
||||
if(pTop)
|
||||
{
|
||||
pTop->x = r.x;
|
||||
pTop->y = r.y + HalfSpacing;
|
||||
pTop->w = r.w;
|
||||
pTop->h = Height;
|
||||
}
|
||||
|
||||
if(pMiddle)
|
||||
{
|
||||
pMiddle->x = r.x;
|
||||
pMiddle->y = r.y + Cut + HalfSpacing;
|
||||
pMiddle->w = r.w;
|
||||
pMiddle->h = Height;
|
||||
}
|
||||
|
||||
if(pBottom)
|
||||
{
|
||||
pBottom->x = r.x;
|
||||
pBottom->y = r.y + Cut * 2 + HalfSpacing;
|
||||
pBottom->w = r.w;
|
||||
pBottom->h = Height;
|
||||
}
|
||||
}
|
||||
|
||||
void CUIRect::HSplitTop(float Cut, CUIRect *pTop, CUIRect *pBottom) const
|
||||
{
|
||||
CUIRect r = *this;
|
||||
|
@ -94,6 +126,38 @@ void CUIRect::VSplitMid(CUIRect *pLeft, CUIRect *pRight, float Spacing) const
|
|||
}
|
||||
}
|
||||
|
||||
void CUIRect::VSpaceAround(CUIRect *pLeft, CUIRect *pMiddle, CUIRect *pRight, float Spacing) const
|
||||
{
|
||||
CUIRect r = *this;
|
||||
const float Cut = r.w / 3;
|
||||
const float HalfSpacing = Spacing / 2;
|
||||
const float Width = Cut - Spacing;
|
||||
|
||||
if(pLeft)
|
||||
{
|
||||
pLeft->x = r.x + HalfSpacing;
|
||||
pLeft->y = r.y;
|
||||
pLeft->w = Width;
|
||||
pLeft->h = r.h;
|
||||
}
|
||||
|
||||
if(pMiddle)
|
||||
{
|
||||
pMiddle->x = r.x + Cut + HalfSpacing;
|
||||
pMiddle->y = r.y;
|
||||
pMiddle->w = Width;
|
||||
pMiddle->h = r.h;
|
||||
}
|
||||
|
||||
if(pRight)
|
||||
{
|
||||
pRight->x = r.x + Cut * 2 + HalfSpacing;
|
||||
pRight->y = r.y;
|
||||
pRight->w = Width;
|
||||
pRight->h = r.h;
|
||||
}
|
||||
}
|
||||
|
||||
void CUIRect::VSplitLeft(float Cut, CUIRect *pLeft, CUIRect *pRight) const
|
||||
{
|
||||
CUIRect r = *this;
|
||||
|
|
|
@ -18,12 +18,53 @@ public:
|
|||
|
||||
/**
|
||||
* Splits 2 CUIRect inside *this* CUIRect horizontally. You can pass null pointers.
|
||||
* The spacing will be applied between the pTop and pBottom while both stay attached to *this*
|
||||
*
|
||||
* @verbatim
|
||||
* +---------------+
|
||||
* |+-------------+|
|
||||
* || pTop ||
|
||||
* |+-------------+|
|
||||
* | *this* |
|
||||
* |+-------------+|
|
||||
* || pBottom ||
|
||||
* |+-------------+|
|
||||
* +---------------+
|
||||
* @endverbatim
|
||||
*
|
||||
* @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 Spacing Total size of margin between split rects.
|
||||
*/
|
||||
void HSplitMid(CUIRect *pTop, CUIRect *pBottom, float Spacing = 0.0f) const;
|
||||
/**
|
||||
* Splits 3 CUIRect inside *this* CUIRect horizontally. You can pass null pointers.
|
||||
* The spacing will be applied between the pTop, pMiddle, pBottom and also the *this*
|
||||
*
|
||||
* @verbatim
|
||||
* +---------------+
|
||||
* | *this* |
|
||||
* |+-------------+|
|
||||
* || pTop ||
|
||||
* |+-------------+|
|
||||
* | |
|
||||
* |+-------------+|
|
||||
* || pMiddle ||
|
||||
* |+-------------+|
|
||||
* | |
|
||||
* |+-------------+|
|
||||
* || pBottom ||
|
||||
* |+-------------+|
|
||||
* | |
|
||||
* +---------------+
|
||||
* @endverbatim
|
||||
*
|
||||
* @param pTop This rect will end up taking the top third of this CUIRect.
|
||||
* @param pMiddle This rect will end up taking the middle third of this CUIRect.
|
||||
* @param pBottom This rect will end up taking the bottom third of this CUIRect.
|
||||
* @param Spacing Total size of margin between split rects.
|
||||
*/
|
||||
void HSpaceAround(CUIRect *pTop, CUIRect *pMiddle, CUIRect *pBottom, float Spacing = 0.0f) const;
|
||||
/**
|
||||
* Splits 2 CUIRect inside *this* CUIRect.
|
||||
*
|
||||
|
@ -50,12 +91,39 @@ public:
|
|||
void HSplitBottom(float Cut, CUIRect *pTop, CUIRect *pBottom) const;
|
||||
/**
|
||||
* Splits 2 CUIRect inside *this* CUIRect vertically. You can pass null pointers.
|
||||
* The spacing will be applied between the pLeft and pRight while both stay attached to *this*
|
||||
*
|
||||
* @verbatim
|
||||
* +--------------------------+
|
||||
* |+-------+ +-------+|
|
||||
* || pLeft | *this* | pRight||
|
||||
* |+-------+ +-------+|
|
||||
* +--------------------------+
|
||||
* @endverbatim
|
||||
*
|
||||
* @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 Spacing Total size of margin between split rects.
|
||||
*/
|
||||
void VSplitMid(CUIRect *pLeft, CUIRect *pRight, float Spacing = 0.0f) const;
|
||||
/**
|
||||
* Splits 3 CUIRect inside *this* CUIRect vertically. You can pass null pointers.
|
||||
* The spacing will be applied between the pLeft, pMiddle, pRight and also the *this*
|
||||
*
|
||||
* @verbatim
|
||||
* +--------------------------------------------------------------+
|
||||
* | +--------+ +--------+ +--------+ |
|
||||
* | *this* | pLeft | | pMiddle| | pRight | |
|
||||
* | +--------+ +--------+ +--------+ |
|
||||
* +--------------------------------------------------------------+
|
||||
* @endverbatim
|
||||
*
|
||||
* @param pLeft This rect will take up the left third of *this* CUIRect.
|
||||
* @param pMiddle This rect will take up the middle third of *this* CUIRect.
|
||||
* @param pRight This rect will take up the right third of *this* CUIRect.
|
||||
* @param Spacing Total size of margin between split rects.
|
||||
*/
|
||||
void VSpaceAround(CUIRect *pLeft, CUIRect *pMiddle, CUIRect *pRight, float Spacing = 0.0f) const;
|
||||
/**
|
||||
* Splits 2 CUIRect inside *this* CUIRect.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue