fixed bug (N_SE-41132, horizontal text moving, handler touch improve)
authorChulheon <ch.jeong47@samsung.com>
Wed, 12 Jun 2013 11:34:11 +0000 (20:34 +0900)
committerChulheon <ch.jeong47@samsung.com>
Wed, 12 Jun 2013 11:35:56 +0000 (20:35 +0900)
Change-Id: I67d79005d83471cb6d1f999194426209b543090c

src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp
src/ui/controls/FUiCtrl_EditPresenter.cpp

index ab99d97..312f682 100644 (file)
@@ -1258,6 +1258,17 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
        int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
        int totalLine = pTextObject->GetTotalLineCount();
 
+       float totalHeight = pTextObject->GetTotalHeightF();
+       float frstDisplayY = pTextObject->GetFirstDisplayPositionYF();
+       FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
+       FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
+       absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
+       absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
+       absTextObjectBounds.width = textObjectBounds.width;
+       absTextObjectBounds.height  = textObjectBounds.height;
+       bool  needToFixYPosition= false;
+
        if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
        {
                return true;
@@ -1280,8 +1291,55 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
                pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);                        
        }
 
+       if (absTextObjectBounds.height > (totalHeight - frstDisplayY))
+       {
+               absTextObjectBounds.height = totalHeight - frstDisplayY;
+               absTextObjectBounds.y += absCursorRect.height;
+               if (absTextObjectBounds.y > absoluteTouchMovedPoint.y || (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
+               {
+                       needToFixYPosition = true;
+               }
+       }
+       else
+       {
+               absTextObjectBounds.y += absCursorRect.height;
+               if (frstDisplayY == 0.0f && absTextObjectBounds.y > absoluteTouchMovedPoint.y)
+               {
+                       needToFixYPosition = true;
+               }
+               else if ((totalHeight - frstDisplayY) == absTextObjectBounds.height && (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
+               {
+                       needToFixYPosition = true;
+               }
+       }
+
+       if (!__singleHandler)
+       {
+               int nextHandlerLine = -1;
+               if (__leftHandler)
+               {
+                       nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
+               }
+               else
+               {
+                       nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
+               }
+
+               if (curCursorLine == nextHandlerLine)
+               {
+                       if (__leftHandler && absoluteTouchMovedPoint.y > absCursorRect.y)
+                       {
+                               needToFixYPosition = true;
+                       }
+                       else if (!__leftHandler && absoluteTouchMovedPoint.y < absCursorRect.y)
+                       {
+                               needToFixYPosition = true;
+                       }
+               }
+       }
+
        touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
-       if (totalLine == 1)
+       if (totalLine == 1 || needToFixYPosition)
        {
                touchPoint.y = cursorRect.y + cursorRect.height/2;
        }
index 2527f76..fbd6f53 100755 (executable)
@@ -1000,9 +1000,7 @@ _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipbo
                {
                        if (__isCopyPasteManagerExist)
                        {
-                               __pCopyPasteManager->CreateHandle();
-                               __pCopyPasteManager->CreateCopyPastePopup();
-                               __pCopyPasteManager->Show();
+                               PostInternalEvent(String(L"ShowCopyPaste"));
                        }
                        __rotated = false;
                }
@@ -2782,22 +2780,56 @@ _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRec
                cursorBounds.height -= cursorHeightDiff;
        }
 
-       if (cursorBounds.x == textBounds.x + textBounds.width)
+       if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
        {
-               cursorBounds.x -= 1.0f;
+               if (__pTextObject->GetBlock() == false)
+               {
+                       cursorBounds.x -= 1.0f;
+               }
+
+               if (cursorBounds.x > textBounds.x + textBounds.width)
+               {
+                       if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
+                       {
+                               cursorBounds.x = textBounds.x + textBounds.width;
+                       }
+                       else
+                       {
+                               return E_SYSTEM;
+                       }
+               }
+
+               if (cursorBounds.x < textBounds.x)
+               {
+                       if (cursorBounds.x > textBounds.x - cursorBounds.width)
+                       {
+                               cursorBounds.x = textBounds.x;
+                       }
+                       else
+                       {
+                               return E_SYSTEM;
+                       }
+               }
        }
-       else if (cursorBounds.x > textBounds.x + textBounds.width)
+       else
        {
-               cursorBounds.x = textBounds.x + textBounds.width;
-               return E_SYSTEM;
-       }
+               if (cursorBounds.x == textBounds.x + textBounds.width)
+               {
+                       cursorBounds.x -= 1.0f;
+               }
+               else if (cursorBounds.x > textBounds.x + textBounds.width)
+               {
+                       cursorBounds.x = textBounds.x + textBounds.width;
+                       return E_SYSTEM;
+               }
 
-       if (__pTextObject->GetBlock() == false)
-       {
-               cursorBounds.x -= 1.0f;
-               if (cursorBounds.x < textBounds.x)
+               if (__pTextObject->GetBlock() == false)
                {
-                       cursorBounds.x = textBounds.x;
+                       cursorBounds.x -= 1.0f;
+                       if (cursorBounds.x < textBounds.x)
+                       {
+                               cursorBounds.x = textBounds.x;
+                       }
                }
        }
 
@@ -2856,22 +2888,56 @@ _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRec
                cursorBounds.height -= cursorHeightDiff;
        }
 
-       if (cursorBounds.x == textBounds.x + textBounds.width)
+       if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
        {
-               cursorBounds.x -= 1.0f;
+               if (__pTextObject->GetBlock() == false)
+               {
+                       cursorBounds.x -= 1.0f;
+               }
+
+               if (cursorBounds.x > textBounds.x + textBounds.width)
+               {
+                       if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
+                       {
+                               cursorBounds.x = textBounds.x + textBounds.width;
+                       }
+                       else
+                       {
+                               return E_SYSTEM;
+                       }
+               }
+
+               if (cursorBounds.x < textBounds.x)
+               {
+                       if (cursorBounds.x > textBounds.x - cursorBounds.width)
+                       {
+                               cursorBounds.x = textBounds.x;
+                       }
+                       else
+                       {
+                               return E_SYSTEM;
+                       }
+               }
        }
-       else if (cursorBounds.x > textBounds.x + textBounds.width)
+       else
        {
-               cursorBounds.x = textBounds.x + textBounds.width;
-               return E_SYSTEM;
-       }
+               if (cursorBounds.x == textBounds.x + textBounds.width)
+               {
+                       cursorBounds.x -= 1.0f;
+               }
+               else if (cursorBounds.x > textBounds.x + textBounds.width)
+               {
+                       cursorBounds.x = textBounds.x + textBounds.width;
+                       return E_SYSTEM;
+               }
 
-       if (__pTextObject->GetBlock() == false)
-       {
-               cursorBounds.x -= 1.0f;
-               if (cursorBounds.x < textBounds.x)
+               if (__pTextObject->GetBlock() == false)
                {
-                       cursorBounds.x = textBounds.x;
+                       cursorBounds.x -= 1.0f;
+                       if (cursorBounds.x < textBounds.x)
+                       {
+                               cursorBounds.x = textBounds.x;
+                       }
                }
        }
 
@@ -3204,6 +3270,7 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                if (!__isCopyPasteManagerExist && !__pFlickAnimationTimer)
                {
                        bool tokenEditting = false;
+                       bool needToCreatePopup = true;
                        if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
                        {
                                _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
@@ -3216,7 +3283,22 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                }
                        }
 
-                       if (IsInternalFocused() && !tokenEditting)
+                       // need to check the status of CheckKeypadExist() API.
+                       /*
+                       if (!__isUSBKeyboardConnected && !__isKeypadExist)
+                       {
+                               needToCreatePopup = false;
+                       }
+                       */
+
+                       _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
+                       SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
+                       if (pAccessibilityManager->IsActivated())
+                       {
+                               needToCreatePopup = false;
+                       }
+
+                       if (IsInternalFocused() && !tokenEditting && needToCreatePopup)
                        {
                                __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
                                SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
@@ -3327,64 +3409,46 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
                if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
                {
                        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())
+                       FloatRectangle lineBounds = __pTextObject->GetBoundsAtLineF(0);
+                       float   textDisplayPositionX = __pTextObject->GetFirstDisplayPositionXF();
+                       float   newTextDisplayPositionX = 0;
+
+                       if (horizontalGap < 0.0f && lineBounds.width - textDisplayPositionX > __textObjectBounds.width)
                        {
-                               currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset+currentLineLength, 1);
-                               if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
+                               newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
+
+                               if (newTextDisplayPositionX >  lineBounds.width - __textObjectBounds.width)
                                {
-                                       __pScrollEffect->previousX = __pScrollEffect->currentX;
-                                       __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
-                                       __isMovingCursorByTouchMove = true;
-                                       __isTouchReleaseSkipped = true;
-                                       StopCursorTimer();
+                                       newTextDisplayPositionX = lineBounds.width - __textObjectBounds.width;
+                               }
 
-                                       SetCursorPosition(currentLineOffset+currentLineLength+1);
-                                       UpdateComponentInformation();
+                               __pScrollEffect->previousX = __pScrollEffect->currentX;
+                               __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+                               __isMovingCursorByTouchMove = true;
+                               __isTouchReleaseSkipped = true;
+                               StopCursorTimer();
 
-                                       currentLineOffset = __pTextObject->GetTextOffsetAtLine(0);
-                                       if (__pScrollEffect->cursorPosition > currentLineOffset)
-                                       {
-                                               SetCursorPosition(__pScrollEffect->cursorPosition);
-                                       }
-                                       else
-                                       {
-                                               __pScrollEffect->cursorPosition = currentLineOffset + 1;
-                                               SetCursorPosition(__pScrollEffect->cursorPosition);
-                                       }
-                                       __pEdit->Invalidate();
-                                       return true;
-                               }
+                               __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
+                               __pEdit->Invalidate();
+                               return true;
                        }
-                       if (horizontalGap > 0.0f && currentLineOffset > 0)
+                       if (horizontalGap > 0.0f && textDisplayPositionX > 0)
                        {
-                               currentCharacterDimension = __pTextObject->GetTextExtentF(currentLineOffset-1, 1);
-                               if (horizontalGap >= currentCharacterDimension.width)
+                               newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
+                               if (newTextDisplayPositionX < 0)
                                {
-                                       __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;
+                                       newTextDisplayPositionX = 0;
                                }
+
+                               __pScrollEffect->previousX = __pScrollEffect->currentX;
+                               __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
+                               __isMovingCursorByTouchMove = true;
+                               __isTouchReleaseSkipped = true;
+                               StopCursorTimer();
+
+                               __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
+                               __pEdit->Invalidate();
+                               return true;
                        }
                }
                else
