27 #ifndef _CEGUICoordConverter_h_
28 #define _CEGUICoordConverter_h_
30 #include "CEGUI/UDim.h"
31 #include "CEGUI/Vector.h"
32 #include "CEGUI/Size.h"
33 #include "CEGUI/Rect.h"
64 return (
float)(int)(( x ) + (( x ) > 0.0f ? 0.5f : -0.5f));
71 inline static float asAbsolute(
const UDim& u,
float base,
bool pixelAlign =
true)
73 return pixelAlign ? alignToPixels(base * u.d_scale + u.d_offset) : base * u.d_scale + u.d_offset;
82 return (base != 0.0f) ? u.d_offset / base + u.d_scale : 0.0f;
91 return Vector2f(asAbsolute(v.d_x, base.d_width, pixelAlign), asAbsolute(v.d_y, base.d_height, pixelAlign));
100 return Vector2f(asRelative(v.d_x, base.d_width), asRelative(v.d_y, base.d_height));
109 return Sizef(asAbsolute(v.d_width, base.d_width, pixelAlign), asAbsolute(v.d_height, base.d_height, pixelAlign));
118 return Sizef(asRelative(v.d_width, base.d_width), asRelative(v.d_height, base.d_height));
121 inline static Rectf asAbsolute(
const URect& r,
const Sizef& base,
bool pixelAlign =
true)
124 asAbsolute(r.d_min.d_x, base.d_width, pixelAlign),
125 asAbsolute(r.d_min.d_y, base.d_height, pixelAlign),
126 asAbsolute(r.d_max.d_x, base.d_width, pixelAlign),
127 asAbsolute(r.d_max.d_y, base.d_height, pixelAlign)
131 inline static Rectf asRelative(
const URect& r,
const Sizef& base)
134 asRelative(r.d_min.d_x, base.d_width),
135 asRelative(r.d_min.d_y, base.d_height),
136 asRelative(r.d_max.d_x, base.d_width),
137 asRelative(r.d_max.d_y, base.d_height)
156 static float screenToWindowX(
const Window& window,
const UDim& x);
173 static float screenToWindowX(
const Window& window,
const float x);
190 static float screenToWindowY(
const Window& window,
const UDim& y);
207 static float screenToWindowY(
const Window& window,
const float y);
224 static Vector2f screenToWindow(
const Window& window,
const UVector2& vec);
241 static Vector2f screenToWindow(
const Window& window,
const Vector2f& vec);
257 static Rectf screenToWindow(
const Window& window,
const URect& rect);
273 static Rectf screenToWindow(
const Window& window,
const Rectf& rect);
290 static float getBaseXValue(
const Window& window);
303 static float getBaseYValue(
const Window& window);
316 static Vector2f getBaseValue(
const Window& window);
322 #endif // end of guard _CEGUICoordConverter_h_
static float asRelative(const UDim &u, float base)
converts given UDim to relative value
Definition: CoordConverter.h:80
static float alignToPixels(float x)
Static method used to return a float value rounded to the nearest integer.
Definition: CoordConverter.h:62
static Vector2f asAbsolute(const Vector2< UDim > &v, const Sizef &base, bool pixelAlign=true)
converts given Vector2 to absolute Vector2f
Definition: CoordConverter.h:89
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
static Sizef asAbsolute(const Size< UDim > &v, const Sizef &base, bool pixelAlign=true)
converts given Size to absolute Sizef
Definition: CoordConverter.h:107
static Sizef asRelative(const Size< UDim > &v, const Sizef &base)
converts given Size to relative Sizef
Definition: CoordConverter.h:116
Utility class that helps in converting various types of co-ordinate between absolute screen positions...
Definition: CoordConverter.h:44
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition: UDim.h:92
static Vector2f asRelative(const Vector2< UDim > &v, const Sizef &base)
converts given Vector2 to relative Vector2f
Definition: CoordConverter.h:98
static float asAbsolute(const UDim &u, float base, bool pixelAlign=true)
converts given UDim to absolute value
Definition: CoordConverter.h:71