32#include "CEGUI/UDim.h"
33#include "CEGUI/Vector.h"
77 inline Size(
const T width,
const T height):
87 inline bool operator==(
const Size& other)
const
89 return d_width == other.d_width && d_height == other.d_height;
92 inline bool operator!=(
const Size& other)
const
94 return !operator==(other);
97 inline Size operator*(
const T c)
const
99 return Size(d_width * c, d_height * c);
102 inline Size operator*(
const Size& s)
const
104 return Size(d_width * s.d_width, d_height * s.d_height);
109 return Size(d_width * vec.d_x, d_height * vec.d_y);
112 inline Size operator+(
const Size& s)
const
114 return Size(d_width + s.d_width, d_height + s.d_height);
117 inline Size operator-(
const Size& s)
const
119 return Size(d_width - s.d_width, d_height - s.d_height);
122 inline void clamp(
const Size& min,
const Size& max)
124 assert(min.d_width <= max.d_width);
125 assert(min.d_height <= max.d_height);
127 if (d_width < min.d_width)
128 d_width = min.d_width;
129 else if (d_width > max.d_width)
130 d_width = max.d_width;
132 if (d_height < min.d_height)
133 d_height = min.d_height;
134 else if (d_height > max.d_height)
135 d_height = max.d_height;
138 inline void scaleToAspect(
AspectMode mode, T ratio)
143 if(d_width <= 0 && d_height <= 0)
148 const T expectedWidth = d_height * ratio;
149 const bool keepHeight = (mode ==
AM_SHRINK) ?
150 expectedWidth <= d_width : expectedWidth >= d_width;
154 d_width = expectedWidth;
158 d_height = d_width / ratio;
167 s <<
"CEGUI::Size<" <<
typeid(T).name() <<
">(" << v.d_width <<
", " << v.d_height <<
")";
174 return Size(side, side);
206typedef Size<float> Sizef;
207typedef Size<UDim> USize;
209inline USize operator*(
const USize& i,
float x)
211 return i * UDim(x,x);
Definition MemoryAllocatedObject.h:110
Class that holds the size (width & height) of something.
Definition Size.h:68
static Size zero()
finger saving alias for Size(0, 0)
Definition Size.h:178
static Size square(const T side)
finger saving alias for Size(side, side)
Definition Size.h:172
static Size one()
finger saving alias for Size(1, 1)
Definition Size.h:184
static Size one_width()
finger saving alias for Size(1, 0)
Definition Size.h:190
static Size one_height()
finger saving alias for Size(0, 1)
Definition Size.h:196
friend std::ostream & operator<<(std::ostream &s, const Size &v)
allows writing the size to std ostream
Definition Size.h:165
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1
T TypeSensitiveZero()
allows you to get UDim(0, 0) if you pass UDim or just 0 if you pass anything else
Definition UDim.h:343
T TypeSensitiveOne()
allows you to get UDim::relative() if you pass UDim or just 1 if you pass anything else
Definition UDim.h:360
AspectMode
How aspect ratio should be maintained.
Definition Size.h:46
@ AM_SHRINK
Definition Size.h:53
@ AM_EXPAND
Definition Size.h:58
@ AM_IGNORE
Ignores the target aspect (default)
Definition Size.h:48