815f7db131f23dbb8ce6af21110d31b77948618c
[platform/framework/native/shell.git] / src / FShell_AppWidgetPopupView.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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                FShell_AppWidgetPopupView.cpp
19  * @brief               This is the implementation file for the _AppWidgetPopupView class.
20  */
21
22 #include <new>
23 #include <Ecore.h>
24 #include <Ecore_X.h>
25 #include <livebox.h>
26 #include <FBaseSysLog.h>
27 #include <FBaseString.h>
28 #include <FGrpDimension.h>
29 #include <FGrpPoint.h>
30 #include <FGrpRectangle.h>
31 #include <FMediaImageTypes.h>
32 #include <FSysSystemTime.h>
33 #include <FUiAnimVisualElementAnimation.h>
34 #include <FUiAnimVisualElementAnimationGroup.h>
35 #include <FUiAnimVisualElementPropertyAnimation.h>
36 #include <FBase_StringConverter.h>
37 #include <FGrp_BitmapImpl.h>
38 #include <FMedia_ImageDecoder.h>
39 #include <FUi_ControlManager.h>
40 #include <FUi_CoordinateSystemUtils.h>
41 #include <FUi_Types.h>
42 #include <FUiAnim_EflNode.h>
43 #include <FUiAnim_VisualElement.h>
44 #include <FUiAnim_VisualElementImpl.h>
45 #include <FUiAnim_VisualElementSurfaceImpl.h>
46 #include <FUiCtrl_Frame.h>
47 #include "FShell_AppWidgetPopupView.h"
48 #include "FShell_AppWidgetPopupViewPresenter.h"
49 #include "FShell_AppWidgetPopupViewEvent.h"
50 #include "FShell_AppWidgetView.h"
51 #include "FShell_IAppWidgetPopupViewEventListener.h"
52
53 using namespace std;
54 using namespace Tizen::Base;
55 using namespace Tizen::Base::Runtime;
56 using namespace Tizen::Graphics;
57 using namespace Tizen::System;
58 using namespace Tizen::Ui;
59 using namespace Tizen::Ui::Controls;
60 using namespace Tizen::Ui::Animations;
61
62 namespace Tizen { namespace Shell
63 {
64
65 const wchar_t* OPEN_ANIMATION = L"Open";
66 const wchar_t* CLOSE_ANIMATION = L"Close";
67
68 _AppWidgetPopupView::_AppWidgetPopupView(_AppWidgetView& appwidgetView)
69         : __pAppWidgetPopupViewPresenter(new (std::nothrow) _AppWidgetPopupViewPresenter(*this))
70         , __pAppWidgetView(&appwidgetView)
71         , __pAppWidgetPopupViewEvent(_AppWidgetPopupViewEvent::CreateInstanceN(*this))
72         , __firstUpdated(false)
73         , __pixmap(-1)
74 {
75 }
76
77 _AppWidgetPopupView::~_AppWidgetPopupView(void)
78 {
79         if (livebox_has_pd(__pAppWidgetView->__pAppWidget))
80         {
81                 livebox_destroy_pd(__pAppWidgetView->__pAppWidget, OnAppWidgetPopupDestroyed, this);
82         }
83
84         __pAppWidgetView = null;
85 }
86
87 _AppWidgetPopupView*
88 _AppWidgetPopupView::CreateAppWidgetPopupN(_AppWidgetView& appwidgetView)
89 {
90         SysTryReturn(NID_UI_CTRL, livebox_has_pd(appwidgetView.__pAppWidget), null, E_SYSTEM, "[E_SYSTEM] A system error occured.");
91
92         unique_ptr<_AppWidgetPopupView> pAppWidgetPopup(new (std::nothrow) _AppWidgetPopupView(appwidgetView));
93         SysTryReturn(NID_UI_CTRL, pAppWidgetPopup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
94
95         result r = GetLastResult();
96         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
97
98         r = pAppWidgetPopup->CreateRootVisualElement();
99         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
100
101         pAppWidgetPopup->AcquireHandle();
102
103         SetLastResult(E_SUCCESS);
104
105         return pAppWidgetPopup.release();
106 }
107
108 result
109 _AppWidgetPopupView::Initialize(const FloatRectangle& bounds)
110 {
111         FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
112
113         FloatRectangle viewAbsoluteBounds = __pAppWidgetView->GetAbsoluteBoundsF();
114         double x = (static_cast<double>(viewAbsoluteBounds.x) + static_cast<double>((viewAbsoluteBounds.width) / 2)) / static_cast<double>(screenSize.width);
115         double y = 0.0f;
116
117         int lower = 0;
118         int upper = 0;
119         __pAppWidgetView->GetRemainingSpace(lower, upper);
120
121         if (lower > upper)
122         {
123                 y = 1.0f;
124         }
125
126         SysLog(NID_UI_CTRL, "[%f %f %f %f]", bounds.x, bounds.y, bounds.width, bounds.height);
127         SysLog(NID_UI_CTRL, "[%f %f %f %f]", viewAbsoluteBounds.x, viewAbsoluteBounds.y, viewAbsoluteBounds.width, viewAbsoluteBounds.height);
128         SysLog(NID_UI_CTRL, "[%f %f]", x, y);
129
130         int ret = livebox_create_pd_with_position(__pAppWidgetView->__pAppWidget, x, y, OnAppWidgetPopupCreated, this);
131         SysTryReturn(NID_UI_CTRL, ret == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
132
133         result r = SetBounds(bounds);
134         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
135
136         SetBackgroundColor(Color(0, 0, 0, 0));
137
138         return r;
139 }
140
141 result
142 _AppWidgetPopupView::AddAppWidgetPopupEventListener(const _IAppWidgetPopupViewEventListener& listener)
143 {
144         result r = __pAppWidgetPopupViewEvent->AddListener(listener);
145         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
146
147         return r;
148 }
149
150 result
151 _AppWidgetPopupView::RemoveAppWidgetPopupEventListener(const _IAppWidgetPopupViewEventListener& listener)
152 {
153         result r = __pAppWidgetPopupViewEvent->RemoveListener(listener);
154         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155
156         return r;
157 }
158
159 Bitmap*
160 _AppWidgetPopupView::GetBitmap(void) const
161 {
162         return __pBitmap.get();
163 }
164
165 void
166 _AppWidgetPopupView::SetPopupBounds(const FloatDimension& size)
167 {
168         FloatRectangle absoluteViewBounds = __pAppWidgetView->GetAbsoluteBoundsF();
169         FloatRectangle popupBounds(0, 0, size.width, size.height);
170
171         int lower = 0;
172         int upper = 0;
173
174         FloatDimension anchorSize = __pAppWidgetView->GetAnchorSize();
175         __pAppWidgetView->GetRemainingSpace(lower, upper);
176
177         if (lower > upper)
178         {
179                 popupBounds.y = absoluteViewBounds.y - size.height + anchorSize.height;
180         }
181         else
182         {
183                 popupBounds.y = absoluteViewBounds.y + absoluteViewBounds.height - anchorSize.height;
184         }
185
186         SetBounds(popupBounds);
187
188         SysLog(NID_UI_CTRL, "[%f %f %f %f]", popupBounds.x, popupBounds.y, popupBounds.width, popupBounds.height);
189 }
190
191 void
192 _AppWidgetPopupView::FireAppWidgetPopupEvent(bool open)
193 {
194         if (__pAppWidgetPopupViewEvent)
195         {
196                 IEventArg* pEventArg = _AppWidgetPopupViewEvent::CreateAppWidgetPopupViewEventArgN(open);
197                 result r = GetLastResult();
198                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
199
200                 __pAppWidgetPopupViewEvent->Fire(*pEventArg);
201         }
202 }
203
204 void
205 _AppWidgetPopupView::GetTouchPostion(const Tizen::Graphics::FloatPoint& point, double& x, double& y) const
206 {
207         FloatRectangle bounds = GetBoundsF();
208
209         x = static_cast<double>(point.x) / static_cast<double>(bounds.width);
210         y = static_cast<double>(point.y) / static_cast<double>(bounds.height);
211 }
212
213 void
214 _AppWidgetPopupView::PlayAnimation(bool open)
215 {
216         const int ANIMATION1_DURATION = 100;
217 //      const int ANIMATION2_DURATION = 300;
218
219         _VisualElement* pVisualElement = GetVisualElement();
220         result r = GetLastResult();
221         SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r));
222
223         VisualElementAnimationGroup animationGroup;
224         animationGroup.SetVisualElementAnimationStatusEventListener(this);
225
226         FloatRectangle bounds = GetBoundsF();
227         bounds.x = 0.0f;
228         bounds.y = 0.0f;
229         
230         FloatRectangle startBounds(bounds.x, bounds.y, bounds.width, 0.0f);
231         FloatRectangle endBounds(bounds);
232         if (!open)
233         {
234                 startBounds = bounds;
235                 endBounds = FloatRectangle(bounds.x, bounds.y, bounds.width, 0.0f);
236         }
237
238         VisualElementPropertyAnimation animation1;
239         animation1.SetPropertyName(L"bounds");
240         animation1.SetStartValue(Variant(startBounds));
241         animation1.SetEndValue(Variant(endBounds));
242         animation1.SetDuration(ANIMATION1_DURATION);
243
244         animationGroup.AddAnimation(animation1);
245 /*
246         float startOpacity = 0.0f;
247         float endOpacity = 1.0f;
248         if (!open)
249         {
250                 startOpacity = 1.0f;
251                 endOpacity = 0.0f;
252         }
253
254         VisualElementPropertyAnimation animation2;
255         animation2.SetPropertyName(L"opacity");
256         animation2.SetStartValue(Variant(startOpacity));
257         animation2.SetEndValue(Variant(endOpacity));
258         animation2.SetDuration(ANIMATION2_DURATION);
259
260         animationGroup.AddAnimation(animation2);
261 */
262         String keyName = (open) ? OPEN_ANIMATION : CLOSE_ANIMATION;
263         pVisualElement->AddAnimation(keyName, animationGroup);
264 }
265
266 result
267 _AppWidgetPopupView::OnAttached(void)
268 {
269         if (__firstUpdated)
270         {
271                 if (__pPixmapObject)
272                 {
273                         _VisualElement* pVisualElement = GetVisualElement();
274                         SysTryReturn(NID_UI_CTRL, pVisualElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
275
276                         _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode());
277                         SysTryReturn(NID_UI_CTRL, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
278
279                         Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer();
280                         SysTryReturn(NID_UI_CTRL, pSmartObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
281
282                         Evas* pEvas = evas_object_evas_get(pSmartObject);
283                         SysTryReturn(NID_UI_CTRL, pEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
284
285                         pEflNode->AddNativeSmartObject(*pVisualElement, __pPixmapObject.get());
286
287                 }
288
289                 PlayAnimation(true);
290         }
291
292         return E_SUCCESS;
293 }
294
295 void
296 _AppWidgetPopupView::OnActivated(void)
297 {
298         SetTouchCapture(false, false);
299 }
300
301 void
302 _AppWidgetPopupView::OnDeactivated(void)
303 {
304         ReleaseTouchCapture();
305 }
306
307 bool
308 _AppWidgetPopupView::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
309 {
310         double x = 0.0;
311         double y = 0.0;
312
313         Point position = _CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition());
314         GetTouchPostion(FloatPoint(static_cast<float>(position.x), static_cast<float>(position.y)), x, y);
315
316         livebox_content_event(__pAppWidgetView->__pAppWidget, PD_MOUSE_DOWN, x, y);
317
318         return false;
319 }
320
321 bool
322 _AppWidgetPopupView::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
323 {
324         FloatRectangle clientBounds(GetClientBoundsF());
325
326         Point position = _CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition());
327         FloatPoint floatPosition(static_cast<float>(position.x), static_cast<float>(position.y));
328
329         if (!clientBounds.Contains(floatPosition))
330         {
331                 PlayAnimation(false);
332         }
333
334         double x = 0.0;
335         double y = 0.0;
336
337         GetTouchPostion(floatPosition, x, y);
338
339         livebox_content_event(__pAppWidgetView->__pAppWidget, PD_MOUSE_UP, x, y);
340
341         return false;
342 }
343
344 bool
345 _AppWidgetPopupView::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
346 {
347         double x = 0.0;
348         double y = 0.0;
349
350         Point position = _CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition());
351         GetTouchPostion(FloatPoint(static_cast<float>(position.x), static_cast<float>(position.y)), x, y);
352
353         livebox_content_event(__pAppWidgetView->__pAppWidget, PD_MOUSE_MOVE, x, y);
354
355         return false;
356 }
357
358 void
359 _AppWidgetPopupView::OnBoundsChanged(void)
360 {
361 }
362
363 void
364 _AppWidgetPopupView::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
365 {
366 }
367
368 void
369 _AppWidgetPopupView::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
370 {
371         if (keyName == CLOSE_ANIMATION)
372         {
373                 SysLog(NID_UI_CTRL, "Close AppWidgetPopup");
374                 Close();
375                 FireAppWidgetPopupEvent(false);
376         }
377 }
378
379 void
380 _AppWidgetPopupView::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
381 {
382 }
383
384 void
385 _AppWidgetPopupView::OnDraw(void)
386 {
387         __pAppWidgetPopupViewPresenter->Draw();
388 }
389
390 result
391 _AppWidgetPopupView::OnAttachedToMainTree(void)
392 {
393         result r = _Window::OnAttachedToMainTree();
394
395         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
396         if (pWindow)
397         {
398                 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
399                 if (pFrame)
400                 {
401                         pFrame->AddFrameEventListener(*this);
402                 }
403         }
404
405         return r;
406 }
407
408 result
409 _AppWidgetPopupView::OnDetachingFromMainTree(void)
410 {
411         result r = _Window::OnDetachingFromMainTree();
412
413         _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
414         if (pWindow)
415         {
416                 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
417                 if (pFrame)
418                 {
419                         pFrame->RemoveFrameEventListener(*this);
420                 }
421         }
422
423         return r;
424 }
425
426 void
427 _AppWidgetPopupView::OnFrameActivated(const Tizen::Ui::Controls::_Frame& source)
428 {
429 }
430
431 void
432 _AppWidgetPopupView::OnFrameDeactivated(const Tizen::Ui::Controls::_Frame& source)
433 {
434         PlayAnimation(false);
435 }
436
437 void
438 _AppWidgetPopupView::OnFrameMinimized(const Tizen::Ui::Controls::_Frame& source)
439 {
440 }
441
442 void
443 _AppWidgetPopupView::OnFrameRestored(const Tizen::Ui::Controls::_Frame& source)
444 {
445 }
446
447 void
448 _AppWidgetPopupView::OnAppWidgetUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::FloatDimension& size)
449 {
450         long long ticks = 0;
451         SystemTime::GetTicks(ticks);
452
453         SysLog(NID_UI_CTRL, "(%f %f) %lld", size.width, size.height, ticks);
454
455         if (size != GetSizeF())
456         {
457                 SetPopupBounds(size);
458         }
459
460         __pBitmap.reset(const_cast<Bitmap*>(&bitmap));
461
462         if (!__firstUpdated)
463         {
464                 PlayAnimation(true);
465                 __firstUpdated = true;
466         }
467         else
468         {
469                 Invalidate(false);
470         }
471 }
472
473 void
474 _AppWidgetPopupView::OnAppWidgetUpdated(int pixmap)
475 {
476         int x = 0;
477         int y = 0;
478         int width = 0;
479         int height = 0;
480
481         ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height);
482         SysTryReturnVoidResult(NID_UI_CTRL, (width > 0) && (height > 0), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid [0x%x %d %d].", pixmap, width , height);
483
484         if (__pixmap != pixmap )
485         {
486                 _VisualElement* pVisualElement = GetVisualElement();
487 //              _VisualElement* pVisualElement = __pAppWidgetView->GetVisualElement();
488                 SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
489
490                 _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode());
491                 SysTryReturnVoidResult(NID_UI_CTRL, pEflNode, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
492
493                 Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer();
494                 SysTryReturnVoidResult(NID_UI_CTRL, pSmartObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
495
496                 Evas* pEvas = evas_object_evas_get(pSmartObject);
497                 SysTryReturnVoidResult(NID_UI_CTRL, pEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
498
499                 __pPixmapObject.reset(evas_object_image_filled_add(pEvas));
500                 SysTryReturnVoidResult(NID_UI_CTRL, __pPixmapObject.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
501
502                 pEflNode->AddNativeSmartObject(*pVisualElement, __pPixmapObject.get());
503
504                 evas_object_image_size_set(__pPixmapObject.get(), width, height);
505                 evas_object_image_colorspace_set(__pPixmapObject.get(), EVAS_COLORSPACE_ARGB8888);
506                 evas_object_image_alpha_set(__pPixmapObject.get(), EINA_TRUE);
507
508                 evas_object_move(__pPixmapObject.get(), 0, 0);
509                 evas_object_show(__pPixmapObject.get());
510
511                 Evas_Native_Surface surface;
512
513                 surface.version = EVAS_NATIVE_SURFACE_VERSION;
514                 surface.type = EVAS_NATIVE_SURFACE_X11;
515                 surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
516                 surface.data.x11.pixmap = pixmap;
517
518                 evas_object_image_native_surface_set(__pPixmapObject.get(), &surface);
519
520                 /*__pixmapDamage.reset(ecore_x_damage_new(pixmap, ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES));
521                 SysTryReturnVoidResult(NID_UI_CTRL, __pixmapDamage.get() != 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
522
523                 __pPixmapEventHandler.reset(ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, OnPixmapDamaged, (void*)this));
524                 SysTryReturnVoidResult(NID_UI_CTRL, __pPixmapEventHandler, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");*/
525
526                 SysLog(NID_UI_CTRL, "[0x%x]", surface.data.x11.pixmap);
527         }
528
529         SysLog(NID_UI_CTRL, "[%d %d %d %d]", x, y, width, height);
530
531         evas_object_image_size_set(__pPixmapObject.get(), width, height);
532         evas_object_image_pixels_dirty_set(__pPixmapObject.get(), EINA_TRUE);
533         evas_object_image_fill_set(__pPixmapObject.get(), 0, 0, width, height);
534         evas_object_image_data_update_add(__pPixmapObject.get(), 0, 0, width, height);
535         evas_object_resize(__pPixmapObject.get(), width, height);
536
537         FloatDimension size(width, height);
538         if (size != GetSizeF())
539         {
540                 SetPopupBounds(size);
541         }
542
543         if (!__firstUpdated)
544         {
545                 PlayAnimation(true);
546                 __firstUpdated = true;
547         }
548
549         __pixmap = pixmap;
550 }
551
552 void
553 _AppWidgetPopupView::OnAppWidgetPopupCreated(struct livebox *pAppWidget, int ret, void* pData)
554 {
555         SysTryReturnVoidResult(NID_UI_CTRL, pAppWidget, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
556         SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
557
558         _AppWidgetPopupView* pAppWidgetViewManager = static_cast<_AppWidgetPopupView*>(pData);
559         SysTryReturnVoidResult(NID_UI_CTRL, pAppWidgetViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
560 }
561
562 void
563 _AppWidgetPopupView::OnAppWidgetPopupDestroyed(struct livebox *pAppWidget, int ret, void* pData)
564 {
565         SysTryReturnVoidResult(NID_UI_CTRL, pAppWidget, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
566         SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
567
568         _AppWidgetPopupView* pAppWidgetViewManager = static_cast<_AppWidgetPopupView*>(pData);
569         SysTryReturnVoidResult(NID_UI_CTRL, pAppWidgetViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
570 }
571
572 Eina_Bool
573 _AppWidgetPopupView::OnPixmapDamaged(void* pData, int type, void* pEvent)
574 {
575         _AppWidgetPopupView* pPopupView = static_cast<_AppWidgetPopupView*>(pData);
576         SysTryReturn(NID_UI_CTRL, pPopupView != null, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[[E_INVALID_ARG] The argument is invalid.");
577
578         Ecore_X_Event_Damage* pDamageEvent = static_cast<Ecore_X_Event_Damage*>(pEvent);
579         SysTryReturn(NID_UI_CTRL, pDamageEvent != null, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
580
581         int pixmap = pPopupView->__pixmap;
582         SysTryReturn(NID_UI_CTRL, pDamageEvent->drawable == pixmap, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid [%d %d].", pDamageEvent->drawable, pixmap);
583
584         int x = 0;
585         int y = 0;
586         int width = 0;
587         int height = 0;
588
589         ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height);
590         SysTryReturn(NID_UI_CTRL, (width > 0) && (height > 0), ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid [0x%x %d %d].", pixmap, width , height);
591
592         Evas_Object* pPixmapObject = pPopupView->__pPixmapObject.get();
593         SysTryReturn(NID_UI_CTRL, pPixmapObject, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
594
595         evas_object_image_pixels_dirty_set(pPixmapObject, EINA_TRUE);
596         evas_object_image_fill_set(pPixmapObject, 0, 0, width, height);
597         evas_object_image_data_update_add(pPixmapObject, 0, 0, width, height);
598
599         SysLog(NID_UI_CTRL, "[%d %d %d]", pixmap, width, height);
600
601         return ECORE_CALLBACK_DONE;
602 }
603
604 }} // Tizen::Shell