Modified return value of move event for scroll.
authorJongwooLee <jongwoo718.lee@samsung.com>
Wed, 5 Jun 2013 05:48:44 +0000 (14:48 +0900)
committerJongwooLee <jongwoo718.lee@samsung.com>
Wed, 5 Jun 2013 05:48:44 +0000 (14:48 +0900)
Change-Id: I081ac61613ce656834257b89e56b4386f4e8ebb1
Signed-off-by: JongwooLee <jongwoo718.lee@samsung.com>
src/ui/controls/FUiCtrl_Gallery.cpp
src/ui/controls/FUiCtrl_GalleryPresenter.cpp
src/ui/controls/FUiCtrl_GalleryViewEventHandler.cpp
src/ui/inc/FUiCtrl_GalleryViewEventHandler.h

index 0ef7b95..d7618d1 100644 (file)
@@ -425,6 +425,15 @@ _Gallery::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
        int distanceX = 0;
        int distanceY = 0;
        gesture.GetDistance(distanceX, distanceY);
+       if (gesture.GetDirection() == _FLICK_DIRECTION_RIGHT
+               || gesture.GetDirection() == _FLICK_DIRECTION_LEFT)
+       {
+               distanceY = 0;
+       }
+       else
+       {
+               distanceX = 0;
+       }
        Point flickPoint(distanceX, distanceY);
 
        viewEventInfo.SetFlickPosition(flickPoint);
@@ -550,12 +559,7 @@ _Gallery::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
        _GalleryViewEventInfo viewEventInfo(const_cast <_TouchInfo&>(touchinfo));
        _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_MOVED, &viewEventInfo);
 
-       bool r = GetPresenter().PostEvent(viewEvent);
-       SysTryReturn(NID_UI_CTRL, r == true, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
-
-       SetLastResult(E_SUCCESS);
-
-       return true;
+       return GetPresenter().PostEvent(viewEvent);
 }
 
 bool
index 3ccdebb..ff8ed59 100644 (file)
@@ -451,7 +451,7 @@ _GalleryPresenter::PostEvent(_GalleryViewEvent& event)
                        return OnBoundsChanged();
                }
                //SetLastResult(E_SUCCESS);
-               return true;
+               return false;
        }
 
        switch (event.GetEventType())
index 3651db2..915f0e0 100644 (file)
@@ -17,6 +17,7 @@
 #include <FBaseErrors.h>
 #include <FGrpFloatDimension.h>
 #include <FBaseSysLog.h>
+#include "FUi_Math.h"
 #include "FUiCtrl_GalleryImageReader.h"
 #include "FUiCtrl_GalleryPresenter.h"
 #include "FUiCtrl_GalleryViewEventInfo.h"
