From 99c176aa8e2358b7c796b6e77af3e5f80d906154 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 31 Jan 2024 13:44:10 +0900 Subject: [PATCH] [Tizen] 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 203d242..2f19070 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -782,6 +782,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 @@ -1129,9 +1134,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 ad37df0..834d992 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -1498,8 +1498,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