Fix issue of applying ellipsis with negative line spacing 86/272386/2
authorabdullah <abdullahhasan10@gmail.com>
Tue, 15 Mar 2022 12:18:37 +0000 (15:18 +0300)
committerabdulleh ghujeh <abdullahhasan10@gmail.com>
Tue, 15 Mar 2022 12:21:35 +0000 (12:21 +0000)
When setting negative line spacing, ellipsis applied even there is space for more lines.

Change-Id: Ife870f11b7b081fcdc0447a5fc96d0fce1a1e95b

automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/text/layouts/layout-engine.cpp

index 0524d55..9d9567b 100644 (file)
@@ -5857,6 +5857,36 @@ int UtcDaliTextEditorTextSizeNegativeLineSpacing(void)
   END_TEST;
 }
 
+int UtcDaliTextEditorNegativeLineSpacingWithEllipsis(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliTextEditorNegativeLineSpacingWithEllipsis");
+
+  TextEditor editor = TextEditor::New();
+
+  float lineSpacing = -20.f;
+
+  editor.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
+  editor.SetProperty(TextEditor::Property::POINT_SIZE, 11.0f);
+  editor.SetProperty(DevelTextEditor::Property::LINE_SPACING, lineSpacing);
+  editor.SetProperty(TextEditor::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
+  editor.SetProperty(DevelTextEditor::Property::ELLIPSIS, true);
+
+  application.GetScene().Add(editor);
+  application.SendNotification();
+  application.Render();
+
+  Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, 0, 123);
+
+  int lineCount = sizeList.Size();
+  DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
 int UtcDaliToolkitTexteditorParagraphTag(void)
 {
   ToolkitTestApplication application;
index e12ce04..bbd3d77 100644 (file)
@@ -2725,6 +2725,37 @@ int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
   END_TEST;
 }
 
+int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
+
+  TextLabel label = TextLabel::New();
+
+  float lineSpacing = -20.f;
+
+  label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
+  label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
+  label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
+  label.SetProperty(TextLabel::Property::MULTI_LINE, true);
+  label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
+  label.SetProperty(TextLabel::Property::ELLIPSIS, true);
+
+  application.GetScene().Add(label);
+  application.SendNotification();
+  application.Render();
+
+  Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
+
+  int lineCount = sizeList.Size();
+  DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
 int UtcDaliToolkitTextlabelParagraphTag(void)
 {
   ToolkitTestApplication application;
index 53030e2..aff78c6 100644 (file)
@@ -1306,6 +1306,15 @@ struct Engine::Impl
       {
         layoutSize.height += GetLineHeight(*lineRun, true);
       }
+      else
+      {
+        //when we apply ellipsis, the last line should not take negative linespacing into account for layoutSize.height calculation
+        //usually we don't includ it in normal cases using GetLineHeight()
+        if(lineRun->lineSpacing < 0)
+        {
+          layoutSize.height -= lineRun->lineSpacing;
+        }
+      }
 
       const Vector<BidirectionalLineInfoRun>& bidirectionalLinesInfo = layoutParameters.textModel->mLogicalModel->mBidirectionalLineInfo;