Properly upgrading CEGUI (window->getRelativeWidth)

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
tgraupmann
Quite a regular
Quite a regular
Posts: 78
Joined: Thu Aug 18, 2005 00:47
Contact:

Properly upgrading CEGUI (window->getRelativeWidth)

Postby tgraupmann » Tue Jun 05, 2007 04:30

Now that getRelativeWidth is gone. What is the equivalent call in CEGUI 0.5.0?

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Jun 05, 2007 10:00

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.

User avatar
tgraupmann
Quite a regular
Quite a regular
Posts: 78
Joined: Thu Aug 18, 2005 00:47
Contact:

Postby tgraupmann » Tue Jun 05, 2007 14:01

I was more looking for an explicit conversion. Is this correct?

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;
        }
}

User avatar
tgraupmann
Quite a regular
Quite a regular
Posts: 78
Joined: Thu Aug 18, 2005 00:47
Contact:

Postby tgraupmann » Thu Jun 07, 2007 21:36

I should have said.

Now that getRelativeWidth is gone. What is the equivalent call (including parameters) in CEGUI 0.5.0?


Return to “Help”

Who is online

Users browsing this forum: No registered users and 24 guests