fixed bug (P130909-04234, N_SE-51856 , N_SE-51858)
authorChulheon <ch.jeong47@samsung.com>
Thu, 12 Sep 2013 00:16:20 +0000 (09:16 +0900)
committerChulheon <ch.jeong47@samsung.com>
Thu, 12 Sep 2013 00:16:20 +0000 (09:16 +0900)
Change-Id: Ide2cb5601de9c22532c948f8e7b432e9897c7504

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

index 732ae30..4ae2337 100644 (file)
@@ -833,6 +833,8 @@ void
 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
 {
        __handlerCursorPos = handlerCursorPos;
+       __rowIndex = -1;
+       __columnIndex = -1;
 }
 
 void
@@ -927,6 +929,11 @@ _EditCopyPasteHandler::AdjustBounds(void)
                }
        }
 
+       if (__singleHandler && pEdit->IsViewModeEnabled())
+       {
+               SetVisibleState(false);
+       }
+
        SetBounds(rect);
        return;
 }
@@ -2082,10 +2089,16 @@ _EditCopyPasteManager::CreateCopyPastePopup(void)
                {
                        String copyText;
                        String cutText;
+                       String selectAllText;
 
                        GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
                        GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
+                       GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
 
+                       if (__pEditPresenter->IsViewModeEnabled())
+                       {
+                               __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
+                       }
                        __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
                        if (!__pEditPresenter->IsViewModeEnabled())
                        {
@@ -2203,7 +2216,7 @@ _EditCopyPasteManager::CreateHandle(void)
 
                __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
 #if EDIT_COPY_PASTE_MAGNIFIER
-//             __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
+               __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
 #endif
        }
 }
@@ -2221,6 +2234,7 @@ _EditCopyPasteManager::Show(void)
                __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
                __pHandle[HANDLER_TYPE_CENTER]->Invalidate();
                __pEditPresenter->DrawText();
+               __pHandle[HANDLER_TYPE_CENTER]->MoveCopyPasteMagnifier();
        }
 
        if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
@@ -2236,25 +2250,6 @@ _EditCopyPasteManager::Show(void)
        if (__pCopyPastePopup)
        {
                __pCopyPastePopup->Open();
-               {
-                       _Window* pWindow = null;
-                       _Control* pControlCore = null;
-
-                       for (pControlCore = __pEdit->GetParent(); pWindow == null; pControlCore = pControlCore->GetParent())
-                       {
-                               if (pControlCore == null)
-                               {
-                                       break;
-                               }
-
-                               pWindow = dynamic_cast<_Window*>(pControlCore);
-                               if (pWindow)
-                               {
-                                       __pCopyPastePopup->SetOwner(pWindow);
-                                       break;
-                               }
-                       }
-               }
                __pCopyPastePopup->ReleaseTouchCapture();
 
                _Control* pControl = __pCopyPastePopup->GetOwner();
@@ -2784,4 +2779,24 @@ _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHan
        return;
 }
 
+void
+_EditCopyPasteManager::DestroyCopyPasteMagnifier(void)
+{
+       //only single case.
+       if (__pHandle[HANDLER_TYPE_CENTER])
+       {
+               __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
+       }
+}
+
+void
+_EditCopyPasteManager::CreateCopyPasteMagnifier(void)
+{
+       //only single case.
+       if (__pHandle[HANDLER_TYPE_CENTER])
+       {
+               __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
+       }
+}
+
 }}} // Tizen::Ui::Controls
index 1cfbd4b..1b1d432 100644 (file)
@@ -267,6 +267,7 @@ _EditPresenter::_EditPresenter(void)
        , __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
        , __dragAndDropStarted(false)
        , __dragAndDropString("")
+       , __isTouchLongPressed(false)
 {
 }
 
@@ -2519,6 +2520,11 @@ _EditPresenter::Draw(Canvas& canvas)
 
        RestoreCopyPasteManager();
 
+       if (__isCopyPasteManagerExist)
+       {
+               __pCopyPasteManager->Show();
+       }
+
        InitializeCursor();
 
        // Set scroll bar
@@ -3380,6 +3386,8 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                return true;
        }
 
+       __isTouchLongPressed = false;
+
        if (__isCopyPasteManagerExist)
        {
                if (__isTouchPressed && !__isCopyPastePopupMoving)
@@ -3415,8 +3423,38 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                __pEdit->SetFocused();
                        }
 
+                       if (GetTextLength() > 0 && __pEdit->IsViewModeEnabled())
+                       {
+                               FloatRectangle cursorBounds;
+                               int start = -1;
+                               int end = -1;
+                               int cursorPos = GetCursorPositionAt(touchInfo.GetCurrentPosition());
+
+                               if (cursorPos == -1)
+                               {
+                                       cursorPos = __cursorPos;
+                               }
+                               else
+                               {
+                                       int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(cursorPos);
+                                       int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
+                                       if (cursorPos != 0 && cursorPos == firstTextIndex && __rowCursorIndex != curCursorLine)
+                                       {
+                                               cursorPos--;
+                                       }
+                               }
+
+                               GetWordPosition(cursorPos, start, end);
+                               SetBlockRange(start, end);
+                               __pCopyPasteManager->CreateHandle();
+                       }
+
                        FadeOutScrollBar(); // Fade out scrollbar when copypaste popup is moving.
-                       __pCopyPasteManager->CreateCopyPastePopup();
+                       if (__needToCreateCopyPastePopup)
+                       {
+                               __pCopyPasteManager->CreateCopyPastePopup();
+                       }
+                       __needToCreateCopyPastePopup = false;
                        __pCopyPasteManager->Show();
 
                        __isTouchPressed = false;
@@ -3565,7 +3603,7 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                needToCreatePopup = false;
                        }
 
-                       if (IsViewModeEnabled() && GetTextLength() == 0)
+                       if (IsViewModeEnabled())
                        {
                                needToCreatePopup = false;
                        }
@@ -3587,6 +3625,7 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
                                __pCopyPasteManager->AddCopyPasteEventListener(*this);
                                UpdateComponentInformation();
+                               __pCopyPasteManager->DestroyCopyPasteMagnifier();
                                __pCopyPasteManager->Show();
                                __isCopyPasteManagerExist = true;
                        }
