From f2e58d7d6fc3a5f5a5833831cab8857a46821178 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 31 Jan 2024 13:44:10 +0900 Subject: [PATCH] Fix editable text font size update issue There is an issue that the font runs of the editable text area are separated when the font size is updated. If the editable text is an active state and the font size is updated, the input font size should also be updated. And due to the feature that changes the selected area's font size when the input font size is updated, unintended font run separation and font size change occur if there is selected text when updating the font size. This patch fixed so that the selection-related logic is not executed when SetInputFontPointSize is called due to an update of the default font size. Change-Id: I1a5f5190d00a25291a8cafc215f5bf0df2cd71f7 Signed-off-by: Bowon Ryu --- automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp | 4 ++++ .../text/controller/text-controller-input-font-handler.cpp | 4 ++-- .../text/controller/text-controller-input-font-handler.h | 2 +- dali-toolkit/internal/text/controller/text-controller.cpp | 9 +++++++-- dali-toolkit/internal/text/controller/text-controller.h | 3 ++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index abb9c85..ccc6bb3 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -3027,6 +3027,10 @@ int utcDaliTextFieldEvent04(void) // Tap grab handle TestGenerateTap(application, 0.0f, 40.0f); + + field.SetProperty(TextField::Property::POINT_SIZE, 12.f); + DALI_TEST_EQUALS(field.GetProperty(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + END_TEST; } diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp index f2d49d2..39ecad1 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp @@ -373,7 +373,7 @@ FontSlant Controller::InputFontHandler::GetInputFontSlant(const Controller& cont return controller.GetDefaultFontSlant(); } -void Controller::InputFontHandler::SetInputFontPointSize(Controller& controller, float size) +void Controller::InputFontHandler::SetInputFontPointSize(Controller& controller, float size, bool defaultFontSizeUpdated) { if(NULL != controller.mImpl->mEventData) { @@ -385,7 +385,7 @@ void Controller::InputFontHandler::SetInputFontPointSize(Controller& controller, CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; - if(EventData::SELECTING == controller.mImpl->mEventData->mState) + if(EventData::SELECTING == controller.mImpl->mEventData->mState && !defaultFontSizeUpdated) { // Update a font description run for the selecting state. FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun(controller.mImpl->mEventData, diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h index bf38a00..8008196 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h @@ -44,7 +44,7 @@ struct Controller::InputFontHandler static void SetInputFontSlant(Controller& controller, FontSlant slant); static bool IsInputFontSlantDefined(const Controller& controller); static FontSlant GetInputFontSlant(const Controller& controller); - static void SetInputFontPointSize(Controller& controller, float size); + static void SetInputFontPointSize(Controller& controller, float size, bool defaultFontSizeUpdated); static float GetInputFontPointSize(const Controller& controller); }; diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index 5402115..b2c67e1 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -783,6 +783,11 @@ void Controller::SetDefaultFontSize(float fontSize, FontSizeType type) mImpl->ClearFontData(); mImpl->RequestRelayout(); + + if(mImpl->mEventData && EventData::INACTIVE != mImpl->mEventData->mState) + { + SetInputFontPointSize(fontSize, true); + } } float Controller::GetDefaultFontSize(FontSizeType type) const @@ -1130,9 +1135,9 @@ FontSlant Controller::GetInputFontSlant() const return InputFontHandler::GetInputFontSlant(*this); } -void Controller::SetInputFontPointSize(float size) +void Controller::SetInputFontPointSize(float size, bool defaultFontSizeUpdated) { - InputFontHandler::SetInputFontPointSize(*this, size); + InputFontHandler::SetInputFontPointSize(*this, size, defaultFontSizeUpdated); } float Controller::GetInputFontPointSize() const diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index 0364335..41910ab 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -1504,8 +1504,9 @@ public: // Default style & Input style * @brief Sets the input font's point size. * * @param[in] size The input font's point size. + * @param[in] defaultFontSizeUpdated True If the default font size is updated and sets the input point size, false otherwise. */ - void SetInputFontPointSize(float size); + void SetInputFontPointSize(float size, bool defaultFontSizeUpdated = false); /** * @brief Retrieves the input font's point size. -- 2.7.4