2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FShell_AppWidgetView.cpp
19 * @brief This is the implementation file for the _AppWidgetView class.
26 #include <livebox-service.h>
27 #include <FBaseColLinkedListT.h>
28 #include <FBaseSysLog.h>
29 #include <FBaseString.h>
30 #include <FGrpBitmap.h>
31 #include <FGrpCanvas.h>
32 #include <FGrpDimension.h>
33 #include <FGrpPoint.h>
34 #include <FGrpRectangle.h>
35 #include <FUiAnimDisplayContext.h>
36 #include <FUiAnimVisualElementPropertyAnimation.h>
37 #include <FBase_StringConverter.h>
38 #include <FGrp_BitmapImpl.h>
39 #include <FMedia_ImageDecoder.h>
40 #include <FUi_TouchFlickGestureDetector.h>
41 #include <FUi_ResourceManager.h>
42 #include <FUi_CoordinateSystemUtils.h>
43 #include <FUiAnim_EflNode.h>
44 #include <FUiAnim_VisualElementImpl.h>
45 #include <FUiAnim_VisualElementSurfaceImpl.h>
46 #include <FUiCtrl_Frame.h>
47 #include "FShell_IAppWidgetViewEventListener.h"
48 #include "FShell_AppWidgetManagerImpl.h"
49 #include "FShell_AppWidgetView.h"
50 #include "FShell_AppWidgetViewPresenter.h"
51 #include "FShell_AppWidgetPopupView.h"
52 #include "FShell_AppWidgetViewManager.h"
55 using namespace Tizen::App;
56 using namespace Tizen::Base;
57 using namespace Tizen::Base::Collection;
58 using namespace Tizen::Graphics;
59 using namespace Tizen::Ui;
60 using namespace Tizen::Ui::Controls;
61 using namespace Tizen::Ui::Animations;
62 using namespace Tizen::Media;
64 namespace Tizen { namespace Shell
67 const int ANIMATION_DURATION = 200;
68 const wchar_t* CLICK_ANIMATION = L"Click";
69 const wchar_t* FLICK_ANIMATION = L"Flick";
71 _AppWidgetView::_AppWidgetView(void)
72 : __pAppWidgetViewPresenter(new (std::nothrow) _AppWidgetViewPresenter(*this))
74 , __pAppWidgetViewManager(null)
75 , __resizeFromRemote(false)
78 , __pAppWidgetViewEventListenerList(new (std::nothrow) LinkedListT<_IAppWidgetViewEventListener*>)
80 __pAppWidgetViewManager = _AppWidgetViewManager::GetInstance();
81 SysTryReturnVoidResult(NID_SHELL, __pAppWidgetViewManager, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
84 _AppWidgetView::~_AppWidgetView(void)
86 __pAppWidgetViewManager->RemoveAppWidgetView(this);
88 if (__pAppWidgetPopupView)
90 __pAppWidgetPopupView->RemoveAppWidgetPopupEventListener(*this);
93 if (__pTouchFlickGestureDetector)
95 RemoveGestureDetector(*__pTouchFlickGestureDetector);
100 _AppWidgetView::CreateAppWidgetViewN(void)
102 unique_ptr<_AppWidgetView> pAppWidgetView(new (std::nothrow) _AppWidgetView());
103 SysTryReturn(NID_SHELL, pAppWidgetView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
105 result r = GetLastResult();
106 SysTryReturn(NID_SHELL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
108 pAppWidgetView->AcquireHandle();
110 SetLastResult(E_SUCCESS);
112 return pAppWidgetView.release();
116 _AppWidgetView::Initialize(const AppId& appId, const Tizen::Base::String& providerName, const Tizen::Graphics::FloatRectangle& rect, const String& userInfo)
118 SysLog(NID_SHELL, "appId [%ls]", appId.GetPointer());
119 SysLog(NID_SHELL, "providerName [%ls]", providerName.GetPointer());
120 SysLog(NID_SHELL, "[%d %d %d %d]", rect.x, rect.y, rect.width, rect.height);
121 SysLog(NID_SHELL, "userInfo [%ls]", userInfo.GetPointer());
123 result r = SetBounds(rect);
124 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
126 r = __pAppWidgetViewPresenter->Initialize(appId, providerName);
127 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
132 unique_ptr<ByteBuffer> pByteBuffer(_ImageDecoder::DecodeToBufferN(__pAppWidgetViewPresenter->GetAppIconPath(), MEDIA_PIXEL_FORMAT_BGRA8888, width, height));
133 unique_ptr<Bitmap> pBitmap(_BitmapImpl::GetNonScaledBitmapN(*pByteBuffer.get(), Dimension(width, height), BITMAP_PIXEL_FORMAT_ARGB8888));
135 __pAppIconBitmap = move(pBitmap);
137 __pAppWidget = __pAppWidgetViewManager->AddAppWidgetView(this, userInfo);
139 SysTryReturn(NID_SHELL, __pAppWidget, r, r, "[%s] Propagating.", GetErrorMessage(r));
141 if (!IsTouchEventEnabled())
143 unique_ptr<_TouchFlickGestureDetector> pTouchFlickGestureDetector(new (std::nothrow) _TouchFlickGestureDetector());
144 SysTryReturn(NID_SHELL, pTouchFlickGestureDetector, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
146 pTouchFlickGestureDetector->SetDelayTouchEventEnabled(true);
147 pTouchFlickGestureDetector->SetCancelTouchEventOnSuccessEnabled(true);
149 r = AddGestureDetector(*pTouchFlickGestureDetector.get());
150 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
152 r = pTouchFlickGestureDetector->AddGestureListener(*this);
153 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155 __pTouchFlickGestureDetector = move(pTouchFlickGestureDetector);
158 Bitmap* pResourceBitmap = null;
160 r = GET_BITMAP_CONFIG_N(LIVEBOX::POPUP_BG_ARROW_UP, BITMAP_PIXEL_FORMAT_ARGB8888, pResourceBitmap);
161 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
163 std::unique_ptr<Bitmap> pArrowUpBitmap(pResourceBitmap);
165 r = GET_BITMAP_CONFIG_N(LIVEBOX::POPUP_BG_ARROW_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, pResourceBitmap);
166 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
168 __pArrowUpBitmap = move(pArrowUpBitmap);
169 __pArrowDownBitmap.reset(pResourceBitmap);
174 AppWidgetProviderInfo*
175 _AppWidgetView::GetAppWidgetProviderInfoN(void) const
177 AppWidgetProviderInfo* pProviderInfo = _AppWidgetManagerImpl::GetInstance()->GetAppWidgetProviderInfoN(GetAppId(), GetProviderName());
178 result r = GetLastResult();
179 SysTryReturn(NID_SHELL, pProviderInfo, null, r, "[%s] Propagating.", GetErrorMessage(r));
181 return pProviderInfo;
185 _AppWidgetView::AddAppWidgetViewEventListener(_IAppWidgetViewEventListener& listener)
187 bool exist = __pAppWidgetViewEventListenerList->Contains(&listener);
188 SysTryReturn(NID_SHELL, exist == false, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[%s] Propagating.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
190 __pAppWidgetViewEventListenerList->Add(&listener);
196 _AppWidgetView::RemoveAppWidgetViewEventListener(_IAppWidgetViewEventListener& listener)
198 result r = __pAppWidgetViewEventListenerList->Remove(&listener);
199 SysTryReturn(NID_SHELL, r == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating.", GetErrorMessage(E_OBJ_NOT_FOUND));
205 _AppWidgetView::GetAppWidgetPopup(void) const
207 return __pAppWidgetPopupView.get();
211 _AppWidgetView::GetAppId(void) const
213 return __pAppWidgetViewPresenter->GetAppId();
217 _AppWidgetView::GetAppWidgetId(void) const
219 return __pAppWidgetViewPresenter->GetAppWidgetId();
223 _AppWidgetView::GetProviderName(void) const
225 return __pAppWidgetViewPresenter->GetProviderName();
229 _AppWidgetView::GetAppIconBitmap(void) const
231 return __pAppIconBitmap.get();
235 _AppWidgetView::GetBitmap(void) const
237 return __pBitmap.get();
241 _AppWidgetView::IsUpdated(void) const
247 _AppWidgetView::GetAnchorSize(void) const
249 Bitmap* pArrowBitmap = null;
253 GetRemainingSpace(lower, upper);
257 pArrowBitmap = __pArrowDownBitmap.get();
261 pArrowBitmap = __pArrowUpBitmap.get();
264 return FloatDimension(pArrowBitmap->GetWidth(), pArrowBitmap->GetHeight());
268 _AppWidgetView::CallProviderRemoved(void)
270 unique_ptr<IEnumeratorT<_IAppWidgetViewEventListener*> > pEnumerator(__pAppWidgetViewEventListenerList->GetEnumeratorN());
273 while (pEnumerator->MoveNext() == E_SUCCESS)
275 _IAppWidgetViewEventListener* pListener = null;
276 pEnumerator->GetCurrent(pListener);
280 pListener->OnAppWidgetProviderRemoved(*this);
287 _AppWidgetView::GetPixmapId(void) const
293 _AppWidgetView::GetNativeAppWidget(void) const
299 _AppWidgetView::OpenAppWidgetPopup(void)
301 result r = E_SUCCESS;
303 const _Control* pParent = GetParent();
305 SysTryReturn(NID_SHELL, pParent, r, r, "[%s] Propagating.", GetErrorMessage(r));
307 FloatDimension size = __pAppWidgetViewManager->GetAppWidgetPopupSize(__pAppWidget);
308 FloatRectangle popupBounds(0, 0, size.width, size.height);
309 FloatRectangle bounds = GetBoundsF();
310 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
315 FloatDimension anchorSize = GetAnchorSize();
316 GetRemainingSpace(lower, upper);
320 popupBounds.y = absoluteBounds.y - size.height + anchorSize.height;
324 popupBounds.y = absoluteBounds.y + absoluteBounds.height - anchorSize.height;
327 SysLog(NID_SHELL, "[%d %d]", popupBounds.y, size.height);
329 if (!__pAppWidgetPopupView)
331 unique_ptr<_AppWidgetPopupView> pAppWidgetPopupView(_AppWidgetPopupView::CreateAppWidgetPopupN(*this));
333 SysTryReturn(NID_SHELL, pAppWidgetPopupView, r, r, "[%s] Propagating.", GetErrorMessage(r));
335 r = pAppWidgetPopupView->Initialize(popupBounds);
336 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
338 r = pAppWidgetPopupView->AddAppWidgetPopupEventListener(*this);
339 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
341 __pAppWidgetPopupView = move(pAppWidgetPopupView);
344 __pAppWidgetPopupView->SetOwner(this);
346 r = __pAppWidgetPopupView->Open();
347 SysTryReturn(NID_SHELL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
353 _AppWidgetView::GetTouchPostion(const FloatPoint& point, double& x, double& y) const
355 FloatRectangle bounds = GetBoundsF();
357 x = static_cast<double>(point.x) / static_cast<double>(bounds.width);
358 y = static_cast<double>(point.y) / static_cast<double>(bounds.height);
362 _AppWidgetView::PlayClickAnimation(void)
364 VisualElementPropertyAnimation animation;
365 animation.SetPropertyName(L"transform.scale.xy");
366 animation.SetEndValue(Variant(FloatPoint(0.8f, 0.8f)));
367 animation.SetDuration(ANIMATION_DURATION);
368 animation.SetAutoReverseEnabled(true);
370 _VisualElement* pVisualElement = GetVisualElement();
371 result r = GetLastResult();
372 SysTryReturnVoidResult(NID_SHELL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r));
374 pVisualElement->AddAnimation(CLICK_ANIMATION, animation);
378 _AppWidgetView::PlayFlickAnimation(void)
380 const int DISTANCE = 30;
382 _VisualElement* pVisualElement = GetVisualElement();
383 result r = GetLastResult();
384 SysTryReturnVoidResult(NID_SHELL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r));
386 FloatRectangle startBounds(pVisualElement->GetBounds());
387 FloatRectangle endBounds(startBounds);
388 endBounds.y = startBounds.y + DISTANCE;
390 VisualElementPropertyAnimation animation;
391 animation.SetPropertyName(L"bounds");
392 animation.SetStartValue(Variant(startBounds));
393 animation.SetEndValue(Variant(endBounds));
394 animation.SetDuration(ANIMATION_DURATION);
395 animation.SetAutoReverseEnabled(true);
396 animation.SetVisualElementAnimationStatusEventListener(this);
398 pVisualElement->AddAnimation(FLICK_ANIMATION, animation);
402 _AppWidgetView::GetRemainingSpace(int& lower, int& upper) const
404 const _Control* pParent = GetParent();
405 result r = GetLastResult();
406 SysTryReturnVoidResult(NID_SHELL, pParent, r, "[%s] Propagating.", GetErrorMessage(r));
408 FloatRectangle parentClientBounds = pParent->GetClientBoundsF();
409 FloatRectangle viewBounds = GetBoundsF();
411 lower = viewBounds.y;
412 upper = parentClientBounds.height - viewBounds.y - viewBounds.height;
414 SysLog(NID_SHELL, "[%d %d]", lower, upper);
418 _AppWidgetView::IsTouchEventEnabled(void) const
420 unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(GetAppId()));
421 int ret = livebox_service_mouse_event(pAppId.get());
427 _AppWidgetView::IsTouchEffectEnabled(void) const
429 unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(GetAppId()));
430 int sizeType = __pAppWidgetViewManager->GetAppWidgetSizeType(GetSizeF());
431 int ret = livebox_service_touch_effect(pAppId.get(), sizeType);
437 _AppWidgetView::OnAttachedToMainTree(void)
439 result r = E_SUCCESS;
441 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
444 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
447 pFrame->AddFrameEventListener(*this);
450 __pAppWidgetViewManager->AddFrameEventListener();
457 _AppWidgetView::OnDetachingFromMainTree(void)
459 result r = E_SUCCESS;
461 _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame();
464 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
467 pFrame->RemoveFrameEventListener(*this);
475 _AppWidgetView::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
480 _AppWidgetView::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
485 _AppWidgetView::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
490 _AppWidgetView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
492 _FlickDirection direction = gesture.GetDirection();
493 if (direction == _FLICK_DIRECTION_DOWN)
495 PlayFlickAnimation();
496 OpenAppWidgetPopup();
503 _AppWidgetView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
509 _AppWidgetView::OnBoundsChanged(void)
511 FloatDimension size(GetSizeF());
513 if (!__resizeFromRemote)
515 __pAppWidgetViewManager->SetAppWidgetSize(*this, size);
521 _AppWidgetView::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
523 int type = livebox_lb_type(__pAppWidget);
524 if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled())
529 Point position = _CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition());
530 GetTouchPostion(FloatPoint(static_cast<float>(position.x), static_cast<float>(position.y)), x, y);
532 livebox_content_event(__pAppWidget, LB_MOUSE_DOWN, x, y);
539 _AppWidgetView::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
541 FloatRectangle clientBounds(GetClientBoundsF());
542 Point position(_CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition()));
543 FloatPoint floatPosition(static_cast<float>(position.x), static_cast<float>(position.y));
545 if (clientBounds.Contains(floatPosition) && IsTouchEffectEnabled())
547 PlayClickAnimation();
552 GetTouchPostion(floatPosition, x, y);
554 int type = livebox_lb_type(__pAppWidget);
555 if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled())
557 livebox_content_event(__pAppWidget, LB_MOUSE_UP, x, y);
560 livebox_click(__pAppWidget, x, y);
566 _AppWidgetView::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
568 int type = livebox_lb_type(__pAppWidget);
569 if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled())
574 Point position = _CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition());
575 GetTouchPostion(FloatPoint(static_cast<float>(position.x), static_cast<float>(position.y)), x, y);
577 livebox_content_event(__pAppWidget, LB_MOUSE_MOVE, x, y);
584 _AppWidgetView::OnAppWidgetPopupViewOpened(void)
589 _AppWidgetView::OnAppWidgetPopupViewClosed(void)
591 __pAppWidgetPopupView.reset(null);
595 _AppWidgetView::OnDraw(void)
597 __pAppWidgetViewPresenter->Draw();
601 _AppWidgetView::OnFrameActivated(const Tizen::Ui::Controls::_Frame& source)
605 livebox_set_visibility(__pAppWidget, LB_SHOW);
610 _AppWidgetView::OnFrameDeactivated(const Tizen::Ui::Controls::_Frame& source)
614 livebox_set_visibility(__pAppWidget, LB_HIDE_WITH_PAUSE);
619 _AppWidgetView::OnFrameMinimized(const Tizen::Ui::Controls::_Frame& source)
624 _AppWidgetView::OnFrameRestored(const Tizen::Ui::Controls::_Frame& source)
629 _AppWidgetView::OnAppWidgetUpdated(const Bitmap& bitmap, const FloatDimension& size)
631 __resizeFromRemote = true;
633 __resizeFromRemote = false;
636 __pBitmap.reset(const_cast<Bitmap*>(&bitmap));
642 _AppWidgetView::OnAppWidgetUpdated(int pixmap)
649 ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height);
650 SysTryReturnVoidResult(NID_SHELL, (width > 0) && (height > 0), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid [0x%x %d %d].", pixmap, width , height);
652 if (__pixmap != pixmap )
654 SetBackgroundColor(Color(0, 0, 0, 0));
656 _VisualElement* pVisualElement = GetVisualElement();
657 SysTryReturnVoidResult(NID_SHELL, pVisualElement, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
659 _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode());
660 SysTryReturnVoidResult(NID_SHELL, pEflNode, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
662 Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer();
663 SysTryReturnVoidResult(NID_SHELL, pSmartObject, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
665 Evas* pEvas = evas_object_evas_get(pSmartObject);
666 SysTryReturnVoidResult(NID_SHELL, pEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
668 __pPixmapObject.reset(evas_object_image_filled_add(pEvas));
669 SysTryReturnVoidResult(NID_SHELL, __pPixmapObject, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
671 _Window* pWindow = GetRootWindow();
672 SysTryReturnVoidResult(NID_SHELL, pWindow, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
674 DisplayContext* pDisplayContext = pWindow->GetDisplayContext();
675 SysTryReturnVoidResult(NID_SHELL, pDisplayContext, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
677 __pVisualElementSurface.reset(_VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(*pDisplayContext, (Handle)__pPixmapObject.get(), Dimension(width, height)));
678 SysTryReturnVoidResult(NID_SHELL, __pVisualElementSurface, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
680 unique_ptr<VisualElement, _VisualElementDeleter> pPixmapVisualElement(new (std::nothrow) VisualElement);
681 SysTryReturnVoidResult(NID_SHELL, pPixmapVisualElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
683 result r = pPixmapVisualElement->Construct();
684 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
686 __pPixmapVisualElement = move(pPixmapVisualElement);
687 __pPixmapVisualElement->SetImplicitAnimationEnabled(false);
689 pVisualElement->AttachChild(__pPixmapVisualElement.get());
691 __pPixmapVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, width, height));
692 __pPixmapVisualElement->SetSurface(__pVisualElementSurface.get());
693 __pPixmapVisualElement->SetShowState(true);
695 evas_object_image_size_set(__pPixmapObject.get(), width, height);
696 evas_object_image_colorspace_set(__pPixmapObject.get(), EVAS_COLORSPACE_ARGB8888);
697 evas_object_image_alpha_set(__pPixmapObject.get(), EINA_TRUE);
699 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
701 evas_object_move(__pPixmapObject.get(), absoluteBounds.x, absoluteBounds.y);
702 evas_object_show(__pPixmapObject.get());
704 Evas_Native_Surface surface;
706 surface.version = EVAS_NATIVE_SURFACE_VERSION;
707 surface.type = EVAS_NATIVE_SURFACE_X11;
708 surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
709 surface.data.x11.pixmap = pixmap;
711 evas_object_image_native_surface_set(__pPixmapObject.get(), &surface);
713 __pixmapDamage.reset(ecore_x_damage_new(pixmap, ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES));
714 SysTryReturnVoidResult(NID_SHELL, __pixmapDamage.get() != 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
716 __pPixmapEventHandler.reset(ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, OnPixmapDamaged, (void*)this));
717 SysTryReturnVoidResult(NID_SHELL, __pPixmapEventHandler, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
719 SysLog(NID_SHELL, "[0x%x][%f %f]", surface.data.x11.pixmap, absoluteBounds.x, absoluteBounds.y);
722 SysLog(NID_SHELL, "[%d %d %d %d]", x, y, width, height);
724 evas_object_image_size_set(__pPixmapObject.get(), width, height);
725 evas_object_image_pixels_dirty_set(__pPixmapObject.get(), EINA_TRUE);
726 evas_object_image_fill_set(__pPixmapObject.get(), 0, 0, width, height);
727 evas_object_image_data_update_add(__pPixmapObject.get(), 0, 0, width, height);
728 evas_object_resize(__pPixmapObject.get(), width, height);
730 __resizeFromRemote = true;
731 SetSize(FloatDimension(static_cast<float>(width), static_cast<float>(height)));
732 __resizeFromRemote = false;
739 _AppWidgetView::OnPixmapDamaged(void* pData, int type, void* pEvent)
741 _AppWidgetView* pAppWidgetView = static_cast<_AppWidgetView*>(pData);
742 SysTryReturn(NID_SHELL, pAppWidgetView != null, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[[E_INVALID_ARG] The argument is invalid.");
744 Ecore_X_Event_Damage* pDamageEvent = static_cast<Ecore_X_Event_Damage*>(pEvent);
745 SysTryReturn(NID_SHELL, pDamageEvent != null, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
747 unsigned int pixmap = static_cast<unsigned int>(pAppWidgetView->__pixmap);
748 SysTryReturn(NID_SHELL, pDamageEvent->drawable == pixmap, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid [%d %d].", pDamageEvent->drawable, pixmap);
755 ecore_x_pixmap_geometry_get(pixmap, &x, &y, &width, &height);
756 SysTryReturn(NID_SHELL, (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);
758 Evas_Object* pPixmapObject = pAppWidgetView->__pPixmapObject.get();
759 SysTryReturn(NID_SHELL, pPixmapObject, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
761 evas_object_image_pixels_dirty_set(pPixmapObject, EINA_TRUE);
762 evas_object_image_fill_set(pPixmapObject, 0, 0, width, height);
763 evas_object_image_data_update_add(pPixmapObject, 0, 0, width, height);
765 SysLog(NID_SHELL, "[%d %d %d]", pixmap, width, height);
767 return ECORE_CALLBACK_DONE;