From: HyeJin Lee Date: Tue, 2 Apr 2013 05:18:57 +0000 (+0900) Subject: fix bug and remove add pending case X-Git-Tag: accepted/tizen_2.1/20130425.033138~542^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c81aff50259437ae6e3cd3c3737742538b66bde8;p=framework%2Fosp%2Fuifw.git fix bug and remove add pending case Change-Id: I015e1231d0221d4c3f149a67ac437fe5da0aa603 --- diff --git a/src/ui/animations/FUiAnim_AnimationManager.cpp b/src/ui/animations/FUiAnim_AnimationManager.cpp index 8596996..3b9d87b 100644 --- a/src/ui/animations/FUiAnim_AnimationManager.cpp +++ b/src/ui/animations/FUiAnim_AnimationManager.cpp @@ -394,7 +394,7 @@ _AnimationManager::RemoveAnimation(VisualElement& target, const Tizen::Base::Str } void -_AnimationManager::RemoveAnimationForProperty(VisualElement& target, const Tizen::Base::String& property) +_AnimationManager::RemoveAnimationByProperty(VisualElement& target, const Tizen::Base::String& property) { if (__pCurrentTransaction) { @@ -661,8 +661,10 @@ _AnimationManager::DiscardTransaction(int transactionId) __pCurrentTransactionExceptGroup = pParentTransaction; } } - - __pCurrentTransaction->RemoveChild(transactionId); + else + { + __pCurrentTransaction->RemoveChild(transactionId); + } return E_SUCCESS; } diff --git a/src/ui/animations/FUiAnim_AnimationManager.h b/src/ui/animations/FUiAnim_AnimationManager.h index 4386faa..645629f 100644 --- a/src/ui/animations/FUiAnim_AnimationManager.h +++ b/src/ui/animations/FUiAnim_AnimationManager.h @@ -52,10 +52,9 @@ public: //for animation result AddAnimation(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); result RemoveAnimation(VisualElement& target, const Tizen::Base::String& keyName); - void RemoveAnimationForProperty(VisualElement& target, const Tizen::Base::String& property); + void RemoveAnimationByProperty(VisualElement& target, const Tizen::Base::String& property); void RemoveAllAnimations(VisualElement& target); bool DoesAnimationExist(VisualElement& target, const Tizen::Base::String& keyName) const; - bool DoesAnimationExistForProperty(VisualElement& target, const Tizen::Base::String& keyName) const; VisualElementAnimation* GetAnimationN(VisualElement& target, const Tizen::Base::String& keyName) const; //for transaction diff --git a/src/ui/animations/FUiAnim_TransactionNode.cpp b/src/ui/animations/FUiAnim_TransactionNode.cpp index 178f2a0..dc4bd99 100644 --- a/src/ui/animations/FUiAnim_TransactionNode.cpp +++ b/src/ui/animations/FUiAnim_TransactionNode.cpp @@ -836,64 +836,12 @@ _TransactionNode::GetAnimationCount(void) const return __animations.GetCount(); } -_AnimationData* -_TransactionNode::GetAnimationDataInPending(VisualElement& target, const String& keyName) const -{ - int pendingCount = __pendingAnimations.GetCount(); - - _AnimationData* pAnimationData = null; - - for (int index = 0; index < pendingCount; index++) - { - pAnimationData = AD_CONST_CAST(__pendingAnimations.GetAt(index)); - - if (&(pAnimationData->GetTarget()) == &target && pAnimationData->IsRemoved() == false) - { - if (pAnimationData->GetName() == keyName) - { - return pAnimationData; - } - } - } - - return null; -} - -_AnimationData* -_TransactionNode::GetAnimationDataInPendingByProperty(VisualElement& target, const String& property) const -{ - int pendingCount = __pendingAnimations.GetCount(); - - _AnimationData* pAnimationData = null; - VisualElementPropertyAnimation* pPropertyAnimation = null; - - for (int index = 0; index < pendingCount; index++) - { - pAnimationData = AD_CONST_CAST(__pendingAnimations.GetAt(index)); - - if (&(pAnimationData->GetTarget()) == &target && pAnimationData->IsRemoved() == false) - { - pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); - - if(pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) - { - return pAnimationData; - } - } - } - - return null; -} - result -_TransactionNode::AddAnimationData(_AnimationData& animationData) +_TransactionNode::AddAnimation(VisualElement& target, const String* pKeyName, VisualElementAnimation& animation) { result r = E_SUCCESS; - ArrayList* pAnimationList = null; - VisualElement* pTarget = &(animationData.GetTarget()); - - __animations.GetValue(pTarget, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { @@ -903,87 +851,15 @@ _TransactionNode::AddAnimationData(_AnimationData& animationData) r = pAnimationList->Construct(); SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to construct animation list."); - __animations.Add(pTarget, pAnimationList); + __animations.Add(&target, pAnimationList); } - animationData.SetBaseTime(_AnimationTime::GetTime()); - animationData.SetPendingMode(_AnimationData::_PENDING_MODE_NONE); - - return pAnimationList->Add(animationData); -} - -void -_TransactionNode::RemoveAnimationData(_AnimationData& animationData) -{ - ArrayList* pAnimationList = null; - VisualElement* pTarget = &(animationData.GetTarget()); - - __animations.GetValue(pTarget, pAnimationList); - - if (pAnimationList == null) - { - return; - } - - pAnimationList->Remove(animationData, true); - - if (pAnimationList->GetCount() <= 0) - { - __animations.Remove(pTarget); - - delete pAnimationList; - } -} - -result -_TransactionNode::SetAnimationDataAsPending(_AnimationData& animationData, bool remove, bool completed) -{ - result r = E_SUCCESS; - - if (remove == true) - { - if (animationData.IsRemoved()) - { - return E_SUCCESS; - } - - if (animationData.GetPendingMode() == _AnimationData::_PENDING_MODE_NONE) - { - r = __pendingAnimations.Add(animationData); - } - - animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVING); - - animationData.NotifyAnimationFinished(completed); - - animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVE); - } - else - { - animationData.SetPendingMode(_AnimationData::_PENDING_MODE_ADD); - - r = __pendingAnimations.Add(animationData); - } - - return r; -} - -result -_TransactionNode::AddAnimation(VisualElement& target, const String* pKeyName, VisualElementAnimation& animation) -{ - result r = E_SUCCESS; - _AnimationData* pAnimationData = new (std::nothrow) _AnimationData(target, pKeyName, animation); SysTryReturnResult(NID_UI_ANIM, pAnimationData != null, E_OUT_OF_MEMORY, "Memory allocation failed."); - if (__isInAnimationTick == true) - { - r = SetAnimationDataAsPending(*pAnimationData, false); - } - else - { - r = AddAnimationData(*pAnimationData); - } + AppLog("\n jinstar : [%d] add animation [a: %d, c: %d]", GetId(), GetAnimationCount()+1, GetChildrenCount()); + + r = pAnimationList->Add(*pAnimationData); if (r != E_SUCCESS) { @@ -1005,40 +881,30 @@ _TransactionNode::RemoveAnimation(VisualElement& target, const String& keyName) result r = E_OBJ_NOT_FOUND; - _AnimationData* pAnimationData = GetAnimationDataInPending(target, keyName); - - if (pAnimationData != null) - { - r = SetAnimationDataAsPending(*pAnimationData, true, false); - SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to add to pending list."); - - return E_SUCCESS; - } - - ArrayList* pAnimationList = null; - - __animations.GetValue(&target, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { return E_OBJ_NOT_FOUND; } + _AnimationData* pAnimationData = null; + int animationCount = pAnimationList->GetCount(); for (int index = 0; index < animationCount; index++) { pAnimationData = AD_CAST(pAnimationList->GetAt(index)); - if (pAnimationData->IsRemoved() == false) + if (pAnimationData->GetName() == keyName) { - if (pAnimationData->GetName() == keyName) + if (pAnimationData->IsRemoved() == false) { - r = SetAnimationDataAsPending(*pAnimationData, true, false); + r = SetAnimationDataAsPending(*pAnimationData, false); SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to add to pending list."); - - break; } + + break; } } @@ -1104,46 +970,34 @@ _TransactionNode::RemoveAnimationByProperty(VisualElement& target, const String& return; } - result r = E_OBJ_NOT_FOUND; - - _AnimationData* pAnimationData = GetAnimationDataInPendingByProperty(target, property); - - if (pAnimationData != null) - { - r = SetAnimationDataAsPending(*pAnimationData, true, false); - SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); - - return; - } - - ArrayList* pAnimationList = null; - - __animations.GetValue(&target, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { return; } + result r = E_SUCCESS; + VisualElementPropertyAnimation* pPropertyAnimation = null; + _AnimationData* pAnimationData = null; int animationCount = pAnimationList->GetCount(); for (int index = 0; index < animationCount; index++) { pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); - if (pAnimationData->IsRemoved() == false) + if (pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) { - pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); - - if (pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) + if (pAnimationData->IsRemoved() == false) { - r = SetAnimationDataAsPending(*pAnimationData, true, false); + r = SetAnimationDataAsPending(*pAnimationData, false); SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); - - break; } + + break; } } @@ -1207,9 +1061,7 @@ _TransactionNode::RemoveAllAnimations(VisualElement& target) return; } - ArrayList* pAnimationList = null; - - __animations.GetValue(&target, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { @@ -1225,7 +1077,7 @@ _TransactionNode::RemoveAllAnimations(VisualElement& target) { pAnimationData = AD_CAST(pAnimationList->GetAt(index)); - r = SetAnimationDataAsPending(*pAnimationData, true, false); + r = SetAnimationDataAsPending(*pAnimationData, false); SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); } @@ -1272,34 +1124,29 @@ _TransactionNode::GetAnimation(VisualElement& target, const String& keyName) con return null; } - _AnimationData* pAnimationData = GetAnimationDataInPending(target, keyName); - - if (pAnimationData != null) - { - return &(pAnimationData->GetAnimation()); - } - - ArrayList* pAnimationList = null; - - __animations.GetValue(&target, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { return null; } + _AnimationData* pAnimationData = null; + int animationCount = pAnimationList->GetCount(); for (int index = 0; index < animationCount; index++) { pAnimationData = AD_CAST(pAnimationList->GetAt(index)); - if (pAnimationData->IsRemoved() == false) + if (pAnimationData->GetName() == keyName) { - if (pAnimationData->GetName() == keyName) + if (pAnimationData->IsRemoved() == false) { return &(pAnimationData->GetAnimation()); } + + return null; } } @@ -1359,16 +1206,7 @@ _TransactionNode::GetAnimationByProperty(VisualElement& target, const String& pr return null; } - _AnimationData* pAnimationData = GetAnimationDataInPendingByProperty(target, property); - - if (pAnimationData != null) - { - return &(pAnimationData->GetAnimation()); - } - - ArrayList* pAnimationList = null; - - __animations.GetValue(&target, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(&target); if (pAnimationList == null) { @@ -1376,6 +1214,7 @@ _TransactionNode::GetAnimationByProperty(VisualElement& target, const String& pr } const VisualElementPropertyAnimation* pPropertyAnimation = null; + _AnimationData* pAnimationData = null; int animationCount = pAnimationList->GetCount(); @@ -1431,6 +1270,29 @@ _TransactionNode::GetChildrenAnimationByProperty(VisualElement& target, const St return pAnimation; } +result +_TransactionNode::SetAnimationDataAsPending(_AnimationData& animationData, bool completed) +{ + result r = E_SUCCESS; + + if (animationData.IsRemoved()) + { + return E_SUCCESS; + } + + AppLog("\n jinstar : [%d] SetAnimationDataAsPending [%ls]", GetId(), animationData.GetName().GetPointer()); + + r = __pendingAnimations.Add(animationData); + + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVING); + + animationData.NotifyAnimationFinished(completed); + + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVE); + + return r; +} + void _TransactionNode::DrawTargets(void) { @@ -1439,7 +1301,6 @@ _TransactionNode::DrawTargets(void) VisualElement* pTarget = null; ArrayList* pAnimationList = null; - //TODO: Check dep. while (pMapEnum->MoveNext() == E_SUCCESS) { pMapEnum->GetKey(pTarget); @@ -1690,9 +1551,7 @@ _TransactionNode::RemoveAnimationByDuplicatedProperty(_AnimationData& animationD VisualElement* pTarget = &(animationData.GetTarget()); - ArrayList* pAnimationList = null; - - __animations.GetValue(pTarget, pAnimationList); + ArrayList* pAnimationList = __animations.GetList(pTarget); if (pAnimationList != null) { @@ -1714,7 +1573,7 @@ _TransactionNode::RemoveAnimationByDuplicatedProperty(_AnimationData& animationD if (pRemovePropertyAnimation && pRemovePropertyAnimation->GetPropertyName() == pPropertyAnimation->GetPropertyName()) { - result r = SetAnimationDataAsPending(*pRemoveAnimationData, true, false); + result r = SetAnimationDataAsPending(*pRemoveAnimationData, false); SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, r, false, "[%s] Failed to add to pending list.", GetErrorMessage(r)); //TODO: refactoring for group @@ -1753,12 +1612,7 @@ _TransactionNode::RemoveAnimationByDuplicatedProperty(_AnimationData& animationD void _TransactionNode::ProcessPendingAnimations(void) { - if (__isInAnimationTick == true) - { - return; - } - - if (__pendingAnimations.GetCount() <= 0) + if (__isInAnimationTick == true || __pendingAnimations.GetCount() <= 0) { return; } @@ -1771,27 +1625,23 @@ _TransactionNode::ProcessPendingAnimations(void) { pAnimationData = AD_CAST(__pendingAnimations.GetAt(index)); - switch(pAnimationData->GetPendingMode()) + if (pAnimationData->GetPendingMode() == _AnimationData::_PENDING_MODE_REMOVE) { - case _AnimationData::_PENDING_MODE_ADD: + VisualElement* pTarget = &(pAnimationData->GetTarget()); - if (AddAnimationData(*pAnimationData) != E_SUCCESS) - { - delete pAnimationData; - } + ArrayList* pAnimationList = __animations.GetList(pTarget); + SysAssertf(pAnimationList, "AnimationList is null!"); - __pendingAnimations.RemoveAt(index, false); - break; + pAnimationList->Remove(*pAnimationData, true); - case _AnimationData::_PENDING_MODE_REMOVE: + if (pAnimationList->GetCount() <= 0) + { + __animations.Remove(pTarget); - RemoveAnimationData(*pAnimationData); + delete pAnimationList; + } __pendingAnimations.RemoveAt(index, false); - break; - - default: - break; } } } @@ -1804,14 +1654,6 @@ _TransactionNode::ProcessAnimationTick(unsigned int tick) return; } - //TODO: Remove because set base time when starts -#if 0 - if (__baseTime > tick) // this node is added in animation tick - { - return; - } -#endif - CalculateProgress(tick); if (__status == _STATUS_READY) @@ -1922,7 +1764,7 @@ _TransactionNode::OnAnimationTick(unsigned int tick) if (__status == _STATUS_FINISH || pAnimationData->GetStatus() == _AnimationData::_STATUS_FINISH) { - SetAnimationDataAsPending(*pAnimationData, true, true); + SetAnimationDataAsPending(*pAnimationData, true); //TODO: refactoring for group if (IsRemovable() == false) diff --git a/src/ui/animations/FUiAnim_TransactionNode.h b/src/ui/animations/FUiAnim_TransactionNode.h index 70dfd8a..97ff750 100644 --- a/src/ui/animations/FUiAnim_TransactionNode.h +++ b/src/ui/animations/FUiAnim_TransactionNode.h @@ -63,7 +63,6 @@ public: enum _PendingMode { _PENDING_MODE_NONE, - _PENDING_MODE_ADD, _PENDING_MODE_REMOVING, _PENDING_MODE_REMOVE }; @@ -196,13 +195,6 @@ public: private: _TransactionNode& operator =(const _TransactionNode& rhs); - result AddAnimationData(_AnimationData& animationData); - void RemoveAnimationData(_AnimationData& animationData); - result SetAnimationDataAsPending(_AnimationData& animationData, bool remove, bool completed = false); - - _AnimationData* GetAnimationDataInPending(VisualElement& target, const Tizen::Base::String& keyName) const; - _AnimationData* GetAnimationDataInPendingByProperty(VisualElement& target, const Tizen::Base::String& property) const; - result RemoveAnimation(VisualElement& target, const Tizen::Base::String& keyName); void RemoveAnimationByProperty(VisualElement& target, const Tizen::Base::String& property); void RemoveAllAnimations(void); @@ -211,6 +203,8 @@ private: const VisualElementAnimation* GetAnimation(VisualElement& target, const Tizen::Base::String& property) const; const VisualElementAnimation* GetAnimationByProperty(VisualElement& target, const Tizen::Base::String& property) const; + result SetAnimationDataAsPending(_AnimationData& animationData, bool completed); + void ReservedRemove(bool remove = true); bool IsReservedRemove(void) const; @@ -275,7 +269,21 @@ protected: ChildrenListT __children; Tizen::Base::Collection::ArrayList __pendingAnimations; - Tizen::Base::Collection::HashMapT __animations; + + class AnimationHashMapT : public Tizen::Base::Collection::HashMapT + { + public: + Tizen::Base::Collection::ArrayList* GetList(VisualElement* pTarget) const + { + Tizen::Base::Collection::ArrayList* pAnimationList = null; + + GetValue(pTarget, pAnimationList); + + return pAnimationList; + } + }; + + AnimationHashMapT __animations; }; // _TransactionNode }}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnim_VisualElementImpl.cpp b/src/ui/animations/FUiAnim_VisualElementImpl.cpp index ab69f03..3ff6f90 100644 --- a/src/ui/animations/FUiAnim_VisualElementImpl.cpp +++ b/src/ui/animations/FUiAnim_VisualElementImpl.cpp @@ -560,7 +560,7 @@ _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property, { // remove sub property for(int i = 0 ; pSubProperties[i] != NULL ; i++) { - pAnimationManager->RemoveAnimationForProperty(*__pPublicInstance, *pSubProperties[i]); + pAnimationManager->RemoveAnimationByProperty(*__pPublicInstance, *pSubProperties[i]); } } if (unlikely(pAnimation)) @@ -569,7 +569,7 @@ _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property, // Adding property animation causes previous animation for same property to be removed in Animation Manager. if (unlikely(IsFailed(AddAnimation(null, *pAnimation)))) { - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property); r = false; } @@ -579,13 +579,13 @@ _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property, { // WARNING: // Remove previous animation even when trying to change the property without animation. - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property); r = false; } } else { - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property); r = false; } return r; @@ -1713,7 +1713,7 @@ _VisualElementImpl::SetShowOpacityI(float showOpacity) if (unlikely(IsFailed(AddAnimation(null, *pPropertyAnimation)))) { needPresentationUpdate = true; - //pAnimationManager->RemoveAnimationForProperty(*presentation.GetPublic(), property); + //pAnimationManager->RemoveAnimationByProperty(*presentation.GetPublic(), property); } delete pPropertyAnimation; @@ -1722,15 +1722,15 @@ _VisualElementImpl::SetShowOpacityI(float showOpacity) { // WARNING: // Remove previous animation even when trying to change the property without animation. - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity); needPresentationUpdate = true; } } else { - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); - pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property); + pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity); needPresentationUpdate = true; }