From b26d446b0cb6a316abc3a79d4fc70d0ae1b7994c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gy=C3=B6rgy=20Straub?= Date: Wed, 9 Sep 2020 15:49:51 +0100 Subject: [PATCH] Fixed DGEUF-1841. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since the text labels are supposed to be aligned to a grid, the new target position is calculated based on this instead of getting the position of the supposedly related text label, which might be midway through an animation at the time. Change-Id: Id83e89c13f2e03325966ab890aa5ca00e94fa100 Signed-off-by: György Straub --- examples/drag-and-drop/drag-and-drop-example.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/drag-and-drop/drag-and-drop-example.cpp b/examples/drag-and-drop/drag-and-drop-example.cpp index 22e733f..b9e7f08 100644 --- a/examples/drag-and-drop/drag-and-drop-example.cpp +++ b/examples/drag-and-drop/drag-and-drop-example.cpp @@ -44,6 +44,8 @@ const float TEXT_LABEL_WIDTH = 250.0f; const float TEXT_LABEL_HEIGHT = 70.0f; const unsigned int TEXT_LABEL_NUM = sizeof(TEXT_LABEL_COLOR) / sizeof(TEXT_LABEL_COLOR[0]); +const float DROP_ANIMATION_DURATION_S = 0.5f; + #if defined(DEBUG_ENABLED) Debug::Filter* gDragAndDropFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DRAG_AND_DROP_EXAMPLE"); #endif @@ -183,14 +185,14 @@ public: } } - Animation mAnimation = Animation::New(0.5f); + Animation mAnimation = Animation::New(DROP_ANIMATION_DURATION_S); if(droppedIndex > mDragIndex) { for(int i = mDragIndex + 1; i <= droppedIndex; i++) { - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y - TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i - 1), 0.0f), AlphaFunction::EASE_OUT); mAnimation.Play(); } @@ -204,11 +206,10 @@ public: } else if(droppedIndex < mDragIndex) { - for(int i = mDragIndex - 1; i >= droppedIndex; i--) { - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y + TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i + 1), 0.0f), AlphaFunction::EASE_OUT); mAnimation.Play(); } @@ -219,23 +220,21 @@ public: } mOrder[droppedIndex] = tmpId; - } - Vector2 pos = detector.GetCurrentScreenPosition(); Vector2 localPos; control.GetParent().ScreenToLocal(localPos.x, localPos.y, pos.x, pos.y); KeyFrames k0 = KeyFrames::New(); k0.Add(0.0f, Vector3(localPos.x - mDragLocalPos.x, localPos.y - mDragLocalPos.y, 0.0f)); - k0.Add(1.0f, Vector3(control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, 0.0f)); + k0.Add(1.0f, Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * droppedIndex, 0.0f)); KeyFrames k1 = KeyFrames::New(); k1.Add(0.0f, 0.1f); k1.Add(1.0f, 1.0f); - Animation dropAnimation = Animation::New(0.5f); + Animation dropAnimation = Animation::New(DROP_ANIMATION_DURATION_S); dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::POSITION), k0, AlphaFunction::EASE_OUT); dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::OPACITY), k1, AlphaFunction::EASE_OUT); dropAnimation.Play(); -- 2.7.4