From: David Steele Date: Fri, 7 Jan 2022 10:19:16 +0000 (+0000) Subject: Merge "DALi Version 2.1.4" into devel/master X-Git-Tag: dali_2.1.5~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a70d28d882e56f123f8eec322b4ca9594b2307cd;hp=35178dae6226eab22f06990f059364bfd59e6939 Merge "DALi Version 2.1.4" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp old mode 100755 new mode 100644 index 0b18d11..e588998 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,16 +15,16 @@ * */ -#include #include +#include #include #include -#include #include -#include +#include #include +#include using namespace Dali; using namespace Toolkit; @@ -33,20 +33,20 @@ using namespace Text; int UtcDaliTextEditorSelectText(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliTextEditorSelectText" ); + tet_infoline("UtcDaliTextEditorSelectText"); // Create a text editor TextEditor textEditor = TextEditor::New(); - textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) ); - textEditor.SetProperty( TextEditor::Property::TEXT, "Hello World" ); + textEditor.SetProperty(Actor::Property::SIZE, Vector2(400.f, 60.f)); + textEditor.SetProperty(TextEditor::Property::TEXT, "Hello World"); // Add the text editor to the stage - application.GetScene().Add( textEditor ); + application.GetScene().Add(textEditor); application.SendNotification(); application.Render(); - Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor ); + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); application.SendNotification(); application.Render(); @@ -58,7 +58,7 @@ int UtcDaliTextEditorSelectText(void) application.Render(); std::string selectedText = textEditorImpl.GetSelectedText(); - DALI_TEST_CHECK( selectedText == "Hello World" ); + DALI_TEST_CHECK(selectedText == "Hello World"); // Select None textEditorImpl.SelectNone(); @@ -67,7 +67,7 @@ int UtcDaliTextEditorSelectText(void) application.Render(); selectedText = textEditorImpl.GetSelectedText(); - DALI_TEST_CHECK( selectedText == "" ); + DALI_TEST_CHECK(selectedText == ""); END_TEST; } @@ -79,33 +79,33 @@ int UtcDaliTextEditorMarkupUnderline(void) TextEditor textEditor = TextEditor::New(); - application.GetScene().Add( textEditor ); + application.GetScene().Add(textEditor); - textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEFGH" ); - textEditor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true ); + textEditor.SetProperty(TextEditor::Property::TEXT, "ABCEFGH"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); application.SendNotification(); application.Render(); uint32_t expectedNumberOfUnderlinedGlyphs = 5u; - Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor ); - const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + const Text::Length numberOfUnderlineRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfUnderlineRuns(); - DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION ); + DALI_TEST_EQUALS(numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION); Vector underlineRuns; underlineRuns.Resize(numberOfUnderlineRuns); textEditorImpl.GetTextController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns); //ABC are underlined - DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION); - DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION); - DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION); //GH are underlined - DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION); - DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION); + DALI_TEST_EQUALS(underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION); END_TEST; } @@ -118,27 +118,26 @@ int UtcDaliTextEditorFontPointSizeLargerThanAtlas(void) // Create a text editor TextEditor textEditor = TextEditor::New(); //Set size to avoid automatic eliding - textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025)); + textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025)); //Set very large font-size using point-size - textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000); + textEditor.SetProperty(TextEditor::Property::POINT_SIZE, 1000); //Specify font-family - textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans"); + textEditor.SetProperty(TextEditor::Property::FONT_FAMILY, "DejaVu Sans"); //Set text to check if appear or not textEditor.SetProperty(TextEditor::Property::TEXT, "A"); - application.GetScene().Add( textEditor ); + application.GetScene().Add(textEditor); application.SendNotification(); application.Render(); //Check if Glyph is added to AtlasGlyphManger or not int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount; - DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION ); + DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION); END_TEST; } - int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void) { ToolkitTestApplication application; @@ -146,25 +145,25 @@ int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void) //Set Map of placeholder: text, font-family and point-size Property::Map placeholderMapSet; - placeholderMapSet["text"] = "A"; + placeholderMapSet["text"] = "A"; placeholderMapSet["fontFamily"] = "DejaVu Sans"; - placeholderMapSet["pixelSize"] = 1000.0f; + placeholderMapSet["pixelSize"] = 1000.0f; // Create a text editor TextEditor textEditor = TextEditor::New(); //Set size to avoid automatic eliding - textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025)); + textEditor.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025)); //Set placeholder - textEditor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet) ; + textEditor.SetProperty(TextEditor::Property::PLACEHOLDER, placeholderMapSet); - application.GetScene().Add( textEditor ); + application.GetScene().Add(textEditor); application.SendNotification(); application.Render(); //Check if Glyph is added to AtlasGlyphManger or not int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount; - DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION ); + DALI_TEST_EQUALS(countAtlas, 1, TEST_LOCATION); END_TEST; } @@ -175,27 +174,27 @@ int UtcDaliTextEditorBackgroundTag(void) tet_infoline("UtcDaliTextEditorBackgroundTag\n"); TextEditor editor = TextEditor::New(); - DALI_TEST_CHECK( editor ); + DALI_TEST_CHECK(editor); - editor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true ); - editor.SetProperty( TextEditor::Property::TEXT, "He World" ); - application.GetScene().Add( editor ); + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "He World"); + application.GetScene().Add(editor); application.SendNotification(); application.Render(); - Toolkit::Internal::TextEditor& editorImpl = GetImpl( editor ); - const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); - DALI_TEST_CHECK( backgroundColorIndicesBuffer ); + DALI_TEST_CHECK(backgroundColorIndicesBuffer); //default color - DALI_TEST_EQUALS( backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); //red color - DALI_TEST_EQUALS( backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); //yellow color - DALI_TEST_EQUALS( backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); END_TEST; } @@ -206,17 +205,17 @@ int UtcDaliTextEditorTextWithSpan(void) tet_infoline("UtcDaliTextEditorTextWithSpan\n"); TextEditor editor = TextEditor::New(); - DALI_TEST_CHECK( editor ); + DALI_TEST_CHECK(editor); - editor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true ); - editor.SetProperty( TextEditor::Property::TEXT, "Hello Span" ); - application.GetScene().Add( editor ); + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); + application.GetScene().Add(editor); application.SendNotification(); application.Render(); Vector3 originalSize = editor.GetNaturalSize(); - editor.SetProperty( TextEditor::Property::TEXT, "Hello Span" ); + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); application.SendNotification(); application.Render(); @@ -225,41 +224,40 @@ int UtcDaliTextEditorTextWithSpan(void) DALI_TEST_GREATER(spanSize.width, originalSize.width, TEST_LOCATION); - Toolkit::Internal::TextEditor& editorImpl = GetImpl( editor ); - const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices(); + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const colorIndicesBuffer1 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices(); - DALI_TEST_CHECK( colorIndicesBuffer1 ); + DALI_TEST_CHECK(colorIndicesBuffer1); //default color - DALI_TEST_EQUALS( colorIndicesBuffer1[0], 0u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer1[0], 0u, TEST_LOCATION); //span color - DALI_TEST_EQUALS( colorIndicesBuffer1[1], 1u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer1[1], 1u, TEST_LOCATION); //default color - DALI_TEST_EQUALS( colorIndicesBuffer1[6], 0u, TEST_LOCATION); - + DALI_TEST_EQUALS(colorIndicesBuffer1[6], 0u, TEST_LOCATION); - editor.SetProperty( TextEditor::Property::TEXT, "Hello Span" ); + editor.SetProperty(TextEditor::Property::TEXT, "Hello Span"); application.SendNotification(); application.Render(); const ColorIndex* const colorIndicesBuffer2 = editorImpl.GetTextController()->GetTextModel()->GetColorIndices(); - DALI_TEST_CHECK( colorIndicesBuffer2 ); + DALI_TEST_CHECK(colorIndicesBuffer2); //default color - DALI_TEST_EQUALS( colorIndicesBuffer2[0], 0u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer2[0], 0u, TEST_LOCATION); //default color - DALI_TEST_EQUALS( colorIndicesBuffer2[1], 0u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer2[1], 0u, TEST_LOCATION); //span color - DALI_TEST_EQUALS( colorIndicesBuffer2[6], 1u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer2[6], 1u, TEST_LOCATION); //default color - DALI_TEST_EQUALS( colorIndicesBuffer2[7], 0u, TEST_LOCATION); + DALI_TEST_EQUALS(colorIndicesBuffer2[7], 0u, TEST_LOCATION); END_TEST; } @@ -279,9 +277,9 @@ int UtcDaliTextEditorControlBackgroundColor(void) application.SendNotification(); application.Render(); - Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); - ControllerPtr controller = editorImpl.GetTextController(); - Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get()); + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + ControllerPtr controller = editorImpl.GetTextController(); + Controller::Impl& controllerImpl = Controller::Impl::GetImplementation(*controller.Get()); // Default color is transparent controllerImpl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor); @@ -298,3 +296,44 @@ int UtcDaliTextEditorControlBackgroundColor(void) END_TEST; } + +int UtcDaliTextEditorTextPositionWithMinLineAndBigFont(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorTextPositionWithMinLine "); + + TextEditor textEditor = TextEditor::New(); + + textEditor.SetProperty(TextEditor::Property::TEXT, "H\ni"); + textEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.GetScene().Add(textEditor); + + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::ViewInterface& view = textEditorImpl.GetTextController()->GetView(); + + Length numberOfGlyphs = view.GetNumberOfGlyphs(); + + DALI_TEST_EQUALS(numberOfGlyphs, 3u, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Vector glyphs; + glyphs.Resize(numberOfGlyphs); + + Vector positions; + positions.Resize(numberOfGlyphs); + + float alignmentOffset = 0u; + numberOfGlyphs = view.GetGlyphs(glyphs.Begin(), + positions.Begin(), + alignmentOffset, + 0u, + numberOfGlyphs); + + DALI_TEST_EQUALS(positions[2].y, 165.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 4e9890c..49a2d25 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -105,6 +105,7 @@ const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGr const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection"; const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength"; const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; +const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale"; const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor"; const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup"; const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings"; @@ -554,6 +555,7 @@ int UtcDaliTextEditorGetPropertyP(void) DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ); @@ -633,6 +635,10 @@ int UtcDaliTextEditorSetPropertyP(void) DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f ); + editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false ); + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION ); + editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true ); + // Reset font style. fontStyleMapSet.Clear(); fontStyleMapSet.Insert( "weight", "normal" ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index a6e2668..a4f5433 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -107,6 +107,7 @@ const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSys const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup"; const char* const PROPERTY_NAME_BACKGROUND = "textBackground"; const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; +const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale"; const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor"; const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter"; @@ -570,6 +571,7 @@ int UtcDaliTextFieldGetPropertyP(void) DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE ); + DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE ); DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ); @@ -652,6 +654,10 @@ int UtcDaliTextFieldSetPropertyP(void) DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f ); + field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false ); + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION ); + field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true ); + // Reset font style. fontStyleMapSet.Clear(); fontStyleMapSet.Insert( "weight", "normal" ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index c060743..621c634 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -74,6 +74,7 @@ const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize"; const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis"; const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay"; const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale"; +const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale"; const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition"; @@ -352,6 +353,7 @@ int UtcDaliToolkitTextLabelGetPropertyP(void) DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION ); END_TEST; @@ -408,6 +410,10 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS( label.GetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f ); + label.SetProperty( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false ); + DALI_TEST_EQUALS( label.GetProperty( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION ); + label.SetProperty( DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true ); + // Reset font style. fontStyleMapSet.Clear(); fontStyleMapSet.Insert( "weight", "normal" ); diff --git a/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h index 74c19df..879bdf0 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_EDITOR_DEVEL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,6 +178,14 @@ enum Type FONT_SIZE_SCALE, /** + * @brief True to enable the font size scale or false to disable. + * @details Name "enableFontSizeScale", type Property::BOOLEAN. + * @note The default value is true. + * If false, font size scale is not apppied. + */ + ENABLE_FONT_SIZE_SCALE, + + /** * @brief The position for primary cursor. * @details Name "primaryCursorPosition", type Property::INTEGER. */ diff --git a/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h index 7498110..a01a4b4 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_FIELD_DEVEL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,6 +163,14 @@ enum FONT_SIZE_SCALE, /** + * @brief True to enable the font size scale or false to disable. + * @details Name "enableFontSizeScale", type Property::BOOLEAN. + * @note The default value is true. + * If false, font size scale is not apppied. + */ + ENABLE_FONT_SIZE_SCALE, + + /** * @brief The position for primary cursor. * @details Name "primaryCursorPosition", type Property::INTEGER. */ diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h index 17a808f..d60c205 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_LABEL_DEVEL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,6 +156,14 @@ enum Type FONT_SIZE_SCALE, /** + * @brief True to enable the font size scale or false to disable. + * @details Name "enableFontSizeScale", type Property::BOOLEAN. + * @note The default value is true. + * If false, font size scale is not apppied. + */ + ENABLE_FONT_SIZE_SCALE, + + /** * @brief The enumerations used to specify whether to position the ellipsis at the END, START or MIDDLE of the text. * @details Name "EllipsisPosition", type [Type](@ref Dali::Toolkit::DevelText::EllipsisPosition::Type) (Property::INTEGER), or Property::STRING. Read/Write * @note Default is EllipsisPosition::END. diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index d35e92b..50139ce 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,6 +146,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "verticalScrollP DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "enableEditing", BOOLEAN, ENABLE_EDITING ) DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextEditor, "selectedText", STRING, SELECTED_TEXT ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "fontSizeScale", FLOAT, FONT_SIZE_SCALE ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "enableFontSizeScale", BOOLEAN, ENABLE_FONT_SIZE_SCALE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "grabHandleColor", VECTOR4, GRAB_HANDLE_COLOR ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP ) diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp index f35c169..1ffaa44 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ * limitations under the License. */ -#include #include +#include #include @@ -610,6 +610,15 @@ void TextEditor::PropertyHandler::SetProperty(Toolkit::TextEditor textEditor, Pr } break; } + case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE: + { + const bool enableFontSizeScale = value.Get(); + if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale)) + { + impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale); + } + break; + } case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: { uint32_t position = static_cast(value.Get()); @@ -1032,6 +1041,11 @@ Property::Value TextEditor::PropertyHandler::GetProperty(Toolkit::TextEditor tex value = impl.mController->GetFontSizeScale(); break; } + case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE: + { + value = impl.mController->IsFontSizeScaleEnabled(); + break; + } case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: { value = static_cast(impl.mController->GetPrimaryCursorPosition()); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 7eec04e..c37208d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,6 +137,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextStar DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableFontSizeScale", BOOLEAN, ENABLE_FONT_SIZE_SCALE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleColor", VECTOR4, GRAB_HANDLE_COLOR ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFilter", MAP, INPUT_FILTER ) diff --git a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp index dc253f0..9a82279 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ * limitations under the License. */ -#include #include +#include #include #include @@ -626,6 +626,15 @@ void TextField::PropertyHandler::SetProperty(Toolkit::TextField textField, Prope } break; } + case Toolkit::DevelTextField::Property::ENABLE_FONT_SIZE_SCALE: + { + const bool enableFontSizeScale = value.Get(); + if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale)) + { + impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale); + } + break; + } case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: { uint32_t position = static_cast(value.Get()); @@ -1003,6 +1012,11 @@ Property::Value TextField::PropertyHandler::GetProperty(Toolkit::TextField textF value = impl.mController->GetFontSizeScale(); break; } + case Toolkit::DevelTextField::Property::ENABLE_FONT_SIZE_SCALE: + { + value = impl.mController->IsFontSizeScaleEnabled(); + break; + } case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: { value = static_cast(impl.mController->GetPrimaryCursorPosition()); diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index ae948e2..8fec200 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,6 +136,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "textFit", DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "minLineSize", FLOAT, MIN_LINE_SIZE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "renderingBackend", INTEGER, RENDERING_BACKEND ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "fontSizeScale", FLOAT, FONT_SIZE_SCALE ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "enableFontSizeScale", BOOLEAN, ENABLE_FONT_SIZE_SCALE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "ellipsisPosition", INTEGER, ELLIPSIS_POSITION ) DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR ) @@ -508,6 +509,15 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro } break; } + case Toolkit::DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE: + { + const bool enableFontSizeScale = value.Get(); + if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale)) + { + impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale); + } + break; + } case Toolkit::DevelTextLabel::Property::ELLIPSIS_POSITION: { DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set @@ -756,6 +766,11 @@ Property::Value TextLabel::GetProperty(BaseObject* object, Property::Index index value = impl.mController->GetFontSizeScale(); break; } + case Toolkit::DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE: + { + value = impl.mController->IsFontSizeScaleEnabled(); + break; + } case Toolkit::DevelTextLabel::Property::ELLIPSIS_POSITION: { value = impl.mController->GetEllipsisPosition(); diff --git a/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp b/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp index 1ce7516..bd93e68 100644 --- a/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp +++ b/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ namespace Dali::Toolkit::Text { - namespace { #if defined(DEBUG_ENABLED) @@ -90,7 +89,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o // Check whether the indices for updating the text is valid if(numberOfCharacters > 0u && (impl.mTextUpdateInfo.mParagraphCharacterIndex > numberOfCharacters || - impl.mTextUpdateInfo.mRequestedNumberOfCharacters > numberOfCharacters)) + impl.mTextUpdateInfo.mRequestedNumberOfCharacters > numberOfCharacters)) { std::string currentText; Utf32ToUtf8(impl.mModel->mLogicalModel->mText.Begin(), numberOfCharacters, currentText); @@ -146,7 +145,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o lineBreakInfo); if(impl.mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || - impl.mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) + impl.mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) { CharacterIndex end = startIndex + requestedNumberOfCharacters; LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin(); @@ -212,7 +211,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o // Get the default font's description. TextAbstraction::FontDescription defaultFontDescription; - TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE * impl.mFontSizeScale; + TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE * impl.GetFontSizeScale(); //Get the number of points per one unit of point-size uint32_t numberOfPointsPerOneUnitOfPointSize = impl.mFontClient.GetNumberOfPointsPerOneUnitOfPointSize(); @@ -223,7 +222,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o defaultFontDescription = impl.mEventData->mPlaceholderFont->mFontDescription; if(impl.mEventData->mPlaceholderFont->sizeDefined) { - defaultPointSize = impl.mEventData->mPlaceholderFont->mDefaultPointSize * impl.mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; + defaultPointSize = impl.mEventData->mPlaceholderFont->mDefaultPointSize * impl.GetFontSizeScale() * numberOfPointsPerOneUnitOfPointSize; } } else if(nullptr != impl.mFontDefaults) @@ -237,7 +236,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o } else { - defaultPointSize = impl.mFontDefaults->mDefaultPointSize * impl.mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; + defaultPointSize = impl.mFontDefaults->mDefaultPointSize * impl.GetFontSizeScale() * numberOfPointsPerOneUnitOfPointSize; } } @@ -352,7 +351,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o } if((nullptr != impl.mEventData) && - impl.mEventData->mPreEditFlag && + impl.mEventData->mPreEditFlag && (0u != impl.mModel->mVisualModel->mCharactersToGlyph.Count())) { Dali::InputMethodContext::PreEditAttributeDataContainer attrs; @@ -565,7 +564,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o if((Controller::NO_OPERATION != (Controller::SHAPE_TEXT & operations)) && !((nullptr != impl.mEventData) && - impl.mEventData->mPreEditFlag && + impl.mEventData->mPreEditFlag && (0u != impl.mModel->mVisualModel->mCharactersToGlyph.Count()))) { //Mark-up processor case diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index e0603f8..6ffa715 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -672,11 +672,11 @@ float Controller::Impl::GetDefaultFontLineHeight() if(nullptr == mFontDefaults) { TextAbstraction::FontDescription fontDescription; - defaultFontId = mFontClient.GetFontId(fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE * mFontSizeScale); + defaultFontId = mFontClient.GetFontId(fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE * GetFontSizeScale()); } else { - defaultFontId = mFontDefaults->GetFontId(mFontClient, mFontDefaults->mDefaultPointSize * mFontSizeScale); + defaultFontId = mFontDefaults->GetFontId(mFontClient, mFontDefaults->mDefaultPointSize * GetFontSizeScale()); } Text::FontMetrics fontMetrics; diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 3c72bdb..92235b0 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -357,6 +357,7 @@ struct Controller::Impl mTextFitMaxSize(DEFAULT_TEXTFIT_MAX), mTextFitStepSize(DEFAULT_TEXTFIT_STEP), mFontSizeScale(DEFAULT_FONT_SIZE_SCALE), + mFontSizeScaleEnabled(true), mTextFitEnabled(false), mTextFitChanged(false), mIsLayoutDirectionChanged(false) @@ -497,6 +498,11 @@ struct Controller::Impl } } + float GetFontSizeScale() + { + return mFontSizeScaleEnabled ? mFontSizeScale : 1.0f; + } + /** * @brief Helper to notify InputMethodContext with surrounding text & cursor changes. */ @@ -976,6 +982,7 @@ public: float mTextFitMaxSize; ///< Maximum Font Size for text fit. Default 100 float mTextFitStepSize; ///< Step Size for font intervalse. Default 1 float mFontSizeScale; ///< Scale value for Font Size. Default 1.0 + bool mFontSizeScaleEnabled : 1; ///< Whether the font size scale is enabled. bool mTextFitEnabled : 1; ///< Whether the text's fit is enabled. bool mTextFitChanged : 1; ///< Whether the text fit property has changed. bool mIsLayoutDirectionChanged : 1; ///< Whether the layout has changed. diff --git a/dali-toolkit/internal/text/text-controller-input-font-handler.cpp b/dali-toolkit/internal/text/text-controller-input-font-handler.cpp index 8a3ac3e..988ddd1 100644 --- a/dali-toolkit/internal/text/text-controller-input-font-handler.cpp +++ b/dali-toolkit/internal/text/text-controller-input-font-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -393,7 +393,7 @@ void Controller::InputFontHandler::SetInputFontPointSize(Controller& controller, startOfSelectedText, lengthOfSelectedText); - fontDescriptionRun.size = static_cast(size * controller.mImpl->mFontSizeScale * 64.f); + fontDescriptionRun.size = static_cast(size * controller.mImpl->GetFontSizeScale() * 64.f); fontDescriptionRun.sizeDefined = true; controller.mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText; diff --git a/dali-toolkit/internal/text/text-controller-text-updater.cpp b/dali-toolkit/internal/text/text-controller-text-updater.cpp index 0bcb97f..ab90270 100644 --- a/dali-toolkit/internal/text/text-controller-text-updater.cpp +++ b/dali-toolkit/internal/text/text-controller-text-updater.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -351,7 +351,7 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri if(addFontSizeRun) { - fontDescriptionRun.size = static_cast(inputStyle.size * impl.mFontSizeScale * 64.f); + fontDescriptionRun.size = static_cast(inputStyle.size * impl.GetFontSizeScale() * 64.f); fontDescriptionRun.sizeDefined = true; } diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index be985d1..41ef903 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -667,6 +667,9 @@ void Controller::SetFontSizeScale(float scale) { mImpl->mFontSizeScale = scale; + // No relayout is required + if(!mImpl->mFontSizeScaleEnabled) return; + // Update the cursor position if it's in editing mode UpdateCursorPosition(mImpl->mEventData); @@ -681,6 +684,24 @@ float Controller::GetFontSizeScale() const return mImpl->mFontDefaults ? mImpl->mFontSizeScale : 1.0f; } +void Controller::SetFontSizeScaleEnabled(bool enabled) +{ + mImpl->mFontSizeScaleEnabled = enabled; + + // Update the cursor position if it's in editing mode + UpdateCursorPosition(mImpl->mEventData); + + // Clear the font-specific data + mImpl->ClearFontData(); + + mImpl->RequestRelayout(); +} + +bool Controller::IsFontSizeScaleEnabled() const +{ + return mImpl->mFontSizeScaleEnabled; +} + void Controller::SetDefaultFontSize(float fontSize, FontSizeType type) { EnsureCreated(mImpl->mFontDefaults); diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index b16186b..03d8e19 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -908,6 +908,20 @@ public: // Default style & Input style float GetFontSizeScale() const; /** + * @brief Set the font size scale enabled flag. + * + * @param[in] enabled whether to enable the font size scale. + */ + void SetFontSizeScaleEnabled(bool enabled); + + /** + * @brief Returns whether the font size scale is enabled or not. + * + * @return @e true if the font size scale is enabled, otherwise returns @e false. + */ + bool IsFontSizeScaleEnabled() const; + + /** * @brief Sets the Placeholder text font size. * @param[in] fontSize The placeholder text font size * @param[in] type The font size type is point size or pixel size diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index a5a6b3b..ab90d50 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -213,7 +213,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, if(lastGlyphIndexOfLine == index) { - penY += -line->descender; + penY += -line->descender + line->lineSpacing; // Get the next line. ++lineIndex; @@ -225,7 +225,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u; - penY += line->ascender + line->lineSpacing; + penY += line->ascender; } } }