DDraceNetwork Docs
CUIRect Class Reference

#include <ui_rect.h>

Collaboration diagram for CUIRect:
[legend]

Public Member Functions

void HSplitMid (CUIRect *pTop, CUIRect *pBottom, float Spacing=0.0f) const
 
void HSplitTop (float Cut, CUIRect *pTop, CUIRect *pBottom) const
 
void HSplitBottom (float Cut, CUIRect *pTop, CUIRect *pBottom) const
 
void VSplitMid (CUIRect *pLeft, CUIRect *pRight, float Spacing=0.0f) const
 
void VSplitLeft (float Cut, CUIRect *pLeft, CUIRect *pRight) const
 
void VSplitRight (float Cut, CUIRect *pLeft, CUIRect *pRight) const
 
void Margin (vec2 Cut, CUIRect *pOtherRect) const
 
void Margin (float Cut, CUIRect *pOtherRect) const
 
void VMargin (float Cut, CUIRect *pOtherRect) const
 
void HMargin (float Cut, CUIRect *pOtherRect) const
 
bool Inside (vec2 Point) const
 
void Draw (ColorRGBA Color, int Corners, float Rounding) const
 
void Draw4 (ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) const
 
vec2 TopLeft () const
 
vec2 Size () const
 
vec2 Center () const
 

Static Public Member Functions

static void Init (IGraphics *pGraphics)
 

Public Attributes

float x
 
float y
 
float w
 
float h
 

Static Private Attributes

static IGraphicss_pGraphics = nullptr
 

Member Function Documentation

◆ Center()

vec2 CUIRect::Center ( ) const
inline

Returns the center position of this CUIRect as a vec2.

Returns
Center position as vec2.

◆ Draw()

void CUIRect::Draw ( ColorRGBA  Color,
int  Corners,
float  Rounding 
) const

Fill background of this CUIRect.

Note
Example of filling a black half transparent background with 5px rounded edges on all sides
MyCuiRect.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 5.0f);
Example of filling a red background with sharp edges
MyCuiRect.Draw(ColorRGBA(1.0f, 0.0f, 0.0f), IGraphics::CORNER_NONE, 0.0f);
Parameters
Color
Corners
Rounding

◆ Draw4()

void CUIRect::Draw4 ( ColorRGBA  ColorTopLeft,
ColorRGBA  ColorTopRight,
ColorRGBA  ColorBottomLeft,
ColorRGBA  ColorBottomRight,
int  Corners,
float  Rounding 
) const

◆ HMargin()

void CUIRect::HMargin ( float  Cut,
CUIRect pOtherRect 
) const

Places pOtherRect inside this CUIRect applying Cut as the margin only on the horizontal axis.

Parameters
CutThe margin.
pOtherRectThe CUIRect to place inside this CUIRect

◆ HSplitBottom()

void CUIRect::HSplitBottom ( float  Cut,
CUIRect pTop,
CUIRect pBottom 
) const

Splits 2 CUIRect inside this CUIRect.

The cut parameter determines the height of the bottom rect, so it allows more customization than HSplitMid.

This method doesn't check if Cut is bigger than this rect height.

Parameters
CutThe height of the pBottom rect.
pTopThe rect that ends up at the top with a height equal to this CUIRect height minus Cut.
pBottomThe rect that ends up at the bottom with a height equal to Cut.

◆ HSplitMid()

void CUIRect::HSplitMid ( CUIRect pTop,
CUIRect pBottom,
float  Spacing = 0.0f 
) const

Splits 2 CUIRect inside this CUIRect horizontally. You can pass null pointers.

Parameters
pTopThis rect will end up taking the top half of this CUIRect.
pBottomThis rect will end up taking the bottom half of this CUIRect.
SpacingTotal size of margin between split rects.

◆ HSplitTop()

void CUIRect::HSplitTop ( float  Cut,
CUIRect pTop,
CUIRect pBottom 
) const

Splits 2 CUIRect inside this CUIRect.

The cut parameter determines the height of the top rect, so it allows more customization than HSplitMid.

This method doesn't check if Cut is bigger than this rect height.

Parameters
CutThe height of the pTop rect.
pTopThe rect that ends up at the top with a height equal to Cut.
pBottomThe rect that ends up at the bottom with a height equal to this rect minus the Cut.

◆ Init()

static void CUIRect::Init ( IGraphics pGraphics)
inlinestatic

◆ Inside()

bool CUIRect::Inside ( vec2  Point) const

Checks whether a point is inside this CUIRect.

Parameters
PointThe point's position.
Returns
true iff the given point is inside this CUIRect.

◆ Margin() [1/2]

void CUIRect::Margin ( float  Cut,
CUIRect pOtherRect 
) const

Places pOtherRect inside this CUIRect with Cut as the margin.

Parameters
CutThe margin.
pOtherRectThe CUIRect to place inside this CUIRect.

◆ Margin() [2/2]

void CUIRect::Margin ( vec2  Cut,
CUIRect pOtherRect 
) const

Places pOtherRect inside this CUIRect with Cut as the margin.

Parameters
CutThe margin as a vec2. The x component applies to the vertical axis. The y component applies to the horizontal axis.
pOtherRectThe CUIRect to place inside this CUIRect.

◆ Size()

vec2 CUIRect::Size ( ) const
inline

Returns the size of this CUIRect as a vec2.

Returns
Size as vec2.

◆ TopLeft()

vec2 CUIRect::TopLeft ( ) const
inline

Returns the top-left position of this CUIRect as a vec2.

Returns
Top-left position as vec2.

◆ VMargin()

void CUIRect::VMargin ( float  Cut,
CUIRect pOtherRect 
) const

Places pOtherRect inside this CUIRect applying Cut as the margin only on the vertical axis.

Parameters
CutThe margin.
pOtherRectThe CUIRect to place inside this CUIRect

◆ VSplitLeft()

void CUIRect::VSplitLeft ( float  Cut,
CUIRect pLeft,
CUIRect pRight 
) const

Splits 2 CUIRect inside this CUIRect.

The cut parameter determines the width of the left rect, so it allows more customization than VSplitMid.

This method doesn't check if Cut is bigger than this rect width.

Parameters
CutThe width of the pLeft rect.
pLeftThe rect that ends up at the left with a width equal to Cut.
pRightThe rect that ends up at the right with a width equal to this rect minus the Cut.

◆ VSplitMid()

void CUIRect::VSplitMid ( CUIRect pLeft,
CUIRect pRight,
float  Spacing = 0.0f 
) const

Splits 2 CUIRect inside this CUIRect vertically. You can pass null pointers.

Parameters
pLeftThis rect will take up the left half of this CUIRect.
pRightThis rect will take up the right half of this CUIRect.
SpacingTotal size of margin between split rects.

◆ VSplitRight()

void CUIRect::VSplitRight ( float  Cut,
CUIRect pLeft,
CUIRect pRight 
) const

Splits 2 CUIRect inside this CUIRect.

The cut parameter determines the width of the right rect, so it allows more customization than VSplitMid.

This method doesn't check if Cut is bigger than this rect width.

Parameters
CutThe width of the pRight rect.
pLeftThe rect that ends up at the left with a width equal to this CUIRect width minus Cut.
pRightThe rect that ends up at the right with a width equal to Cut.

Member Data Documentation

◆ h

float CUIRect::h

◆ s_pGraphics

IGraphics * CUIRect::s_pGraphics = nullptr
staticprivate

◆ w

float CUIRect::w

◆ x

float CUIRect::x

◆ y

float CUIRect::y

The documentation for this class was generated from the following files: