fixed bug (magnifier display error)
authorChulheon <ch.jeong47@samsung.com>
Sat, 6 Apr 2013 09:14:15 +0000 (18:14 +0900)
committerChulheon <ch.jeong47@samsung.com>
Sat, 6 Apr 2013 09:16:44 +0000 (18:16 +0900)
Change-Id: Ia08573426b04d13e05ed1a5b708ae26403c961cb

src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp

index 5447718..4418b89 100755 (executable)
@@ -68,6 +68,7 @@ public:
        void CaptureTextArea(Canvas& canvas);
        void MoveMagnifier(const FloatPoint& point, int handlerCursorPos);
        Bitmap* GetMagnifierBitmap(void) const;
+       virtual result OnAttachedToMainTree(void);
 
 private:
        _EditCopyPasteMagnifier(const _EditCopyPasteMagnifier& value);
@@ -145,9 +146,54 @@ CATCH:
        return null;
 }
 
+result
+_EditCopyPasteMagnifier::OnAttachedToMainTree(void)
+{
+       result r = E_SUCCESS;
+
+       if (GetOwner() == null)
+       {
+               _Edit* pEdit = __pCopyPasteManager->GetEdit();
+               SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
+
+               _EditPresenter* pEditPresenter = pEdit->GetPresenter();
+               SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
+
+               _Form* pParentForm = pEditPresenter->GetParentForm();
+               if (pParentForm)
+               {
+                       SetOwner(pParentForm);
+               }
+               else
+               {
+                       _Form* pForm = null;
+                       _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
+                       if (pCurrentFrame)
+                       {
+                               pForm = pCurrentFrame->GetCurrentForm();
+                               if (pForm)
+                               {
+                                       SetOwner(pForm);
+                               }
+                               else
+                               {
+                                       SetOwner(pCurrentFrame);
+                               }
+                       }
+               }
+       }
+
+       return r;
+}
+
 void
 _EditCopyPasteMagnifier::OnDraw(void)
 {
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_INVALID_STATE, "pEcoreEvas is null.");
+
+       pEcoreEvas->SetWindowBounds(*GetRootWindow(), GetBoundsF());
+
        Canvas* pCanvas = GetCanvasN();
        if (pCanvas == null)
        {
@@ -183,6 +229,7 @@ _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
        SysTryReturnVoidResult(NID_UI_CTRL, pTextVisualElement, E_INVALID_STATE, "pTextVisualElement is null.");
 
        Canvas* pTextCanvas = pTextVisualElement->GetCanvasN();
+       SysTryReturnVoidResult(NID_UI_CTRL, pTextCanvas, E_INVALID_STATE, "pTextCanvas is null.");
 
        float captureWidth = 0.0f;
        float captureHeight = 0.0f;
@@ -199,18 +246,25 @@ _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
 
        FloatRectangle textVisualElementBounds = pTextVisualElement->GetBounds();
        FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
-
        if (cursorBounds.x >= captureWidth/2.0f)
        {
                captureBounds.x = cursorBounds.x - captureWidth/2.0f;
        }
        else
        {
-               captureBounds.x = captureWidth/2.0f - cursorBounds.x;
+               captureBounds.x = 0.0f;
        }
+
        if (cursorBounds.x <=  textVisualElementBounds.width - captureWidth/2.0f)
        {
-               captureBounds.width = captureWidth;
+               if (captureBounds.x != 0.0f)
+               {
+                       captureBounds.width = captureWidth;
+               }
+               else
+               {
+                       captureBounds.width = captureWidth/2.0f + cursorBounds.x;
+               }
        }
        else
        {
@@ -231,7 +285,16 @@ _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
        bitmap.Construct(*pTextCanvas, captureBounds);
        bitmap.Scale(FloatDimension(bitmap.GetWidth()*1.5f, bitmap.GetHeight()*1.5f));
 
-       canvas.DrawBitmap(FloatPoint(capturePosX, capturePosY), bitmap);
+       if (captureBounds.x != 0.0f)
+       {
+               canvas.DrawBitmap(FloatPoint(capturePosX, capturePosY), bitmap);
+       }
+       else
+       {
+
+               canvas.DrawBitmap(FloatPoint(capturePosX + (captureWidth/2.0f -cursorBounds.x)*1.5f, capturePosY), bitmap);
+       }
+
        delete pTextCanvas;
 }
 
@@ -776,6 +839,11 @@ _EditCopyPasteHandler::CheckReverseStatus(void)
                screenSize.height = pControlManager->GetScreenSizeF().width;
        }
 
+       if (__singleHandler)
+       {
+               return;
+       }
+
        if (__leftHandler)
        {
                if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
@@ -828,7 +896,7 @@ _EditCopyPasteHandler::CheckReverseStatus(void)
                }
                else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
                {
-                       if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < 0.0f)
+                       if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
                        {
                                __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
                                rect.x += rect.width;
@@ -1033,12 +1101,11 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
        //if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(FloatPoint(absCursorRect.x, absCursorRect.y + absCursorRect.height))))
        if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(FloatPoint(checkPoint.x, checkPoint.y))))
        {
-               SysLog(NID_UI, "OnTouchMoved is called");
                int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
                int totalLine = pTextObject->GetTotalLineCount();
                FloatRectangle editVisibleArea = __pCopyPasteManager->GetEditVisibleAreaF();
 
-               if (pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+               if (pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || (pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE && totalLine == 1))
                {
                        if (point.x - __touchPressedPoint.x >= 0.0f) // RightSide
                        {