diff --git a/include/eepp/math/transformable.hpp b/include/eepp/math/transformable.hpp index 9413399ce..70cb8a6b8 100644 --- a/include/eepp/math/transformable.hpp +++ b/include/eepp/math/transformable.hpp @@ -54,7 +54,7 @@ class EE_API Transformable { const Transform& getTransform() const; const Transform& getInverseTransform() const; - private: + protected: Vector2f mScaleOrigin; ///< Origin of scaling of the object Vector2f mRotationOrigin; ///< Origin of rotation of the object diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index b3948dbd7..eaefeb6fb 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -373,7 +373,6 @@ class EE_API UINode : public Transformable { std::string mId; Uint32 mIdHash; Vector2f mDpPos; - Vector2f mRealPos; Vector2f mScreenPos; Vector2i mScreenPosi; Sizei mSize; diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 770d24db9..3041fa4f6 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -25,7 +25,6 @@ UINode * UINode::New() { UINode::UINode() : mIdHash( 0 ), mDpPos( 0, 0 ), - mRealPos( 0, 0 ), mSize( 0, 0 ), mRealSize( 0, 0 ), mFlags( UI_CONTROL_DEFAULT_FLAGS ), @@ -80,14 +79,12 @@ UINode::~UINode() { void UINode::worldToNodeTranslation( Vector2f& Pos ) const { UINode * ParentLoop = mParentCtrl; - Pos.x -= mRealPos.x; - Pos.y -= mRealPos.y; + Pos -= mPosition; while ( NULL != ParentLoop ) { const Vector2f& ParentPos = ParentLoop->getRealPosition(); - Pos.x -= ParentPos.x; - Pos.y -= ParentPos.y; + Pos -= ParentPos; ParentLoop = ParentLoop->getParent(); } @@ -99,8 +96,7 @@ void UINode::nodeToWorldTranslation( Vector2f& Pos ) const { while ( NULL != ParentLoop ) { const Vector2f& ParentPos = ParentLoop->getRealPosition(); - Pos.x += ParentPos.x; - Pos.y += ParentPos.y; + Pos += ParentPos; ParentLoop = ParentLoop->getParent(); } @@ -131,8 +127,7 @@ Uint32 UINode::onMessage( const UIMessage * Msg ) { void UINode::setInternalPosition( const Vector2f& Pos ) { mDpPos = Pos; - mRealPos = Vector2f( Pos.x * PixelDensity::getPixelDensity(), Pos.y * PixelDensity::getPixelDensity() ); - Transformable::setPosition( mRealPos.x, mRealPos.y ); + Transformable::setPosition( Pos.x * PixelDensity::getPixelDensity(), Pos.y * PixelDensity::getPixelDensity() ); setDirty(); } @@ -149,10 +144,9 @@ UINode * UINode::setPosition( const Float& x, const Float& y ) { } void UINode::setPixelsPosition( const Vector2f& Pos ) { - if ( mRealPos != Pos ) { - mDpPos = Vector2f( PixelDensity::pxToDp( Pos.x ), PixelDensity::pxToDp( Pos.y ) ); - mRealPos = Pos; - Transformable::setPosition( mRealPos.x, mRealPos.y ); + if ( mPosition != Pos ) { + mDpPos = PixelDensity::pxToDp( Pos ); + Transformable::setPosition( Pos.x, Pos.y ); setDirty(); onPositionChange(); } @@ -167,7 +161,7 @@ const Vector2f& UINode::getPosition() const { } const Vector2f &UINode::getRealPosition() const { - return mRealPos; + return mPosition; } void UINode::setInternalSize( const Sizei& size ) { @@ -449,7 +443,7 @@ void UINode::update( const Time& time ) { dragDiff.x = (Float)( mDragPoint.x - Pos.x ); dragDiff.y = (Float)( mDragPoint.y - Pos.y ); - setPixelsPosition( mRealPos - dragDiff ); + setPixelsPosition( mPosition - dragDiff ); mDragPoint = Pos; @@ -1432,7 +1426,7 @@ void UINode::updateScreenPos() { if ( !(mNodeFlags & NODE_FLAG_POSITION_DIRTY) ) return; - Vector2f Pos( mRealPos.x, mRealPos.y ); + Vector2f Pos( mPosition ); nodeToWorldTranslation( Pos ); diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 2e5850488..0a3687928 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -41,7 +41,7 @@ bool UIWidget::isType( const Uint32& type ) const { void UIWidget::updateAnchorsDistances() { if ( NULL != mParentCtrl ) { - mDistToBorder = Rect( mRealPos.x, mRealPos.y, mParentCtrl->getRealSize().x - ( mRealPos.x + mRealSize.x ), mParentCtrl->getRealSize().y - ( mRealPos.y + mRealSize.y ) ); + mDistToBorder = Rect( mPosition.x, mPosition.y, mParentCtrl->getRealSize().x - ( mPosition.x + mRealSize.x ), mParentCtrl->getRealSize().y - ( mPosition.y + mRealSize.y ) ); } } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 1c89918b8..9eafdf1a7 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -853,14 +853,14 @@ void UIWindow::updateResize() { case RESIZE_LEFT: { Pos.x -= mResizePos.x; - UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); + UINode::setPixelsPosition( mPosition.x + Pos.x, mPosition.y ); internalSize( mRealSize.getWidth() - Pos.x, mRealSize.getHeight() ); break; } case RESIZE_TOP: { Pos.y -= mResizePos.y; - UINode::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mPosition.x, mPosition.y + Pos.y ); internalSize( mRealSize.getWidth(), mRealSize.getHeight() - Pos.y ); break; } @@ -873,7 +873,7 @@ void UIWindow::updateResize() { case RESIZE_TOPLEFT: { Pos -= mResizePos; - UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mPosition.x + Pos.x, mPosition.y + Pos.y ); internalSize( mRealSize.getWidth() - Pos.x, mRealSize.getHeight() - Pos.y ); break; } @@ -881,7 +881,7 @@ void UIWindow::updateResize() { { Pos.y -= mResizePos.y; Pos.x += mResizePos.x; - UINode::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mPosition.x, mPosition.y + Pos.y ); internalSize( Pos.x, mRealSize.getHeight() - Pos.y ); break; } @@ -889,7 +889,7 @@ void UIWindow::updateResize() { { Pos.x -= mResizePos.x; Pos.y += mResizePos.y; - UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); + UINode::setPixelsPosition( mPosition.x + Pos.x, mPosition.y ); internalSize( mRealSize.getWidth() - Pos.x, Pos.y ); break; } @@ -1082,7 +1082,7 @@ void UIWindow::maximize() { setPixelsPosition( mNonMaxPos ); internalSize( mNonMaxSize ); } else { - mNonMaxPos = mRealPos; + mNonMaxPos = mPosition; mNonMaxSize = mRealSize; setPosition( 0, 0 );