32 #include "CEGUI/Vector.h"
33 #include "CEGUI/Size.h"
44 public AllocatedObject<Rect<T> >
52 inline Rect(
const T& left,
const T& top,
const T& right,
const T& bottom):
57 inline Rect(
const Vector2<T>& min,
const Vector2<T>& max):
62 inline Rect(
const Vector2<T>& pos,
const Size<T>& size):
64 d_max(pos + Vector2<T>(size.d_width, size.d_height))
67 inline Rect(
const Rect& r):
72 inline Rect& operator=(
const Rect& rhs)
80 inline void left(
const T& v)
85 inline const T& left()
const
90 inline void top(
const T& v)
95 inline const T& top()
const
100 inline void right(
const T& v)
105 inline const T& right()
const
110 inline void bottom(
const T& v)
115 inline const T& bottom()
const
140 void setSize(
const Size<T>& size)
142 d_max = d_min +
Vector2<T>(size.d_width, size.d_height);
154 void setWidth(
const T& w)
156 d_max.d_x = d_min.d_x + w;
165 return d_max.d_x - d_min.d_x;
168 void setHeight(
const T& h)
170 d_max.d_y = d_min.d_y + h;
179 return d_max.d_y - d_min.d_y;
192 if ((d_max.d_x > rect.d_min.d_x) &&
193 (d_min.d_x < rect.d_max.d_x) &&
194 (d_max.d_y > rect.d_min.d_y) &&
195 (d_min.d_y < rect.d_max.d_y))
200 ret.d_min.d_x = (d_min.d_x > rect.d_min.d_x) ? d_min.d_x : rect.d_min.d_x;
201 ret.d_max.d_x = (d_max.d_x < rect.d_max.d_x) ? d_max.d_x : rect.d_max.d_x;
202 ret.d_min.d_y = (d_min.d_y > rect.d_min.d_y) ? d_min.d_y : rect.d_min.d_y;
203 ret.d_max.d_y = (d_max.d_y < rect.d_max.d_y) ? d_max.d_y : rect.d_max.d_y;
209 return Rect(0.0f, 0.0f, 0.0f, 0.0f);
241 if ((d_min.d_x > v.d_x) ||
242 (d_max.d_x <= v.d_x) ||
243 (d_min.d_y > v.d_y) ||
244 (d_max.d_y <= v.d_y))
267 setWidth(size.d_width);
272 setHeight(size.d_height);
291 setWidth(size.d_width);
296 setHeight(size.d_height);
318 if (curr_sz.d_width > max_sz.d_width)
320 setWidth(max_sz.d_width);
322 else if (curr_sz.d_width < min_sz.d_width)
324 setWidth(min_sz.d_width);
327 if (curr_sz.d_height > max_sz.d_height)
329 setHeight(max_sz.d_height);
331 else if (curr_sz.d_height < min_sz.d_height)
333 setHeight(min_sz.d_height);
341 inline bool operator==(
const Rect& rhs)
const
343 return ((d_min == rhs.d_min) && (d_max == rhs.d_max));
346 inline bool operator!=(
const Rect& rhs)
const
348 return !operator==(rhs);
351 inline Rect operator*(T scalar)
const
353 return Rect(d_min * scalar, d_max * scalar);
356 const Rect& operator*=(T scalar)
363 Rect operator+(
const Rect& r)
const
365 return Rect(d_min + r.d_min, d_max + r.d_max);
368 inline friend std::ostream& operator << (std::ostream& s,
const Rect& v)
370 s <<
"CEGUI::Rect<" <<
typeid(T).name() <<
">(" << v.d_min.d_x <<
", " << v.d_min.d_y <<
", " << v.d_max.d_x <<
", " << v.d_max.d_y <<
")";
393 typedef Rect<float> Rectf;
396 inline Rect<UDim> operator * (
const Rect<UDim>& v,
const float c)
398 return Rect<UDim>(v.d_min * c, v.d_max * c);
401 typedef Rect<UDim> URect;
406 #endif // end of guard _CEGUIRect_h_
Class used as a two dimensional vector (aka a Point)
Definition: ForwardRefs.h:122
void setPosition(const Vector2< T > &min)
set the position of the Rect (leaves size in tact)
Definition: Rect.h:124
void constrainSizeMin(const Size< T > &size)
check the size of the Rect object and if it is smaller than sz, resize it so it isn't.
Definition: Rect.h:287
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
const Vector2< T > & getPosition() const
Return top-left position of Rect as a Vector2
Definition: Rect.h:135
Class that holds the size (width & height) of something.
Definition: ForwardRefs.h:112
Rect getIntersection(const Rect &rect) const
return a Rect that is the intersection of 'this' Rect with the Rect 'rect'
Definition: Rect.h:190
Size< T > getSize() const
return the size of the Rect area
Definition: Rect.h:149
bool isPointInRect(const Vector2< T > &v) const
Return true if the given Vector2 falls within this Rect.
Definition: Rect.h:239
T getWidth() const
return width of Rect area
Definition: Rect.h:163
void constrainSize(const Size< T > &max_sz, const Size< T > &min_sz)
check the size of the Rect object and if it is bigger than max_sz or smaller than min_sz...
Definition: Rect.h:314
void offset(const Vector2< T > &v)
Applies an offset the Rect object.
Definition: Rect.h:223
void constrainSizeMax(const Size< T > &size)
check the size of the Rect object and if it is bigger than sz, resize it so it isn't.
Definition: Rect.h:263
T getHeight() const
return height of Rect area
Definition: Rect.h:177
static Rect zero()
finger saving alias for zero sized, zero positioned rect
Definition: Rect.h:375
Class encapsulating operations on a Rectangle.
Definition: ForwardRefs.h:89