diff -crB TGUI-master/include/TGUI/ChildWindow.hpp tgui-patch/include/TGUI/ChildWindow.hpp *** TGUI-master/include/TGUI/ChildWindow.hpp 2013-07-10 18:20:40.000000000 +0200 --- tgui-patch/include/TGUI/ChildWindow.hpp 2013-07-13 15:14:45.374505128 +0200 *************** *** 52,60 **** /// Places the title on the right side of the title bar TitleAlignmentRight }; ! ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Default constructor /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --- 52,59 ---- /// Places the title on the right side of the title bar TitleAlignmentRight }; ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Default constructor /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// *************** *** 348,354 **** /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void destroy(); ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Used internally to get the size of the child window. --- 347,388 ---- /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void destroy(); ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! /// \brief Set the child window to be kept inside its parent. ! /// ! /// When it's set to true, the child window will always be kept automatically inside its parent. ! /// It will be fully kept on left, right and top. At the bottom of the parent only the titlebar will be kept inside. ! /// It's set to false by default. ! /// ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! void keepInParent(bool enabled); ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! /// \brief Tells whether the child window is kept inside its parent. ! /// ! /// When it's set to true, the child window will always be kept automatically inside its parent. ! /// It will be fully kept on left, right and top. At the bottom of the parent only the titlebar will be kept inside. ! /// It's set to false by default. ! /// ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! bool isKeptInParent(); ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! /// \brief Set the position of the object. ! /// ! /// It overrides the Transform::setPosition() function. ! /// ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! void setPosition(float x, float y); ! ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! /// \brief Set the position of the object. ! /// ! /// It overrides the Transform::setPosition() function. ! /// ! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! void setPosition (const Vector2f &position); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Used internally to get the size of the child window. *************** *** 422,427 **** --- 456,463 ---- Texture m_TextureTitleBar_R; tgui::Button* m_CloseButton; + + bool m_KeepInParent; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }; diff -crB TGUI-master/include/TGUI/Transformable.hpp tgui-patch/include/TGUI/Transformable.hpp *** TGUI-master/include/TGUI/Transformable.hpp 2013-07-10 18:20:40.000000000 +0200 --- tgui-patch/include/TGUI/Transformable.hpp 2013-07-13 15:08:51.387133538 +0200 *************** *** 60,66 **** /// \see move, getPosition /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! virtual void setPosition(float x, float y); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --- 60,66 ---- /// \see move, getPosition /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! void setPosition(float x, float y); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff -crB TGUI-master/src/TGUI/ChildWindow.cpp tgui-patch/src/TGUI/ChildWindow.cpp *** TGUI-master/src/TGUI/ChildWindow.cpp 2013-07-10 18:20:40.000000000 +0200 --- tgui-patch/src/TGUI/ChildWindow.cpp 2013-07-13 15:02:49.879927000 +0200 *************** *** 48,54 **** m_DraggingPosition (0, 0), m_DistanceToSide (5), m_TitleAlignment (TitleAlignmentCentered), ! m_BorderColor (0, 0, 0) { m_Callback.widgetType = Type_ChildWindow; m_CloseButton = new tgui::Button(); --- 48,55 ---- m_DraggingPosition (0, 0), m_DistanceToSide (5), m_TitleAlignment (TitleAlignmentCentered), ! m_BorderColor (0, 0, 0), ! m_KeepInParent(false) { m_Callback.widgetType = Type_ChildWindow; m_CloseButton = new tgui::Button(); *************** *** 69,75 **** m_DraggingPosition (childWindowToCopy.m_DraggingPosition), m_DistanceToSide (childWindowToCopy.m_DistanceToSide), m_TitleAlignment (childWindowToCopy.m_TitleAlignment), ! m_BorderColor (childWindowToCopy.m_BorderColor) { // Copy the textures TGUI_TextureManager.copyTexture(childWindowToCopy.m_IconTexture, m_IconTexture); --- 70,77 ---- m_DraggingPosition (childWindowToCopy.m_DraggingPosition), m_DistanceToSide (childWindowToCopy.m_DistanceToSide), m_TitleAlignment (childWindowToCopy.m_TitleAlignment), ! m_BorderColor (childWindowToCopy.m_BorderColor), ! m_KeepInParent (childWindowToCopy.m_KeepInParent) { // Copy the textures TGUI_TextureManager.copyTexture(childWindowToCopy.m_IconTexture, m_IconTexture); *************** *** 892,897 **** --- 894,972 ---- // Reset the old clipping area glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); } + + void ChildWindow::keepInParent(bool enabled) + { + m_KeepInParent = enabled; + } + + bool ChildWindow::isKeptInParent() + { + return m_KeepInParent; + } + + void ChildWindow::setPosition(float x, float y) + { + if (m_KeepInParent) + { + + //sets the y value only + if (y < 0) + { + Transformable::setPosition(getPosition().x, 0); + } + else if (y > m_Parent->getDisplaySize().y - m_TitleBarHeight) + { + Transformable::setPosition(getPosition().x, m_Parent->getDisplaySize().y - m_TitleBarHeight); + } + else Transformable::setPosition(getPosition().x, y); + + //sets the x value only + if (x < 0) + { + Transformable::setPosition(0, getPosition().y); + } + else if (x > m_Parent->getDisplaySize().x - getSize().x) + { + Transformable::setPosition(m_Parent->getDisplaySize().x - getSize().x, getPosition().y); + } + else Transformable::setPosition(x, getPosition().y); + + } + else Transformable::setPosition(x, y); + } + + void ChildWindow::setPosition (const Vector2f &position) + { + if (m_KeepInParent) + { + + //sets the y value only + if (position.y < 0) + { + Transformable::setPosition(getPosition().x, 0); + } + else if (position.y > m_Parent->getDisplaySize().y - m_TitleBarHeight) + { + Transformable::setPosition(getPosition().x, m_Parent->getDisplaySize().y - m_TitleBarHeight); + } + else Transformable::setPosition(getPosition().x, position.y); + + //sets the x value only + if (position.x < 0) + { + Transformable::setPosition(0, getPosition().y); + } + else if (position.x > m_Parent->getDisplaySize().x - getSize().x) + { + Transformable::setPosition(m_Parent->getDisplaySize().x - getSize().x, getPosition().y); + } + else Transformable::setPosition(position.x, getPosition().y); + + } + else Transformable::setPosition(position); + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }