From 8e369410b566113d10a6cc760b133f61a7dfc6ca Mon Sep 17 00:00:00 2001 From: abdullah Date: Tue, 15 Mar 2022 15:18:37 +0300 Subject: [PATCH] Fix issue of applying ellipsis with negative line spacing When setting negative line spacing, ellipsis applied even there is space for more lines. Change-Id: Ife870f11b7b081fcdc0447a5fc96d0fce1a1e95b --- .../src/dali-toolkit/utc-Dali-TextEditor.cpp | 30 ++++++++++++++++++ .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 31 +++++++++++++++++++ .../internal/text/layouts/layout-engine.cpp | 9 ++++++ 3 files changed, 70 insertions(+) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 0524d55d51..9d9567b124 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -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 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; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index e12ce04025..bbd3d77c6d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -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 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; diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 53030e2564..aff78c62e5 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -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& bidirectionalLinesInfo = layoutParameters.textModel->mLogicalModel->mBidirectionalLineInfo; -- 2.34.1