@@ -58,6 +59,8 @@ _GalleryViewEventHandler::_GalleryViewEventHandler(_GalleryPresenter& presenter,
        , __pinchMode(false)
        , __touchPointId(0)
        , __currentItemIndex(NO_CHANGE_ITEM_INDEX)
+       , __moveDirection(MOVE_DIRECTION_NONE)
+       , __endOfRange(false)
 {
        // Do nothing.
 }
@@ -131,6 +134,11 @@ _GalleryViewEventHandler::OnTouchDoublePressed(_GalleryViewEventInfo& eventInfo)
 bool
 _GalleryViewEventHandler::OnTouchMoved(_GalleryViewEventInfo& eventInfo)
 {
+       if (__moveDirection == MOVE_DIRECTION_VERTICAL)
+       {
+               return false;
+       }
+
        if (__pinchMode == true || __touchPointId != eventInfo.GetPointId())
        {
                return true;
@@ -150,7 +158,7 @@ _GalleryViewEventHandler::OnTouchMoved(_GalleryViewEventInfo& eventInfo)
 
        //SetLastResult(E_SUCCESS);
 
-       return true;
+       return __moveDirection == MOVE_DIRECTION_VERTICAL ? false : !__endOfRange;
 }
 
 bool
@@ -210,6 +218,7 @@ _GalleryViewEventHandler::OnTouchReleased(_GalleryViewEventInfo& eventInfo)
        r = RefreshView();
        SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
        __flickingDirection = FLICK_DIRECTION_NONE;
+       __moveDirection = MOVE_DIRECTION_NONE;
 
        //SetLastResult(E_SUCCESS);
 
@@ -318,9 +327,19 @@ _GalleryViewEventHandler::OnTouchFlicked(_GalleryViewEventInfo& eventInfo)
                return true;
        }
 
+       if (__moveDirection == MOVE_DIRECTION_VERTICAL)
+       {
+               return false;
+       }
+
        result r = E_SUCCESS;
        if (__zoomMode == false)
        {
+               if (eventInfo.GetFlickPosition(). x == 0)
+               {
+                       return false;
+               }
+
                __moving = true;
                if (eventInfo.GetFlickPosition().x > 0)
                {
@@ -366,7 +385,7 @@ _GalleryViewEventHandler::OnTouchFlicked(_GalleryViewEventInfo& eventInfo)
 
        //SetLastResult(E_SUCCESS);
 
-       return true;
+       return !__endOfRange;
 
 CATCH:
        SetRollbackCanvas();
@@ -566,6 +585,7 @@ _GalleryViewEventHandler::FlickToTheRight(void)
        FloatRectangle rect = viewRect;
        int currentItemIndex = __galleryPresenter.GetCurrentItemIndex();
        int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1);
+       __endOfRange = false;
 
        __flickingDirection = FLICK_DIRECTION_RIGHT;
        if (leftCanvasIndex == NOT_EXIST_CANVAS)
@@ -573,6 +593,7 @@ _GalleryViewEventHandler::FlickToTheRight(void)
                if (currentItemIndex - 1 < 0)
                {
                        __flickingDirection = FLICK_DIRECTION_NONE;
+                       __endOfRange = true;
                        return E_SUCCESS;
                }
                else
@@ -627,6 +648,7 @@ _GalleryViewEventHandler::FlickToTheLeft(void)
        FloatRectangle rect = viewRect;
        int currentItemIndex = __galleryPresenter.GetCurrentItemIndex();
        int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1);
+       __endOfRange = false;
 
        __flickingDirection = FLICK_DIRECTION_LEFT;
        if (rightCanvasIndex == NOT_EXIST_CANVAS)
@@ -634,6 +656,7 @@ _GalleryViewEventHandler::FlickToTheLeft(void)
                if (currentItemIndex + 1 >= __galleryPresenter.GetItemCount())
                {
                        __flickingDirection = FLICK_DIRECTION_NONE;
+                       __endOfRange = true;
                        return E_SUCCESS;
                }
                else
@@ -833,6 +856,7 @@ _GalleryViewEventHandler::MoveCanvas(const FloatDimension& distance, _GalleryAni
        int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex);
        int rightCanvasIndex = NOT_EXIST_CANVAS;
        int leftCanvasIndex = NOT_EXIST_CANVAS;
+       __endOfRange = false;
 
        if (currentItemIndex != 0)
        {
@@ -880,15 +904,26 @@ _GalleryViewEventHandler::MoveCanvas(const FloatDimension& distance, _GalleryAni
        }
        else
        {
+               if (__moveDirection == MOVE_DIRECTION_NONE && _Abs(distance.width) < _Abs(distance.height))
+               {
+                       __moveDirection = MOVE_DIRECTION_VERTICAL;
+                       return E_SUCCESS;
+               }
+               else
+               {
+                       __moveDirection = MOVE_DIRECTION_HORIZONTAL;
+               }
                rect.x -= distance.width;
        }
 
        if (rect.x > 0 && leftCanvasIndex == NOT_EXIST_CANVAS && __zoomMode == false)
        {
+               __endOfRange = true;
                return E_SUCCESS;
        }
        else if (rect.x < 0 && rightCanvasIndex == NOT_EXIST_CANVAS && __zoomMode == false)
        {
+               __endOfRange = true;
                return E_SUCCESS;
        }
 
index c732b9e..51bd407 100644 (file)
@@ -37,6 +37,13 @@ enum FlickDirection
        FLICK_DIRECTION_RIGHT
 };
 
+enum MoveDirection
+{
+       MOVE_DIRECTION_NONE = 0,
+       MOVE_DIRECTION_HORIZONTAL,
+       MOVE_DIRECTION_VERTICAL
+};
+
 class _GalleryImageReader;
 class _GalleryModel;
 class _GalleryPresenter;
@@ -110,6 +117,8 @@ private:
        bool __pinchMode;
        unsigned long __touchPointId;
        int __currentItemIndex;
+       MoveDirection __moveDirection;
+       bool __endOfRange;
 }; // _GalleryViewEventHandler
 
 }}} // Tizen::Ui::Controls