TextFit : modified it to work even if you change the text or multi-line attributes. 26/209326/5
authorJoogab Yun <joogab.yun@samsung.com>
Fri, 5 Jul 2019 01:51:23 +0000 (10:51 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Tue, 9 Jul 2019 04:26:02 +0000 (13:26 +0900)
    // text fit test
    Property::Map backgroundMap;
    backgroundMap["color"] = Color::RED;
    backgroundMap["enable"] = true;

    Property::Map textFitMap;
    textFitMap["enable"] = true;
    textFitMap["minSize"] = 10.f;
    textFitMap["maxSize"] = 100.f;
    textFitMap["stepSize"] = 1.f;
    textFitMap["fontSizeType"] = "pointSize";

    textFit = TextLabel::New(  "This is a Text Fit sample text " );
    textFit.SetSize( 750, 100 );
    textFit.SetParentOrigin(ParentOrigin::TOP_LEFT);
    textFit.SetAnchorPoint(AnchorPoint::TOP_LEFT);
    textFit.SetPosition( 100.f, 100.f);
    textFit.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMap );
    textFit.SetProperty( Toolkit::DevelTextLabel::Property::BACKGROUND, backgroundMap );
    stage.Add( textFit );

    stage.GetRootLayer().TouchSignal().Connect( this, &HelloWorldController::OnTextFitTouch );

  bool OnTextFitTouch( Actor actor, const TouchData& touch )
  {

    textFit.SetProperty( TextLabel::Property::TEXT, "Long enough message for TextLabel!! ");
    textFit.SetProperty( TextLabel::Property::MULTI_LINE, true );

    return true;
  }

Change-Id: I81927d70db58211892fc98592eadfccf5a69d374

dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index 0259391..c521817 100755 (executable)
@@ -959,12 +959,10 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
   Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
 
-  // If the same text comes for relayouting for same layout size we don't need to calculate point size again.
-  // Like for color change.
-  if (mController->IsTextFitEnabled() && (mController->GetTextFitContentSize() != contentSize ) )
+  if( mController->IsTextFitEnabled() )
   {
-    mController->FitPointSizeforLayout(contentSize);
-    mController->SetTextFitContentSize(contentSize);
+    mController->FitPointSizeforLayout( contentSize );
+    mController->SetTextFitContentSize( contentSize );
   }
 
   // Support Right-To-Left
index 36c5194..a7b098a 100755 (executable)
@@ -2128,6 +2128,9 @@ bool Controller::CheckForTextFit( float pointSize, Size& layoutSize )
 
 void Controller::FitPointSizeforLayout( Size layoutSize )
 {
+  const OperationsMask operations  = mImpl->mOperationsPending;
+  if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
+  {
     bool actualellipsis = mImpl->mModel->mElideEnabled;
     float minPointSize = mImpl->mTextFitMinSize;
     float maxPointSize = mImpl->mTextFitMaxSize;
@@ -2174,6 +2177,7 @@ void Controller::FitPointSizeforLayout( Size layoutSize )
     mImpl->mFontDefaults->mFitPointSize = pointSizeArray[bestSizeIndex];
     mImpl->mFontDefaults->sizeDefined = true;
     ClearFontData();
+  }
 }
 
 float Controller::GetHeightForWidth( float width )