Merge "Adding DropShadow effect for popup, message box, progress popup title." into...
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Indicator.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17 /**
18  * @file                FUiCtrl_Indicator.cpp
19  * @brief               This is the implementation file for the _Form class.
20  */
21
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"
41
42 using namespace Tizen::Base::Runtime;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Animations;
46
47 namespace
48 {
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;
57
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;
64 }
65
66 namespace Tizen { namespace Ui { namespace Controls
67 {
68
69 struct _IndicatorDataAnimation
70 {
71    Ecore_X_Window xwin;
72    double duration;
73 };
74
75 enum
76 {
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 */
80 } _IndicatorType;
81
82 _Indicator*
83 _Indicator::CreateIndicator(void)
84 {
85         result r = E_SUCCESS;
86         Color bgColor(0xff343432);
87
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.");
91
92         r = pIndicator->ConstructControlVisualElement();
93         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
94
95         pIndicator->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
96
97         return pIndicator;
98
99 CATCH:
100         delete pIndicator;
101         return null;
102 }
103
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)
112         , __pWindow(null)
113         , __showstate(false)
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)
121         , __quickpanelOpened(false)
122 {
123 }
124
125 _Indicator::~_Indicator(void)
126 {
127         if (__pConnectionTimer != null)
128         {
129                 __pConnectionTimer->Cancel();
130                 delete __pConnectionTimer;
131                 __pConnectionTimer = null;
132         }
133
134         if (__pAnimationTimer != null)
135         {
136                 __pAnimationTimer->Cancel();
137                 delete __pAnimationTimer;
138                 __pAnimationTimer = null;
139         }
140
141         _UiEventManager::GetInstance()->RemoveTouchEventListener(*this);
142 }
143
144 result
145 _Indicator::SetIndicatorShowState(bool state)
146 {
147         result r = E_SUCCESS;
148
149         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
150         SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
151
152         Ecore_X_Window win = 0;
153
154         if (__pWindow)
155         {
156                 r = pEcoreEvas->SetIndicatorShowState(*__pWindow, state);
157                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
158                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
159         }
160
161         __showstate = state;
162
163         SetShowState(state);
164
165         if (state)
166         {
167                 SetIndicatorOpacity(__opacity);
168         }
169
170         return r;
171 }
172
173 void
174 _Indicator::SetIndicatorAutoHide(bool portrait, bool landscape)
175 {
176         Ecore_X_Window win = 0;
177         if (__pWindow)
178         {
179                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
180         }
181
182         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
183         {
184                 if (portrait)
185                 {
186                         Color bgColor(0x00000000);
187                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
188                         if (__pPortraitVisualElement)
189                         {
190                                 __pPortraitVisualElement->SetShowState(false);
191                         }
192                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
193                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
194                 }
195                 else
196                 {
197                         SetIndicatorOpacity(__opacity);
198                         if (__pPortraitVisualElement)
199                         {
200                                 __pPortraitVisualElement->SetShowState(true);
201                         }
202                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
203                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
204                 }
205         }
206         else
207         {
208                 if (landscape)
209                 {
210                         Color bgColor(0x00000000);
211                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
212                         if (__pLandscapeVisualElement)
213                         {
214                                 __pLandscapeVisualElement->SetShowState(false);
215                         }
216                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
217                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
218                 }
219                 else
220                 {
221                         SetIndicatorOpacity(__opacity);
222                         if (__pLandscapeVisualElement)
223                         {
224                                 __pLandscapeVisualElement->SetShowState(true);
225                         }
226                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
227                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
228                 }
229         }
230         __portraitautohide = portrait;
231         __landscapeautohide = landscape;
232
233 }
234
235 result
236 _Indicator::SetIndicatorOpacity(_IndicatorOpacity opacity)
237 {
238         result r = E_SUCCESS;
239
240         if (opacity == _INDICATOR_OPACITY_OPAQUE)
241         {
242                 Color bgColor(0xff1e1e1e);
243                 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
244         }
245         else if (opacity == _INDICATOR_OPACITY_TRANSLUCENT)
246         {
247                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
248                 {
249                         Color bgColor(0x7f000000);
250                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
251                 }
252                 else
253                 {
254                         Color bgColor(0x00000000);
255                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
256                 }
257         }
258
259         __opacity = opacity;
260
261         return r;
262 }
263
264 bool
265 _Indicator::GetIndicatorShowState(void) const
266 {
267         return __showstate;
268 }
269
270 _IndicatorOpacity
271 _Indicator::GetIndicatorOpacity(void) const
272 {
273         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
274         {
275                 if (__portraitautohide)
276                 {
277                         return _INDICATOR_OPACITY_TRANSPARENT;
278                 }
279         }
280         else
281         {
282                 if (__landscapeautohide)
283                 {
284                         return _INDICATOR_OPACITY_TRANSPARENT;
285                 }
286         }
287
288         return __opacity;
289 }
290
291 bool
292 _Indicator::GetIndicatorAutoHide(void) const
293 {
294         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
295         {
296                 return __portraitautohide;
297         }
298         else
299         {
300                 return __landscapeautohide;
301         }
302
303 }
304
305 Rectangle
306 _Indicator::GetIndicatorBounds(void) const
307 {
308         const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize();
309         const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width);
310
311         Rectangle indicatorbounds(0, 0, 0, 0);
312
313         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
314         {
315                 indicatorbounds.width = portraitSize.width;
316         }
317         else
318         {
319                 indicatorbounds.width = landscapeSize.width;
320         }
321         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
322
323         _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
324         SysTryReturn(NID_UI_CTRL, pCoordSystem, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
325
326         _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
327         SysTryReturn(NID_UI_CTRL, pXformer, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
328
329         indicatorbounds = pXformer->Transform(indicatorbounds);
330
331         return indicatorbounds;
332 }
333
334 FloatRectangle
335 _Indicator::GetIndicatorBoundsF(void) const
336 {
337         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
338         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
339
340         FloatRectangle indicatorbounds(0.0f, 0.0f, 0.0f, 0.0f);
341
342         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
343         {
344                 indicatorbounds.width = portraitSize.width;
345         }
346         else
347         {
348                 indicatorbounds.width = landscapeSize.width;
349         }
350
351         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
352
353         _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
354         SysTryReturn(NID_UI_CTRL, pCoordSystem, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
355
356         _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
357         SysTryReturn(NID_UI_CTRL, pXformer, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
358
359         indicatorbounds = pXformer->Transform(indicatorbounds);
360
361         return indicatorbounds;
362 }
363
364 result
365 _Indicator::AddIndicatorObject(_Control* pControl, _Window* pWindow)
366 {
367         result r = E_SUCCESS;
368
369         __pWindow = pWindow;
370
371         __pPortraitVisualElement =      _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_PORTRAIT, pControl);
372         SysTryReturn(NID_UI_CTRL, __pPortraitVisualElement, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
373         __pLandscapeVisualElement = _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, pControl);
374         SysTryReturn(NID_UI_CTRL, __pLandscapeVisualElement, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
375         __pPortraitIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_PORTRAIT);
376         SysTryReturn(NID_UI_CTRL, __pPortraitIndicatorEvasObject, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
377         __pLandscapeIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_LANDSCAPE);
378         SysTryReturn(NID_UI_CTRL, __pLandscapeIndicatorEvasObject, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
379
380         _ControlOrientation orientation = pControl->GetOrientation();
381         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
382         {
383                 r = ChangeCurrentVisualElement(__pPortraitVisualElement);
384         }
385         else
386         {
387                 r = ChangeCurrentVisualElement(__pLandscapeVisualElement);
388         }
389
390         Ecore_Evas *pPortraitEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject);
391         SysTryReturn(NID_UI_CTRL, pPortraitEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
392         Ecore_Evas *pLandscapeEe = ecore_evas_object_ecore_evas_get(__pLandscapeIndicatorEvasObject);
393         SysTryReturn(NID_UI_CTRL, pLandscapeEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
394
395         ecore_evas_data_set(pPortraitEe, pPortPublicKey, __pPortraitIndicatorEvasObject);
396         ecore_evas_data_set(pLandscapeEe, pLandPublicKey, __pLandscapeIndicatorEvasObject);
397         ecore_evas_data_set(pPortraitEe, pIndicatorKey, this);
398         ecore_evas_data_set(pLandscapeEe, pIndicatorKey, this);
399         ecore_evas_callback_delete_request_set(pPortraitEe, _Indicator::OnDisconnected);
400         ecore_evas_callback_delete_request_set(pLandscapeEe, _Indicator::OnDisconnected);
401
402         ecore_evas_callback_msg_handle_set(pPortraitEe, _Indicator::OnMessageHandle);
403         ecore_evas_callback_msg_handle_set(pLandscapeEe, _Indicator::OnMessageHandle);
404
405         Activate();
406
407         return r;
408 }
409
410 result
411 _Indicator::DeleteIndicatorObject(void)
412 {
413         result r = E_SUCCESS;
414
415         r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_PORTRAIT, __pPortraitVisualElement);
416         r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, __pLandscapeVisualElement);
417
418         if (__pPortraitVisualElement)
419         {
420                 if (__pPortraitVisualElement == __pCurrentVisualElement)
421                 {
422                         r = DetachChild(*__pPortraitVisualElement);
423                 }
424         }
425         if (__pLandscapeVisualElement)
426         {
427                 if (__pLandscapeVisualElement == __pCurrentVisualElement)
428                 {
429                         r = DetachChild(*__pLandscapeVisualElement);
430                 }
431         }
432
433         Ecore_Evas *pPortraitEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject);
434         Ecore_Evas *pLandscapeEe = ecore_evas_object_ecore_evas_get(__pLandscapeIndicatorEvasObject);
435
436         if (pPortraitEe)
437         {
438                 ecore_evas_callback_delete_request_set(pPortraitEe, null);
439                 ecore_evas_callback_msg_handle_set(pPortraitEe, null);
440         }
441
442         if (pLandscapeEe)
443         {
444                 ecore_evas_callback_delete_request_set(pLandscapeEe, null);
445                 ecore_evas_callback_msg_handle_set(pLandscapeEe, null);
446         }
447
448         __pPortraitIndicatorEvasObject = null;
449         __pLandscapeIndicatorEvasObject = null;
450         __pPortraitVisualElement = null;
451         __pLandscapeVisualElement = null;
452         __pCurrentVisualElement = null;
453
454         return r;
455 }
456
457 result
458 _Indicator::ChangeCurrentVisualElement(Tizen::Ui::Animations::_VisualElement* pVisualElement)
459 {
460         result r = E_SUCCESS;
461
462         if (!(__pCurrentVisualElement == pVisualElement))
463         {
464                 r = AttachChild(*pVisualElement);
465                 if (__pCurrentVisualElement)
466                 {
467                         r = DetachChild(*__pCurrentVisualElement);
468                 }
469                 __pCurrentVisualElement = pVisualElement;
470         }
471
472         return r;
473 }
474
475 void
476 _Indicator::OnChangeLayout(_ControlOrientation orientation)
477 {
478         RemoveIndicatorAnimations();
479         if (__pAnimationTimer != null)
480         {
481                 __pAnimationTimer->Cancel();
482                 __animationing = false;
483         }
484
485         Ecore_X_Window win = 0;
486         if (__pWindow)
487         {
488                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
489         }
490
491         __orientation = orientation;
492
493         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
494         {
495                 ChangeCurrentVisualElement(__pPortraitVisualElement);
496                 SetClipChildrenEnabled(true);
497
498                 if (__portraitautohide)
499                 {
500                         Color bgColor(0x00000000);
501                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
502                         if (__pPortraitVisualElement)
503                         {
504                                 __pPortraitVisualElement->SetShowState(false);
505                         }
506                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
507                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
508                 }
509                 else
510                 {
511                         SetIndicatorOpacity(__opacity);
512                         if (__pPortraitVisualElement)
513                         {
514                                 __pPortraitVisualElement->SetShowState(true);
515                         }
516                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
517                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
518                 }
519
520         }
521         else
522         {
523                 ChangeCurrentVisualElement(__pLandscapeVisualElement);
524                 SetClipChildrenEnabled(false);
525
526                 if (__landscapeautohide)
527                 {
528                         Color bgColor(0x00000000);
529                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
530                         if (__pLandscapeVisualElement)
531                         {
532                                 __pLandscapeVisualElement->SetShowState(false);
533                         }
534                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
535                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
536                 }
537                 else
538                 {
539                         SetIndicatorOpacity(__opacity);
540                         if (__pLandscapeVisualElement)
541                         {
542                                 __pLandscapeVisualElement->SetShowState(true);
543                         }
544                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
545                         ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
546                 }
547         }
548 }
549
550 result
551 _Indicator::OnAttachedToMainTree(void)
552 {
553         result r = E_SUCCESS;
554
555         if (__pCurrentVisualElement)
556         {
557                 r = ChangeCurrentVisualElement(__pCurrentVisualElement);
558         }
559
560         return r;
561 }
562
563 void
564 _Indicator::OnTimerExpired(Timer& timer)
565 {
566         if (__pConnectionTimer == &timer)
567         {
568                 Eina_Bool result = EINA_TRUE;
569
570                 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
571                 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
572                 {
573                         result = ecore_evas_extn_plug_connect(__pPortraitIndicatorEvasObject, pPortraitSvcName, 0, EINA_FALSE);
574                 }
575                 else
576                 {
577                         result = ecore_evas_extn_plug_connect(__pLandscapeIndicatorEvasObject, pLandScapeSvcName, 0, EINA_FALSE);
578                 }
579
580                 if (result == EINA_TRUE)
581                 {
582                         timer.Cancel();
583                 }
584                 else
585                 {
586                         timer.Start(CONNECTION_INTERVAL);
587                 }
588         }
589         else if(__pAnimationTimer == &timer)
590         {
591                 ShowIndicatorEffect(false, ANIMATION_DURATION);
592
593                 timer.Cancel();
594                 __animationing = false;
595         }
596 }
597
598 void
599 _Indicator::OnDisconnected(Ecore_Evas *pEe)
600 {
601         _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
602         SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
603
604         if (pIndicator->__pConnectionTimer == null)
605         {
606                 pIndicator->__pConnectionTimer = new (std::nothrow) Timer;
607                 if (pIndicator->__pConnectionTimer == null)
608                 {
609                         return;
610                 }
611
612                 result r = pIndicator->__pConnectionTimer->Construct(*pIndicator);
613                 if (r != E_SUCCESS)
614                 {
615                         delete pIndicator->__pConnectionTimer;
616                         pIndicator->__pConnectionTimer = null;
617
618                         return;
619                 }
620         }
621
622         pIndicator->__pConnectionTimer->Start(CONNECTION_INTERVAL);
623 }
624
625 result
626 _Indicator::SetNotificationTrayOpenEnabled(bool enable)
627 {
628         Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
629
630         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
631
632         unsigned int val[3];
633         int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
634
635         if (returnResult)
636         {
637                 if (enable)
638                 {
639                         val[1] = 1;
640                 }
641                 else
642                 {
643                         val[1] = 0;
644                 }
645
646                 ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
647         }
648
649         return E_SUCCESS;
650 }
651
652 bool
653 _Indicator::IsNotificationTrayOpenEnabled(void) const
654 {
655         Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
656
657         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
658
659         unsigned int val[3];
660         int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
661
662         if (returnResult)
663         {
664                 if (val[1] == 1)
665                 {
666                         return true;
667                 }
668                 else
669                 {
670                         return false;
671                 }
672         }
673         return false;
674 }
675
676 void
677 _Indicator::OnMessageHandle(Ecore_Evas *pEe, int msgDomain, int msgId, void *data, int size)
678 {
679         if (!data)
680         {
681                 return;
682         }
683
684         _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
685         SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
686
687         Evas_Object* pPortraitIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pPortPublicKey);
688         Evas_Object* pLandscapeIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pLandPublicKey);
689
690         if (msgDomain == MSG_DOMAIN_CONTROL_INDICATOR)
691         {
692                 if (msgId == MSG_ID_INDICATOR_REPEAT_EVENT)
693                 {
694                         int *repeat = (int*)data;
695                         if (1 == *repeat)
696                         {
697                                 if (pPortraitIndicatorEvasObject)
698                            {
699                                         evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_TRUE);
700                            }
701                                 if (pLandscapeIndicatorEvasObject)
702                                 {
703                            evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_TRUE);
704                                 }
705                         }
706                         else
707                         {
708                                 if (pPortraitIndicatorEvasObject)
709                            {
710                            evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_FALSE);
711                            }
712                                 if (pLandscapeIndicatorEvasObject)
713                                 {
714                            evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_FALSE);
715                                 }
716                         }
717                 }
718                 else if (msgId == MSG_ID_INDICATOR_START_ANIMATION)
719                 {
720                         _IndicatorDataAnimation* pData = (_IndicatorDataAnimation*)data;
721                         Ecore_X_Window win = 0;
722                         _Window* pWindow = pIndicator->__pWindow;
723                         if (pWindow)
724                         {
725                                         win = (Ecore_X_Window)pWindow->GetNativeHandle();
726                         }
727
728                         if (pData->xwin == win)
729                         {
730                                 pIndicator->ShowIndicatorEffect(true, pData->duration);
731                         }
732                 }
733
734         }
735 }
736
737 HitTestResult
738 _Indicator::OnHitTest(const Tizen::Graphics::FloatPoint& point)
739 {
740         if (!IsVisible())
741         {
742                 return HIT_TEST_NOWHERE;
743         }
744
745         if (!GetBounds().Contains(point))
746         {
747                 return HIT_TEST_NOWHERE;
748         }
749
750         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
751         {
752                 if (__portraitautohide)
753                 {
754                         return HIT_TEST_NOWHERE;
755                 }
756                 else
757                 {
758                         return HIT_TEST_MATCH;
759                 }
760         }
761         else
762         {
763                 if (__landscapeautohide)
764                 {
765                         return HIT_TEST_NOWHERE;
766                 }
767                 else
768                 {
769                         return HIT_TEST_MATCH;
770                 }
771         }
772
773 }
774
775 void
776 _Indicator::SetIndicatorOrientation(Tizen::Ui::_ControlOrientation orientation)
777 {
778         __orientation = orientation;
779 }
780
781 void
782 _Indicator::SetWindow(_Window* pWindow)
783 {
784         __pWindow = pWindow;
785 }
786
787 result
788 _Indicator::ShowIndicatorEffect(bool down, int duration)
789 {
790         Ecore_X_Window win = 0;
791         if (__pWindow)
792         {
793                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
794         }
795
796         VisualElementPropertyAnimation* pSlideAnimation = new (std::nothrow) VisualElementPropertyAnimation();
797         SysTryReturnResult(NID_UI_CTRL, pSlideAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
798
799         pSlideAnimation->SetDuration(duration);
800         pSlideAnimation->SetPropertyName( L"bounds.position");
801         pSlideAnimation->SetVisualElementAnimationStatusEventListener(this);
802
803         float indicatorHeight = 0.0f;
804         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __orientation, indicatorHeight);
805
806         String* pUserData = null;
807         if (down)
808         {
809                 Color bgColor(0xff1e1e1e);
810                 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
811
812                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
813                 {
814                         if (__pPortraitVisualElement)
815                         {
816                                 __pPortraitVisualElement->SetShowState(true);
817                         }
818                 }
819                 else
820                 {
821                         if (__pLandscapeVisualElement)
822                         {
823                                 __pLandscapeVisualElement->SetShowState(true);
824                         }
825                 }
826
827                 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
828                 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, 0.0f)));
829                 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_1);
830                 pUserData = new (std::nothrow) String(L"DownAnimation");
831                 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
832         }
833         else
834         {
835                 pSlideAnimation->SetStartValue(Variant(FloatPoint(0.0f, 0.0f)));
836                 pSlideAnimation->SetEndValue(Variant(FloatPoint(0.0f, -indicatorHeight)));
837                 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
838                 pUserData = new (std::nothrow) String(L"UpAnimation");
839                 SysTryReturnResult(NID_UI_CTRL, pUserData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
840         }
841         pSlideAnimation->SetUserData((void*)(pUserData));
842         AddAnimation( L"bounds.position", *pSlideAnimation);
843
844         delete pSlideAnimation;
845
846         return E_SUCCESS;
847 }
848
849 void
850 _Indicator::RemoveIndicatorAnimations(void)
851 {
852         if (__pAnimationTimer)
853         {
854                 __pAnimationTimer->Cancel();
855         }
856         RemoveAllAnimations();
857 }
858
859 bool
860 _Indicator::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
861 {
862         bool r = false;
863         if (IsVisible() ==false)
864         {
865                 return false;
866         }
867
868         int pointId = touchinfo.GetPointId();
869         _TouchManager* pTouchManager = _TouchManager::GetInstance();
870
871         FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
872         int indicatorHeight = 0;
873         if (__pWindow)
874         {
875                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
876         }
877         else
878         {
879                 return false;
880         }
881         if (touchPosition.y < indicatorHeight)
882         {
883                 if (__animationing)
884                 {
885                         return true;
886                 }
887                 else
888                 {
889                         __startTouchPoint = touchinfo.GetCurrentPosition();
890                         __touchPressed = true;
891                         __pointId = pointId;
892                 }
893
894                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
895                 {
896                         if (__portraitautohide)
897                         {
898                                 return false;
899                         }
900                         else
901                         {
902                                 return true;
903                         }
904                 }
905                 else
906                 {
907                         if (__landscapeautohide)
908                         {
909                                 return false;
910                         }
911                         else
912                         {
913                                 return true;
914                         }
915                 }
916         }
917
918         if (pTouchManager->IsListenerOnly(pointId) == true )
919         {
920                 return true;
921         }
922         else
923         {
924                 return false;
925         }
926 }
927
928 bool
929 _Indicator::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
930 {
931         if (IsVisible() ==false)
932         {
933                 return false;
934         }
935
936         _TouchManager* pTouchManager = _TouchManager::GetInstance();
937
938         if (__touchPressed)
939         {
940                 if (touchinfo.GetPointId() == __pointId)
941                 {
942                         __touchPressed = false;
943                 }
944
945                 FloatPoint touchPosition = source.ConvertToScreenPosition(touchinfo.GetCurrentPosition());
946                 int indicatorHeight = 0;
947                 if (__pWindow)
948                 {
949                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
950                 }
951                 else
952                 {
953                         return false;
954                 }
955                 if (touchPosition.y < indicatorHeight)
956                 {
957                         if (__animationing)
958                         {
959                                 return true;
960                         }
961                 }
962
963                 if (pTouchManager->IsListenerOnly(touchinfo.GetPointId()) == true)
964                 {
965                         return true;
966                 }
967                 else
968                 {
969                         return false;
970                 }
971         }
972         else if (__quickpanelOpened == true)
973         {
974                 OnChangeLayout(__orientation);
975                 __quickpanelOpened = false;
976         }
977         return false;
978 }
979
980 bool
981 _Indicator::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
982 {
983         bool r = false;
984
985         if (IsVisible() ==false)
986         {
987                 return false;
988         }
989
990         int pointId = touchinfo.GetPointId();
991         _TouchManager* pTouchManager = _TouchManager::GetInstance();
992
993         if (__touchPressed)
994         {
995                 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
996                 float gap = touchPoint.y - __startTouchPoint.y;
997
998                 int touchGap = 0;
999                 if (__pWindow)
1000                 {
1001                         GET_SHAPE_CONFIG(FORM::INDICATOR_TOUCH_GAP, __pWindow->GetOrientation(), touchGap);
1002                 }
1003                 else
1004                 {
1005                         return false;
1006                 }
1007
1008                 if (gap < touchGap || __animationing)
1009                 {
1010                 }
1011                 else
1012                 {
1013                         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1014                         {
1015                                 if (__portraitautohide)
1016                                 {
1017                                         ShowIndicatorEffect(true, ANIMATION_DURATION);
1018                                 }
1019                         }
1020                         else
1021                         {
1022                                 if (__landscapeautohide)
1023                                 {
1024                                         ShowIndicatorEffect(true, ANIMATION_DURATION);
1025                                 }
1026                         }
1027                 }
1028                 
1029                 if (pTouchManager->IsListenerOnly(pointId) == true)
1030                 {
1031                         r = true;
1032                 }
1033                 else
1034                 {
1035                         r = false;
1036                 }
1037         }
1038         else
1039         {
1040                 if (__pAnimationTimer)
1041                 {
1042                         __pAnimationTimer->Cancel();
1043                 }
1044                 __quickpanelOpened = true;
1045                 __animationing = false;
1046                 r = false;
1047         }
1048         return r;
1049 }
1050
1051 bool
1052 _Indicator::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1053 {
1054         return false;
1055 }
1056
1057 void
1058 _Indicator::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
1059 {
1060         String* pUserData = (String*) animation.GetUserData();
1061
1062         if ((pUserData != null) && (*pUserData == String(L"DownAnimation")))
1063         {
1064                 if (__pAnimationTimer == null)
1065                 {
1066                         __pAnimationTimer = new (std::nothrow) Timer;
1067                         if (__pAnimationTimer == null)
1068                         {
1069                                 return;
1070                         }
1071
1072                         result r = __pAnimationTimer->Construct(*this);
1073                         if (r != E_SUCCESS)
1074                         {
1075                                 delete __pAnimationTimer;
1076                                 __pAnimationTimer = null;
1077
1078                                 return;
1079                         }
1080                 }
1081
1082                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1083                 {
1084                         if (__portraitautohide)
1085                         {
1086                                 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1087                                 __animationing = true;
1088                         }
1089                 }
1090                 else
1091                 {
1092                         if (__landscapeautohide)
1093                         {
1094                                 __pAnimationTimer->Start(ANIMATION_INTERVAL);
1095                                 __animationing = true;
1096                         }
1097                 }
1098         }
1099 }
1100
1101 void
1102 _Indicator::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
1103 {
1104
1105 }
1106
1107 void
1108 _Indicator::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
1109 {
1110         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1111         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1112
1113         String* pUserData = (String*) animation.GetUserData();
1114
1115         if ((pUserData != null) && (*pUserData == String(L"UpAnimation")))
1116         {
1117                 Color bgColor(0x00000000);
1118
1119                 int indicatorHeight = 0;
1120                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorHeight);
1121
1122                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1123                 {
1124                         if (__portraitautohide)
1125                         {
1126                                 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1127                                 if (__pPortraitVisualElement && __portraitautohide)
1128                                 {
1129                                         __pPortraitVisualElement->SetShowState(false);
1130                                 }
1131                         }
1132                         SetBounds(FloatRectangle(0.0f, 0.0f, portraitSize.width, indicatorHeight));
1133                 }
1134                 else
1135                 {
1136                         if (__landscapeautohide)
1137                         {
1138                                 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1139                                 if (__pLandscapeVisualElement && __landscapeautohide)
1140                                 {
1141                                         __pLandscapeVisualElement->SetShowState(false);
1142                                 }
1143                         }
1144                         SetBounds(FloatRectangle(0.0f, 0.0f, landscapeSize.width, indicatorHeight));
1145                 }
1146                 delete pUserData;
1147         }
1148 }
1149
1150 void
1151 _Indicator::Activate(void)
1152 {
1153         _UiEventManager::GetInstance()->AddTouchEventListener(*this);
1154
1155         return;
1156 }
1157
1158 void
1159 _Indicator::Deactivate(void)
1160 {
1161         _UiEventManager::GetInstance()->RemoveTouchEventListener(*this);
1162
1163         if (__pAnimationTimer)
1164         {
1165                 __pAnimationTimer->Cancel();
1166         }
1167         RemoveAllAnimations();
1168
1169         Ecore_X_Window win = 0;
1170         if (__pWindow)
1171         {
1172                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
1173         }
1174
1175         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
1176         {
1177                 if (__portraitautohide)
1178                 {
1179                         Color bgColor(0x00000000);
1180                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1181
1182                         if (__pPortraitVisualElement)
1183                         {
1184                                 __pPortraitVisualElement->SetShowState(false);
1185                                 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1186                         }
1187                         __animationing = false;
1188                 }
1189         }
1190         else
1191         {
1192                 if (__landscapeautohide)
1193                 {
1194                         Color bgColor(0x00000000);
1195                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1196
1197                         if (__pLandscapeVisualElement)
1198                         {
1199                                 __pLandscapeVisualElement->SetShowState(false);
1200                                 ecore_x_e_illume_indicator_type_set(win, ECORE_X_ILLUME_INDICATOR_TYPE_2);
1201                         }
1202                         __animationing = false;
1203                 }
1204         }
1205
1206         return;
1207 }
1208
1209 }}} // Tizen::Ui::Controls