_VisualElement* __pRoot;
Bitmap* __pHandlerBitmap;
FloatPoint __touchPressedPoint;
+ FloatPoint __absoluteTouchPressedPoint;
_EditCopyPasteManager* __pCopyPasteManager;
bool __leftHandler;
bool __reverseCheck;
: __pRoot(null)
, __pHandlerBitmap(null)
, __touchPressedPoint(0.0f, 0.0f)
+ , __absoluteTouchPressedPoint(0.0f, 0.0f)
, __pCopyPasteManager(pCopyPasteManager)
, __leftHandler(leftHandler)
, __reverseCheck(false)
: __pRoot(null)
, __pHandlerBitmap(null)
, __touchPressedPoint(0.0f, 0.0f)
+ , __absoluteTouchPressedPoint(0.0f, 0.0f)
, __pCopyPasteManager(pCopyPasteManager)
, __leftHandler(leftHandler)
, __reverseCheck(false)
CreateCopyPasteMagnifier();
#endif
__touchPressedPoint = touchinfo.GetCurrentPosition();
+ __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
__isTouchPressed = true;
Invalidate();
return true;
CheckReverseStatus();
__isTouchPressed = false;
__isTouchMoving = false;
+ __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
DestroyCopyPasteMagnifier();
__pCopyPasteManager->CreateCopyPastePopup();
__pCopyPasteManager->Show();
FloatPoint touchPoint(0.0f, 0.0f);
FloatPoint checkPoint(0.0f, 0.0f);
__isTouchMoving = true;
+ bool cursorChange = false;
_Edit* pEdit = __pCopyPasteManager->GetEdit();
SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
_EditPresenter* pEditPresenter = pEdit->GetPresenter();
SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
+
TextObject* pTextObject = pEditPresenter->GetTextObject();
+ SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
+
+ int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
+ int totalLine = pTextObject->GetTotalLineCount();
if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
{
return true;
}
+
if (!__singleHandler)
{
previousCursorPos = __pCopyPasteManager->GetCursorPosition();
__pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
}
+
+ FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
cursorRect = __pCopyPasteManager->GetCursorBoundsF(false);
absCursorRect = __pCopyPasteManager->GetCursorBoundsF(true);
-
touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
touchPoint.y = cursorRect.y + cursorRect.height + (point.y - __touchPressedPoint.y);
- checkPoint.x = absCursorRect.x + (point.x - __touchPressedPoint.x);
- checkPoint.y = absCursorRect.y + absCursorRect.height + (point.y - __touchPressedPoint.y);
cursorPos = __pCopyPasteManager->GetCursorPositionAt(touchPoint);
- //if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(FloatPoint(absCursorRect.x, absCursorRect.y + absCursorRect.height))))
- if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(FloatPoint(checkPoint.x, checkPoint.y))))
+ if (cursorPos != -1)
{
- int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
- int totalLine = pTextObject->GetTotalLineCount();
- FloatRectangle editVisibleArea = __pCopyPasteManager->GetEditVisibleAreaF();
+ FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
+ pEdit->CalculateAbsoluteCursorBounds(cursorPos, cursorBounds);
+ cursorChange = true;
+ checkPoint.x = cursorBounds.x;
+
+ if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f || totalLine == 1)
+ {
+ checkPoint.y = cursorBounds.y + cursorBounds.height;
+ }
+ else
+ {
+ checkPoint.y = cursorBounds.y;
+ }
+ }
- if (pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || (pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE && totalLine == 1))
+ if (cursorPos == -1 || (cursorChange && !__pCopyPasteManager->CheckHandleBounds(FloatPoint(checkPoint.x, checkPoint.y))))
+ {
+ if (cursorPos != -1)
{
- if (point.x - __touchPressedPoint.x >= 0.0f) // RightSide
+ if (totalLine == 1)
{
- if (__handlerCursorPos == pEditPresenter->GetTextLength())
+ pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
+ }
+ else
+ {
+ if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
{
- cursorPos = __handlerCursorPos;
+ if (curCursorLine < totalLine - 1)
+ {
+ if (!pTextObject->IsDisplayedLastLine())
+ {
+ int line = pTextObject->GetFirstDisplayLineIndex();
+ pTextObject->SetFirstDisplayLineIndex(line+1);
+ }
+ else
+ {
+ if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+ {
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
+ else
+ {
+ __pCopyPasteManager->SetCursorPosition(previousCursorPos);
+ pEditPresenter->SetCursorChangedFlag(!__leftHandler);
+ return true;
+ }
+ }
+ }
}
else
{
- cursorPos = __handlerCursorPos + 1;
-
- if (!__singleHandler && __leftHandler && (cursorPos == pEditPresenter->GetTextLength()))
+ if (curCursorLine !=0)
{
- cursorPos = __handlerCursorPos;
+ if (!pTextObject->IsDisplayedFirstLine())
+ {
+ int line = pTextObject->GetFirstDisplayLineIndex();
+ pTextObject->SetFirstDisplayLineIndex(line-1);
+ }
+ else
+ {
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
}
}
}
- else //LeftSide
+ }
+ else
+ {
+ if (totalLine == 1)
{
- if (__handlerCursorPos != 0)
+ if (point.x - __touchPressedPoint.x == 0.0f)
{
- cursorPos = __handlerCursorPos - 1;
+ __pCopyPasteManager->SetCursorPosition(previousCursorPos);
+ pEditPresenter->SetCursorChangedFlag(!__leftHandler);
+ return true;
- if (!__singleHandler && __leftHandler)
+ }
+ else if (point.x - __touchPressedPoint.x > 0.0f)
+ {
+ if (__handlerCursorPos == pEditPresenter->GetTextLength())
{
- pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
+ cursorPos = __handlerCursorPos;
+ }
+ else
+ {
+ cursorPos = __handlerCursorPos + 1;
+
+ if (!__singleHandler && __leftHandler && (cursorPos == pEditPresenter->GetTextLength()))
+ {
+ cursorPos = __handlerCursorPos;
+ }
}
}
- }
- if (point.y < 0.0f || (point.y > GetBoundsF().height))
- {
- __pCopyPasteManager->SetCursorPosition(previousCursorPos);
- pEditPresenter->SetCursorChangedFlag(!__leftHandler);
- return true;
- }
- }
- else
- {
- if (point.y - __touchPressedPoint.y >= 0.0f) // DownSide
- {
- if (curCursorLine < totalLine - 1)
+ else
{
- int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
- int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
- cursorPos = offset + firstTextIndex;
- int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
- if (offset > textLength)
+ if (__handlerCursorPos != 0)
{
- cursorPos = firstTextIndex+textLength;
+ cursorPos = __handlerCursorPos - 1;
+
+ if (!__singleHandler && __leftHandler)
+ {
+ pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
+ }
}
- int line = pTextObject->GetFirstDisplayLineIndex();
- pTextObject->SetFirstDisplayLineIndex(line+1);
+ }
+ if (point.y < 0.0f || (point.y > GetBoundsF().height))
+ {
+ __pCopyPasteManager->SetCursorPosition(previousCursorPos);
+ pEditPresenter->SetCursorChangedFlag(!__leftHandler);
+ return true;
}
}
else
{
- if (curCursorLine !=0)
+ if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
{
- int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
- int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
- cursorPos = offset + firstTextIndex;
- int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
- if (offset > textLength)
+ if (curCursorLine < totalLine - 1)
+ {
+ int offset = __handlerCursorPos - 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 (!pTextObject->IsDisplayedLastLine())
+ {
+ int line = pTextObject->GetFirstDisplayLineIndex();
+ pTextObject->SetFirstDisplayLineIndex(line+1);
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
+ else
+ {
+ if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+ {
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
+ else
+ {
+ __pCopyPasteManager->SetCursorPosition(previousCursorPos);
+ pEditPresenter->SetCursorChangedFlag(!__leftHandler);
+ return true;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (curCursorLine !=0)
{
- cursorPos = firstTextIndex+textLength;
+ int offset = __handlerCursorPos - 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 (!pTextObject->IsDisplayedFirstLine())
+ {
+ int line = pTextObject->GetFirstDisplayLineIndex();
+ pTextObject->SetFirstDisplayLineIndex(line-1);
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
+ else
+ {
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ pEditPresenter->ScrollPanelToCursorPosition(true);
+ }
}
- int line = pTextObject->GetFirstDisplayLineIndex();
- pTextObject->SetFirstDisplayLineIndex(line-1);
}
}
}
int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
__pEdit->SetBlockRange(leftHandlerPos, rightHandlerPos);
- __pEditPresenter->SetCursorChangedFlag(false);//!isLeftHandle);
+ __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
__pEditPresenter->DrawText();
AdjustBounds();
}