add patch
[framework/osp/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 <FGrp_CoordinateSystem.h>
24 #include <FUiAnim_VisualElementSurfaceImpl.h>
25 #include "FUiAnim_VisualElement.h"
26 #include "FUiAnim_VisualElementImpl.h"
27 #include "FUiAnim_EflNode.h"
28 #include "FUi_EcoreEvasMgr.h"
29 #include "FUi_EcoreEvas.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUi_CoordinateSystemUtils.h"
32 #include "FUi_Window.h"
33 #include "FUiCtrl_Form.h"
34 #include "FUiCtrl_Indicator.h"
35 #include "FUiCtrl_IndicatorManager.h"
36 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
37
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Animations;
42
43 namespace Tizen { namespace Ui { namespace Controls
44 {
45
46 static const char* pPortraitSvcName = "elm_indicator_portrait";
47 static const char* pLandScapeSvcName = "elm_indicator_landscape";
48 static const char* pPortPublicKey = "__Plug_Ecore_Evas_Port";
49 static const char* pLandPublicKey = "__Plug_Ecore_Evas_Land";
50 static const char* pIndicatorKey = "Inidcator_Manager_Object";
51 static const int CONNECTION_INTERVAL = 1000;
52
53 #define MSG_DOMAIN_CONTROL_INDICATOR 0x10001
54 #define MSG_ID_INDICATOR_REPEAT_EVENT 0x10002
55 #define MSG_ID_INDICATOR_ROTATION 0x10003
56 #define MSG_ID_INDICATOR_OPACITY 0X1004
57 #define MSG_ID_INDICATOR_TYPE 0X1005
58
59 typedef enum
60 {
61    _INDICATOR_TYPE_UNKNOWN, /**< Unknown indicator type mode */
62    _INDICATOR_TYPE_1, /**< Type 0 the the indicator */
63    _INDICATOR_TYPE_2, /**< Type 1 the indicator */
64 } _IndicatorTypeMode;
65
66 _Indicator*
67 _Indicator::CreateIndicator(void)
68 {
69         result r = E_SUCCESS;
70         Color bgColor(0xff343432);
71
72         _Indicator* pIndicator = new (std::nothrow) _Indicator;
73         SysTryReturn(NID_UI_CTRL, pIndicator, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
74         SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
75
76         r = pIndicator->ConstructControlVisualElement();
77         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
78
79         pIndicator->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
80
81         return pIndicator;
82
83 CATCH:
84         delete pIndicator;
85         return null;
86 }
87
88 _Indicator::_Indicator(void)
89         : __pPortraitIndicatorEvasObject(null)
90         , __pLandscapeIndicatorEvasObject(null)
91         , __pConnectionTimer(null)
92         , __pPortraitVisualElement(null)
93         , __pLandscapeVisualElement(null)
94         , __pCurrentVisualElement(null)
95         , __pWindow(null)
96         , __showstate(false)
97         , __portraitautohide(false)
98         , __landscapeautohide(false)
99         , __opacity(_INDICATOR_OPACITY_OPAQUE)
100         , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
101 {
102 }
103
104 _Indicator::~_Indicator(void)
105 {
106         if (__pConnectionTimer != null)
107         {
108                 __pConnectionTimer->Cancel();
109                 delete __pConnectionTimer;
110                 __pConnectionTimer = null;
111         }
112 }
113
114 result
115 _Indicator::SetIndicatorShowState(bool state)
116 {
117         result r = E_SUCCESS;
118
119         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
120         SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
121
122         if (__pWindow)
123         {
124                 r = pEcoreEvas->SetIndicatorShowState(*__pWindow, state);
125                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
126         }
127
128         __showstate = state;
129
130         SetShowState(state);
131
132         if (state)
133         {
134                 SetIndicatorOpacity(__opacity);
135         }
136
137         return r;
138 }
139
140 void
141 _Indicator::SetIndicatorAutoHide(bool portrait, bool landscape)
142 {
143         Ecore_X_Window win = 0;
144         if (__pWindow)
145         {
146                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
147         }
148
149         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
150         {
151                 if (portrait)
152                 {
153                         Color bgColor(0x00000000);
154                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
155                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
156                 }
157                 else
158                 {
159                         SetIndicatorOpacity(__opacity);
160                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
161                 }
162         }
163         else
164         {
165                 if (landscape)
166                 {
167                         Color bgColor(0x00000000);
168                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
169                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
170                 }
171                 else
172                 {
173                         SetIndicatorOpacity(__opacity);
174                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
175                 }
176         }
177         __portraitautohide = portrait;
178         __landscapeautohide = landscape;
179
180 }
181
182 result
183 _Indicator::SetIndicatorOpacity(_IndicatorOpacity opacity)
184 {
185         result r = E_SUCCESS;
186
187         if (opacity == _INDICATOR_OPACITY_OPAQUE)
188         {
189                 Color bgColor(0xff1e1e1e);
190                 SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
191         }
192         else if (opacity == _INDICATOR_OPACITY_TRANSLUCENT)
193         {
194                 if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
195                 {
196                         Color bgColor(0x7f000000);
197                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
198                 }
199                 else
200                 {
201                         Color bgColor(0x00000000);
202                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
203                 }
204         }
205
206         __opacity = opacity;
207
208         return r;
209 }
210
211 bool
212 _Indicator::GetIndicatorShowState(void) const
213 {
214         return __showstate;
215 }
216
217 _IndicatorOpacity
218 _Indicator::GetIndicatorOpacity(void) const
219 {
220         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
221         {
222                 if (__portraitautohide)
223                 {
224                         return _INDICATOR_OPACITY_TRANSPARENT;
225                 }
226         }
227         else
228         {
229                 if (__landscapeautohide)
230                 {
231                         return _INDICATOR_OPACITY_TRANSPARENT;
232                 }
233         }
234
235         return __opacity;
236 }
237
238 bool
239 _Indicator::GetIndicatorAutoHide(void) const
240 {
241         if (__orientation == _CONTROL_ORIENTATION_PORTRAIT)
242         {
243                 return __portraitautohide;
244         }
245         else
246         {
247                 return __landscapeautohide;
248         }
249
250 }
251
252 Rectangle
253 _Indicator::GetIndicatorBounds(void) const
254 {
255         const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize();
256         const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width);
257
258         _ControlOrientation orientation = __pWindow->GetOrientation();
259
260         Rectangle indicatorbounds(0, 0, 0, 0);
261
262         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
263         {
264                 indicatorbounds.width = portraitSize.width;
265                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
266         }
267         else
268         {
269                 indicatorbounds.width = landscapeSize.width;
270                 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
271         }
272
273         _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
274         SysTryReturn(NID_UI_CTRL, pCoordSystem, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
275
276         _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
277         SysTryReturn(NID_UI_CTRL, pXformer, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
278
279         indicatorbounds = pXformer->Transform(indicatorbounds);
280
281         return indicatorbounds;
282 }
283
284 FloatRectangle
285 _Indicator::GetIndicatorBoundsF(void) const
286 {
287         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
288         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
289
290         _ControlOrientation orientation = __pWindow->GetOrientation();
291
292         FloatRectangle indicatorbounds(0.0f, 0.0f, 0.0f, 0.0f);
293
294         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
295         {
296                 indicatorbounds.width = portraitSize.width;
297                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
298         }
299         else
300         {
301                 indicatorbounds.width = landscapeSize.width;
302                 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, __pWindow->GetOrientation(), indicatorbounds.height);
303         }
304
305         _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
306         SysTryReturn(NID_UI_CTRL, pCoordSystem, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
307
308         _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer();
309         SysTryReturn(NID_UI_CTRL, pXformer, FloatRectangle(-1.0, -1.0, -1.0, -1.0), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed.");
310
311         indicatorbounds = pXformer->Transform(indicatorbounds);
312
313         return indicatorbounds;
314 }
315
316 result
317 _Indicator::AddIndicatorObject(_Control* pControl, _Window* pWindow)
318 {
319         result r = E_SUCCESS;
320
321         __pWindow = pWindow;
322
323         __pPortraitVisualElement =      _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_PORTRAIT, pControl);
324         SysTryReturn(NID_UI_CTRL, __pPortraitVisualElement, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
325         __pLandscapeVisualElement = _IndicatorManager::GetInstance()->GetIndicatorVisualElement(pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, pControl);
326         SysTryReturn(NID_UI_CTRL, __pLandscapeVisualElement, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface.");
327         __pPortraitIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_PORTRAIT);
328         SysTryReturn(NID_UI_CTRL, __pPortraitIndicatorEvasObject, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
329         __pLandscapeIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pControl, _INDICATOR_ORIENTATION_LANDSCAPE);
330         SysTryReturn(NID_UI_CTRL, __pLandscapeIndicatorEvasObject, null,  E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object.");
331
332         _ControlOrientation orientation = pControl->GetOrientation();
333         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
334         {
335                 r = ChangeCurrentVisualElement(__pPortraitVisualElement);
336         }
337         else
338         {
339                 r = ChangeCurrentVisualElement(__pLandscapeVisualElement);
340         }
341
342         Ecore_Evas *pPortraitEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject);
343         SysTryReturn(NID_UI_CTRL, pPortraitEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
344         Ecore_Evas *pLandscapeEe = ecore_evas_object_ecore_evas_get(__pLandscapeIndicatorEvasObject);
345         SysTryReturn(NID_UI_CTRL, pLandscapeEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
346
347         ecore_evas_data_set(pPortraitEe, pPortPublicKey, __pPortraitIndicatorEvasObject);
348         ecore_evas_data_set(pLandscapeEe, pLandPublicKey, __pLandscapeIndicatorEvasObject);
349         ecore_evas_data_set(pPortraitEe, pIndicatorKey, this);
350         ecore_evas_data_set(pLandscapeEe, pIndicatorKey, this);
351         ecore_evas_callback_delete_request_set(pPortraitEe, _Indicator::OnDisconnected);
352         ecore_evas_callback_delete_request_set(pLandscapeEe, _Indicator::OnDisconnected);
353
354         ecore_evas_callback_msg_handle_set(pPortraitEe, _Indicator::OnMessageHandle);
355         ecore_evas_callback_msg_handle_set(pLandscapeEe, _Indicator::OnMessageHandle);
356
357         return r;
358 }
359
360 result
361 _Indicator::DeleteIndicatorObject(void)
362 {
363         result r = E_SUCCESS;
364
365         r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_PORTRAIT, __pPortraitVisualElement);
366         r = _IndicatorManager::GetInstance()->ReleaseIndicatorVisualElement(__pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, __pLandscapeVisualElement);
367
368         if (__pPortraitVisualElement)
369         {
370                 if (__pPortraitVisualElement == __pCurrentVisualElement)
371                 {
372                         r = DetachChild(*__pPortraitVisualElement);
373                 }
374         }
375         if (__pLandscapeVisualElement)
376         {
377                 if (__pLandscapeVisualElement == __pCurrentVisualElement)
378                 {
379                         r = DetachChild(*__pLandscapeVisualElement);
380                 }
381         }
382
383         __pPortraitIndicatorEvasObject = null;
384         __pLandscapeIndicatorEvasObject = null;
385         __pPortraitVisualElement = null;
386         __pLandscapeVisualElement = null;
387         __pCurrentVisualElement = null;
388
389         return r;
390 }
391
392 result
393 _Indicator::ChangeCurrentVisualElement(Tizen::Ui::Animations::_VisualElement* pVisualElement)
394 {
395         result r = E_SUCCESS;
396
397         if (!(__pCurrentVisualElement == pVisualElement))
398         {
399                 r = AttachChild(*pVisualElement);
400                 if (__pCurrentVisualElement)
401                 {
402                         r = DetachChild(*__pCurrentVisualElement);
403                 }
404                 __pCurrentVisualElement = pVisualElement;
405         }
406
407         return r;
408 }
409
410 void
411 _Indicator::OnChangeLayout(_ControlOrientation orientation)
412 {
413         Ecore_X_Window win = 0;
414         if (__pWindow)
415         {
416                 win = (Ecore_X_Window)__pWindow->GetNativeHandle();
417         }
418
419         __orientation = orientation;
420
421         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
422         {
423                 ChangeCurrentVisualElement(__pPortraitVisualElement);
424                 SetClipChildrenEnabled(true);
425
426                 if (__portraitautohide)
427                 {
428                         Color bgColor(0x00000000);
429                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
430                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
431                 }
432                 else
433                 {
434                         SetIndicatorOpacity(__opacity);
435                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
436                 }
437
438         }
439         else
440         {
441                 ChangeCurrentVisualElement(__pLandscapeVisualElement);
442                 SetClipChildrenEnabled(false);
443
444                 if (__landscapeautohide)
445                 {
446                         Color bgColor(0x00000000);
447                         SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
448                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
449                 }
450                 else
451                 {
452                         SetIndicatorOpacity(__opacity);
453                         ecore_x_e_illume_indicator_opacity_set(win, ECORE_X_ILLUME_INDICATOR_OPAQUE);
454                 }
455         }
456 }
457
458 result
459 _Indicator::OnAttachedToMainTree(void)
460 {
461         result r = E_SUCCESS;
462
463         if (__pCurrentVisualElement)
464         {
465                 r = ChangeCurrentVisualElement(__pCurrentVisualElement);
466         }
467
468         return r;
469 }
470
471 void
472 _Indicator::OnTimerExpired(Timer& timer)
473 {
474         Eina_Bool result = EINA_TRUE;
475
476         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
477         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
478         {
479                 result = ecore_evas_extn_plug_connect(__pPortraitIndicatorEvasObject, pPortraitSvcName, 0, EINA_FALSE);
480         }
481         else
482         {
483                 result = ecore_evas_extn_plug_connect(__pLandscapeIndicatorEvasObject, pLandScapeSvcName, 0, EINA_FALSE);
484         }
485
486         if (result == EINA_TRUE)
487         {
488                 timer.Cancel();
489         }
490         else
491         {
492                 timer.Start(CONNECTION_INTERVAL);
493         }
494 }
495
496 void
497 _Indicator::OnDisconnected(Ecore_Evas *pEe)
498 {
499         _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey);
500         SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object");
501
502         if (pIndicator->__pConnectionTimer == null)
503         {
504                 pIndicator->__pConnectionTimer = new (std::nothrow) Timer;
505                 if (pIndicator->__pConnectionTimer == null)
506                 {
507                         return;
508                 }
509
510                 result r = pIndicator->__pConnectionTimer->Construct(*pIndicator);
511                 if (r != E_SUCCESS)
512                 {
513                         delete pIndicator->__pConnectionTimer;
514                         pIndicator->__pConnectionTimer = null;
515
516                         return;
517                 }
518         }
519
520         pIndicator->__pConnectionTimer->Start(CONNECTION_INTERVAL);
521 }
522
523 result
524 _Indicator::SetNotificationTrayOpenEnabled(bool enable)
525 {
526         Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
527
528         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
529
530         unsigned int val[3];
531         int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
532
533         if (returnResult)
534         {
535                 if (enable)
536                 {
537                         val[1] = 1;
538                 }
539                 else
540                 {
541                         val[1] = 0;
542                 }
543
544                 ecore_x_window_prop_card32_set(win, atomPanelScrollable, val, 3);
545         }
546
547         return E_SUCCESS;
548 }
549
550 bool
551 _Indicator::IsNotificationTrayOpenEnabled(void) const
552 {
553         Ecore_X_Window win = (Ecore_X_Window)__pWindow->GetNativeHandle();
554
555         Ecore_X_Atom atomPanelScrollable = ecore_x_atom_get("_E_MOVE_PANEL_SCROLLABLE_STATE");
556
557         unsigned int val[3];
558         int returnResult = ecore_x_window_prop_card32_get(win, atomPanelScrollable, val, 3);
559
560         if (returnResult)
561         {
562                 if (val[1] == 1)
563                 {
564                         return true;
565                 }
566                 else
567                 {
568                         return false;
569                 }
570         }
571         return false;
572 }
573
574 void
575 _Indicator::OnMessageHandle(Ecore_Evas *pEe, int msgDomain, int msgId, void *data, int size)
576 {
577         if (!data)
578         {
579                 return;
580         }
581
582         Evas_Object* pPortraitIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pPortPublicKey);
583         Evas_Object* pLandscapeIndicatorEvasObject = (Evas_Object*)ecore_evas_data_get(pEe, pLandPublicKey);
584
585         if (msgDomain == MSG_DOMAIN_CONTROL_INDICATOR)
586         {
587                 if (msgId == MSG_ID_INDICATOR_REPEAT_EVENT)
588                 {
589                         int *repeat = (int*)data;
590                         if (1 == *repeat)
591                         {
592                                 if (pPortraitIndicatorEvasObject)
593                            {
594                                         evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_TRUE);
595                            }
596                                 if (pLandscapeIndicatorEvasObject)
597                                 {
598                            evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_TRUE);
599                                 }
600                         }
601                         else
602                         {
603                                 if (pPortraitIndicatorEvasObject)
604                            {
605                            evas_object_repeat_events_set(pPortraitIndicatorEvasObject, EINA_FALSE);
606                            }
607                                 if (pLandscapeIndicatorEvasObject)
608                                 {
609                            evas_object_repeat_events_set(pLandscapeIndicatorEvasObject, EINA_FALSE);
610                                 }
611                         }
612                 }
613         }
614 }
615
616 HitTestResult
617 _Indicator::OnHitTest(const Tizen::Graphics::FloatPoint& point)
618 {
619         if (!IsVisible())
620         {
621                 return HIT_TEST_NOWHERE;
622         }
623
624         if (!GetBounds().Contains(point))
625         {
626                 return HIT_TEST_NOWHERE;
627         }
628
629         Evas_Object* pImageObject = null;
630         if (this->__pCurrentVisualElement)
631         {
632                 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*this->__pCurrentVisualElement);
633                 if (pImpl)
634                 {
635                         _EflNode* pNativeNode = dynamic_cast< _EflNode* >(pImpl->GetNativeNode());
636                         if (pNativeNode)
637                         {
638                                 VisualElementSurface* pPortraitSurface = pNativeNode->GetSurface();
639                                 if (pPortraitSurface)
640                                 {
641                                         _EflVisualElementSurfaceImpl* pSurface = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pPortraitSurface));
642                                         if (pSurface)
643                                         {
644                                                 pImageObject = (Evas_Object*)pSurface->GetNativeHandle();
645                                         }
646                                 }
647                         }
648                 }
649         }
650
651         if (pImageObject)
652         {
653                 if (!evas_object_repeat_events_get(pImageObject))
654                 {
655                         return HIT_TEST_MATCH;
656                 }
657                 else
658                 {
659                         return HIT_TEST_NOWHERE;
660                 }
661         }
662         else
663         {
664                 return HIT_TEST_NOWHERE;
665         }
666 }
667
668 void
669 _Indicator::SetIndicatorOrientation(Tizen::Ui::_ControlOrientation orientation)
670 {
671         __orientation = orientation;
672 }
673
674 void
675 _Indicator::SetWindow(_Window* pWindow)
676 {
677         __pWindow = pWindow;
678 }
679
680 }}} // Tizen::Ui::Controls