Merge "Fix cursor display issue." into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Thu, 9 Feb 2017 16:33:48 +0000 (08:33 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 9 Feb 2017 16:33:48 +0000 (08:33 -0800)
1  2 
dali-toolkit/internal/text/text-controller.cpp

@@@ -1344,17 -1344,16 +1344,17 @@@ Vector3 Controller::GetNaturalSize(
                                                                             BIDI_INFO         |
                                                                             SHAPE_TEXT        |
                                                                             GET_GLYPH_METRICS );
 +
 +    // Set the update info to relayout the whole text.
 +    mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
 +    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 +
      // Make sure the model is up-to-date before layouting
      mImpl->UpdateModel( onlyOnceOperations );
  
      // Layout the text for the new width.
      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT );
  
 -    // Set the update info to relayout the whole text.
 -    mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
 -    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 -
      // Store the actual control's size to restore later.
      const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize;
  
@@@ -1417,11 -1416,6 +1417,11 @@@ float Controller::GetHeightForWidth( fl
                                                                             BIDI_INFO         |
                                                                             SHAPE_TEXT        |
                                                                             GET_GLYPH_METRICS );
 +
 +    // Set the update info to relayout the whole text.
 +    mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
 +    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 +
      // Make sure the model is up-to-date before layouting
      mImpl->UpdateModel( onlyOnceOperations );
  
      // Layout the text for the new width.
      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | LAYOUT );
  
 -    // Set the update info to relayout the whole text.
 -    mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
 -    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 -
      // Store the actual control's width.
      const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
  
@@@ -1711,17 -1709,14 +1711,14 @@@ bool Controller::KeyEvent( const Dali::
      {
        textChanged = BackspaceKeyEvent();
      }
-     else if( IsKey( keyEvent,  Dali::DALI_KEY_POWER ) )
-     {
-       mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode.
-       // Avoids calling the InsertText() method which can delete selected text
-     }
-     else if( IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
+     else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) ||
+              IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
               IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
      {
+       // Power key/Menu/Home key behaviour does not allow edit mode to resume.
        mImpl->ChangeState( EventData::INACTIVE );
-       // Menu/Home key behaviour does not allow edit mode to resume like Power key
-       // Avoids calling the InsertText() method which can delete selected text
+       // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text.
      }
      else if( Dali::DALI_KEY_SHIFT_LEFT == keyCode )
      {
@@@ -2461,8 -2456,7 +2458,8 @@@ bool Controller::RemoveText( int cursor
        numberOfCharacters = currentText.Count() - cursorIndex;
      }
  
 -    if( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
 +    if( mImpl->mEventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
 +        ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) )
      {
        // Mark the paragraphs to be updated.
        mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );