Commit b26d446b0cb6a316abc3a79d4fc70d0ae1b7994c
1 parent
0415b32b
Fixed DGEUF-1841.
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 <g.straub@partner.samsung.com>
Showing
1 changed file
with
9 additions
and
10 deletions
examples/drag-and-drop/drag-and-drop-example.cpp
| ... | ... | @@ -44,6 +44,8 @@ const float TEXT_LABEL_WIDTH = 250.0f; |
| 44 | 44 | const float TEXT_LABEL_HEIGHT = 70.0f; |
| 45 | 45 | const unsigned int TEXT_LABEL_NUM = sizeof(TEXT_LABEL_COLOR) / sizeof(TEXT_LABEL_COLOR[0]); |
| 46 | 46 | |
| 47 | +const float DROP_ANIMATION_DURATION_S = 0.5f; | |
| 48 | + | |
| 47 | 49 | #if defined(DEBUG_ENABLED) |
| 48 | 50 | Debug::Filter* gDragAndDropFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DRAG_AND_DROP_EXAMPLE"); |
| 49 | 51 | #endif |
| ... | ... | @@ -183,14 +185,14 @@ public: |
| 183 | 185 | } |
| 184 | 186 | } |
| 185 | 187 | |
| 186 | - Animation mAnimation = Animation::New(0.5f); | |
| 188 | + Animation mAnimation = Animation::New(DROP_ANIMATION_DURATION_S); | |
| 187 | 189 | |
| 188 | 190 | if(droppedIndex > mDragIndex) |
| 189 | 191 | { |
| 190 | 192 | for(int i = mDragIndex + 1; i <= droppedIndex; i++) |
| 191 | 193 | { |
| 192 | - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; | |
| 193 | - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y - TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); | |
| 194 | + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), | |
| 195 | + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i - 1), 0.0f), AlphaFunction::EASE_OUT); | |
| 194 | 196 | mAnimation.Play(); |
| 195 | 197 | } |
| 196 | 198 | |
| ... | ... | @@ -204,11 +206,10 @@ public: |
| 204 | 206 | } |
| 205 | 207 | else if(droppedIndex < mDragIndex) |
| 206 | 208 | { |
| 207 | - | |
| 208 | 209 | for(int i = mDragIndex - 1; i >= droppedIndex; i--) |
| 209 | 210 | { |
| 210 | - float y = mTextLabel[mOrder[i]].GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y; | |
| 211 | - mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), Vector3(TEXT_LABEL_POSITION_X, y + TEXT_LABEL_HEIGHT, 0.0f), AlphaFunction::EASE_OUT); | |
| 211 | + mAnimation.AnimateTo(Property(mTextLabel[mOrder[i]], Actor::Property::POSITION), | |
| 212 | + Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * (i + 1), 0.0f), AlphaFunction::EASE_OUT); | |
| 212 | 213 | mAnimation.Play(); |
| 213 | 214 | } |
| 214 | 215 | |
| ... | ... | @@ -219,23 +220,21 @@ public: |
| 219 | 220 | } |
| 220 | 221 | |
| 221 | 222 | mOrder[droppedIndex] = tmpId; |
| 222 | - | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - | |
| 226 | 225 | Vector2 pos = detector.GetCurrentScreenPosition(); |
| 227 | 226 | Vector2 localPos; |
| 228 | 227 | control.GetParent().ScreenToLocal(localPos.x, localPos.y, pos.x, pos.y); |
| 229 | 228 | |
| 230 | 229 | KeyFrames k0 = KeyFrames::New(); |
| 231 | 230 | k0.Add(0.0f, Vector3(localPos.x - mDragLocalPos.x, localPos.y - mDragLocalPos.y, 0.0f)); |
| 232 | - k0.Add(1.0f, Vector3(control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).x, control.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y, 0.0f)); | |
| 231 | + k0.Add(1.0f, Vector3(TEXT_LABEL_POSITION_X, TEXT_LABEL_POSITION_START_Y + TEXT_LABEL_HEIGHT * droppedIndex, 0.0f)); | |
| 233 | 232 | |
| 234 | 233 | KeyFrames k1 = KeyFrames::New(); |
| 235 | 234 | k1.Add(0.0f, 0.1f); |
| 236 | 235 | k1.Add(1.0f, 1.0f); |
| 237 | 236 | |
| 238 | - Animation dropAnimation = Animation::New(0.5f); | |
| 237 | + Animation dropAnimation = Animation::New(DROP_ANIMATION_DURATION_S); | |
| 239 | 238 | dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::POSITION), k0, AlphaFunction::EASE_OUT); |
| 240 | 239 | dropAnimation.AnimateBetween(Property(mTextLabel[mDragRealIndex], Actor::Property::OPACITY), k1, AlphaFunction::EASE_OUT); |
| 241 | 240 | dropAnimation.Play(); | ... | ... |