From 74159569dd73f9ccaf8b06354a793e7bbdb2b68a Mon Sep 17 00:00:00 2001 From: HeeJu Kang Date: Sat, 16 Mar 2013 16:02:31 +0900 Subject: [PATCH] Fixed Touch effect/event Change-Id: Ieeebb1cf150dc3e1428792917de8989a8f4e1491 Signed-off-by: HeeJu Kang --- src/FShell_AppWidgetView.cpp | 55 +++++++++++++++++++++++++++++++------------- src/FShell_AppWidgetView.h | 2 ++ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/FShell_AppWidgetView.cpp b/src/FShell_AppWidgetView.cpp index d7c4ff8..4f50067 100644 --- a/src/FShell_AppWidgetView.cpp +++ b/src/FShell_AppWidgetView.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include "FUi_TouchFlickGestureDetector.h" @@ -126,23 +128,26 @@ _AppWidgetView::Initialize(const AppId& appId, const Tizen::Base::String& provid __pAppIconBitmap = move(pBitmap); - unique_ptr<_TouchFlickGestureDetector> pTouchFlickGestureDetector(new (std::nothrow) _TouchFlickGestureDetector()); - SysTryReturn(NID_UI_CTRL, pTouchFlickGestureDetector, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + __pAppWidget = __pAppWidgetViewManager->AddAppWidgetView(this, userInfo); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pAppWidget, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pTouchFlickGestureDetector->SetDelayTouchEventEnabled(true); - pTouchFlickGestureDetector->SetCancelTouchEventOnSuccessEnabled(true); + if (livebox_has_pd(__pAppWidget)) + { + unique_ptr<_TouchFlickGestureDetector> pTouchFlickGestureDetector(new (std::nothrow) _TouchFlickGestureDetector()); + SysTryReturn(NID_UI_CTRL, pTouchFlickGestureDetector, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); - r = AddGestureDetector(*pTouchFlickGestureDetector.get()); - SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pTouchFlickGestureDetector->SetDelayTouchEventEnabled(true); + pTouchFlickGestureDetector->SetCancelTouchEventOnSuccessEnabled(true); - r = pTouchFlickGestureDetector->AddGestureListener(*this); - SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = AddGestureDetector(*pTouchFlickGestureDetector.get()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pTouchFlickGestureDetector = move(pTouchFlickGestureDetector); + r = pTouchFlickGestureDetector->AddGestureListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pAppWidget = __pAppWidgetViewManager->AddAppWidgetView(this, userInfo); - r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, __pAppWidget, r, r, "[%s] Propagating.", GetErrorMessage(r)); + __pTouchFlickGestureDetector = move(pTouchFlickGestureDetector); + } Bitmap* pResourceBitmap = null; @@ -377,6 +382,24 @@ _AppWidgetView::GetRemainingSpace(int& lower, int& upper) const SysLog(NID_UI_CTRL, "[%d %d]", lower, upper); } +bool +_AppWidgetView::IsTouchEventEnabled(void) const +{ + unique_ptr pAppId(_StringConverter::CopyToCharArrayN(GetAppId())); + int ret = livebox_service_mouse_event(pAppId.get()); + + return ( ret == 1 ); +} + +bool +_AppWidgetView::IsTouchEffectEnabled(void) const +{ + unique_ptr pAppId(_StringConverter::CopyToCharArrayN(GetAppId())); + int ret = livebox_service_touch_effect(pAppId.get()); + + return ( ret == 1 ); +} + result _AppWidgetView::OnAttachedToMainTree(void) { @@ -428,7 +451,7 @@ bool _AppWidgetView::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { int type = livebox_lb_type(__pAppWidget); - if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled()) { double x = 0.0; double y = 0.0; @@ -449,7 +472,7 @@ _AppWidgetView::OnTouchReleased(const _Control& source, const _TouchInfo& touchI Point position(_CoordinateSystemUtils::ConvertToInteger(touchInfo.GetCurrentPosition())); FloatPoint floatPosition(static_cast(position.x), static_cast(position.y)); - if (clientBounds.Contains(floatPosition)) + if (clientBounds.Contains(floatPosition) && IsTouchEffectEnabled()) { PlayClickAnimation(); } @@ -459,7 +482,7 @@ _AppWidgetView::OnTouchReleased(const _Control& source, const _TouchInfo& touchI GetTouchPostion(floatPosition, x, y); int type = livebox_lb_type(__pAppWidget); - if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled()) { livebox_content_event(__pAppWidget, LB_MOUSE_UP, x, y); } @@ -473,7 +496,7 @@ bool _AppWidgetView::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) { int type = livebox_lb_type(__pAppWidget); - if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + if (((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) && IsTouchEventEnabled()) { double x = 0.0; double y = 0.0; diff --git a/src/FShell_AppWidgetView.h b/src/FShell_AppWidgetView.h index f4e782b..993e75c 100644 --- a/src/FShell_AppWidgetView.h +++ b/src/FShell_AppWidgetView.h @@ -98,6 +98,8 @@ private: void PlayClickAnimation(void); void PlayFlickAnimation(void); void GetRemainingSpace(int& lower, int& upper) const; + bool IsTouchEventEnabled(void) const; + bool IsTouchEffectEnabled(void) const; virtual result OnAttachedToMainTree(void); virtual result OnDetachingFromMainTree(void); -- 2.7.4