@@ -3709,10 +3748,119 @@ _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo
 
        if (__isCopyPasteManagerExist)
        {
-               __pCopyPasteManager->Show();
-               if (!__isClearIconPressed)
+               if (!IsBlocked() && GetTextLength() > 0 && __isTouchLongPressed)
                {
-                       __isCopyPastePopupMoving = true;
+                       int cursorPos = -1; 
+                       int rowIndex = -1;
+                       int columnIndex = -1;
+                       FloatPoint touchPoint = touchInfo.GetCurrentPosition();
+                       int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__cursorPos);
+                       int totalLine = __pTextObject->GetTotalLineCount();
+                       float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
+                       float totalHeight = __pTextObject->GetTotalHeightF();
+
+                       if (touchPoint.x < __textObjectBounds.x)
+                       {
+                               touchPoint.x = __textObjectBounds.x;
+                       }
+                       if (touchPoint.x > __textObjectBounds.x + __textObjectBounds.width)
+                       {
+                               touchPoint.x = __textObjectBounds.x + __textObjectBounds.width;
+                       }
+                       if (__textObjectBounds.y > touchPoint.y)
+                       {
+                               if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
+                               {
+                                       touchPoint.y = __textObjectBounds.y; //not need to scroll the text.
+                               }
+                       }
+                       if (__textObjectBounds.y + __textObjectBounds.height < touchPoint.y)
+                       {
+                               if (totalLine == 1 || (totalHeight - firstDisplayY < __textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
+                               {
+                                       touchPoint.y = __textObjectBounds.y + __textObjectBounds.height; // check TextObject
+                               }
+                       }
+
+                       if(!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
+                       {
+                               if (totalHeight < __textObjectBounds.height)
+                               {
+                                       if (totalHeight < touchPoint.y)
+                                       {
+                                               touchPoint.y = totalHeight;
+                                       }
+                               }
+                       }
+                       cursorPos = GetCursorPositionAt(touchPoint, rowIndex, columnIndex);
+                       if (cursorPos == -1)
+                       {
+                               FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
+                               CalculateCursorBounds(__textObjectBounds, cursorRect, __rowCursorIndex, __columnCursorIndex);
+                               if (totalLine != 1)
+                               {
+                                       if (touchPoint.y > (cursorRect.y + cursorRect.height))
+                                       {
+                                               if (curCursorLine < totalLine - 1)
+                                               {
+                                                       int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
+                                                       int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
+                                                       cursorPos = offset + firstTextIndex;
+                                                       int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
+                                                       if (offset > textLength)
+                                                       {
+                                                               cursorPos = firstTextIndex+textLength;
+                                                       }
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if (curCursorLine !=0)
+                                               {
+                                                       if (__rowCursorIndex == 0)
+                                                       {
+                                                               cursorPos = -1;
+                                                       }
+                                                       else
+                                                       {
+                                                               int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
+                                                               int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
+                                                               cursorPos = offset + firstTextIndex;
+                                                               int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
+                                                               if (offset > textLength)
+                                                               {
+                                                                       cursorPos = firstTextIndex+textLength;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               if (cursorPos == -1)
+                               {
+                                       return true;
+                               }
+                               SetCursorPosition(cursorPos);
+                       }
+                       else
+                       {
+                               SetCursorPosition(cursorPos, rowIndex, columnIndex);
+                       }
+                       ScrollPanelToCursorPosition(true);
+                       __pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
+                       __pCopyPasteManager->Show();
+                       if (!__isClearIconPressed)
+                       {
+                               __isCopyPastePopupMoving = true;
+                       }
+                       return true;
+               }
+               else
+               {
+                       __pCopyPasteManager->Show();
+                       if (!__isClearIconPressed)
+                       {
+                               __isCopyPastePopupMoving = true;
+                       }
                }
        }
 
@@ -4795,6 +4943,10 @@ _EditPresenter::OnLongPressGestureDetected(void)
                return false;
        }
 
+       int rowIndex = -1;
+       int columnIndex = -1;
+       int cursorPos = -1;
+
        if (__isCopyPasteManagerExist)
        {
 
@@ -4808,9 +4960,7 @@ _EditPresenter::OnLongPressGestureDetected(void)
                        _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, __dragAndDropString);
                        SysTryReturn(NID_UI_CTRL, pDragAndDropItem, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-                       int rowIndex;
-                       int columnIndex;
-                       int cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
+                       cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
                        if (cursorPos != -1)
                        {
                                SetCursorPosition(cursorPos);
@@ -4827,7 +4977,24 @@ _EditPresenter::OnLongPressGestureDetected(void)
                        __dragAndDropStarted = true;
                        InitializeCopyPasteManager();
                }
+               else
 #endif
+               if (!IsBlocked())
+               {
+                       cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
+                       if (cursorPos != -1)
+                       {
+                               SetCursorPosition(cursorPos);
+                       }
+                       else
+                       {
+                               return true;
+                       }
+                       __pCopyPasteManager->CreateCopyPasteMagnifier();
+                       __pCopyPasteManager->Show();
+                       __isTouchLongPressed = true;
+                       __needToCreateCopyPastePopup = true;
+               }
                return true;
        }
        else if (IsCurrentFocused() == false)
@@ -4864,9 +5031,7 @@ _EditPresenter::OnLongPressGestureDetected(void)
                        StopPasswordTimer();
                }
 
-               int rowIndex;
-               int columnIndex;
-               int cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
+               cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
                if (cursorPos != -1)
                {
                        SetCursorPosition(cursorPos);
@@ -4884,6 +5049,8 @@ _EditPresenter::OnLongPressGestureDetected(void)
                __pCopyPasteManager->AddCopyPasteEventListener(*this);
                __pCopyPasteManager->Show();
                __isCopyPasteManagerExist = true;
+               __isTouchLongPressed = true;
+               __needToCreateCopyPastePopup = true;
 
        }
 
@@ -4950,6 +5117,7 @@ _EditPresenter::OnTapGestureDetected(void)
                __pCopyPasteManager->AddCopyPasteEventListener(*this);
                __pCopyPasteManager->Show();
                __isCopyPasteManagerExist = true;
+               __needToCreateCopyPastePopup = true;
 
                __pEdit->Draw();
        }
@@ -6688,6 +6856,7 @@ _EditPresenter::OnNotifiedN(IList* pArgs)
                        if (__pCopyPasteManager)
                        {
                                __pCopyPasteManager->CreateHandle();
+                               __pCopyPasteManager->DestroyCopyPasteMagnifier();
                                if (__needToCreateCopyPastePopup)
                                {
                                        if (__pParentPanel)
index 121e59c..67cbfe2 100644 (file)
@@ -120,6 +120,8 @@ public:
        Tizen::Graphics::FloatRectangle GetEditVisibleAreaF(void) const;
        _ContextMenu* GetCopyPastePopup(void) const;
        void GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const;
+       void DestroyCopyPasteMagnifier(void);
+       void CreateCopyPasteMagnifier(void);
 private:
        _EditCopyPasteManager(const _EditCopyPasteManager& value);
        _EditCopyPasteManager& operator =(const _EditCopyPasteManager& value);
index 51b99c2..213d36b 100755 (executable)
@@ -603,6 +603,7 @@ private:
        FloatRectangle __calculatedCursorBounds;
        bool __dragAndDropStarted;
        Tizen::Base::String __dragAndDropString;
+       bool __isTouchLongPressed;
 }; // _EditPresenter
 
 }}} // Tizen::Ui::Controls