2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_DateTimeBar.cpp
20 * @brief This is the implementation file for the _DateTimeBar class.
23 #include <FUiAnimVisualElementAnimationGroup.h>
24 #include <FUiAnimVisualElementPropertyAnimation.h>
25 #include "FUiAnim_VisualElement.h"
26 #include "FUi_AccessibilityContainer.h"
27 #include "FUi_AccessibilityElement.h"
28 #include "FUi_ResourceManager.h"
29 #include "FUiCtrl_DateTimeBar.h"
30 #include "FUiCtrl_DateTimeBarPresenter.h"
31 #include "FUiCtrl_ActionEvent.h"
32 #include "FUiCtrl_Frame.h"
33 #include "FUiCtrl_Form.h"
34 #include "FUi_CoordinateSystemUtils.h"
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Media;
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Ui::Animations;
42 namespace Tizen { namespace Ui { namespace Controls
44 _DateTimeBar::_DateTimeBar(void)
45 : __pDateTimeBarPresenter(null)
46 , __pActionEvent(null)
47 , __selectedBoxId(DATETIME_ID_NONE)
48 , __alignment(DATETIME_BAR_ALIGN_DOWN)
49 , __pDateTimeChangeEvent(null)
50 , __pGestureFlick(null)
51 , __parentWindowBounds(0.0f, 0.0f, 0.0f, 0.0f)
53 , __accessibilityFocusOutIndex(-1)
54 , __isAnimating(false)
59 _DateTimeBar::~_DateTimeBar(void)
61 ReleaseTouchCapture();
63 if (GetVisualElement())
65 GetVisualElement()->RemoveAllAnimations();
68 if (__pDateTimeChangeEvent != null)
70 delete __pDateTimeChangeEvent;
71 __pDateTimeChangeEvent = null;
76 delete __pActionEvent;
77 __pActionEvent = null;
80 delete __pDateTimeBarPresenter;
81 __pDateTimeBarPresenter = null;
83 delete __pGestureFlick;
84 __pGestureFlick = null;
86 RemoveAllAccessibilityElement();
92 _DateTimeBar::CreateDateTimeBarN(_Control& owner)
97 _DateTimeBar* pDateTimeBar = new (std::nothrow) _DateTimeBar;
98 SysTryReturn(NID_UI_CTRL, pDateTimeBar != null, null, E_OUT_OF_MEMORY,
99 "[E_OUT_OF_MEMORY] Memory allocation failed.");
101 r = pDateTimeBar->CreateRootVisualElement();
102 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
104 pDateTimeBar->__pOwner = &owner;
106 pDateTimeBar->__pDateTimeBarPresenter = _DateTimeBarPresenter::CreateInstanceN(*pDateTimeBar);
108 SysTryCatch(NID_UI_CTRL, pDateTimeBar->__pDateTimeBarPresenter != null, , r,
109 "[%s] Propagating.", GetErrorMessage(r));
111 pDateTimeBar->__pDateTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*pDateTimeBar);
112 SysTryCatch(NID_UI_CTRL, (pDateTimeBar->__pDateTimeChangeEvent != null), , E_OUT_OF_MEMORY,
113 "[E_OUT_OF_MEMORY] Memory allocation failed.");
115 pDateTimeBar->AcquireHandle();
117 if (pDateTimeBar->GetVisualElement() != null)
119 pDateTimeBar->GetVisualElement()->SetSurfaceOpaque(false);
122 pDateTimeBar->__pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector();
123 SysTryCatch(NID_UI_CTRL, (pDateTimeBar->__pGestureFlick != null), , E_OUT_OF_MEMORY,
124 "[E_OUT_OF_MEMORY] Memory allocation failed.");
126 pDateTimeBar->AddGestureDetector(*(pDateTimeBar->__pGestureFlick));
127 SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
129 r = pDateTimeBar->__pGestureFlick->AddGestureListener(*pDateTimeBar);
130 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
132 pDateTimeBar->InitializeAccessibilityElement();
141 _DateTimeBar::SetPositionAndAlignment(const FloatPoint& point, _DateTimeBarAlignment alignment)
145 result r = E_SUCCESS;
146 SetAlignment(alignment);
148 r = __pDateTimeBarPresenter->LoadArrowBitmap();
149 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
153 r = GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), height);
154 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
159 if (alignment == DATETIME_BAR_ALIGN_DOWN)
161 SetPosition(FloatPoint(point.x, point.y));
166 SetPosition(FloatPoint(point.x, point.y - height));
169 __pDateTimeBarPresenter->CalculateWindowBounds();
174 _DateTimeBarAlignment
175 _DateTimeBar::GetAlignment(void) const
181 _DateTimeBar::SetAlignment(_DateTimeBarAlignment alignment)
183 __alignment = alignment;
188 _DateTimeBar::OnDraw(void)
192 __pDateTimeBarPresenter->Draw();
197 _DateTimeBar::RemoveAllItems(void)
201 result r = E_SUCCESS;
203 r = __pDateTimeBarPresenter->RemoveAllItems();
204 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
210 _DateTimeBar::SetInitialValue(int minValue, int maxValue, int displayValue, _DateTimeId boxId)
214 result r = E_SUCCESS;
216 SetSelectedBoxId(boxId);
218 __pDateTimeBarPresenter->SetMinimumValue(minValue);
219 __pDateTimeBarPresenter->SetMaximumValue(maxValue);
221 r = __pDateTimeBarPresenter->AddItems(displayValue);
222 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
228 _DateTimeBar::GetSelectedBoxId(void) const
230 return __selectedBoxId;
234 _DateTimeBar::SetSelectedBoxId(_DateTimeId boxId)
236 __selectedBoxId = boxId;
242 _DateTimeBar::InitializeAccessibilityElement(void)
245 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
249 pContainer->Activate(true);
250 pContainer->AddListener(*this);
257 _DateTimeBar::GetItemCount(void) const
261 return __pDateTimeBarPresenter->GetItemCount();
265 _DateTimeBar::AddActionEventListener(const _IActionEventListener& listener)
269 result r = E_SUCCESS;
271 if (__pActionEvent == null)
273 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
274 SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_SYSTEM, E_SYSTEM,
275 "[%s] Propagating.", GetErrorMessage(r));
277 r = __pActionEvent->AddListener(listener);
278 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
284 _DateTimeBar::RemoveActionEventListener(const _IActionEventListener& listener)
288 result r = E_OBJ_NOT_FOUND;
292 r = __pActionEvent->RemoveListener(listener);
295 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
301 _DateTimeBar::AddDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
305 return __pDateTimeChangeEvent->AddListener(listener);
309 _DateTimeBar::RemoveDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
313 return __pDateTimeChangeEvent->RemoveListener(listener);
317 _DateTimeBar::FireDateTimeChangeEvent(_DateTimeChangeStatus status)
321 _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status);
322 SysTryReturn(NID_UI_CTRL, (pDateTimeEventArg != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
323 "[E_OUT_OF_MEMORY] Memory allocation failed.");
325 __pDateTimeChangeEvent->Fire(*pDateTimeEventArg);
331 _DateTimeBar::FireActionEvent(int actionId)
337 Tizen::Base::Runtime::IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
338 result r = GetLastResult();
339 SysTryReturn(NID_UI_CTRL, pEventArg, false, r, "[%s] Propagating.", GetErrorMessage(r));
341 __pActionEvent->Fire(*pEventArg);
348 _DateTimeBar::CalculateArrowBounds(const FloatRectangle& bounds)
352 FloatRectangle arrowBounds(0.0f, 0.0f, 0.0f, 0.0f);
354 arrowBounds = __pDateTimeBarPresenter->GetArrowBounds();
355 arrowBounds.x = bounds.x + (bounds.width / 2.0f) - (arrowBounds.width / 2.0f);
356 arrowBounds.x -= __pDateTimeBarPresenter->GetWindowBounds().x;
358 __pDateTimeBarPresenter->SetArrowBounds(arrowBounds);
364 _DateTimeBar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
372 return __pDateTimeBarPresenter->OnTouchPressed(source, touchinfo);
376 _DateTimeBar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
384 return __pDateTimeBarPresenter->OnTouchReleased(source, touchinfo);
388 _DateTimeBar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
396 return __pDateTimeBarPresenter->OnTouchMoved(source, touchinfo);
400 _DateTimeBar::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
404 return __pDateTimeBarPresenter->OnTouchCanceled(source, touchinfo);
408 _DateTimeBar::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
412 gesture.GetDistance(xDistance, yDistance);
413 int duration = gesture.GetDuration();
414 return __pDateTimeBarPresenter->OnFlickGestureDetected(xDistance, yDistance, duration);
418 _DateTimeBar::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
424 _DateTimeBar::OnTouchMoveHandled(const Tizen::Ui::_Control& control)
428 return __pDateTimeBarPresenter->OnTouchMoveHandled(control);
432 _DateTimeBar::OnAttachedToMainTree(void)
436 return _Window::OnAttachedToMainTree();
440 _DateTimeBar::OnDetachingFromMainTree(void)
442 return _Window::OnDetachingFromMainTree();
446 _DateTimeBar::OnActivated(void)
448 VisualElement* pVisualElement = null;
449 VisualElementAnimation *pAnimation = null;
451 pVisualElement = GetVisualElement();
452 SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get visual element.");
453 pAnimation = CreateAnimationN(*pVisualElement, true);
454 SysTryReturnVoidResult(NID_UI_CTRL, pAnimation != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
455 pVisualElement->AddAnimation(L"BarOpenAnimation", *pAnimation);
458 SetTouchCapture(true, true);
460 return _Window::OnActivated();
464 _DateTimeBar::OnDeactivated(void)
466 ReleaseTouchCapture();
468 return _Window::OnDeactivated();
472 _DateTimeBar::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText)
474 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
475 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
477 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
478 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
480 String labelText = itemText;
481 pAccessibilityElement->SetBounds(itemBounds);
482 pAccessibilityElement->SetLabel(labelText);
483 pAccessibilityElement->SetTraitWithStringId(GetAccessibilityTraitValue());
484 pContainer->AddElement(*pAccessibilityElement);
485 __accessibilityElements.Add(pAccessibilityElement);
491 _DateTimeBar::InsertAccessibilityElementAt(int index, const FloatRectangle& itemBounds, const String& itemText)
493 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
494 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
496 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
497 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
499 String labelText = itemText;
500 pAccessibilityElement->SetBounds(itemBounds);
501 pAccessibilityElement->SetLabel(labelText);
502 pAccessibilityElement->SetTraitWithStringId(GetAccessibilityTraitValue());
503 pContainer->InsertElement(*pAccessibilityElement, index);
504 __accessibilityElements.InsertAt(pAccessibilityElement, index);
510 _DateTimeBar::RemoveAccessibilityElementAt(int index)
512 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
513 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
515 _AccessibilityElement* pAccessibilityElement = null;
517 if (__accessibilityElements.GetAt(index, pAccessibilityElement) == E_SUCCESS)
519 __accessibilityElements.RemoveAt(index);
520 pContainer->RemoveElement(*pAccessibilityElement);
527 _DateTimeBar::RemoveAllAccessibilityElement(void)
529 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
530 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
532 _AccessibilityElement* pAccessibilityElement = null;
534 while (__accessibilityElements.GetCount() > 0)
536 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
538 __accessibilityElements.RemoveAt(0);
539 pContainer->RemoveElement(*pAccessibilityElement);
547 _DateTimeBar::GetAccessibilityTraitValue() const
549 const char* ACCESSIBILITY_TRAITS_DAY = "IDS_TPLATFORM_BODY_DAY_LC";
550 const char* ACCESSIBILITY_TRAITS_MONTH = "IDS_TPLATFORM_BODY_MONTH_LC";
551 const char* ACCESSIBILITY_TRAITS_YEAR = "IDS_TPLATFORM_BODY_YEAR_LC";
552 const char* ACCESSIBILITY_TRAITS_HOUR = "IDS_TPLATFORM_BODY_HOUR_LC";
553 const char* ACCESSIBILITY_TRAITS_MINUTE = "IDS_TPLATFORM_BODY_MINUTE_LC";
554 char* traitsValue = null;
556 if (GetSelectedBoxId() == DATETIME_ID_DAY)
558 traitsValue = const_cast<char*>(ACCESSIBILITY_TRAITS_DAY);
560 else if (GetSelectedBoxId() == DATETIME_ID_MONTH)
562 traitsValue = const_cast<char*>(ACCESSIBILITY_TRAITS_MONTH);
564 else if (GetSelectedBoxId() == DATETIME_ID_YEAR)
566 traitsValue = const_cast<char*>(ACCESSIBILITY_TRAITS_YEAR);
568 else if (GetSelectedBoxId() == DATETIME_ID_HOUR)
570 traitsValue = const_cast<char*>(ACCESSIBILITY_TRAITS_HOUR);
572 else if (GetSelectedBoxId() == DATETIME_ID_MINUTE)
574 traitsValue = const_cast<char*>(ACCESSIBILITY_TRAITS_MINUTE);
581 _DateTimeBar::GetMonthValue(int month) const
588 monthValue = L"January";
591 monthValue = L"February";
594 monthValue = L"March";
597 monthValue = L"April";
603 monthValue = L"June";
606 monthValue = L"July";
609 monthValue = L"August";
612 monthValue = L"September";
615 monthValue = L"October";
618 monthValue = L"November";
621 monthValue = L"December";
631 _DateTimeBar::SetFont(Font& pFont)
633 __pDateTimeBarPresenter->SetFont(pFont);
639 _DateTimeBar::SetParentWindowBounds(FloatRectangle& parentWindowBounds)
641 __parentWindowBounds = parentWindowBounds;
646 _DateTimeBar::GetParentWindowBounds() const
648 return __parentWindowBounds;
652 _DateTimeBar::RefreshItems(void)
656 if (GetSelectedBoxId() == DATETIME_ID_MONTH)
658 GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
660 else if (GetSelectedBoxId() == DATETIME_ID_YEAR)
662 GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
666 GET_SHAPE_CONFIG(DATETIMEBAR::DAY_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
669 __pDateTimeBarPresenter->SetInitialAnimationValue(itemWidth);
671 __pDateTimeBarPresenter->StartAnimationEffect();
673 if (unlikely((_AccessibilityManager::IsActivated())))
675 _AccessibilityElement* pAccessibilityElement = GetAccessibilityElementAt(__pDateTimeBarPresenter->GetSelectedItemIndex() - 1);
677 if (pAccessibilityElement != null)
679 _AccessibilityManager::GetInstance()->SetGlobalFocusedElement(*pAccessibilityElement);
687 _DateTimeBar::OnFocusGained(const _Control& control)
689 __pDateTimeBarPresenter->ChangeFocusStatus();
690 __pDateTimeBarPresenter->SetFocusedItemBounds();
691 __pDateTimeBarPresenter->SetItemFocused(true);
697 _DateTimeBar::OnFocusLost(const _Control& control)
699 __pDateTimeBarPresenter->SetItemFocused(false);
704 _DateTimeBar::OnFocusModeStateChanged(void)
706 __pDateTimeBarPresenter->FocusModeChanged();
712 _DateTimeBar::OnDrawFocus(void)
718 _DateTimeBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
720 return __pDateTimeBarPresenter->OnKeyPressed(source,keyInfo);
724 _DateTimeBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
726 return __pDateTimeBarPresenter->OnKeyReleased(source,keyInfo);
730 _DateTimeBar::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
732 return __pDateTimeBarPresenter->OnAccessibilityFocusMovedNext(control, element);
736 _DateTimeBar::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
738 return __pDateTimeBarPresenter->OnAccessibilityFocusMovedPrevious(control, element);
742 _DateTimeBar::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
748 _DateTimeBar::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
754 _DateTimeBar::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
756 if (__accessibilityFocusOutIndex == -1)
763 if (GetSelectedBoxId() == DATETIME_ID_MONTH)
765 GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
767 else if (GetSelectedBoxId() == DATETIME_ID_YEAR)
769 GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
773 GET_SHAPE_CONFIG(DATETIMEBAR::DAY_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth);
776 _AccessibilityElement* pFocusInAccessibilityElement = null;
778 int focusInIndex = GetIndexFromAccessibilityElementPoint(FloatPoint(element.GetBounds().x, element.GetBounds().y));
780 pFocusInAccessibilityElement = GetAccessibilityElementAt(focusInIndex);
782 if (__accessibilityFocusOutIndex < focusInIndex)
784 if (pFocusInAccessibilityElement != null && (pFocusInAccessibilityElement->GetBounds().x + pFocusInAccessibilityElement->GetBounds().width >
785 __pDateTimeBarPresenter->GetWindowBounds().x + __pDateTimeBarPresenter->GetWindowBounds().width))
787 __pDateTimeBarPresenter->MoveNext();
791 else if (__accessibilityFocusOutIndex > focusInIndex)
793 if (pFocusInAccessibilityElement != null && pFocusInAccessibilityElement->GetBounds().x < 0)
795 __pDateTimeBarPresenter->MovePrevious();
803 _DateTimeBar::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
805 __accessibilityFocusOutIndex = GetIndexFromAccessibilityElementPoint(FloatPoint(element.GetBounds().x, element.GetBounds().y));
811 _DateTimeBar::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
817 _DateTimeBar::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
823 _DateTimeBar::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
828 _AccessibilityElement*
829 _DateTimeBar::GetAccessibilityElementAt(int index) const
831 result r = E_SUCCESS;
832 _AccessibilityElement* pAccessibilityElement = null;
834 r = __accessibilityElements.GetAt(index, pAccessibilityElement);
835 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
837 return pAccessibilityElement;
841 _DateTimeBar::GetIndexFromAccessibilityElementPoint(const FloatPoint& point) const
843 _AccessibilityElement* pAccessibilityElement = null;
845 for (int index = __accessibilityElements.GetCount() -1; index >= 0; index--)
847 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
849 if (pAccessibilityElement->GetBounds().Contains(point))
859 VisualElementAnimationGroup*
860 _DateTimeBar::CreateAnimationN(VisualElement& source, bool open)
862 FloatRectangle startValue = source.GetBounds();
863 VisualElementAnimationGroup* pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup();
864 SysTryReturn(NID_UI_CTRL, pAnimationGroup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
866 VisualElementPropertyAnimation* pOpacityAnimation = null;
867 VisualElementPropertyAnimation* pBoundsAnimation = null;
868 String* pUserData = null;
870 pAnimationGroup->SetDuration(ANIMATION_DURATION);
872 pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation();
873 SysTryCatch(NID_UI_CTRL, (pOpacityAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
875 pOpacityAnimation->SetPropertyName("opacity");
879 pUserData = new (std::nothrow) String(L"BarOpenAnimation");
880 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
882 pOpacityAnimation->SetStartValue(Variant(0.0f));
883 pOpacityAnimation->SetEndValue(Variant(1.0f));
887 pUserData = new (std::nothrow) String(L"BarCloseAnimation");
888 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
890 pOpacityAnimation->SetStartValue(Variant(1.0f));
891 pOpacityAnimation->SetEndValue(Variant(0.0f));
893 pOpacityAnimation->SetDuration(ANIMATION_DURATION);
894 pAnimationGroup->AddAnimation(*pOpacityAnimation);
895 delete pOpacityAnimation;
896 pOpacityAnimation = null;
898 pBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
899 SysTryCatch(NID_UI_CTRL, (pBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
901 pBoundsAnimation->SetPropertyName(L"bounds.position");
902 startValue.y = startValue.y - POSITION_ANIMATION_VALUE;
906 pBoundsAnimation->SetStartValue(Variant(FloatPoint(startValue.x, startValue.y)));
907 pBoundsAnimation->SetEndValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y)));
908 pBoundsAnimation->SetUserData((void*)(pUserData));
912 pBoundsAnimation->SetStartValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y)));
913 pBoundsAnimation->SetEndValue(Variant(FloatPoint(startValue.x, startValue.y)));
914 pBoundsAnimation->SetUserData((void*)(pUserData));
916 pBoundsAnimation->SetDuration(ANIMATION_DURATION);
917 pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
918 pAnimationGroup->AddAnimation(*pBoundsAnimation);
919 delete pBoundsAnimation;
920 pBoundsAnimation = null;
922 return pAnimationGroup;
925 delete pAnimationGroup;
926 delete pOpacityAnimation;
932 _DateTimeBar::CloseDateTimeBar()
934 VisualElement* pVisualElement = null;
935 VisualElementAnimation *pAnimation = null;
937 __isAnimating = true;
938 pVisualElement = GetVisualElement();
939 SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get visual element.");
940 pAnimation = CreateAnimationN(*pVisualElement, false);
941 SysTryReturnVoidResult(NID_UI_CTRL, pAnimation != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
942 pVisualElement->AddAnimation(L"BarCloseAnimation", *pAnimation);
948 _DateTimeBar::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
950 String* pUserData = (String*) animation.GetUserData();
952 if ((pUserData != null) && (*pUserData == String(L"BarOpenAnimation")))
956 else if ((pUserData != null) && (*pUserData == String(L"BarCloseAnimation")))
958 FloatRectangle bounds = target.GetBounds();
959 bounds.y = bounds.y + POSITION_ANIMATION_VALUE;
960 SetVisibleState(false);
962 target.SetBounds(bounds);
964 __isAnimating = false;
969 }}} // Tizen::Ui::Controls