From: abdullah Date: Tue, 15 Mar 2022 12:18:37 +0000 (+0300) Subject: Fix issue of applying ellipsis with negative line spacing X-Git-Tag: dali_2.1.15~9^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8e369410b566113d10a6cc760b133f61a7dfc6ca;ds=inline 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 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 0524d55..9d9567b 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 e12ce04..bbd3d77 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 53030e2..aff78c6 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;