Properly upgrading CEGUI (window->getRelativeWidth)
Posted: Tue Jun 05, 2007 04:30
Now that getRelativeWidth is gone. What is the equivalent call in CEGUI 0.5.0?
The official forum for CEGUI
http://cegui.org/forum/
Code: Select all
float relativeWidth = m_Window->getRelativeWidth()
Code: Select all
float relativeWidth = m_Window->getWidth().d_scale;
float relativeWidth = m_Window->getWidth().asRelative(0);
float relativeWidth = m_Window->getWidth().asRelative(m_Window->getWidth().d_offset);
float relativeWidth = m_Window->getWidth().asRelative(m_Window->getPosition().d_x));
Code: Select all
CEGUI/CEGUIWindow.h: float getRelativeWidth(void) const { return d_area.getWidth().asRelative(getParentWidth()); }
CEGUI/CEGUIWindow.h: float getRelativeHeight(void) const { return d_area.getHeight().asRelative(getParentHeight()); }
#if defined(CEGUI_ALIGN_ELEMENTS_TO_PIXELS)
# define PixelAligned(x) ( (float)(int)(( x ) + 0.5f) )
#else
# define PixelAligned(x) ( x )
#endif
float Window::absoluteToRelativeX_impl(const Window* window, float x) const
{
// get size object for whatever we are using as a base for the conversion
Size sz = getWindowSize_impl(window);
if (sz.d_width)
{
return PixelAligned(x) / sz.d_width;
}
else
{
return 0;
}
}
float Window::absoluteToRelativeY_impl(const Window* window, float y) const
{
// get size object for whatever we are using as a base for the conversion
Size sz = getWindowSize_impl(window);
if (sz.d_height)
{
return PixelAligned(y) / sz.d_height;
}
else
{
return 0;
}
}