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.cpp;h=09a444138b80ad7c5dc855a885eb7241e583869e;hp=36c293e66f2fd269aaf7a20e43ae04c6851198be;hb=677d489c37efac76c7449f7e22d66b3fc92c4af1;hpb=cb1a9e02b309e48b8599fa7bb34ab7856fb823e7 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 36c293e..09a4441 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -614,6 +614,8 @@ bool Controller::RemoveText( int cursorOffset, // Cursor position retreat oldCursorIndex = cursorIndex; + mImpl->mEventData->mScrollAfterDelete = true; + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters ); removed = true; } @@ -1112,8 +1114,8 @@ Vector3 Controller::GetNaturalSize() mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u; mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count(); - // Store the actual control's width. - const float actualControlWidth = mImpl->mVisualModel->mControlSize.width; + // Store the actual control's size to restore later. + const Size actualControlSize = mImpl->mVisualModel->mControlSize; DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ), static_cast( onlyOnceOperations | @@ -1138,8 +1140,8 @@ Vector3 Controller::GetNaturalSize() // Clear the update info. This info will be set the next time the text is updated. mImpl->mTextUpdateInfo.Clear(); - // Restore the actual control's width. - mImpl->mVisualModel->mControlSize.width = actualControlWidth; + // Restore the actual control's size. + mImpl->mVisualModel->mControlSize = actualControlSize; DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z ); } @@ -1434,13 +1436,6 @@ void Controller::TextInsertedEvent() // Apply modifications to the model; TODO - Optimize this mImpl->mOperationsPending = ALL_OPERATIONS; - - // Queue a cursor reposition event; this must wait until after DoRelayout() - if( EventData::IsEditingState( mImpl->mEventData->mState ) ) - { - mImpl->mEventData->mUpdateCursorPosition = true; - mImpl->mEventData->mScrollAfterUpdatePosition = true; - } } void Controller::TextDeletedEvent() @@ -1457,13 +1452,6 @@ void Controller::TextDeletedEvent() // Apply modifications to the model; TODO - Optimize this mImpl->mOperationsPending = ALL_OPERATIONS; - - // Queue a cursor reposition event; this must wait until after DoRelayout() - mImpl->mEventData->mUpdateCursorPosition = true; - if( 0u != mImpl->mLogicalModel->mText.Count() ) - { - mImpl->mEventData->mScrollAfterDelete = true; - } } bool Controller::DoRelayout( const Size& size, @@ -1930,16 +1918,13 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // TODO: At the moment the underline runs are only for pre-edit. mImpl->mVisualModel->mUnderlineRuns.Clear(); - Vector utf32Characters; - Length characterCount( 0u ); + // Keep the current number of characters. + const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u; - // Remove the previous IMF pre-edit (predicitive text) - if( mImpl->mEventData->mPreEditFlag && - ( 0u != mImpl->mEventData->mPreEditLength ) ) + // Remove the previous IMF pre-edit. + if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) ) { - const CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition; - - removedPrevious = RemoveText( -static_cast( offset ), + removedPrevious = RemoveText( -static_cast( mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition ), mImpl->mEventData->mPreEditLength, DONT_UPDATE_INPUT_STYLE ); @@ -1948,10 +1933,13 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ } else { - // Remove the previous Selection + // Remove the previous Selection. removedPrevious = RemoveSelectedText(); } + Vector utf32Characters; + Length characterCount = 0u; + if( !text.empty() ) { // Convert text into UTF-32 @@ -2116,6 +2104,8 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition ); } + const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u; + if( ( 0u == mImpl->mLogicalModel->mText.Count() ) && mImpl->IsPlaceholderAvailable() ) { @@ -2129,6 +2119,16 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ { // Queue an inserted event mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED ); + + mImpl->mEventData->mUpdateCursorPosition = true; + if( numberOfCharacters < currentNumberOfCharacters ) + { + mImpl->mEventData->mScrollAfterDelete = true; + } + else + { + mImpl->mEventData->mScrollAfterUpdatePosition = true; + } } if( maxLengthReached ) @@ -2441,8 +2441,11 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt else { ShowPlaceholderText(); - mImpl->mEventData->mUpdateCursorPosition = true; } + + mImpl->mEventData->mUpdateCursorPosition = true; + mImpl->mEventData->mScrollAfterDelete = true; + mImpl->RequestRelayout(); mImpl->mControlInterface.TextChanged(); break; @@ -2530,8 +2533,9 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons else { ShowPlaceholderText(); - mImpl->mEventData->mUpdateCursorPosition = true; } + mImpl->mEventData->mUpdateCursorPosition = true; + mImpl->mEventData->mScrollAfterDelete = true; } requestRelayout = true; break; @@ -2618,8 +2622,9 @@ bool Controller::BackspaceKeyEvent() else { ShowPlaceholderText(); - mImpl->mEventData->mUpdateCursorPosition = true; } + mImpl->mEventData->mUpdateCursorPosition = true; + mImpl->mEventData->mScrollAfterDelete = true; } return removed;