applied function ( Swipe to move the text)
authorChulheon <ch.jeong47@samsung.com>
Fri, 31 May 2013 10:34:24 +0000 (19:34 +0900)
committerChulheon <ch.jeong47@samsung.com>
Fri, 31 May 2013 10:38:45 +0000 (19:38 +0900)
Change-Id: I58c5530b0eac7e10a9d5e5c9c0021f7c4a681e98

src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/inc/FUiCtrl_EditPresenter.h

index a7b41c9..3b82178 100644 (file)
@@ -1403,6 +1403,9 @@ _EditPresenter::Initialize(const _Control& control)
 
        __pScrollEffect->previousY = -1.0f;
        __pScrollEffect->currentY = -1.0f;
+       __pScrollEffect->previousX = -1.0f;
+       __pScrollEffect->currentX = -1.0f;
+       __pScrollEffect->cursorPosition = -1;
 
        pEditModel = new (std::nothrow) _EditModel;
        SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
@@ -2893,6 +2896,9 @@ _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchIn
 
        __pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
        __pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
+       __pScrollEffect->previousX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
+       __pScrollEffect->currentX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
+       __pScrollEffect->cursorPosition = GetCursorPosition();
 
        FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
 
@@ -3218,59 +3224,123 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
                        return true;
                }
 
-               int newIndex = -1;
-               FloatRectangle fromBounds;
-               FloatRectangle toBounds;
-
-               CalculateCursorBounds(__textObjectBounds, fromBounds);
-               newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
-               if (newIndex != -1)
+               if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
                {
-                       if (Math::Abs(newIndex - __cursorPos) > 3)
+                       float   horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
+                       FloatDimension currentCharacterDimension;
+                       int currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+                       int currentLineLength = __pTextObject->GetTextLengthAtLine(0);
+                       if (horizontalGap < 0.0f && currentLineOffset+currentLineLength < GetTextLength())
                        {
-                               return true;
-                       }
-
-                       CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
-                       __isCursorChanged = true;
-                       SetCursorPosition(newIndex);
-
-                       __isMovingCursorByTouchMove = true;
-                       __isTouchReleaseSkipped = true;
-
-                       StopCursorTimer();
-                       MoveCursor(fromBounds, toBounds);
-                       __pEdit->Invalidate();
+                               currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset+currentLineLength, 1);
+                               if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+                               {
+                                       __pScrollEffect->previousX = __pScrollEffect->currentX;
+                                       __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+                                       __isMovingCursorByTouchMove = true;
+                                       __isTouchReleaseSkipped = true;
+                                       StopCursorTimer();
 
-                       return true;
-               }
+                                       SetCursorPosition(currentLineOffset+currentLineLength+1);
+                                       UpdateComponentInformation();
 
-               if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
-               {
-                       float   horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
-                       FloatDimension currentCharacterDimension;
-                       if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
+                                       currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+                                       if (__pScrollEffect->cursorPosition > currentLineOffset)
+                                       {
+                                               SetCursorPosition(__pScrollEffect->cursorPosition);
+                                       }
+                                       else
+                                       {
+                                               __pScrollEffect->cursorPosition = currentLineOffset + 1;
+                                               SetCursorPosition(__pScrollEffect->cursorPosition);
+                                       }
+                                       __pEdit->Invalidate();
+                                       return true;
+                               }
+                       }
+                       if (horizontalGap > 0.0f && currentLineOffset > 0)
                        {
-                               currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
+                               currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset-1, 1);
                                if (horizontalGap >= currentCharacterDimension.width)
                                {
-                                       SetCursorPosition(__cursorPos+1);
+                                       __pScrollEffect->previousX = __pScrollEffect->currentX;
+                                       __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+                                       __isMovingCursorByTouchMove = true;
+                                       __isTouchReleaseSkipped = true;
+                                       StopCursorTimer();
+
+                                       SetCursorPosition(currentLineOffset);
+                                       UpdateComponentInformation();
+                                       currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
+                                       currentLineLength = __pTextObject->GetTextLengthAtLine(0);
+                                       if (__pScrollEffect->cursorPosition < currentLineOffset + currentLineLength)
+                                       {
+                                               SetCursorPosition(__pScrollEffect->cursorPosition);
+                                       }
+                                       else
+                                       {
+                                               __pScrollEffect->cursorPosition = currentLineOffset + currentLineLength;
+                                               SetCursorPosition(__pScrollEffect->cursorPosition);
+                                       }
                                        __pEdit->Invalidate();
                                        return true;
                                }
                        }
-                       if (horizontalGap < 0.0f && __cursorPos > 0)
+               }
+               else
+               {
+                       int newIndex = -1;
+                       FloatRectangle fromBounds;
+                       FloatRectangle toBounds;
+                       CalculateCursorBounds(__textObjectBounds, fromBounds);
+                       newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
+                       if (newIndex != -1)
                        {
-                               currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
-                               if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+                               if (Math::Abs(newIndex - __cursorPos) > 3)
                                {
-                                       SetCursorPosition(__cursorPos-1);
-                                       __pEdit->Invalidate();
                                        return true;
                                }
+
+                               CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
+                               __isCursorChanged = true;
+                               SetCursorPosition(newIndex);
+
+                               __isMovingCursorByTouchMove = true;
+                               __isTouchReleaseSkipped = true;
+
+                               StopCursorTimer();
+                               MoveCursor(fromBounds, toBounds);
+                               __pEdit->Invalidate();
+
+                               return true;
                        }
-               }
 
+                               if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+                       {
+                               float   horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
+                               FloatDimension currentCharacterDimension;
+                               if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
+                               {
+                                       currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
+                                       if (horizontalGap >= currentCharacterDimension.width)
+                                       {
+                                               SetCursorPosition(__cursorPos+1);
+                                               __pEdit->Invalidate();
+                                               return true;
+                                       }
+                               }
+                               if (horizontalGap < 0.0f && __cursorPos > 0)
+                               {
+                                       currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
+                                       if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+                                       {
+                                               SetCursorPosition(__cursorPos-1);
+                                               __pEdit->Invalidate();
+                                               return true;
+                                       }
+                               }
+                       }
+               }
                if (__isMovingCursorByTouchMove)
                {
                        return true;
index a19036e..35594a3 100644 (file)
@@ -79,7 +79,10 @@ struct _EditScrollEffectInfo
 {
        float previousY;
        float currentY;
+       float previousX;
+       float currentX;
        float effectGap;
+       int cursorPosition;
        int effectFrame;
        int touchScrollFrameLevel[EDIT_SCROLLFRAME_MAX];
 };