Fix for issue N_SE-56126
authorKunal Sinha <kunal.sinha@samsung.com>
Tue, 29 Oct 2013 15:29:29 +0000 (20:59 +0530)
committerKunal Sinha <kunal.sinha@samsung.com>
Wed, 30 Oct 2013 07:35:32 +0000 (13:05 +0530)
Change-Id: Idcd462abb7004543154ee407e8b70be7cbc8b0d2
Signed-off-by: Kunal Sinha <kunal.sinha@samsung.com>
src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/controls/FUiCtrl_TokenEditPresenter.cpp
src/ui/inc/FUiCtrl_EditPresenter.h

index 1cecf57..36115df 100644 (file)
@@ -3965,7 +3965,7 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
                        return true;
                }
 
-               if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+               if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
                {
                        float   horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
                        FloatRectangle lineBounds = __pTextObject->GetBoundsAtLineF(0);
@@ -3981,7 +3981,7 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
 
                                newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
 
-                               if (newTextDisplayPositionX >  lineBounds.width - __textObjectBounds.width)
+                               if (newTextDisplayPositionX > lineBounds.width - __textObjectBounds.width)
                                {
                                        newTextDisplayPositionX = lineBounds.width - __textObjectBounds.width;
                                }
@@ -4047,32 +4047,6 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
 
                                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)
                {
@@ -10741,12 +10715,16 @@ _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
 result
 _EditPresenter::SetTextBounds(Rectangle& bounds)
 {
-       __textObjectBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
-       if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+       FloatRectangle floatBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
+       if (__textObjectBounds != floatBounds)
        {
-               __pTextObject->SetBounds(__textObjectBounds);
-               __pTextObject->Compose();
-               __isCursorChanged = true;
+               __textObjectBounds = floatBounds;
+               if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+               {
+                       __pTextObject->SetBounds(__textObjectBounds);
+                       __pTextObject->Compose();
+                       __isCursorChanged = true;
+               }
        }
        return E_SUCCESS;
 }
@@ -10754,12 +10732,15 @@ _EditPresenter::SetTextBounds(Rectangle& bounds)
 result
 _EditPresenter::SetTextBounds(FloatRectangle& bounds)
 {
-       __textObjectBounds = bounds;
-       if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+       if (__textObjectBounds != bounds)
        {
-               __pTextObject->SetBounds(__textObjectBounds);
-               __pTextObject->Compose();
-               __isCursorChanged = true;
+               __textObjectBounds = bounds;
+               if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+               {
+                       __pTextObject->SetBounds(__textObjectBounds);
+                       __pTextObject->Compose();
+                       __isCursorChanged = true;
+               }
        }
        return E_SUCCESS;
 }
index abef4e9..394288d 100644 (file)
@@ -1293,6 +1293,7 @@ _TokenEditPresenter::RemoveTokenAt(int index, bool isClearText)
        r = CalculateTokenPositionFromIndex(index);
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to calculate token position.");
 
+
        r = SetInitialBounds();
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds.");
 
@@ -2186,64 +2187,67 @@ _TokenEditPresenter::SetTokenBoundsByTouchInfo(const _TouchInfo& touchinfo)
        result r = E_SUCCESS;
        float currentYPosition = touchinfo.GetCurrentPosition().y;
 
-       if (_FloatCompare(__prevScrollValue, 0.0f))
-       {
-               __prevScrollValue = currentYPosition;
-       }
-       else    // Adjust moved y position to all tokens.
+       if (!IsHorizontalDirection(touchinfo))
        {
-               if (__isNeedToScroll)       // Need to scroll
+               if (_FloatCompare(__prevScrollValue, 0.0f))
                {
-                       float tempDefference = __prevScrollValue - currentYPosition;
-
                        __prevScrollValue = currentYPosition;
-                       __scrollValue -= tempDefference;
-
-                       if (__scrollValue < -__maxScrollValue)
+               }
+               else    // Adjust moved y position to all tokens.
+               {
+                       if (__isNeedToScroll)       // Need to scroll
                        {
-                               __scrollValue = -__maxScrollValue;
+                               float tempDefference = __prevScrollValue - currentYPosition;
 
-                               return E_SUCCESS;
-                       }
+                               __prevScrollValue = currentYPosition;
+                               __scrollValue -= tempDefference;
 
-                       if (__scrollValue > 0.0f)
-                       {
-                               __scrollValue = 0.0f;
+                               if (__scrollValue < -__maxScrollValue)
+                               {
+                                       __scrollValue = -__maxScrollValue;
 
-                               return E_SUCCESS;
-                       }
+                                       return E_SUCCESS;
+                               }
 
-                       int tokenCount = GetTokenCount();
-                       CalculateTokenPositionFromIndex(0);
-                       for (int i = 0; i < tokenCount; i++)
-                       {
-                               _Token* pToken = null;
-                               pToken = static_cast< _Token* >(__pTokenList->GetAt(i));
+                               if (__scrollValue > 0.0f)
+                               {
+                                       __scrollValue = 0.0f;
 
-                               if (pToken != null)
+                                       return E_SUCCESS;
+                               }
+
+                               int tokenCount = GetTokenCount();
+                               CalculateTokenPositionFromIndex(0);
+                               for (int i = 0; i < tokenCount; i++)
+                               {
+                                       _Token* pToken = null;
+                                       pToken = static_cast< _Token* >(__pTokenList->GetAt(i));
+
+                                       if (pToken != null)
+                                       {
+                                               pToken->SetBounds(pToken->displayRect);
+                                       }
+                                       TrimTokenAndAdjustEllipsisAt(i);
+                                       InitializeTokenVisibilityAt(i);
+                               }
+
+                               if (__pTitleTextObject->GetTextLength() != 0)
                                {
-                                       pToken->SetBounds(pToken->displayRect);
+                                       __titleTextRect.y = __titleTextRectForScroll.y + __scrollValue;
                                }
-                               TrimTokenAndAdjustEllipsisAt(i);
-                               InitializeTokenVisibilityAt(i);
-                       }
 
-                       if (__pTitleTextObject->GetTextLength() != 0)
+                               __pTokenEdit->Invalidate();
+                       }
+                       else
                        {
-                               __titleTextRect.y = __titleTextRectForScroll.y + __scrollValue;
+                               __prevScrollValue = 0.0f;
+                               __scrollValue = 0.0f;
                        }
-
-                       __pTokenEdit->Invalidate();
-               }
-               else
-               {
-                       __prevScrollValue = 0.0f;
-                       __scrollValue = 0.0f;
                }
-       }
 
