 |
Gorgon Game Engine
|
Go to the documentation of this file.
3 #include "../Geometry/Margin.h"
4 #include "../Geometry/Size.h"
5 #include "../Geometry/Bounds.h"
7 namespace Gorgon {
namespace UI {
50 int Calculate(
int parentwidth,
int emwidth = 10)
const {
53 return int(std::round((
double)value * parentwidth / 100));
55 return int(std::round((
double)value / 1000));
57 return int(std::round((
double)value * parentwidth / 10000));
59 return int(std::round(value * emwidth / 100));
70 return (
float)value * parentwidth / 100.f;
72 return (
float)value * parentwidth / 10000.f;
74 return (
float)value / 1000;
76 return (
float)value * emwidth / 100.f;
126 return {p.
X(parent.
Width, emwidth), p.
Y(parent.
Height, emwidth)};
Dimension data for components. Allows relative position and sizing.
Definition: Dimension.h:9
Unit GetUnit() const
Returns the unit of the dimension.
Definition: Dimension.h:95
int operator()(int parentwidth, int emwidth=10) const
Returns the calculated dimension in pixels.
Definition: Dimension.h:45
void Set(int value)
Changes the value of the dimension without modifying the units.
Definition: Dimension.h:100
T_ Left
Left margin.
Definition: Margin.h:167
Geometry::Point Convert(const Point &p, const Geometry::Size &parent, int emwidth=10)
Converts a dimension based point to pixel based point.
Definition: Dimension.h:125
T_ X
X coordinate.
Definition: Point.h:368
T_ Height
Height of this size object.
Definition: Size.h:261
@ Pixel
Fixed pixel based dimensions.
Definition: Dimension.h:18
void Set(int value, Unit unit)
Changes the value and unit of the dimension.
Definition: Dimension.h:105
T_ Top
Top margin.
Definition: Margin.h:170
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
int GetValue() const
Returns the value of the dimension, should not be considered as pixels.
Definition: Dimension.h:90
bool IsRelative() const
Returns if the dimension is relative to the parentwidth.
Definition: Dimension.h:84
int Calculate(int parentwidth, int emwidth=10) const
Returns the calculated dimension in pixels.
Definition: Dimension.h:50
T_ Bottom
Bottom margin.
Definition: Margin.h:176
@ BasisPoint
Dimension will be relative to the parent and given in 1/10000.
Definition: Dimension.h:29
float CalculateFloat(float parentwidth, float emwidth=10) const
Returns the calculated dimension in pixels.
Definition: Dimension.h:67
T_ Right
Right margin.
Definition: Margin.h:173
T_ Y
Y coordinate.
Definition: Point.h:371
T_ Width
Width of this size object.
Definition: Size.h:258
@ EM
Dimension will be relative to the text size, given value is the percent of the width of an EM dash.
Definition: Dimension.h:35
Dimension(int value=0, Unit unit=Pixel)
Constructs a new dimension or type casts integer to dimension
Definition: Dimension.h:41
@ MilliPixel
1/1000th of a pixel, there are only few places that this will be used.
Definition: Dimension.h:26
Unit
Unit for dimensions.
Definition: Dimension.h:16
@ Percent
Dimension will be relative to the parent and given in percent.
Definition: Dimension.h:22