[Tizen] Fix editable text font size update issue 17/320717/1
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 31 Jan 2024 04:44:10 +0000 (13:44 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Thu, 21 Nov 2024 09:05:21 +0000 (18:05 +0900)
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 <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp
dali-toolkit/internal/text/controller/text-controller-input-font-handler.h
dali-toolkit/internal/text/controller/text-controller.cpp
dali-toolkit/internal/text/controller/text-controller.h

index f033a33fc6342080621bcac6d3ec55d558b1ff15..b6cbebbbf7c36e45a385852f1e912e778eb54d98 100644 (file)
@@ -2879,6 +2879,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<float>(TextField::Property::INPUT_POINT_SIZE), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+
   END_TEST;
 }
 
index f2d49d2ff142e1c6e8059f97c6408dd3360ea854..39ecad17ba9bf2b84e4ccb5c4b3975ccdc2a0b07 100644 (file)
@@ -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,
index bf38a005ca2b3f2e1a0a6fc1381bb3d40c2a580b..80081968c6d54104e5e549a257844a92733747a5 100644 (file)
@@ -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);
 };
 
index d4082fb4ec7392c755c5076a1557302d9a9b3306..b7f19a679f977fe55484f4db83dabc5217efd006 100644 (file)
@@ -729,6 +729,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
@@ -1076,9 +1081,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
index b6f0affe391353712a04930b0bed32340769d78f..a564e4b08d8027e67c17c532c0cefaacb6736e6f 100644 (file)
@@ -1438,8 +1438,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.