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-impl.cpp;h=045fb8afbc28c519420ab70499e3dafa01082907;hp=a96d23c33338562a5ad0f939f863b7874afeb628;hb=a96792fc04dcf6a4bba17985fd940a4256c1820e;hpb=14abad437f0a1737b07aead32134ebd37b8e4891 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index a96d23c..045fb8a 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -507,10 +507,14 @@ void Controller::Impl::ClearGlyphModelData(CharacterIndex startIndex, CharacterI mModel->mVisualModel->mCharactersPerGlyph.Erase(charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex, charactersPerGlyphBuffer + endGlyphIndexPlusOne); - // Clear the positions buffer. - Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin(); - mModel->mVisualModel->mGlyphPositions.Erase(positionsBuffer + mTextUpdateInfo.mStartGlyphIndex, - positionsBuffer + endGlyphIndexPlusOne); + // Should pass if mGlyphPositions has already been cleared in Controller::Relayouter::Relayout + if(0u != mModel->mVisualModel->mGlyphPositions.Count()) + { + // Clear the positions buffer. + Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin(); + mModel->mVisualModel->mGlyphPositions.Erase(positionsBuffer + mTextUpdateInfo.mStartGlyphIndex, + positionsBuffer + endGlyphIndexPlusOne); + } } if(NO_OPERATION != (LAYOUT & operations)) @@ -1209,7 +1213,9 @@ void Controller::Impl::SetTextSelectionRange(const uint32_t* pStart, const uint3 if(mEventData->mSelectionEnabled && (pStart || pEnd)) { - uint32_t length = static_cast(mModel->mLogicalModel->mText.Count()); + uint32_t length = static_cast(mModel->mLogicalModel->mText.Count()); + uint32_t oldStart = mEventData->mLeftSelectionPosition; + uint32_t oldEnd = mEventData->mRightSelectionPosition; if(pStart) { @@ -1233,6 +1239,11 @@ void Controller::Impl::SetTextSelectionRange(const uint32_t* pStart, const uint3 mEventData->mUpdateLeftSelectionPosition = true; mEventData->mUpdateRightSelectionPosition = true; } + + if(mSelectableControlInterface != nullptr) + { + mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition); + } } } @@ -1253,7 +1264,7 @@ bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index, bool focus return false; } - if(mEventData->mPrimaryCursorPosition == index) + if(mEventData->mPrimaryCursorPosition == index && mEventData->mState != EventData::SELECTING) { // Nothing for same cursor position. return false; @@ -1265,9 +1276,18 @@ bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index, bool focus // If there is no focus, only the value is updated. if(focused) { + bool wasInSelectingState = mEventData->mState == EventData::SELECTING; + uint32_t oldStart = mEventData->mLeftSelectionPosition; + uint32_t oldEnd = mEventData->mRightSelectionPosition; ChangeState(EventData::EDITING); mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition; mEventData->mUpdateCursorPosition = true; + + if(mSelectableControlInterface != nullptr && wasInSelectingState) + { + mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition); + } + ScrollTextToMatchCursor(); } @@ -1384,9 +1404,17 @@ void Controller::Impl::RetrieveSelection(std::string& selectedText, bool deleteA void Controller::Impl::SetSelection(int start, int end) { + uint32_t oldStart = mEventData->mLeftSelectionPosition; + uint32_t oldEnd = mEventData->mRightSelectionPosition; + mEventData->mLeftSelectionPosition = start; mEventData->mRightSelectionPosition = end; mEventData->mUpdateCursorPosition = true; + + if(mSelectableControlInterface != nullptr) + { + mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, start, end); + } } std::pair Controller::Impl::GetSelectionIndexes() const