28 #ifndef _CEGUICoordConverter_h_
29 #define _CEGUICoordConverter_h_
31 #include "CEGUI/UDim.h"
32 #include "CEGUI/Vector.h"
33 #include "CEGUI/Size.h"
34 #include "CEGUI/Rect.h"
63 inline static float alignToPixels(
float x)
65 return (
float)(int)(( x ) + (( x ) > 0.0f ? 0.5f : -0.5f));
72 inline static float asAbsolute(
const UDim& u,
float base,
bool pixelAlign =
true)
74 return pixelAlign ? alignToPixels(base * u.d_scale + u.d_offset) : base * u.d_scale + u.d_offset;
81 inline static float asRelative(
const UDim& u,
float base)
83 return (base != 0.0f) ? u.d_offset / base + u.d_scale : 0.0f;
92 return Vector2f(asAbsolute(v.d_x, base.d_width, pixelAlign), asAbsolute(v.d_y, base.d_height, pixelAlign));
101 return Vector2f(asRelative(v.d_x, base.d_width), asRelative(v.d_y, base.d_height));
110 return Sizef(asAbsolute(v.d_width, base.d_width, pixelAlign), asAbsolute(v.d_height, base.d_height, pixelAlign));
119 return Sizef(asRelative(v.d_width, base.d_width), asRelative(v.d_height, base.d_height));
122 inline static Rectf asAbsolute(
const URect& r,
const Sizef& base,
bool pixelAlign =
true)
125 asAbsolute(r.d_min.d_x, base.d_width, pixelAlign),
126 asAbsolute(r.d_min.d_y, base.d_height, pixelAlign),
127 asAbsolute(r.d_max.d_x, base.d_width, pixelAlign),
128 asAbsolute(r.d_max.d_y, base.d_height, pixelAlign)
132 inline static Rectf asRelative(
const URect& r,
const Sizef& base)
135 asRelative(r.d_min.d_x, base.d_width),
136 asRelative(r.d_min.d_y, base.d_height),
137 asRelative(r.d_max.d_x, base.d_width),
138 asRelative(r.d_max.d_y, base.d_height)
157 static float screenToWindowX(
const Window& window,
const UDim& x);
174 static float screenToWindowX(
const Window& window,
const float x);
191 static float screenToWindowY(
const Window& window,
const UDim& y);
208 static float screenToWindowY(
const Window& window,
const float y);
225 static Vector2f screenToWindow(
const Window& window,
const UVector2& vec);
242 static Vector2f screenToWindow(
const Window& window,
const Vector2f& vec);
258 static Rectf screenToWindow(
const Window& window,
const URect& rect);
274 static Rectf screenToWindow(
const Window& window,
const Rectf& rect);
291 static float getBaseXValue(
const Window& window);
304 static float getBaseYValue(
const Window& window);
317 static Vector2f getBaseValue(
const Window& window);
323 #endif // end of guard _CEGUICoordConverter_h_