* @brief This is the implementation file for the _DateTimeBar class.
*/
+#include <FUiAnimVisualElementAnimationGroup.h>
+#include <FUiAnimVisualElementPropertyAnimation.h>
#include "FUiAnim_VisualElement.h"
#include "FUi_AccessibilityContainer.h"
#include "FUi_AccessibilityElement.h"
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();
}
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
#include <FGrp_TextTextSimple.h>
#include "FUi_CoordinateSystemUtils.h"
#include "FUi_ResourceManager.h"
+#include "FUiAnim_VisualElement.h"
#include "FUiCtrl_DateTimeUtils.h"
#include "FUiCtrl_DateTimeBar.h"
#include "FUiCtrl_DateTimeBarPresenter.h"
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
{
{
__isTouchMoved = false;
PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- __pDateTimeBar->SetVisibleState(false);
- __pDateTimeBar->Close();
+ __pDateTimeBar->CloseDateTimeBar();
ResetFlickAnimationTimer();
__pDateTimeBar->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED);
return true;
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)
#include <FBaseString.h>
#include <FBaseDateTime.h>
+#include <FUiAnimIVisualElementAnimationStatusEventListener.h>
+#include <FUiAnimVisualElementAnimationGroup.h>
#include "FUi_Window.h"
#include "FUi_UiTouchEvent.h"
#include "FUi_IAccessibilityListener.h"
, virtual public Tizen::Base::Runtime::IEventListener
, virtual public _IUiEventListener
, virtual public _IUiEventPreviewer
+ , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
{
public:
virtual ~_DateTimeBar(void);
_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);
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;