From: Seongjun Yim Date: Fri, 29 Mar 2013 10:18:42 +0000 (+0900) Subject: refactoring gesture module X-Git-Tag: 2.1b_release~53^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50dd09d3d33542e0b6fb1ba86906edec972f7756;p=platform%2Fframework%2Fnative%2Fweb.git refactoring gesture module Change-Id: Ie081b4447922f1850da06c4c0e59585b57597ed9 Signed-off-by: Seongjun Yim --- diff --git a/src/controls/FWebCtrl_GestureState.cpp b/src/controls/FWebCtrl_GestureState.cpp index b0b9924..a7bd5a0 100755 --- a/src/controls/FWebCtrl_GestureState.cpp +++ b/src/controls/FWebCtrl_GestureState.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "FWebCtrl_GestureState.h" #include "FWebCtrl_Web.h" @@ -51,8 +50,6 @@ static const double PINCH_ZOOM_DISTANCE_TOLERANCE = 40.0; void SetGestureEvent(Ewk_Event_Gesture& gestureEvent, Ewk_Gesture_Type gestureType, const Point& absPoint, const Point& velocity, double scale, int count) { - memset(&gestureEvent, 0, sizeof(gestureEvent)); - gestureEvent.type = gestureType; gestureEvent.position.x = absPoint.x; gestureEvent.position.y = absPoint.y; @@ -64,10 +61,10 @@ SetGestureEvent(Ewk_Event_Gesture& gestureEvent, Ewk_Gesture_Type gestureType, c } -_TapGestureState::_TapGestureState(_Web* pWeb, _PinchGestureState* pPinchListener) +_TapGestureState::_TapGestureState(_Web* pWeb) : __pWebCore(pWeb) - , __pPinchListener(pPinchListener) , __longPressed(false) + , __doubleTapped(false) { } @@ -77,202 +74,117 @@ _TapGestureState::~_TapGestureState(void) } -void -_TapGestureState::OnLongPressGestureDetected(const _TouchLongPressGestureDetector& gesture) +bool +_TapGestureState::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) { - __longPressed = true; - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); SysAssertf(pSmartData, "Failed to get webkit smart data."); Ewk_Event_Gesture gestureEvent; - SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0, 0); + SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0.0, 0); pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); -} - - -bool -_TapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) -{ - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); - SysAssertf(pSmartData, "Failed to get webkit smart data."); - - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - SysAssertf(pTouchManager, "Failed to get webkit smart data."); - - if (pTouchManager->GetPointCount() == 2) - { - result r = E_SUCCESS; - - std::unique_ptr > pTouchList(pTouchManager->GetMultiFingerInfoListN()); - SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - std::unique_ptr > pEnum(pTouchList->GetBidirectionalEnumeratorN()); - SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - _FingerInfo* pFingerInfo = null; - - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); - - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); - - __pPinchListener->InitializeFactor(); - double zoomFactor = __pPinchListener->GetZoomFactor(firstFinger, secondFinger); - Point center(__pPinchListener->GetCenterPoint(firstFinger, secondFinger)); - - Point absPoint = __pWebCore->GetAbsoluteCoordinate(center); - - Ewk_Event_Gesture gestureEvent; - - SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0); - pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); - - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH); - } - else - { - __longPressed = false; - - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - - Ewk_Event_Gesture gestureEvent; - - SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 1); - pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); - } + __longPressed = true; return true; } bool -_TapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +_TapGestureState::OnTapGestureDetected(_TouchTapGestureDetector& gesture) { - if (__pWebCore->GetWebSettingImpl()->IsScrollEnabled()) - { - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); - SysAssertf(pSmartData, "Failed to get webkit smart data."); - - Ewk_Event_Gesture gestureEvent; - - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - - SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0); - pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); - - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING); - } + __doubleTapped = true; return true; } bool -_TapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +_TapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); SysAssertf(pSmartData, "Failed to get webkit smart data."); - if (!__longPressed) - { - Ewk_Event_Gesture gestureEvent; + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); + Ewk_Event_Gesture gestureEvent; - SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 1); - pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); - } + SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, 1); + pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); + + __longPressed = false; + __doubleTapped = false; return true; } bool -_TapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +_TapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) { const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); SysAssertf(pSmartData, "Failed to get webkit smart data."); Ewk_Event_Gesture gestureEvent; - SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0, 0); - pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); - - return true; -} - - -_DoubleTapGestureState::_DoubleTapGestureState(_Web* pWeb) - : __pWebCore(pWeb) -{ -} - + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); -_DoubleTapGestureState::~_DoubleTapGestureState(void) -{ -} + SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0); + pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); + __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING); -bool -_DoubleTapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) -{ return true; } bool -_DoubleTapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +_TapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) { - return true; -} - + if (__longPressed) + { + return true; + } -bool -_DoubleTapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) -{ const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); SysAssertf(pSmartData, "Failed to get webkit smart data."); Ewk_Event_Gesture gestureEvent; - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 2); - pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); + if (__doubleTapped) + { + SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, 2); + pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); + } + else + { + SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, 1); + } pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); - return true; } bool -_DoubleTapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +_TapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) { - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); + const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); + SysAssertf(pSmartData, "Failed to get webkit smart data."); + + Ewk_Event_Gesture gestureEvent; + + SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0.0, 0); + pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); return true; } -_PanningGestureState::_PanningGestureState(_Web* pWeb, _PinchGestureState* pPinchListener) +_PanningGestureState::_PanningGestureState(_Web* pWeb) : __pWebCore(pWeb) - , __pPinchListener(pPinchListener) { } @@ -285,52 +197,6 @@ _PanningGestureState::~_PanningGestureState(void) bool _PanningGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { - result r = E_SUCCESS; - - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); - SysAssertf(pSmartData, "Failed to get webkit smart data."); - - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - SysAssertf(pTouchManager, "Failed to get webkit smart data."); - - std::unique_ptr > pTouchList(pTouchManager->GetMultiFingerInfoListN()); - SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - std::unique_ptr > pEnum(pTouchList->GetBidirectionalEnumeratorN()); - SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - _FingerInfo* pFingerInfo = null; - - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); - - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); - - __pPinchListener->InitializeFactor(); - - double zoomFactor = __pPinchListener->GetZoomFactor(firstFinger, secondFinger); - Point center(__pPinchListener->GetCenterPoint(firstFinger, secondFinger)); - - Point absPoint = __pWebCore->GetAbsoluteCoordinate(center); - - Ewk_Event_Gesture gestureEvent; - - SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0); - pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); - - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH); - return true; } @@ -338,18 +204,15 @@ _PanningGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& t bool _PanningGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) { - if (__pWebCore->GetWebSettingImpl()->IsScrollEnabled()) - { - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); - SysAssertf(pSmartData, "Failed to get webkit smart data."); + const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); + SysAssertf(pSmartData, "Failed to get webkit smart data."); - Ewk_Event_Gesture gestureEvent; + Ewk_Event_Gesture gestureEvent; - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0); - pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); - } + SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0); + pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); return true; } @@ -365,7 +228,7 @@ _PanningGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0); + SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0); pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); @@ -393,14 +256,18 @@ _FlickGestureState::~_FlickGestureState(void) } -void -_FlickGestureState::OnFlickGestureDetected(const _TouchFlickGestureDetector& gesture) +bool +_FlickGestureState::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) { + __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_FLICK); + int duration = gesture.GetDuration(); gesture.GetDistance(__velocity.x, __velocity.y); __velocity.x = (__velocity.x * FLICK_SCROLL_WEIGHT) / duration; __velocity.y = (__velocity.y * FLICK_SCROLL_WEIGHT) / duration; + + return true; } @@ -414,10 +281,10 @@ _FlickGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& tou Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0); + SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0); pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); - SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, absPoint, Point(0, 0), 0, 0); + SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, Point(0, 0), Point(0, 0), 0.0, 0); pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); @@ -459,6 +326,7 @@ _FlickGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& to _PinchGestureState::_PinchGestureState(_Web* pWeb) : __pWebCore(pWeb) + , __standardScale(0.0) { } @@ -467,131 +335,72 @@ _PinchGestureState::~_PinchGestureState(void) { } -void -_PinchGestureState::InitializeFactor(void) -{ - __baseDistance = 0; - __distanceTolerance = PINCH_ZOOM_DISTANCE_TOLERANCE; -} - -double -_PinchGestureState::GetZoomFactor(const Point& firstFinger, const Point& secondFinger) -{ - int diffX = secondFinger.x - firstFinger.x; - int diffY = secondFinger.y - firstFinger.y; - int distance = static_cast < int >(sqrt((diffX * diffX) + (diffY * diffY))); - double relativeFactor = 1.0; - if (!__baseDistance) - { - __baseDistance = distance; - return relativeFactor; - } - - if (__distanceTolerance) - { - if (distance < (__baseDistance - __distanceTolerance)) - { - __baseDistance -= __distanceTolerance; - __distanceTolerance = 0; - } - else if (distance > (__baseDistance + __distanceTolerance)) - { - __baseDistance += __distanceTolerance; - __distanceTolerance= 0; - } - - return relativeFactor; - } - relativeFactor = 1.0 + (((distance - __baseDistance) / static_cast < double >(__baseDistance)) * PINCH_ZOOM_FINGER_FACTOR); - - return relativeFactor; -} - - -Point -_PinchGestureState::GetCenterPoint(const Point& firstFinger, const Point& secondFinger) +bool +_PinchGestureState::OnPinchGestureStarted(_TouchPinchGestureDetector& gesture) { - int diffX = fabs(secondFinger.x - firstFinger.x); - int diffY = fabs(secondFinger.y - firstFinger.y); - double distance = sqrt((diffX * diffX) + (diffY * diffY)); - - Point center; + __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH); - if (diffX && diffY) - { - double ratio = atan((diffY / static_cast < double >(diffX))); - int additionalX = static_cast < int >((distance / 2) * cos(ratio)); - int additionalY = static_cast < int >((distance / 2) * sin(ratio)); + const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); + SysAssertf(pSmartData, "Failed to get webkit smart data."); - center.x = (secondFinger.x > firstFinger.x) ? (firstFinger.x + additionalX) : (secondFinger.x + additionalX); - center.y = (secondFinger.y > firstFinger.y) ? (firstFinger.y + additionalY) : (secondFinger.y + additionalY); - } - else - { - center.x = (firstFinger.x + secondFinger.x) / 2; - center.y = (firstFinger.y + secondFinger.y) / 2; - } + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(gesture.GetCenterPointF()))); + __standardScale = static_cast< double >(gesture.GetScaleF()); - return center; -} + Ewk_Event_Gesture gestureEvent; + SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 1.0, 0); + pSmartData->api->gesture_start(const_cast(pSmartData), &gestureEvent); -bool -_PinchGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) -{ return true; } bool -_PinchGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +_PinchGestureState::OnPinchGestureChanged(_TouchPinchGestureDetector& gesture) { - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get(__pWebCore->GetWebNativeNode())); + const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); SysAssertf(pSmartData, "Failed to get webkit smart data."); - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - SysAssertf(pTouchManager, "Failed to get webkit smart data."); - - if (pTouchManager->GetPointCount() == 2) - { - result r = E_SUCCESS; - - Ewk_Event_Gesture gestureEvent; + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(gesture.GetCenterPointF()))); + double relScale = static_cast< double >(gesture.GetScaleF()) /__standardScale; - std::unique_ptr > pTouchList(pTouchManager->GetMultiFingerInfoListN()); - SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + Ewk_Event_Gesture gestureEvent; - std::unique_ptr > pEnum(pTouchList->GetBidirectionalEnumeratorN()); - SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), relScale, 0); + pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); - _FingerInfo* pFingerInfo = null; + return true; +} - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); +bool +_PinchGestureState::OnPinchGestureFinished(_TouchPinchGestureDetector& gesture) +{ + const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); + SysAssertf(pSmartData, "Failed to get webkit smart data."); - Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); + Ewk_Event_Gesture gestureEvent; - r = pEnum->MoveNext(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, Point(0, 0), Point(0, 0), 0.0, 0); + pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); - r = pEnum->GetCurrent(pFingerInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); - Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint())); + return true; +} - double zoomFactor = GetZoomFactor(firstFinger, secondFinger); - Point center(GetCenterPoint(firstFinger, secondFinger)); - Point absPoint = __pWebCore->GetAbsoluteCoordinate(center); +bool +_PinchGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + return true; +} - SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0); - pSmartData->api->gesture_move(const_cast(pSmartData), &gestureEvent); - } +bool +_PinchGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ return true; } @@ -599,24 +408,6 @@ _PinchGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touch bool _PinchGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) { - const Ewk_View_Smart_Data* pSmartData = static_cast(evas_object_smart_data_get( __pWebCore->GetWebNativeNode())); - SysAssertf(pSmartData, "Failed to get webkit smart data."); - - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - SysAssertf(pTouchManager, "Failed to get webkit smart data."); - - if (pTouchManager->GetPointCount() == 1) - { - Ewk_Event_Gesture gestureEvent; - - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - - SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 0, 0); - pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); - - __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); - } - return true; } @@ -629,9 +420,7 @@ _PinchGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& to Ewk_Event_Gesture gestureEvent; - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition()))); - - SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 0, 0); + SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, Point(0, 0), Point(0, 0), 0.0, 0); pSmartData->api->gesture_end(const_cast(pSmartData), &gestureEvent); __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP); diff --git a/src/controls/FWebCtrl_GestureState.h b/src/controls/FWebCtrl_GestureState.h index ba1bc50..9ca76f3 100755 --- a/src/controls/FWebCtrl_GestureState.h +++ b/src/controls/FWebCtrl_GestureState.h @@ -35,6 +35,10 @@ namespace Tizen { namespace Ui { class _Control; class _TouchInfo; +class _TouchFlickGestureDetector; +class _TouchLongPressGestureDetector; +class _TouchPinchGestureDetector; +class _TouchTapGestureDetector; }} // Tizen::Ui namespace Tizen { namespace Web { namespace Controls @@ -42,19 +46,17 @@ namespace Tizen { namespace Web { namespace Controls class _Web; -class _PinchGestureState +class _TapGestureState : public Tizen::Ui::_ITouchEventListener { public: - _PinchGestureState(_Web* pWeb); + _TapGestureState(_Web* pWeb); - virtual ~_PinchGestureState(void); - - void InitializeFactor(void); + virtual ~_TapGestureState(void); - Tizen::Graphics::Point GetCenterPoint(const Tizen::Graphics::Point& firstFinger, const Tizen::Graphics::Point& secondFinger); + bool OnLongPressGestureDetected(Tizen::Ui::_TouchLongPressGestureDetector& gesture); - double GetZoomFactor(const Tizen::Graphics::Point& firstFinger, const Tizen::Graphics::Point& secondFinger); + bool OnTapGestureDetected(Tizen::Ui::_TouchTapGestureDetector& gesture); virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); @@ -67,20 +69,19 @@ public: private: _Web* __pWebCore; - int __baseDistance; + bool __longPressed; - int __distanceTolerance; + bool __doubleTapped; }; -class _TapGestureState + +class _PanningGestureState : public Tizen::Ui::_ITouchEventListener { public: - _TapGestureState(_Web* pWeb, _PinchGestureState* pPinchListener); + _PanningGestureState(_Web* pWeb); - virtual ~_TapGestureState(void); - - void OnLongPressGestureDetected(const Tizen::Ui::_TouchLongPressGestureDetector& gesture); + virtual ~_PanningGestureState(void); virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); @@ -92,19 +93,17 @@ public: private: _Web* __pWebCore; - - _PinchGestureState* __pPinchListener; - - bool __longPressed; }; -class _DoubleTapGestureState +class _FlickGestureState : public Tizen::Ui::_ITouchEventListener { public: - _DoubleTapGestureState(_Web* pWeb); + _FlickGestureState(_Web* pWeb); - virtual ~_DoubleTapGestureState(void); + virtual ~_FlickGestureState(void); + + bool OnFlickGestureDetected(Tizen::Ui::_TouchFlickGestureDetector& gesture); virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); @@ -116,39 +115,23 @@ public: private: _Web* __pWebCore; + + Tizen::Graphics::Point __velocity; }; -class _PanningGestureState +class _PinchGestureState : public Tizen::Ui::_ITouchEventListener { public: - _PanningGestureState(_Web* pWeb, _PinchGestureState* pPinchListener); - - virtual ~_PanningGestureState(void); - - virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); - - virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); - - virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); - - virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + _PinchGestureState(_Web* pWeb); -private: - _Web* __pWebCore; + virtual ~_PinchGestureState(void); - _PinchGestureState* __pPinchListener; -}; + bool OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture); -class _FlickGestureState - : public Tizen::Ui::_ITouchEventListener -{ -public: - _FlickGestureState(_Web* pWeb); - - virtual ~_FlickGestureState(void); + bool OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture); - void OnFlickGestureDetected(const Tizen::Ui::_TouchFlickGestureDetector& gesture); + bool OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture); virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); @@ -161,7 +144,7 @@ public: private: _Web* __pWebCore; - Tizen::Graphics::Point __velocity; + double __standardScale; }; }}} // Tizen::Web::Controls diff --git a/src/controls/FWebCtrl_Utility.cpp b/src/controls/FWebCtrl_Utility.cpp index e169d32..cd3cd0b 100755 --- a/src/controls/FWebCtrl_Utility.cpp +++ b/src/controls/FWebCtrl_Utility.cpp @@ -51,6 +51,7 @@ _Utility::~_Utility(void) { } + Evas* _Utility::GetEvasFromUiApp() { diff --git a/src/controls/FWebCtrl_Web.cpp b/src/controls/FWebCtrl_Web.cpp index 1a3eca8..e946f6a 100755 --- a/src/controls/FWebCtrl_Web.cpp +++ b/src/controls/FWebCtrl_Web.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -118,14 +119,15 @@ static const char WEB_CTRL[] = "webcontrol"; _Web::_Web(void) - : __pGestureHandler(null) + : __gestureType(WEB_GESTURE_TYPE_TAP) + , __pGestureHandler(null) , __pEflWebkit(null) , __pGestureFlick(null) , __pGestureLongPress(null) + , __pGesturePinch(null) , __pGestureDoubleTap(null) , __pTouchEventInfoList(null) , __pTapGestureHandler(null) - , __pDoubleTapGestureHandler(null) , __pPanningGestureHandler(null) , __pFlickGestureHandler(null) , __pPinchGestureHandler(null) @@ -185,13 +187,10 @@ _Web::InitializeGestureStates(void) __pPinchGestureHandler = std::unique_ptr<_PinchGestureState>(new (std::nothrow) _PinchGestureState(this)); SysTryReturnResult(NID_WEB_CTRL, __pPinchGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this, __pPinchGestureHandler.get())); + __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this)); SysTryReturnResult(NID_WEB_CTRL, __pTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - __pDoubleTapGestureHandler = std::unique_ptr<_DoubleTapGestureState>(new (std::nothrow) _DoubleTapGestureState(this)); - SysTryReturnResult(NID_WEB_CTRL, __pDoubleTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this, __pPinchGestureHandler.get())); + __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this)); SysTryReturnResult(NID_WEB_CTRL, __pPanningGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); __pFlickGestureHandler = std::unique_ptr<_FlickGestureState>(new (std::nothrow) _FlickGestureState(this)); @@ -208,13 +207,10 @@ _Web::AddGestureListeners(void) { result r = E_SUCCESS; - _ITouchFlickGestureEventListener* pFlickListener = dynamic_cast< _ITouchFlickGestureEventListener* >(this); - SysAssertf(pFlickListener != null, "Failed to get flick gesture listener"); - std::unique_ptr<_TouchFlickGestureDetector> pGestureFlick(new (std::nothrow) _TouchFlickGestureDetector()); SysTryReturnResult(NID_WEB_CTRL, pGestureFlick.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pGestureFlick->AddGestureListener(*pFlickListener); + r = pGestureFlick->AddGestureListener(*this); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); r = AddGestureDetector(*pGestureFlick.get()); @@ -222,13 +218,10 @@ _Web::AddGestureListeners(void) __pGestureFlick = std::move(pGestureFlick); - _ITouchLongPressGestureEventListener* pLongPressListener = dynamic_cast< _ITouchLongPressGestureEventListener* >(this); - SysAssertf(pLongPressListener != null, "Failed to get longpress gesture listener"); - std::unique_ptr<_TouchLongPressGestureDetector> pGestureLongPress(new (std::nothrow) _TouchLongPressGestureDetector()); SysTryReturnResult(NID_WEB_CTRL, pGestureLongPress.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pGestureLongPress->AddGestureListener(*pLongPressListener); + r = pGestureLongPress->AddGestureListener(*this); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); r = AddGestureDetector(*pGestureLongPress.get()); @@ -236,13 +229,10 @@ _Web::AddGestureListeners(void) __pGestureLongPress = std::move(pGestureLongPress); - _ITouchTapGestureEventListener* pDoubleTapListener = dynamic_cast< _ITouchTapGestureEventListener* >(this); - SysAssertf(pDoubleTapListener != null, "Failed to get tap gesture listener"); - std::unique_ptr<_TouchTapGestureDetector> pGestureDoubleTap(new (std::nothrow) _TouchTapGestureDetector()); SysTryReturnResult(NID_WEB_CTRL, pGestureDoubleTap.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pGestureDoubleTap->AddGestureListener(*pDoubleTapListener); + r = pGestureDoubleTap->AddGestureListener(*this); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); r = AddGestureDetector(*pGestureDoubleTap.get()); @@ -250,6 +240,17 @@ _Web::AddGestureListeners(void) __pGestureDoubleTap = std::move(pGestureDoubleTap); + std::unique_ptr<_TouchPinchGestureDetector> pGesturePinch(new (std::nothrow) _TouchPinchGestureDetector()); + SysTryReturnResult(NID_WEB_CTRL, pGesturePinch.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = pGesturePinch->AddGestureListener(*this); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AddGestureDetector(*pGesturePinch.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pGesturePinch = std::move(pGesturePinch); + return E_SUCCESS; } @@ -259,24 +260,27 @@ _Web::RemoveGestureListener(void) { if (__pGestureFlick.get()) { - _ITouchFlickGestureEventListener* pListener = dynamic_cast< _ITouchFlickGestureEventListener* >(this); - __pGestureFlick->RemoveGestureListener(*pListener); + __pGestureFlick->RemoveGestureListener(*this); RemoveGestureDetector(*__pGestureFlick); } if (__pGestureLongPress.get()) { - _ITouchLongPressGestureEventListener* pListener = dynamic_cast< _ITouchLongPressGestureEventListener* >(this); - __pGestureLongPress->RemoveGestureListener(*pListener); + __pGestureLongPress->RemoveGestureListener(*this); RemoveGestureDetector(*__pGestureLongPress); } if (__pGestureDoubleTap.get()) { - _ITouchTapGestureEventListener* pListener = dynamic_cast< _ITouchTapGestureEventListener* >(this); - __pGestureDoubleTap->RemoveGestureListener(*pListener); + __pGestureDoubleTap->RemoveGestureListener(*this); RemoveGestureDetector(*__pGestureDoubleTap); } + + if (__pGesturePinch.get()) + { + __pGesturePinch->RemoveGestureListener(*this); + RemoveGestureDetector(*__pGesturePinch); + } } @@ -307,56 +311,28 @@ _Web::InitializeWebNativeNode(void) Point _Web::GetAbsoluteCoordinate(Point relativePoint) { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer(); - SysAssertf(pXformer, "Failed to get coordinate transformer."); - - int absX = pXformer->TransformHorizontal(relativePoint.x + GetAbsoluteBounds().x); - int absY = pXformer->TransformVertical(relativePoint.y + GetAbsoluteBounds().y); - - return Point(absX, absY); + return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint)); } FloatPoint _Web::GetAbsoluteCoordinate(FloatPoint relativePoint) { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer(); - SysAssertf(pXformer, "Failed to get coordinate transformer."); - - float absX = pXformer->TransformHorizontal(relativePoint.x + GetAbsoluteBoundsF().x); - float absY = pXformer->TransformVertical(relativePoint.y + GetAbsoluteBoundsF().y); - - return FloatPoint(absX, absY); + return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint)); } Point _Web::GetRelativeCoordinate(Point absolutePoint) { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); - SysAssertf(pXformer, "Failed to get coordinate transformer."); - - Point bound(GetAbsoluteCoordinate(Point(0, 0))); - - int absX = pXformer->TransformHorizontal(absolutePoint.x - bound.x); - int absY = pXformer->TransformVertical(absolutePoint.y - bound.y); - - return Point(absX, absY); + return _CoordinateSystemUtils::InverseTransform(ConvertToControlPosition(absolutePoint)); } FloatPoint _Web::GetRelativeCoordinate(FloatPoint absolutePoint) { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); - SysAssertf(pXformer, "Failed to get coordinate transformer."); - - FloatPoint bound(GetAbsoluteCoordinate(FloatPoint(0.0, 0.0))); - - float absX = pXformer->TransformHorizontal(absolutePoint.x - bound.x); - float absY = pXformer->TransformVertical(absolutePoint.y - bound.y); - - return FloatPoint(absX, absY); + return _CoordinateSystemUtils::InverseTransform(ConvertToControlPosition(absolutePoint)); } @@ -421,22 +397,22 @@ _Web::ChangeGesture(_WebGestureType type) { case WEB_GESTURE_TYPE_TAP: __pGestureHandler = __pTapGestureHandler.get(); + __gestureType = WEB_GESTURE_TYPE_TAP; break; - case WEB_GESTURE_TYPE_DOUBLE_TAP: - __pGestureHandler = __pDoubleTapGestureHandler.get(); - break; - case WEB_GESTURE_TYPE_PANNING: __pGestureHandler = __pPanningGestureHandler.get(); + __gestureType = WEB_GESTURE_TYPE_PANNING; break; case WEB_GESTURE_TYPE_FLICK: __pGestureHandler = __pFlickGestureHandler.get(); + __gestureType = WEB_GESTURE_TYPE_FLICK; break; case WEB_GESTURE_TYPE_PINCH: __pGestureHandler = __pPinchGestureHandler.get(); + __gestureType = WEB_GESTURE_TYPE_PINCH; break; default: @@ -452,7 +428,7 @@ _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { SendTouchEventForJavaScript(touchInfo); - __pGestureHandler->OnTouchPressed(source, touchInfo); + return __pGestureHandler->OnTouchPressed(source, touchInfo); } return true; @@ -462,11 +438,11 @@ _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) bool _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) { - if (__pEflWebkit.get()) + if (__pEflWebkit.get() && __pWebSettingImpl->IsScrollEnabled()) { SendTouchEventForJavaScript(touchInfo); - __pGestureHandler->OnTouchMoved(source, touchInfo); + return __pGestureHandler->OnTouchMoved(source, touchInfo); } return true; @@ -480,11 +456,11 @@ _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) { SendTouchEventForJavaScript(touchInfo); - __pGestureHandler->OnTouchReleased(source, touchInfo); + return __pGestureHandler->OnTouchReleased(source, touchInfo); _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(GetWebNativeNode(), WEB_CTRL)); - if (pWebImpl && pWebImpl->GetLoadingListener() && pWebImpl->GetTextFromBlock().GetLength() > 0) + if (pWebImpl->GetLoadingListener() && pWebImpl->GetTextFromBlock().GetLength() > 0) { pWebImpl->FireWebPageBlockSelectedEvent(); } @@ -495,6 +471,7 @@ _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) return true; } + bool _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) { @@ -509,13 +486,74 @@ _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) } +void +_Web::OnTouchPressHandled(const _Control& control) +{ +} + + +void +_Web::OnTouchReleaseHandled(const _Control& control) +{ +} + + +void +_Web::OnTouchMoveHandled(const _Control& control) +{ +} + + +void +_Web::OnTouchCancelHandled(const _Control& control) +{ +} + + +bool +_Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_TAP) + { + return __pTapGestureHandler->OnLongPressGestureDetected(gesture); + } + + return true; +} + + +bool +_Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return true; +} + + +bool +_Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +{ + if (__pEflWebkit.get()) + { + return __pTapGestureHandler->OnTapGestureDetected(gesture); + } + + return true; +} + + +bool +_Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +{ + return true; +} + + bool _Web::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) { if (__pEflWebkit.get() && __pWebSettingImpl->IsScrollEnabled()) { - ChangeGesture(WEB_GESTURE_TYPE_FLICK); - static_cast< _FlickGestureState* >(__pGestureHandler)->OnFlickGestureDetected(gesture); + return __pFlickGestureHandler->OnFlickGestureDetected(gesture); } return true; @@ -530,15 +568,11 @@ _Web::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) bool -_Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +_Web::OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture) { if (__pEflWebkit.get()) { - _TapGestureState* pTapGestureHandler = dynamic_cast< _TapGestureState* >(__pGestureHandler); - if (pTapGestureHandler) - { - pTapGestureHandler->OnLongPressGestureDetected(gesture); - } + return __pPinchGestureHandler->OnPinchGestureStarted(gesture); } return true; @@ -546,18 +580,23 @@ _Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) bool -_Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +_Web::OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture) { + if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH) + { + return __pPinchGestureHandler->OnPinchGestureChanged(gesture); + } + return true; } bool -_Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +_Web::OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture) { - if (__pEflWebkit.get()) + if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH) { - ChangeGesture(WEB_GESTURE_TYPE_DOUBLE_TAP); + return __pPinchGestureHandler->OnPinchGestureFinished(gesture); } return true; @@ -565,14 +604,14 @@ _Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture) bool -_Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +_Web::OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture) { return true; } Canvas* -_Web::OnCanvasRequestedN(const Dimension& size) +_Web::OnCanvasRequestedFN(const FloatRectangle& bounds) { result r = E_SUCCESS; @@ -580,9 +619,11 @@ _Web::OnCanvasRequestedN(const Dimension& size) Eina_Rectangle rect; BufferInfo bufferInfo; - Point absSize = GetAbsoluteCoordinate(Point(size.width, size.height)); + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(GetAbsoluteCoordinate(FloatPoint(bounds.x, bounds.y)))); + Dimension absSize(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::HorizontalTransform(bounds.width)), + _CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::VerticalTransform(bounds.height))); - EINA_RECTANGLE_SET(&rect, 0, 0, absSize.x, absSize.y); + EINA_RECTANGLE_SET(&rect, absPoint.x, absPoint.y, absSize.width, absSize.height); Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame)); SysTryReturn(NID_WEB_CTRL, pScreenShot, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM)); @@ -611,8 +652,8 @@ _Web::OnCapturedBitmapRequestedN(void) ByteBuffer buffer; BufferInfo bufferInfo; - Dimension size = GetSize(); - Point absSize = GetAbsoluteCoordinate(Point(size.width, size.height)); + Dimension size(GetSize()); + Point absSize(GetAbsoluteCoordinate(Point(size.width, size.height))); EINA_RECTANGLE_SET(&rect, 0, 0, absSize.x, absSize.y); diff --git a/src/controls/FWebCtrl_Web.h b/src/controls/FWebCtrl_Web.h index 5700f65..c6c5885 100755 --- a/src/controls/FWebCtrl_Web.h +++ b/src/controls/FWebCtrl_Web.h @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace Tizen { namespace Ui @@ -47,6 +48,7 @@ namespace Tizen { namespace Graphics class Canvas; class Dimension; class Point; +class FloatRectangle; }} // Tizen::Graphics namespace Tizen { namespace Web { namespace Controls @@ -54,7 +56,6 @@ namespace Tizen { namespace Web { namespace Controls class _EflWebkit; class _WebSettingImpl; class _TapGestureState; -class _DoubleTapGestureState; class _PanningGestureState; class _FlickGestureState; class _PinchGestureState; @@ -62,7 +63,6 @@ class _PinchGestureState; enum _WebGestureType { WEB_GESTURE_TYPE_TAP, - WEB_GESTURE_TYPE_DOUBLE_TAP, WEB_GESTURE_TYPE_PANNING, WEB_GESTURE_TYPE_FLICK, WEB_GESTURE_TYPE_PINCH @@ -72,6 +72,7 @@ class _Web : public Tizen::Ui::_Control , Tizen::Ui::_ITouchFlickGestureEventListener , Tizen::Ui::_ITouchLongPressGestureEventListener + , Tizen::Ui::_ITouchPinchGestureEventListener , Tizen::Ui::_ITouchTapGestureEventListener , virtual public Tizen::Base::Runtime::IEventListener , virtual public Tizen::Ui::_IUiEventListener @@ -92,43 +93,42 @@ public: void ChangeGesture(_WebGestureType type); Tizen::Graphics::Point GetAbsoluteCoordinate(Tizen::Graphics::Point relativePoint); - Tizen::Graphics::FloatPoint GetAbsoluteCoordinate(Tizen::Graphics::FloatPoint relativePoint); Tizen::Graphics::Point GetRelativeCoordinate(Tizen::Graphics::Point absolutePoint); - Tizen::Graphics::FloatPoint GetRelativeCoordinate(Tizen::Graphics::FloatPoint absolutePoint); void SetWebSettingImpl(Tizen::Web::Controls::_WebSettingImpl* pWebSettingImpl); - _WebSettingImpl* GetWebSettingImpl(void) const; virtual result OnAttaching(const _Control* pParent); - virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); - virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); - virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); - virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); - virtual bool OnFlickGestureDetected(Tizen::Ui::_TouchFlickGestureDetector& gesture); + virtual void OnTouchPressHandled(const Tizen::Ui::_Control& control); + virtual void OnTouchReleaseHandled(const Tizen::Ui::_Control& control); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + virtual void OnTouchCancelHandled(const Tizen::Ui::_Control& control); + virtual bool OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture); + + virtual bool OnFlickGestureDetected(Tizen::Ui::_TouchFlickGestureDetector& gesture); virtual bool OnFlickGestureCanceled(Tizen::Ui::_TouchFlickGestureDetector& gesture); virtual bool OnLongPressGestureDetected(Tizen::Ui::_TouchLongPressGestureDetector& gesture); - virtual bool OnLongPressGestureCanceled(Tizen::Ui::_TouchLongPressGestureDetector& gesture); virtual bool OnTapGestureDetected(Tizen::Ui::_TouchTapGestureDetector& gesture); - virtual bool OnTapGestureCanceled(Tizen::Ui::_TouchTapGestureDetector& gesture); - virtual Tizen::Graphics::Canvas* OnCanvasRequestedN(const Tizen::Graphics::Dimension& size); - + virtual Tizen::Graphics::Canvas* OnCanvasRequestedFN(const Tizen::Graphics::FloatRectangle& size); virtual Tizen::Graphics::Bitmap* OnCapturedBitmapRequestedN(void); private: @@ -161,19 +161,21 @@ private: std::unique_ptr __pGestureLongPress; + std::unique_ptr __pGesturePinch; + std::unique_ptr __pGestureDoubleTap; std::unique_ptr > __pTouchEventInfoList; std::unique_ptr<_TapGestureState> __pTapGestureHandler; - std::unique_ptr<_DoubleTapGestureState> __pDoubleTapGestureHandler; - std::unique_ptr<_PanningGestureState> __pPanningGestureHandler; std::unique_ptr<_FlickGestureState> __pFlickGestureHandler; std::unique_ptr<_PinchGestureState> __pPinchGestureHandler; + + _WebGestureType __gestureType; }; // _Web }}} // Tizen::Web::Controls