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.
18 * @file FUiCtrl_Indicator.cpp
19 * @brief This is the implementation file for the _Form class.
22 #include <FGrpRectangle.h>
23 #include <FUiAnimAnimationTransaction.h>
24 #include <FUiAnimVisualElementPropertyAnimation.h>
25 #include <FGrp_CoordinateSystem.h>
26 #include <FUiAnim_VisualElementSurfaceImpl.h>
27 #include "FUiAnim_VisualElement.h"
28 #include "FUiAnim_VisualElementImpl.h"
29 #include "FUiAnim_EflNode.h"
30 #include "FUi_EcoreEvasMgr.h"
31 #include "FUi_EcoreEvas.h"
32 #include "FUi_ResourceManager.h"
33 #include "FUi_CoordinateSystemUtils.h"
34 #include "FUi_UiEventManager.h"
35 #include "FUi_Window.h"
36 #include "FUi_TouchManager.h"
37 #include "FUiCtrl_Form.h"
38 #include "FUiCtrl_Indicator.h"
39 #include "FUiCtrl_IndicatorManager.h"
40 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
42 using namespace Tizen::Base::Runtime;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Animations;
49 const char* pPortraitSvcName = "elm_indicator_portrait";
50 const char* pLandScapeSvcName = "elm_indicator_landscape";
51 const char* pPortPublicKey = "__Plug_Ecore_Evas_Port";
52 const char* pLandPublicKey = "__Plug_Ecore_Evas_Land";
53 const char* pIndicatorKey = "Inidcator_Manager_Object";
54 const int CONNECTION_INTERVAL = 1000;
55 const int ANIMATION_INTERVAL = 3000;
56 const int ANIMATION_DURATION = 200;
58 const int MSG_DOMAIN_CONTROL_INDICATOR = 0x10001;
59 const int MSG_ID_INDICATOR_REPEAT_EVENT = 0x10002;
60 const int MSG_ID_INDICATOR_ROTATION = 0x10003;
61 const int MSG_ID_INDICATOR_OPACITY = 0X1004;
62 const int MSG_ID_INDICATOR_TYPE = 0X1005;
63 const int MSG_ID_INDICATOR_START_ANIMATION = 0X10006;
66 namespace Tizen { namespace Ui { namespace Controls
69 struct _IndicatorDataAnimation
77 _INDICATOR_TYPE_UNKNOWN, /**< Unknown indicator type mode */
78 _INDICATOR_TYPE_1, /**< Type 0 the the indicator */
79 _INDICATOR_TYPE_2, /**< Type 1 the indicator */
83 _Indicator::CreateIndicator(void)
86 Color bgColor(0xff343432);
88 _Indicator* pIndicator = new (std::nothrow) _Indicator;
89 SysTryReturn(NID_UI_CTRL, pIndicator, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
90 SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
92 r = pIndicator->ConstructControlVisualElement();
93 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
95 pIndicator->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
104 _Indicator::_Indicator(void)
105 : __pPortraitIndicatorEvasObject(null)
106 , __pLandscapeIndicatorEvasObject(null)
107 , __pConnectionTimer(null)
108 , __pAnimationTimer(null)
109 , __pPortraitVisualElement(null)
110 , __pLandscapeVisualElement(null)
111 , __pCurrentVisualElement(null)
114 , __portraitautohide(false)
115 , __landscapeautohide(false)
116 , __opacity(_INDICATOR_OPACITY_OPAQUE)
117 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
118 , __startTouchPoint(0.0f, 0.0f)
119 , __animationing(false)
120 , __touchPressed(false)
124 _Indicator::~_Indicator(void)
126 if (__pConnectionTimer != null)
128 __pConnectionTimer->Cancel();
129 delete __pConnectionTimer;
130 __pConnectionTimer = null;
133 if (__pAnimationTimer != null)
135 __pAnimationTimer->Cancel();
136 delete __pAnimationTimer;
137 __pAnimationTimer = null;
140 _UiEventManager::GetInstance()->RemoveTouchEventListener(*this);
144 _Indicator::SetIndicatorShowState(bool state)
146 result r = E_SUCCESS;
148 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
149 SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
151 Ecore_X_Window win = 0;
155 r = pEcoreEvas->SetIndicatorShowState(*__pWindow, state);
156 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
157 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
166 SetIndicatorOpacity(__opacity);
173 _Indicator::SetIndicatorAutoHide(bool portrait, bool landscape)
175 Ecore_X_Window win = 0;
178 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
181 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
185 Color bgColor(0x00000000);
186 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
187 if (__pPortraitVisualElement)
189 __pPortraitVisualElement->SetShowState(false);
191 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
192 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
196 SetIndicatorOpacity(__opacity);
197 if (__pPortraitVisualElement)
199 __pPortraitVisualElement->SetShowState(true);
201 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
202 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
209 Color bgColor(0x00000000);
210 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
211 if (__pLandscapeVisualElement)
213 __pLandscapeVisualElement->SetShowState(false);
215 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
216 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
220 SetIndicatorOpacity(__opacity);
221 if (__pLandscapeVisualElement)
223 __pLandscapeVisualElement->SetShowState(true);
225 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
226 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
229 __portraitautohide = portrait;
230 __landscapeautohide = landscape;
235 _Indicator::SetIndicatorOpacity(_IndicatorOpacity opacity)
237 result r = E_SUCCESS;
239 if (opacity == _INDICATOR_OPACITY_OPAQUE)
241 Color bgColor(0xff1e1e1e);
242 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
244 else if (opacity == _INDICATOR_OPACITY_TRANSLUCENT)
246 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
248 Color bgColor(0x7f000000);
249 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
253 Color bgColor(0x00000000);
254 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
264 _Indicator::GetIndicatorShowState(void) const
270 _Indicator::GetIndicatorOpacity(void) const
272 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
274 if (__portraitautohide)
276 return _INDICATOR_OPACITY_TRANSPARENT;
281 if (__landscapeautohide)
283 return _INDICATOR_OPACITY_TRANSPARENT;
291 _Indicator::GetIndicatorAutoHide(void) const
293 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
295 return __portraitautohide;
299 return __landscapeautohide;
305 _Indicator::GetIndicatorBounds(void) const
307 const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize();
308 const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width);
310 Rectangle indicatorbounds(0, 0, 0, 0);
312 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
314 indicatorbounds.width = portraitSize.width;
318 indicatorbounds.width = landscapeSize.width;
320 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
322 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
323 SysTryReturn(NID_UI_CTRL, pCoordSystem, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
325 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
326 SysTryReturn(NID_UI_CTRL, pXformer, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
328 indicatorbounds = pXformer->Transform(indicatorbounds);
330 return indicatorbounds;
334 _Indicator::GetIndicatorBoundsF(void) const
336 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
337 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
339 FloatRectangle indicatorbounds(0.0f, 0.0f, 0.0f, 0.0f);
341 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
343 indicatorbounds.width = portraitSize.width;
347 indicatorbounds.width = landscapeSize.width;
350 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
352 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
353 SysTryReturn(NID_UI_CTRL, pCoordSystem, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
355 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
356 SysTryReturn(NID_UI_CTRL, pXformer, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
358 indicatorbounds = pXformer->Transform(indicatorbounds);
360 return indicatorbounds;
364 _Indicator::AddIndicatorObject(_Control* pControl, _Window* pWindow)
366 result r = E_SUCCESS;
370 __pPortraitVisualElement = _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_PORTRAIT, pControl);
371 SysTryReturn(NID_UI_CTRL, __pPortraitVisualElement, null, E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
372 __pLandscapeVisualElement = _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, pControl);
373 SysTryReturn(NID_UI_CTRL, __pLandscapeVisualElement, null, E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
374 __pPortraitIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_PORTRAIT);
375 SysTryReturn(NID_UI_CTRL, __pPortraitIndicatorEvasObject, null, E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
376 __pLandscapeIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_LANDSCAPE);
377 SysTryReturn(NID_UI_CTRL, __pLandscapeIndicatorEvasObject, null, E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
379 _ControlOrientation orientation = pControl->GetOrientation();
380 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
382 r = ChangeCurrentVisualElement(__pPortraitVisualElement);
386 r = ChangeCurrentVisualElement(__pLandscapeVisualElement);
389 Ecore_Evas *pPortraitEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject);
390 SysTryReturn(NID_UI_CTRL, pPortraitEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
391 Ecore_Evas *pLandscapeEe = ecore_evas_object_ecore_evas_get(__pLandscapeIndicatorEvasObject);
392 SysTryReturn(NID_UI_CTRL, pLandscapeEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
394 ecore_evas_data_set(pPortraitEe, pPortPublicKey, __pPortraitIndicatorEvasObject);
395 ecore_evas_data_set(pLandscapeEe, pLandPublicKey, __pLandscapeIndicatorEvasObject);
396 ecore_evas_data_set(pPortraitEe, pIndicatorKey, this);
397 ecore_evas_data_set(pLandscapeEe, pIndicatorKey, this);
398 ecore_evas_callback_delete_request_set(pPortraitEe, _Indicator::OnDisconnected);
399 ecore_evas_callback_delete_request_set(pLandscapeEe, _Indicator::OnDisconnected);
401 ecore_evas_callback_msg_handle_set(pPortraitEe, _Indicator::OnMessageHandle);
402 ecore_evas_callback_msg_handle_set(pLandscapeEe, _Indicator::OnMessageHandle);
410 _Indicator::DeleteIndicatorObject(void)
412 result r = E_SUCCESS;
414 r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_PORTRAIT, __pPortraitVisualElement);
415 r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, __pLandscapeVisualElement);
417 if (__pPortraitVisualElement)
419 if (__pPortraitVisualElement == __pCurrentVisualElement)
421 r = DetachChild(*__pPortraitVisualElement);
424 if (__pLandscapeVisualElement)
426 if (__pLandscapeVisualElement == __pCurrentVisualElement)
428 r = DetachChild(*__pLandscapeVisualElement);
432 __pPortraitIndicatorEvasObject = null;
433 __pLandscapeIndicatorEvasObject = null;
434 __pPortraitVisualElement = null;
435 __pLandscapeVisualElement = null;
436 __pCurrentVisualElement = null;
442 _Indicator::ChangeCurrentVisualElement(Tizen::Ui::Animations::_VisualElement* pVisualElement)
444 result r = E_SUCCESS;
446 if (!(__pCurrentVisualElement == pVisualElement))
448 r = AttachChild(*pVisualElement);
449 if (__pCurrentVisualElement)
451 r = DetachChild(*__pCurrentVisualElement);
453 __pCurrentVisualElement = pVisualElement;
460 _Indicator::OnChangeLayout(_ControlOrientation orientation)
462 RemoveIndicatorAnimations();
463 if (__pAnimationTimer != null)
465 __pAnimationTimer->Cancel();
466 __animationing = false;
469 Ecore_X_Window win = 0;
472 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
475 __orientation = orientation;
477 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
479 ChangeCurrentVisualElement(__pPortraitVisualElement);
480 SetClipChildrenEnabled(true);
482 if (__portraitautohide)
484 Color bgColor(0x00000000);
485 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
486 if (__pPortraitVisualElement)
488 __pPortraitVisualElement->SetShowState(false);
490 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
491 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
495 SetIndicatorOpacity(__opacity);
496 if (__pPortraitVisualElement)
498 __pPortraitVisualElement->SetShowState(true);
500 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
501 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
507 ChangeCurrentVisualElement(__pLandscapeVisualElement);
508 SetClipChildrenEnabled(false);
510 if (__landscapeautohide)
512 Color bgColor(0x00000000);
513 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
514 if (__pLandscapeVisualElement)
516 __pLandscapeVisualElement->SetShowState(false);
518 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
519 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
523 SetIndicatorOpacity(__opacity);
524 if (__pLandscapeVisualElement)
526 __pLandscapeVisualElement->SetShowState(true);
528 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
529 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
535 _Indicator::OnAttachedToMainTree(void)
537 result r = E_SUCCESS;
539 if (__pCurrentVisualElement)
541 r = ChangeCurrentVisualElement(__pCurrentVisualElement);
548 _Indicator::OnTimerExpired(Timer& timer)
550 if (__pConnectionTimer == &timer)
552 Eina_Bool result = EINA_TRUE;
554 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
555 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
557 result = ecore_evas_extn_plug_connect(__pPortraitIndicatorEvasObject, pPortraitSvcName, 0, EINA_FALSE);
561 result = ecore_evas_extn_plug_connect(__pLandscapeIndicatorEvasObject, pLandScapeSvcName, 0, EINA_FALSE);
564 if (result == EINA_TRUE)
570 timer.Start(CONNECTION_INTERVAL);
573 else if(__pAnimationTimer == &timer)
575 ShowIndicatorEffect(false, ANIMATION_DURATION);
578 __animationing = false;
583 _Indicator::OnDisconnected(Ecore_Evas *pEe)
585 _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
586 SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
588 if (pIndicator->__pConnectionTimer == null)
590 pIndicator->__pConnectionTimer = new (std::nothrow) Timer;
591 if (pIndicator->__pConnectionTimer == null)
596 result r = pIndicator->__pConnectionTimer->Construct(*pIndicator);
599 delete pIndicator->__pConnectionTimer;
600 pIndicator->__pConnectionTimer = null;
606 pIndicator->__pConnectionTimer->Start(CONNECTION_INTERVAL);
610 _Indicator::SetNotificationTrayOpenEnabled(bool enable)
612 Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
614 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
617 int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
630 ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
637 _Indicator::IsNotificationTrayOpenEnabled(void) const
639 Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
641 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
644 int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
661 _Indicator::OnMessageHandle(Ecore_Evas *pEe, int msgDomain, int msgId, void *data, int size)
668 _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
669 SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
671 Evas_Object* pPortraitIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pPortPublicKey);
672 Evas_Object* pLandscapeIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pLandPublicKey);
674 if (msgDomain == MSG_DOMAIN_CONTROL_INDICATOR)
676 if (msgId == MSG_ID_INDICATOR_REPEAT_EVENT)
678 int *repeat = (int*)data;
681 if (pPortraitIndicatorEvasObject)
683 evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_TRUE);
685 if (pLandscapeIndicatorEvasObject)
687 evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_TRUE);
692 if (pPortraitIndicatorEvasObject)
694 evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_FALSE);
696 if (pLandscapeIndicatorEvasObject)
698 evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_FALSE);
702 else if (msgId == MSG_ID_INDICATOR_START_ANIMATION)
704 _IndicatorDataAnimation* pData = (_IndicatorDataAnimation*)data;
705 Ecore_X_Window win = 0;
706 _Window* pWindow = pIndicator->__pWindow;
709 win = (Ecore_X_Window)pWindow->GetNativeHandle();
712 if (pData->xwin == win)
714 pIndicator->ShowIndicatorEffect(true, pData->duration);
722 _Indicator::OnHitTest(const Tizen::Graphics::FloatPoint& point)
726 return HIT_TEST_NOWHERE;
729 if (!GetBounds().Contains(point))
731 return HIT_TEST_NOWHERE;
734 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
736 if (__portraitautohide)
738 return HIT_TEST_NOWHERE;
742 return HIT_TEST_MATCH;
747 if (__landscapeautohide)
749 return HIT_TEST_NOWHERE;
753 return HIT_TEST_MATCH;
760 _Indicator::SetIndicatorOrientation(Tizen::Ui::_ControlOrientation orientation)
762 __orientation = orientation;
766 _Indicator::SetWindow(_Window* pWindow)
772 _Indicator::ShowIndicatorEffect(bool down, int duration)
774 Ecore_X_Window win = 0;
777 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
780 VisualElementPropertyAnimation* pSlideAnimation = new (std::nothrow) VisualElementPropertyAnimation();
781 SysTryReturnResult(NID_UI_CTRL, pSlideAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
783 pSlideAnimation->SetDuration(duration);
784 pSlideAnimation->SetPropertyName( L"bounds.position");
785 pSlideAnimation->SetVisualElementAnimationStatusEventListener(this);
787 float indicatorHeight = 0.0f;
788 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __orientation, indicatorHeight);
790 String* pUserData = null;
793 Color bgColor(0xff1e1e1e);
794 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
796 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
798 if (__pPortraitVisualElement)
800 __pPortraitVisualElement->SetShowState(true);
805 if (__pLandscapeVisualElement)
807 __pLandscapeVisualElement->SetShowState(true);
811 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
812 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, 0.0f)));
813 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
814 pUserData = new (std::nothrow) String(L"DownAnimation");
815 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
819 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, 0.0f)));
820 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
821 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
822 pUserData = new (std::nothrow) String(L"UpAnimation");
823 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
825 pSlideAnimation->SetUserData((void*)(pUserData));
826 AddAnimation( L"bounds.position", *pSlideAnimation);
828 delete pSlideAnimation;
834 _Indicator::RemoveIndicatorAnimations(void)
836 if (__pAnimationTimer)
838 __pAnimationTimer->Cancel();
840 RemoveAllAnimations();
844 _Indicator::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
847 if (IsVisible() ==false)
852 int pointId = touchinfo.GetPointId();
853 _TouchManager* pTouchManager = _TouchManager::GetInstance();
855 FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
856 int indicatorHeight = 0;
859 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
865 if (touchPosition.y < indicatorHeight)
873 __startTouchPoint = touchinfo.GetCurrentPosition();
874 __touchPressed = true;
878 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
880 if (__portraitautohide)
891 if (__landscapeautohide)
902 if (pTouchManager->IsListenerOnly(pointId) == true )
913 _Indicator::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
915 if (IsVisible() ==false)
920 _TouchManager* pTouchManager = _TouchManager::GetInstance();
924 if (touchinfo.GetPointId() == __pointId)
926 __touchPressed = false;
929 FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
930 int indicatorHeight = 0;
933 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
939 if (touchPosition.y < indicatorHeight)
947 if (pTouchManager->IsListenerOnly(touchinfo.GetPointId()) == true)
960 _Indicator::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
964 if (IsVisible() ==false)
969 int pointId = touchinfo.GetPointId();
970 _TouchManager* pTouchManager = _TouchManager::GetInstance();
974 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
975 float gap = touchPoint.y - __startTouchPoint.y;
980 GET_SHAPE_CONFIG(FORM::INDICATOR_TOUCH_GAP, __pWindow->GetOrientation(), touchGap);
987 if (gap < touchGap || __animationing)
992 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
994 if (__portraitautohide)
996 ShowIndicatorEffect(true, ANIMATION_DURATION);
1001 if (__landscapeautohide)
1003 ShowIndicatorEffect(true, ANIMATION_DURATION);
1008 if (pTouchManager->IsListenerOnly(pointId) == true)
1025 _Indicator::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1031 _Indicator::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
1033 String* pUserData = (String*) animation.GetUserData();
1035 if ((pUserData != null) && (*pUserData == String(L"DownAnimation")))
1037 if (__pAnimationTimer == null)
1039 __pAnimationTimer = new (std::nothrow) Timer;
1040 if (__pAnimationTimer == null)
1045 result r = __pAnimationTimer->Construct(*this);
1048 delete __pAnimationTimer;
1049 __pAnimationTimer = null;
1055 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1057 if (__portraitautohide)
1059 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1060 __animationing = true;
1065 if (__landscapeautohide)
1067 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1068 __animationing = true;
1075 _Indicator::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
1081 _Indicator::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
1083 String* pUserData = (String*) animation.GetUserData();
1085 if ((pUserData != null) && (*pUserData == String(L"UpAnimation")))
1087 Color bgColor(0x00000000);
1089 int indicatorHeight = 0;
1090 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
1091 SetBounds(FloatRectangle(0.0f, 0.0f, GetIndicatorBoundsF().width, indicatorHeight));
1093 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1095 if (__portraitautohide)
1097 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1098 if (__pPortraitVisualElement && __portraitautohide)
1100 __pPortraitVisualElement->SetShowState(false);
1106 if (__landscapeautohide)
1108 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1109 if (__pLandscapeVisualElement && __landscapeautohide)
1111 __pLandscapeVisualElement->SetShowState(false);
1120 _Indicator::Activate(void)
1122 _UiEventManager::GetInstance()->AddTouchEventListener(*this);
1128 _Indicator::Deactivate(void)
1130 _UiEventManager::GetInstance()->RemoveTouchEventListener(*this);
1132 if (__pAnimationTimer)
1134 __pAnimationTimer->Cancel();
1136 RemoveAllAnimations();
1138 Ecore_X_Window win = 0;
1141 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
1144 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1146 if (__portraitautohide)
1148 Color bgColor(0x00000000);
1149 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1151 if (__pPortraitVisualElement)
1153 __pPortraitVisualElement->SetShowState(false);
1154 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1156 __animationing = false;
1161 if (__landscapeautohide)
1163 Color bgColor(0x00000000);
1164 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1166 if (__pLandscapeVisualElement)
1168 __pLandscapeVisualElement->SetShowState(false);
1169 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1171 __animationing = false;
1178 }}} // Tizen::Ui::Controls