Crazy Eddie's GUI System  0.8.7
CEGUI::UDim Class Reference

Dimension that has both a relative 'scale' portion and and absolute 'offset' portion. More...

+ Inheritance diagram for CEGUI::UDim:
+ Collaboration diagram for CEGUI::UDim:

Public Member Functions

 UDim (float scale, float offset)
 
 UDim (const UDim &v)
 
UDim operator+ (const UDim &other) const
 
UDim operator- (const UDim &other) const
 
UDim operator* (const float val) const
 
UDim operator* (const UDim &other) const
 
UDim operator/ (const UDim &other) const
 
const UDimoperator+= (const UDim &other)
 
const UDimoperator-= (const UDim &other)
 
const UDimoperator*= (const UDim &other)
 
const UDimoperator/= (const UDim &other)
 
bool operator== (const UDim &other) const
 
bool operator!= (const UDim &other) const
 

Static Public Member Functions

static UDim zero ()
 finger saving convenience method returning UDim(0, 0)
 
static UDim relative ()
 finger saving convenience method returning UDim(1, 0) More...
 
static UDim percent ()
 finger saving convenience method returning UDim(0.01, 0) More...
 
static UDim px ()
 finger saving convenience method returning UDim(0, 1) More...
 

Public Attributes

float d_scale
 
float d_offset
 

Friends

UDim operator* (const float val, const UDim &u)
 
std::ostream & operator<< (std::ostream &s, const UDim &v)
 allows writing the udim to std ostream
 

Detailed Description

Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.

The meaning of this class depends on where you use it, it is just a float tuple. We will only describe the usual usecase for CEGUI::Window position and size. CEGUI::Window gets that behavior from CEGUI::Element.

UDims are used for both positioning and sizing (hence the name dimension).

The scale component describes the amount of dimension we take from the parent CEGUI::Element. The offset component describes the amount of pixels and is not dependent on any element in the tree.

Example: 50% of parent's width
UDim(0.5f, 0);
Example: 100px
UDim(0, 100.0f);
Negative components
You can use negative components in UDim and they are in fact very useful!
UDim(1.0f, -100.0f); // 100px to the left from the right edge of parent widget
Floating point
Both components are floats, that means that expressing fractions of pixels is allowed even though such construct goes against the definition of pixel.
UDim(0.0f, 1.123456f); // perfectly valid UDim

Keep in mind that if you use such dimensions they will likely get pixel aligned before rendering. You can disable such behavior via Element::setPixelAligned.

See also
CEGUI::UVector2
CEGUI::USize
CEGUI::URect

Member Function Documentation

static UDim CEGUI::UDim::percent ( )
inlinestatic

finger saving convenience method returning UDim(0.01, 0)

Note
Allows quite neat 50 * UDim::percent() self documenting syntax
static UDim CEGUI::UDim::px ( )
inlinestatic

finger saving convenience method returning UDim(0, 1)

Note
Allows quite neat 100 * UDim::px() self documenting syntax, you can combine it with UDim::relative() as well (using operator+)
static UDim CEGUI::UDim::relative ( )
inlinestatic

finger saving convenience method returning UDim(1, 0)

Note
Allows quite neat 0.5 * UDim::relative() self documenting syntax