Properly upgrading CEGUI (window->getRelativeWidth)
Moderators: CEGUI MVP, CEGUI Team
- tgraupmann
- Quite a regular
- Posts: 78
- Joined: Thu Aug 18, 2005 00:47
- Contact:
Properly upgrading CEGUI (window->getRelativeWidth)
Now that getRelativeWidth is gone. What is the equivalent call in CEGUI 0.5.0?
From http://www.cegui.org.uk/wiki/index.php/ ... .0_Release
getXPosition, getWindowXPosition, getRelativeXPosition and getAbsoluteXPosition members are replaced with a single getXPosition member returning a UDim.
getXPosition, getWindowXPosition, getRelativeXPosition and getAbsoluteXPosition members are replaced with a single getXPosition member returning a UDim.
- tgraupmann
- Quite a regular
- Posts: 78
- Joined: Thu Aug 18, 2005 00:47
- Contact:
I was more looking for an explicit conversion. Is this correct?
became
Browsing the CEGUI SDK 0.4.1 source, I see:
Code: Select all
float relativeWidth = m_Window->getRelativeWidth()
became
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));
Browsing the CEGUI SDK 0.4.1 source, I see:
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;
}
}
- tgraupmann
- Quite a regular
- Posts: 78
- Joined: Thu Aug 18, 2005 00:47
- Contact:
Who is online
Users browsing this forum: No registered users and 24 guests