Merge "Add the protected code and fix the crash issue" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
1  2 
dali-toolkit/internal/text/text-controller.cpp

@@@ -466,16 -466,6 +466,16 @@@ bool Controller::IsSelectionEnabled() c
    return mImpl->mEventData->mSelectionEnabled;
  }
  
 +void Controller::SetShiftSelectionEnabled( bool enabled )
 +{
 +  mImpl->mEventData->mShiftSelectionFlag = enabled;
 +}
 +
 +bool Controller::IsShiftSelectionEnabled() const
 +{
 +  return mImpl->mEventData->mShiftSelectionFlag;
 +}
 +
  // public : Update
  
  void Controller::SetText( const std::string& text )
@@@ -1192,14 -1182,14 +1192,14 @@@ const Vector4& Controller::GetOutlineCo
    return mImpl->mModel->mVisualModel->GetOutlineColor();
  }
  
 -void Controller::SetOutlineWidth( float width )
 +void Controller::SetOutlineWidth( unsigned int width )
  {
    mImpl->mModel->mVisualModel->SetOutlineWidth( width );
  
    mImpl->RequestRelayout();
  }
  
 -float Controller::GetOutlineWidth() const
 +unsigned int Controller::GetOutlineWidth() const
  {
    return mImpl->mModel->mVisualModel->GetOutlineWidth();
  }
@@@ -1244,15 -1234,10 +1244,15 @@@ const std::string& Controller::GetDefau
    return EMPTY_STRING;
  }
  
 -void Controller::SetDefaultLineSpacing( float lineSpacing )
 +bool Controller::SetDefaultLineSpacing( float lineSpacing )
  {
 -  //TODO finish implementation
 -  mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing );
 +  if( std::abs(lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000 )
 +  {
 +    mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
 +    mImpl->mRecalculateNaturalSize = true;
 +    return true;
 +  }
 +  return false;
  }
  
  float Controller::GetDefaultLineSpacing() const
@@@ -2120,15 -2105,8 +2120,15 @@@ void Controller::GetPlaceholderProperty
  
  Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
  {
 -  const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
 -  if ( firstline && firstline->direction )
 +  if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
 +  {
 +    return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
 +  }
 +
 +  const Character character = mImpl->mModel->mLogicalModel->mText[0];
 +  Script script = TextAbstraction::GetCharacterScript( character );
 +
 +  if( TextAbstraction::IsRightToLeftScript( script ) )
    {
      return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT;
    }
    return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
  }
  
 +Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
 +{
 +  return mImpl->mModel->GetVerticalLineAlignment();
 +}
 +
 +void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
 +{
 +  mImpl->mModel->mVerticalLineAlignment = alignment;
 +}
 +
  // public : Relayout.
  
  Controller::UpdateTextType Controller::Relayout( const Size& size )
    {
      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height );
  
+     if( ( 0 == mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd ) &&
+         ( 0 == mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) &&
+         ( ( mImpl->mModel->mVisualModel->mControlSize.width < Math::MACHINE_EPSILON_1000 ) || ( mImpl->mModel->mVisualModel->mControlSize.height < Math::MACHINE_EPSILON_1000 ) ) )
+     {
+       mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
+     }
      // Layout operations that need to be done if the size changes.
      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
                                                               LAYOUT                    |
@@@ -2769,17 -2744,7 +2776,17 @@@ ImfManager::ImfCallbackData Controller:
  
    if( retrieveText )
    {
 -    mImpl->GetText( numberOfWhiteSpaces, text );
 +    if( !mImpl->IsShowingPlaceholderText() )
 +    {
 +      // Retrieves the normal text string.
 +      mImpl->GetText( numberOfWhiteSpaces, text );
 +    }
 +    else
 +    {
 +      // When the current text is Placeholder Text, the surrounding text should be empty string.
 +      // It means DALi should send empty string ("") to IME.
 +      text = "";
 +    }
    }
  
    ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
@@@ -3412,7 -3377,7 +3419,7 @@@ bool Controller::DoRelayout( const Size
      const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
      const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
      const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
 -    float outlineWidth = mImpl->mModel->GetOutlineWidth();
 +    const float outlineWidth = static_cast<float>( mImpl->mModel->GetOutlineWidth() );
  
      // Set the layout parameters.
      Layout::Parameters layoutParameters( size,
@@@ -3739,7 -3704,7 +3746,7 @@@ bool Controller::DeleteEvent( int keyCo
                            1,
                            UPDATE_INPUT_STYLE );
    }
 -  else if( ( mImpl->mEventData->mPrimaryCursorPosition >= 0 ) && ( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) )
 +  else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE )
    {
      // Remove the character after the current cursor position
      removed = RemoveText( 0,
@@@ -3878,7 -3843,6 +3885,7 @@@ void Controller::ClearFontData(
    mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
                                                             VALIDATE_FONTS            |
                                                             SHAPE_TEXT                |
 +                                                           BIDI_INFO                 |
                                                             GET_GLYPH_METRICS         |
                                                             LAYOUT                    |
                                                             UPDATE_LAYOUT_SIZE        |