![]() |
Gorgon Game Engine
|
Dimension data for components. Allows relative position and sizing. More...
Public Types | |
enum | Unit { Pixel, Percent, MilliPixel, BasisPoint, EM } |
Unit for dimensions. More... | |
Public Member Functions | |
Dimension (int value=0, Unit unit=Pixel) | |
Constructs a new dimension or type casts integer to dimension More... | |
int | Calculate (int parentwidth, int emwidth=10) const |
Returns the calculated dimension in pixels. More... | |
float | CalculateFloat (float parentwidth, float emwidth=10) const |
Returns the calculated dimension in pixels. More... | |
Unit | GetUnit () const |
Returns the unit of the dimension. More... | |
int | GetValue () const |
Returns the value of the dimension, should not be considered as pixels. More... | |
bool | IsRelative () const |
Returns if the dimension is relative to the parentwidth. More... | |
int | operator() (int parentwidth, int emwidth=10) const |
Returns the calculated dimension in pixels. More... | |
void | Set (int value) |
Changes the value of the dimension without modifying the units. More... | |
void | Set (int value, Unit unit) |
Changes the value and unit of the dimension. More... | |
Dimension data for components. Allows relative position and sizing.
enum Unit |
Unit for dimensions.
Dimensions in UI system does not allow floating point numbers as floating point numbers are not precise and may cause issues. Additionally, final values always rounded, so that the symbols are always on full pixels.
Enumerator | |
---|---|
Pixel | Fixed pixel based dimensions. |
Percent | Dimension will be relative to the parent and given in percent. If higher resolution is necessary use BasisPoint. |
MilliPixel | 1/1000th of a pixel, there are only few places that this will be used. Currently only rotation center use non-integer pixels |
BasisPoint | Dimension will be relative to the parent and given in 1/10000. |
EM | Dimension will be relative to the text size, given value is the percent of the width of an EM dash. If no font information is found, 10px will be used for EM dash. Thus, 1 unit will be 0.1 pixels. |
Constructs a new dimension or type casts integer to dimension
int Calculate | ( | int | parentwidth, |
int | emwidth = 10 |
||
) | const |
Returns the calculated dimension in pixels.
References Dimension::BasisPoint, Dimension::EM, Dimension::MilliPixel, Dimension::Percent, and Dimension::Pixel.
float CalculateFloat | ( | float | parentwidth, |
float | emwidth = 10 |
||
) | const |
Returns the calculated dimension in pixels.
References Dimension::BasisPoint, Dimension::EM, Dimension::MilliPixel, Dimension::Percent, and Dimension::Pixel.
Unit GetUnit | ( | ) | const |
Returns the unit of the dimension.
int GetValue | ( | ) | const |
Returns the value of the dimension, should not be considered as pixels.
bool IsRelative | ( | ) | const |
Returns if the dimension is relative to the parentwidth.
References Dimension::BasisPoint, and Dimension::Percent.
int operator() | ( | int | parentwidth, |
int | emwidth = 10 |
||
) | const |
Returns the calculated dimension in pixels.
References Dimension::Calculate().
void Set | ( | int | value | ) |
Changes the value of the dimension without modifying the units.
void Set | ( | int | value, |
Unit | unit | ||
) |
Changes the value and unit of the dimension.