-       r = SetInitialBounds();
-       SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds.");
+               r = SetInitialBounds();
+               SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds.");
+       }
 
        return r;
 }
@@ -3625,7 +3629,7 @@ _TokenEditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touc
                                float totalHeight = GetTextBoundsF().y + GetTextBoundsF().height - __scrollValue + tokenBottomMargin;
                                float controlHeight = __pTokenEdit->GetBoundsF().height;
 
-                               if (totalHeight > controlHeight)
+                               if (totalHeight > controlHeight && (!IsHorizontalDirection(touchinfo)))
                                {
                                        pScroll->SetScrollVisibility(true);
                                }
index 9373664..49a16ce 100644 (file)
@@ -383,6 +383,7 @@ protected:
        _Edit* GetEditView(void) const;
        bool AdjustRTLTextAlignment(const _EditTextType textType);
        void RestoreCopyPasteManager(void);
+       bool IsHorizontalDirection(const _TouchInfo& touchInfo);
 
 private:
        virtual void OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action);
@@ -424,7 +425,6 @@ private:
        result DrawTextForEntireFontSetting(Tizen::Graphics::Canvas& canvas);
        result DrawTitleText(void);
        result MoveCursor(const Tizen::Graphics::FloatRectangle& fromRect, const Tizen::Graphics::FloatRectangle& toRect);
-       bool IsHorizontalDirection(const _TouchInfo& touchInfo);
        result ScrollContentsOnFlick(void);
        result ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar);
        // todo : move to PastePasswordEchoCharacter