Merge "Add MIN_LINE_SIZE property" into devel/master
authorjoogab yun <joogab.yun@samsung.com>
Mon, 18 May 2020 01:30:00 +0000 (01:30 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 18 May 2020 01:30:00 +0000 (01:30 +0000)
1  2 
dali-toolkit/internal/text/text-controller.cpp

@@@ -1462,6 -1462,22 +1462,22 @@@ float Controller::GetDefaultLineSpacing
    return mImpl->mLayoutEngine.GetDefaultLineSpacing();
  }
  
+ bool Controller::SetDefaultLineSize( float lineSize )
+ {
+   if( std::fabs( lineSize - mImpl->mLayoutEngine.GetDefaultLineSize() ) > Math::MACHINE_EPSILON_1000 )
+   {
+     mImpl->mLayoutEngine.SetDefaultLineSize(lineSize);
+     mImpl->mRecalculateNaturalSize = true;
+     return true;
+   }
+   return false;
+ }
+ float Controller::GetDefaultLineSize() const
+ {
+   return mImpl->mLayoutEngine.GetDefaultLineSize();
+ }
  void Controller::SetInputColor( const Vector4& color )
  {
    if( NULL != mImpl->mEventData )
@@@ -1520,32 -1536,17 +1536,32 @@@ void Controller::SetInputFontFamily( co
      {
        CharacterIndex startOfSelectedText = 0u;
        Length lengthOfSelectedText = 0u;
 -      FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 -                                                                            mImpl->mModel->mLogicalModel,
 -                                                                            startOfSelectedText,
 -                                                                            lengthOfSelectedText );
  
 -      fontDescriptionRun.familyLength = fontFamily.size();
 -      fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
 -      memcpy( fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength );
 -      fontDescriptionRun.familyDefined = true;
 -
 -      // The memory allocated for the font family name is freed when the font description is removed from the logical model.
 +      if( EventData::SELECTING == mImpl->mEventData->mState )
 +      {
 +        // Update a font description run for the selecting state.
 +        FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 +                                                                              mImpl->mModel->mLogicalModel,
 +                                                                              startOfSelectedText,
 +                                                                              lengthOfSelectedText );
 +
 +        fontDescriptionRun.familyLength = fontFamily.size();
 +        fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
 +        memcpy( fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength );
 +        fontDescriptionRun.familyDefined = true;
 +
 +        // The memory allocated for the font family name is freed when the font description is removed from the logical model.
 +
 +        mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 +      }
 +      else
 +      {
 +        mImpl->mTextUpdateInfo.mCharacterIndex = 0;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 +      }
  
        // Request to relayout.
        mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
        mImpl->mRecalculateNaturalSize = true;
        mImpl->RequestRelayout();
  
 -      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 -
        // As the font changes, recalculate the handle positions is needed.
        mImpl->mEventData->mUpdateLeftSelectionPosition = true;
        mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@@ -1590,28 -1595,13 +1606,28 @@@ void Controller::SetInputFontWeight( Fo
      {
        CharacterIndex startOfSelectedText = 0u;
        Length lengthOfSelectedText = 0u;
 -      FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 -                                                                            mImpl->mModel->mLogicalModel,
 -                                                                            startOfSelectedText,
 -                                                                            lengthOfSelectedText );
  
 -      fontDescriptionRun.weight = weight;
 -      fontDescriptionRun.weightDefined = true;
 +      if( EventData::SELECTING == mImpl->mEventData->mState )
 +      {
 +        // Update a font description run for the selecting state.
 +        FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 +                                                                              mImpl->mModel->mLogicalModel,
 +                                                                              startOfSelectedText,
 +                                                                              lengthOfSelectedText );
 +
 +        fontDescriptionRun.weight = weight;
 +        fontDescriptionRun.weightDefined = true;
 +
 +        mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 +      }
 +      else
 +      {
 +        mImpl->mTextUpdateInfo.mCharacterIndex = 0;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 +      }
  
        // Request to relayout.
        mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
        mImpl->mRecalculateNaturalSize = true;
        mImpl->RequestRelayout();
  
 -      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 -
        // As the font might change, recalculate the handle positions is needed.
        mImpl->mEventData->mUpdateLeftSelectionPosition = true;
        mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@@ -1667,28 -1661,13 +1683,28 @@@ void Controller::SetInputFontWidth( Fon
      {
        CharacterIndex startOfSelectedText = 0u;
        Length lengthOfSelectedText = 0u;
 -      FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 -                                                                            mImpl->mModel->mLogicalModel,
 -                                                                            startOfSelectedText,
 -                                                                            lengthOfSelectedText );
  
 -      fontDescriptionRun.width = width;
 -      fontDescriptionRun.widthDefined = true;
 +      if( EventData::SELECTING == mImpl->mEventData->mState )
 +      {
 +        // Update a font description run for the selecting state.
 +        FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 +                                                                              mImpl->mModel->mLogicalModel,
 +                                                                              startOfSelectedText,
 +                                                                              lengthOfSelectedText );
 +
 +        fontDescriptionRun.width = width;
 +        fontDescriptionRun.widthDefined = true;
 +
 +        mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 +      }
 +      else
 +      {
 +        mImpl->mTextUpdateInfo.mCharacterIndex = 0;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 +      }
  
        // Request to relayout.
        mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
        mImpl->mRecalculateNaturalSize = true;
        mImpl->RequestRelayout();
  
 -      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 -
        // As the font might change, recalculate the handle positions is needed.
        mImpl->mEventData->mUpdateLeftSelectionPosition = true;
        mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@@ -1744,28 -1727,13 +1760,28 @@@ void Controller::SetInputFontSlant( Fon
      {
        CharacterIndex startOfSelectedText = 0u;
        Length lengthOfSelectedText = 0u;
 -      FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 -                                                                            mImpl->mModel->mLogicalModel,
 -                                                                            startOfSelectedText,
 -                                                                            lengthOfSelectedText );
  
 -      fontDescriptionRun.slant = slant;
 -      fontDescriptionRun.slantDefined = true;
 +      if( EventData::SELECTING == mImpl->mEventData->mState )
 +      {
 +        // Update a font description run for the selecting state.
 +        FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 +                                                                              mImpl->mModel->mLogicalModel,
 +                                                                              startOfSelectedText,
 +                                                                              lengthOfSelectedText );
 +
 +        fontDescriptionRun.slant = slant;
 +        fontDescriptionRun.slantDefined = true;
 +
 +        mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 +      }
 +      else
 +      {
 +        mImpl->mTextUpdateInfo.mCharacterIndex = 0;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 +      }
  
        // Request to relayout.
        mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
        mImpl->mRecalculateNaturalSize = true;
        mImpl->RequestRelayout();
  
 -      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 -
        // As the font might change, recalculate the handle positions is needed.
        mImpl->mEventData->mUpdateLeftSelectionPosition = true;
        mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@@ -1821,28 -1793,13 +1837,28 @@@ void Controller::SetInputFontPointSize
      {
        CharacterIndex startOfSelectedText = 0u;
        Length lengthOfSelectedText = 0u;
 -      FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 -                                                                            mImpl->mModel->mLogicalModel,
 -                                                                            startOfSelectedText,
 -                                                                            lengthOfSelectedText );
  
 -      fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
 -      fontDescriptionRun.sizeDefined = true;
 +      if( EventData::SELECTING == mImpl->mEventData->mState )
 +      {
 +        // Update a font description run for the selecting state.
 +        FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
 +                                                                              mImpl->mModel->mLogicalModel,
 +                                                                              startOfSelectedText,
 +                                                                              lengthOfSelectedText );
 +
 +        fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
 +        fontDescriptionRun.sizeDefined = true;
 +
 +        mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 +      }
 +      else
 +      {
 +        mImpl->mTextUpdateInfo.mCharacterIndex = 0;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 +        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 +      }
  
        // Request to relayout.
        mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
        mImpl->mRecalculateNaturalSize = true;
        mImpl->RequestRelayout();
  
 -      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
 -      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
 -
        // As the font might change, recalculate the handle positions is needed.
        mImpl->mEventData->mUpdateLeftSelectionPosition = true;
        mImpl->mEventData->mUpdateRightSelectionPosition = true;