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 Ecore_Evas *pPortraitEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject);
433 Ecore_Evas *pLandscapeEe = ecore_evas_object_ecore_evas_get(__pLandscapeIndicatorEvasObject);
437 ecore_evas_callback_delete_request_set(pPortraitEe, null);
438 ecore_evas_callback_msg_handle_set(pPortraitEe, null);
443 ecore_evas_callback_delete_request_set(pLandscapeEe, null);
444 ecore_evas_callback_msg_handle_set(pLandscapeEe, null);
447 __pPortraitIndicatorEvasObject = null;
448 __pLandscapeIndicatorEvasObject = null;
449 __pPortraitVisualElement = null;
450 __pLandscapeVisualElement = null;
451 __pCurrentVisualElement = null;
457 _Indicator::ChangeCurrentVisualElement(Tizen::Ui::Animations::_VisualElement* pVisualElement)
459 result r = E_SUCCESS;
461 if (!(__pCurrentVisualElement == pVisualElement))
463 r = AttachChild(*pVisualElement);
464 if (__pCurrentVisualElement)
466 r = DetachChild(*__pCurrentVisualElement);
468 __pCurrentVisualElement = pVisualElement;
475 _Indicator::OnChangeLayout(_ControlOrientation orientation)
477 RemoveIndicatorAnimations();
478 if (__pAnimationTimer != null)
480 __pAnimationTimer->Cancel();
481 __animationing = false;
484 Ecore_X_Window win = 0;
487 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
490 __orientation = orientation;
492 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
494 ChangeCurrentVisualElement(__pPortraitVisualElement);
495 SetClipChildrenEnabled(true);
497 if (__portraitautohide)
499 Color bgColor(0x00000000);
500 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
501 if (__pPortraitVisualElement)
503 __pPortraitVisualElement->SetShowState(false);
505 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
506 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
510 SetIndicatorOpacity(__opacity);
511 if (__pPortraitVisualElement)
513 __pPortraitVisualElement->SetShowState(true);
515 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
516 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
522 ChangeCurrentVisualElement(__pLandscapeVisualElement);
523 SetClipChildrenEnabled(false);
525 if (__landscapeautohide)
527 Color bgColor(0x00000000);
528 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
529 if (__pLandscapeVisualElement)
531 __pLandscapeVisualElement->SetShowState(false);
533 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
534 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
538 SetIndicatorOpacity(__opacity);
539 if (__pLandscapeVisualElement)
541 __pLandscapeVisualElement->SetShowState(true);
543 ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
544 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
550 _Indicator::OnAttachedToMainTree(void)
552 result r = E_SUCCESS;
554 if (__pCurrentVisualElement)
556 r = ChangeCurrentVisualElement(__pCurrentVisualElement);
563 _Indicator::OnTimerExpired(Timer& timer)
565 if (__pConnectionTimer == &timer)
567 Eina_Bool result = EINA_TRUE;
569 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
570 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
572 result = ecore_evas_extn_plug_connect(__pPortraitIndicatorEvasObject, pPortraitSvcName, 0, EINA_FALSE);
576 result = ecore_evas_extn_plug_connect(__pLandscapeIndicatorEvasObject, pLandScapeSvcName, 0, EINA_FALSE);
579 if (result == EINA_TRUE)
585 timer.Start(CONNECTION_INTERVAL);
588 else if(__pAnimationTimer == &timer)
590 ShowIndicatorEffect(false, ANIMATION_DURATION);
593 __animationing = false;
598 _Indicator::OnDisconnected(Ecore_Evas *pEe)
600 _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
601 SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
603 if (pIndicator->__pConnectionTimer == null)
605 pIndicator->__pConnectionTimer = new (std::nothrow) Timer;
606 if (pIndicator->__pConnectionTimer == null)
611 result r = pIndicator->__pConnectionTimer->Construct(*pIndicator);
614 delete pIndicator->__pConnectionTimer;
615 pIndicator->__pConnectionTimer = null;
621 pIndicator->__pConnectionTimer->Start(CONNECTION_INTERVAL);
625 _Indicator::SetNotificationTrayOpenEnabled(bool enable)
627 Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
629 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
632 int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
645 ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
652 _Indicator::IsNotificationTrayOpenEnabled(void) const
654 Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
656 Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
659 int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
676 _Indicator::OnMessageHandle(Ecore_Evas *pEe, int msgDomain, int msgId, void *data, int size)
683 _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
684 SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
686 Evas_Object* pPortraitIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pPortPublicKey);
687 Evas_Object* pLandscapeIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pLandPublicKey);
689 if (msgDomain == MSG_DOMAIN_CONTROL_INDICATOR)
691 if (msgId == MSG_ID_INDICATOR_REPEAT_EVENT)
693 int *repeat = (int*)data;
696 if (pPortraitIndicatorEvasObject)
698 evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_TRUE);
700 if (pLandscapeIndicatorEvasObject)
702 evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_TRUE);
707 if (pPortraitIndicatorEvasObject)
709 evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_FALSE);
711 if (pLandscapeIndicatorEvasObject)
713 evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_FALSE);
717 else if (msgId == MSG_ID_INDICATOR_START_ANIMATION)
719 _IndicatorDataAnimation* pData = (_IndicatorDataAnimation*)data;
720 Ecore_X_Window win = 0;
721 _Window* pWindow = pIndicator->__pWindow;
724 win = (Ecore_X_Window)pWindow->GetNativeHandle();
727 if (pData->xwin == win)
729 pIndicator->ShowIndicatorEffect(true, pData->duration);
737 _Indicator::OnHitTest(const Tizen::Graphics::FloatPoint& point)
741 return HIT_TEST_NOWHERE;
744 if (!GetBounds().Contains(point))
746 return HIT_TEST_NOWHERE;
749 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
751 if (__portraitautohide)
753 return HIT_TEST_NOWHERE;
757 return HIT_TEST_MATCH;
762 if (__landscapeautohide)
764 return HIT_TEST_NOWHERE;
768 return HIT_TEST_MATCH;
775 _Indicator::SetIndicatorOrientation(Tizen::Ui::_ControlOrientation orientation)
777 __orientation = orientation;
781 _Indicator::SetWindow(_Window* pWindow)
787 _Indicator::ShowIndicatorEffect(bool down, int duration)
789 Ecore_X_Window win = 0;
792 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
795 VisualElementPropertyAnimation* pSlideAnimation = new (std::nothrow) VisualElementPropertyAnimation();
796 SysTryReturnResult(NID_UI_CTRL, pSlideAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
798 pSlideAnimation->SetDuration(duration);
799 pSlideAnimation->SetPropertyName( L"bounds.position");
800 pSlideAnimation->SetVisualElementAnimationStatusEventListener(this);
802 float indicatorHeight = 0.0f;
803 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __orientation, indicatorHeight);
805 String* pUserData = null;
808 Color bgColor(0xff1e1e1e);
809 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
811 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
813 if (__pPortraitVisualElement)
815 __pPortraitVisualElement->SetShowState(true);
820 if (__pLandscapeVisualElement)
822 __pLandscapeVisualElement->SetShowState(true);
826 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
827 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, 0.0f)));
828 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
829 pUserData = new (std::nothrow) String(L"DownAnimation");
830 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
834 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, 0.0f)));
835 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
836 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
837 pUserData = new (std::nothrow) String(L"UpAnimation");
838 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
840 pSlideAnimation->SetUserData((void*)(pUserData));
841 AddAnimation( L"bounds.position", *pSlideAnimation);
843 delete pSlideAnimation;
849 _Indicator::RemoveIndicatorAnimations(void)
851 if (__pAnimationTimer)
853 __pAnimationTimer->Cancel();
855 RemoveAllAnimations();
859 _Indicator::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
862 if (IsVisible() ==false)
867 int pointId = touchinfo.GetPointId();
868 _TouchManager* pTouchManager = _TouchManager::GetInstance();
870 FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
871 int indicatorHeight = 0;
874 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
880 if (touchPosition.y < indicatorHeight)
888 __startTouchPoint = touchinfo.GetCurrentPosition();
889 __touchPressed = true;
893 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
895 if (__portraitautohide)
906 if (__landscapeautohide)
917 if (pTouchManager->IsListenerOnly(pointId) == true )
928 _Indicator::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
930 if (IsVisible() ==false)
935 _TouchManager* pTouchManager = _TouchManager::GetInstance();
939 if (touchinfo.GetPointId() == __pointId)
941 __touchPressed = false;
944 FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
945 int indicatorHeight = 0;
948 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
954 if (touchPosition.y < indicatorHeight)
962 if (pTouchManager->IsListenerOnly(touchinfo.GetPointId()) == true)
975 _Indicator::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
979 if (IsVisible() ==false)
984 int pointId = touchinfo.GetPointId();
985 _TouchManager* pTouchManager = _TouchManager::GetInstance();
989 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
990 float gap = touchPoint.y - __startTouchPoint.y;
995 GET_SHAPE_CONFIG(FORM::INDICATOR_TOUCH_GAP, __pWindow->GetOrientation(), touchGap);
1002 if (gap < touchGap || __animationing)
1007 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1009 if (__portraitautohide)
1011 ShowIndicatorEffect(true, ANIMATION_DURATION);
1016 if (__landscapeautohide)
1018 ShowIndicatorEffect(true, ANIMATION_DURATION);
1023 if (pTouchManager->IsListenerOnly(pointId) == true)
1040 _Indicator::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1046 _Indicator::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
1048 String* pUserData = (String*) animation.GetUserData();
1050 if ((pUserData != null) && (*pUserData == String(L"DownAnimation")))
1052 if (__pAnimationTimer == null)
1054 __pAnimationTimer = new (std::nothrow) Timer;
1055 if (__pAnimationTimer == null)
1060 result r = __pAnimationTimer->Construct(*this);
1063 delete __pAnimationTimer;
1064 __pAnimationTimer = null;
1070 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1072 if (__portraitautohide)
1074 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1075 __animationing = true;
1080 if (__landscapeautohide)
1082 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1083 __animationing = true;
1090 _Indicator::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
1096 _Indicator::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
1098 String* pUserData = (String*) animation.GetUserData();
1100 if ((pUserData != null) && (*pUserData == String(L"UpAnimation")))
1102 Color bgColor(0x00000000);
1104 int indicatorHeight = 0;
1105 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
1106 SetBounds(FloatRectangle(0.0f, 0.0f, GetIndicatorBoundsF().width, indicatorHeight));
1108 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1110 if (__portraitautohide)
1112 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1113 if (__pPortraitVisualElement && __portraitautohide)
1115 __pPortraitVisualElement->SetShowState(false);
1121 if (__landscapeautohide)
1123 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1124 if (__pLandscapeVisualElement && __landscapeautohide)
1126 __pLandscapeVisualElement->SetShowState(false);
1135 _Indicator::Activate(void)
1137 _UiEventManager::GetInstance()->AddTouchEventListener(*this);
1143 _Indicator::Deactivate(void)
1145 _UiEventManager::GetInstance()->RemoveTouchEventListener(*this);
1147 if (__pAnimationTimer)
1149 __pAnimationTimer->Cancel();
1151 RemoveAllAnimations();
1153 Ecore_X_Window win = 0;
1156 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
1159 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1161 if (__portraitautohide)
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 (__pPortraitVisualElement)
1168 __pPortraitVisualElement->SetShowState(false);
1169 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1171 __animationing = false;
1176 if (__landscapeautohide)
1178 Color bgColor(0x00000000);
1179 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1181 if (__pLandscapeVisualElement)
1183 __pLandscapeVisualElement->SetShowState(false);
1184 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1186 __animationing = false;
1193 }}} // Tizen::Ui::Controls