X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-text-updater.cpp;h=8a197860b24989dcfa116e9b2a87f85c1604e7c0;hp=69e05bfc9a058d86bdf1dfe972a0b65200c06c20;hb=3ce558ca09f928cb18cacfa80f52eb0c591181b9;hpb=3feac03362a8bb2d90a8b3e5defe9d2d704d2d3c diff --git a/dali-toolkit/internal/text/text-controller-text-updater.cpp b/dali-toolkit/internal/text/text-controller-text-updater.cpp index 69e05bf..8a19786 100644 --- a/dali-toolkit/internal/text/text-controller-text-updater.cpp +++ b/dali-toolkit/internal/text/text-controller-text-updater.cpp @@ -55,7 +55,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& ResetText(controller); // Remove the style. - controller.ClearStyleData(); + impl.ClearStyleData(); CharacterIndex lastCursorIndex = 0u; @@ -69,6 +69,11 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& (EventData::EDITING_WITH_GRAB_HANDLE == eventData->mState) || (EventData::EDITING_WITH_PASTE_POPUP == eventData->mState)) { + if((impl.mSelectableControlInterface != nullptr) && (EventData::SELECTING == eventData->mState)) + { + impl.mSelectableControlInterface->SelectionChanged(eventData->mLeftSelectionPosition, eventData->mRightSelectionPosition, eventData->mPrimaryCursorPosition, eventData->mPrimaryCursorPosition); + } + impl.ChangeState(EventData::EDITING); } } @@ -82,7 +87,9 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& MarkupProcessData markupProcessData(logicalModel->mColorRuns, logicalModel->mFontDescriptionRuns, logicalModel->mEmbeddedItems, - logicalModel->mAnchors); + logicalModel->mAnchors, + logicalModel->mUnderlinedCharacterRuns, + logicalModel->mBackgroundColorRuns); Length textSize = 0u; const uint8_t* utf8 = NULL; @@ -137,11 +144,13 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& controller.ShowPlaceholderText(); } + unsigned int oldCursorPos = (nullptr != eventData ? eventData->mPrimaryCursorPosition : 0); + // Resets the cursor position. controller.ResetCursorPosition(lastCursorIndex); // Scrolls the text to make the cursor visible. - controller.ResetScrollPosition(); + impl.ResetScrollPosition(); impl.RequestRelayout(); @@ -154,6 +163,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& // Do this last since it provides callbacks into application code. if(NULL != impl.mEditableControlInterface) { + impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, lastCursorIndex); impl.mEditableControlInterface->TextChanged(true); } } @@ -170,9 +180,10 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri return; } - bool removedPrevious = false; - bool removedSelected = false; - bool maxLengthReached = false; + bool removedPrevious = false; + bool removedSelected = false; + bool maxLengthReached = false; + unsigned int oldCursorPos = eventData->mPrimaryCursorPosition; DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n", &controller, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"), eventData->mPrimaryCursorPosition, eventData->mPreEditFlag, eventData->mPreEditStartPosition, eventData->mPreEditLength); @@ -254,7 +265,8 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri const Length numberOfCharactersInModel = logicalModel->mText.Count(); // Restrict new text to fit within Maximum characters setting. - Length maxSizeOfNewText = std::min((impl.mMaximumNumberOfCharacters - numberOfCharactersInModel), characterCount); + Length temp_length = (impl.mMaximumNumberOfCharacters > numberOfCharactersInModel ? impl.mMaximumNumberOfCharacters - numberOfCharactersInModel : 0); + Length maxSizeOfNewText = std::min(temp_length, characterCount); maxLengthReached = (characterCount > maxSizeOfNewText); // The cursor position. @@ -415,6 +427,11 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri } } + if(nullptr != impl.mEditableControlInterface) + { + impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, eventData->mPrimaryCursorPosition); + } + if(maxLengthReached) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count()); @@ -558,6 +575,11 @@ bool Controller::TextUpdater::RemoveText( RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex); } + if(nullptr != impl.mEditableControlInterface) + { + impl.mEditableControlInterface->CursorPositionChanged(previousCursorIndex, cursorIndex); + } + // Cursor position retreat previousCursorIndex = cursorIndex; @@ -585,6 +607,9 @@ bool Controller::TextUpdater::RemoveSelectedText(Controller& controller) if(EventData::SELECTING == impl.mEventData->mState) { std::string removedString; + uint32_t oldSelStart = impl.mEventData->mLeftSelectionPosition; + uint32_t oldSelEnd = impl.mEventData->mRightSelectionPosition; + impl.RetrieveSelection(removedString, true); if(!removedString.empty()) @@ -601,6 +626,11 @@ bool Controller::TextUpdater::RemoveSelectedText(Controller& controller) RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex); } + + if(impl.mSelectableControlInterface != nullptr) + { + impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, impl.mEventData->mPrimaryCursorPosition, impl.mEventData->mPrimaryCursorPosition); + } } }