Page 1 of 1

Properly upgrading CEGUI (window->getRelativeWidth)

Posted: Tue Jun 05, 2007 04:30
by tgraupmann
Now that getRelativeWidth is gone. What is the equivalent call in CEGUI 0.5.0?

Posted: Tue Jun 05, 2007 10:00
by Rackle
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.

Posted: Tue Jun 05, 2007 14:01
by tgraupmann
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;
        }
}

Posted: Thu Jun 07, 2007 21:36
by tgraupmann
I should have said.

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