@@ -3519,6 +3583,9 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        FloatRectangle panelAbsBounds(0.0f, 0.0f, 0.0f, 0.0f);
        FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
 
+       _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
+       SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
+
        if (IsViewModeEnabled() == true)
        {
                return false;
@@ -3581,12 +3648,17 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                                r = __pEdit->SendTextBlockEvent(0, textLength);
                                UpdateComponentInformation();
                                SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
-                               __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
-                               SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
-                               __pCopyPasteManager->AddCopyPasteEventListener(*this);
-                               __pCopyPasteManager->CreateCopyPastePopup();
-                               __pCopyPasteManager->Show();
-                               __isCopyPasteManagerExist = true;
+
+                               if (!pAccessibilityManager->IsActivated())
+                               {
+                                       __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
+                                       SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
+                                       __pCopyPasteManager->AddCopyPasteEventListener(*this);
+                                       __pCopyPasteManager->CreateCopyPastePopup();
+                                       __pCopyPasteManager->Show();
+                                       __isCopyPasteManagerExist = true;
+                               }
+
                                break;
                        case _KEY_C:
                                textLength = __pEdit->GetTextLength();
@@ -4181,13 +4253,17 @@ _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
                }
                else if (__textBlockMoving)
                {
-                       __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
-                       SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
-                       __pCopyPasteManager->AddCopyPasteEventListener(*this);
-                       __pCopyPasteManager->CreateCopyPastePopup();
-                       __pCopyPasteManager->Show();
-                       __isCopyPasteManagerExist = true;
-
+                       _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
+                       SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
+                       if (!pAccessibilityManager->IsActivated())
+                       {
+                               __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
+                               SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
+                               __pCopyPasteManager->AddCopyPasteEventListener(*this);
+                               __pCopyPasteManager->CreateCopyPastePopup();
+                               __pCopyPasteManager->Show();
+                               __isCopyPasteManagerExist = true;
+                       }
                        __textBlockMoving = false;
                }
                return true;
@@ -4378,6 +4454,14 @@ _EditPresenter::OnLongPressGestureDetected(void)
 {
        SysLog(NID_UI_CTRL, "OnLongPressGestureDetected");
 
+       _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
+       SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
+       if (pAccessibilityManager->IsActivated())
+       {
+               SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
+               return false;
+       }
+
        if (__isClearIconPressed)
        {
                return true;
@@ -4438,6 +4522,14 @@ _EditPresenter::OnTapGestureDetected(void)
 {
        SysLog(NID_UI_CTRL, "OnTapGestureDetected");
 
+       _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
+       SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
+       if (pAccessibilityManager->IsActivated())
+       {
+               SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
+               return false;
+       }
+
        if (IsInternalFocused() == false)
        {
                return true;
@@ -6119,6 +6211,7 @@ _EditPresenter::OnNotifiedN(IList* pArgs)
                {
                        if (__pCopyPasteManager)
                        {
+                               DrawText();
                                __pCopyPasteManager->CreateHandle();
                                __pCopyPasteManager->CreateCopyPastePopup();
                                __pCopyPasteManager->Show();