From: Bhavya Kumili Date: Thu, 23 May 2013 04:49:29 +0000 (+0530) Subject: DateTimeBar VI effects merge to tizen branch X-Git-Tag: accepted/tizen/20130924.144426~1^2~782^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fc7a0b204ea889881dd752921324bafaef53b02;p=platform%2Fframework%2Fnative%2Fuifw.git DateTimeBar VI effects merge to tizen branch Change-Id: Ibea67de2ffce8b7afb8f8b9bf23913d570bfb784 --- diff --git a/src/ui/controls/FUiCtrl_DateTimeBar.cpp b/src/ui/controls/FUiCtrl_DateTimeBar.cpp index 95da538..c346f41 100644 --- a/src/ui/controls/FUiCtrl_DateTimeBar.cpp +++ b/src/ui/controls/FUiCtrl_DateTimeBar.cpp @@ -20,6 +20,8 @@ * @brief This is the implementation file for the _DateTimeBar class. */ +#include +#include #include "FUiAnim_VisualElement.h" #include "FUi_AccessibilityContainer.h" #include "FUi_AccessibilityElement.h" @@ -425,9 +427,18 @@ _DateTimeBar::OnDetachingFromMainTree(void) void _DateTimeBar::OnActivated(void) { - RefreshItems(); + VisualElement* pVisualElement = null; + VisualElementAnimation *pAnimation = null; + + pVisualElement = GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get visual element."); + pAnimation = CreateAnimationN(*pVisualElement, true); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimation != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pVisualElement->AddAnimation(L"BarOpenAnimation", *pAnimation); + delete pAnimation; SetTouchCapture(true, true); + return _Window::OnActivated(); } @@ -805,4 +816,109 @@ _DateTimeBar::GetIndexFromAccessibilityElementPoint(const FloatPoint& point) con return -1; } +VisualElementAnimationGroup* +_DateTimeBar::CreateAnimationN(VisualElement& source, bool open) +{ + FloatRectangle startValue = source.GetBounds(); + VisualElementAnimationGroup* pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup(); + SysTryReturn(NID_UI_CTRL, pAnimationGroup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + VisualElementPropertyAnimation* pOpacityAnimation = null; + VisualElementPropertyAnimation* pBoundsAnimation = null; + String* pOpenUserData = new String(L"BarOpenAnimation"); + SysTryReturn(NID_UI_CTRL, pOpenUserData, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + + String* pCloseUserData = new String(L"BarCloseAnimation"); + SysTryReturn(NID_UI_CTRL, pCloseUserData, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + + pAnimationGroup->SetDuration(ANIMATION_DURATION); + + pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pOpacityAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOpacityAnimation->SetPropertyName("opacity"); + + if (open == true) + { + pOpacityAnimation->SetStartValue(Variant(0.0f)); + pOpacityAnimation->SetEndValue(Variant(1.0f)); + } + else + { + pOpacityAnimation->SetStartValue(Variant(1.0f)); + pOpacityAnimation->SetEndValue(Variant(0.0f)); + } + pOpacityAnimation->SetDuration(ANIMATION_DURATION); + pAnimationGroup->AddAnimation(*pOpacityAnimation); + delete pOpacityAnimation; + + pBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pBoundsAnimation->SetPropertyName(L"bounds.position"); + startValue.y = startValue.y - POSITION_ANIMATION_VALUE; + + if (open) + { + pBoundsAnimation->SetStartValue(Variant(FloatPoint(startValue.x, startValue.y))); + pBoundsAnimation->SetEndValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y))); + pBoundsAnimation->SetUserData((void*)(pOpenUserData)); + } + else + { + pBoundsAnimation->SetStartValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y))); + pBoundsAnimation->SetEndValue(Variant(FloatPoint(startValue.x, startValue.y))); + pBoundsAnimation->SetUserData((void*)(pCloseUserData)); + } + pBoundsAnimation->SetDuration(ANIMATION_DURATION); + pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + pAnimationGroup->AddAnimation(*pBoundsAnimation); + delete pBoundsAnimation; + + return pAnimationGroup; + +CATCH: + delete pAnimationGroup; + delete pOpacityAnimation; + delete pOpenUserData; + delete pCloseUserData; + return null; +} + +void +_DateTimeBar::CloseDateTimeBar() +{ + VisualElement* pVisualElement = null; + VisualElementAnimation *pAnimation = null; + + pVisualElement = GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get visual element."); + pAnimation = CreateAnimationN(*pVisualElement, false); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimation != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pVisualElement->AddAnimation(L"BarCloseAnimation", *pAnimation); + + delete pAnimation; +} + +void +_DateTimeBar::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally) +{ + String* pUserData = (String*) animation.GetUserData(); + + if ((pUserData != null) && (*pUserData == String(L"BarOpenAnimation"))) + { + RefreshItems(); + } + else if ((pUserData != null) && (*pUserData == String(L"BarCloseAnimation"))) + { + FloatRectangle bounds = target.GetBounds(); + bounds.y = bounds.y + POSITION_ANIMATION_VALUE; + SetVisibleState(false); + Close(); + target.SetBounds(bounds); + } + + delete pUserData; +} + }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp index dea9773..0197afe 100644 --- a/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp +++ b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp @@ -25,6 +25,7 @@ #include #include "FUi_CoordinateSystemUtils.h" #include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" #include "FUiCtrl_DateTimeUtils.h" #include "FUiCtrl_DateTimeBar.h" #include "FUiCtrl_DateTimeBarPresenter.h" @@ -34,6 +35,7 @@ using namespace Tizen::Ui; using namespace Tizen::Base; using namespace Tizen::Base::Runtime; using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; namespace Tizen { namespace Ui { namespace Controls { @@ -1147,8 +1149,7 @@ _DateTimeBarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& { __isTouchMoved = false; PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP); - __pDateTimeBar->SetVisibleState(false); - __pDateTimeBar->Close(); + __pDateTimeBar->CloseDateTimeBar(); ResetFlickAnimationTimer(); __pDateTimeBar->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED); return true; @@ -1186,9 +1187,7 @@ _DateTimeBarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& if (pItem != null) { - __pDateTimeBar->SetVisibleState(false); - __pDateTimeBar->Close(); - + __pDateTimeBar->CloseDateTimeBar(); __pDateTimeBar->FireActionEvent(pItem->GetActionId()); if (__pDateTimeBar->GetSelectedBoxId() >= DATETIME_ID_YEAR && __pDateTimeBar->GetSelectedBoxId() <= DATETIME_ID_DAY) diff --git a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp index bb5f55f..41c611d 100644 --- a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp @@ -1214,8 +1214,7 @@ _EditDatePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& to { if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated()) { - __pEditDate->GetDateTimeBar()->SetVisibleState(false); - __pEditDate->GetDateTimeBar()->Close(); + __pEditDate->GetDateTimeBar()->CloseDateTimeBar(); } __selectedId = DATETIME_ID_NONE; diff --git a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp index 5c43b9a..ce3746d 100644 --- a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp @@ -1443,8 +1443,7 @@ _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& to { if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated()) { - __pEditTime->GetDateTimeBar()->SetVisibleState(false); - __pEditTime->GetDateTimeBar()->Close(); + __pEditTime->GetDateTimeBar()->CloseDateTimeBar(); } __selectedId = DATETIME_ID_NONE; diff --git a/src/ui/inc/FUiCtrl_DateTimeBar.h b/src/ui/inc/FUiCtrl_DateTimeBar.h index e3d8a05..f2efe96 100644 --- a/src/ui/inc/FUiCtrl_DateTimeBar.h +++ b/src/ui/inc/FUiCtrl_DateTimeBar.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include "FUi_Window.h" #include "FUi_UiTouchEvent.h" #include "FUi_IAccessibilityListener.h" @@ -54,6 +56,7 @@ class _DateTimeBar , virtual public Tizen::Base::Runtime::IEventListener , virtual public _IUiEventListener , virtual public _IUiEventPreviewer + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener { public: virtual ~_DateTimeBar(void); @@ -123,6 +126,11 @@ public: _AccessibilityElement* GetAccessibilityElementAt(int index) const; int GetIndexFromAccessibilityElementPoint(const Tizen::Graphics::FloatPoint& point) const; + void CloseDateTimeBar(void); + virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){} + virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){} + private: _DateTimeBar(void); @@ -132,7 +140,11 @@ private: void SetAlignment(_DateTimeBarAlignment alignment); void SetSelectedBoxId(_DateTimeId boxId); void InitializeAccessibilityElement(void); + Tizen::Ui::Animations::VisualElementAnimationGroup* CreateAnimationN(Tizen::Ui::Animations::VisualElement& source, bool open); private: + static const int ANIMATION_DURATION = 167; + static const int POSITION_ANIMATION_VALUE = 20; + _DateTimeBarPresenter* __pDateTimeBarPresenter; _ActionEvent* __pActionEvent;