Fix TextFit do not work properly 62/303662/2
authorANZ1217 <chihun.jeong@samsung.com>
Wed, 3 Jan 2024 06:51:34 +0000 (15:51 +0900)
committerANZ1217 <chihun.jeong@samsung.com>
Wed, 3 Jan 2024 07:12:25 +0000 (16:12 +0900)
When check for textfit, it doesn't distinguish between cases
where the layout does not change because text is too large
and the layout does not change because text is too small.

Now CheckForTextFit returns false when text is too large.

Change-Id: I03a414406ee336ec7bf24c8d067fc73379d119f7

dali-toolkit/internal/text/controller/text-controller-relayouter.cpp
dali-toolkit/internal/text/controller/text-controller-relayouter.h

index 6b3bba7..bc3bb55 100644 (file)
@@ -234,16 +234,18 @@ bool Controller::Relayouter::CheckForTextFit(Controller& controller, float point
   // Make sure the model is up-to-date before layouting
   impl.UpdateModel(onlyOnceOperations);
 
+  bool layoutTooSmall = false;
   DoRelayout(impl,
              Size(layoutSize.width, MAX_FLOAT),
              static_cast<OperationsMask>(onlyOnceOperations | LAYOUT),
-             textSize);
+             textSize,
+             layoutTooSmall);
 
   // Clear the update info. This info will be set the next time the text is updated.
   textUpdateInfo.Clear();
   textUpdateInfo.mClearAll = true;
 
-  if(textSize.width > layoutSize.width || textSize.height > layoutSize.height)
+  if(layoutTooSmall || textSize.width > layoutSize.width || textSize.height > layoutSize.height)
   {
     return false;
   }
@@ -673,6 +675,12 @@ Controller::UpdateTextType Controller::Relayouter::Relayout(Controller& controll
 
 bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size, OperationsMask operationsRequired, Size& layoutSize)
 {
+  bool layoutTooSmall = false;
+  return DoRelayout(impl, size, operationsRequired, layoutSize, layoutTooSmall);
+}
+
+bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size, OperationsMask operationsRequired, Size& layoutSize, bool& layoutTooSmall)
+{
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::Relayouter::DoRelayout %p size %f,%f\n", &impl, size.width, size.height);
   DALI_TRACE_SCOPE(gTraceFilter2, "DALI_TEXT_DORELAYOUT");
   bool viewUpdated(false);
@@ -794,6 +802,7 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size
                                                 isHiddenInputEnabled,
                                                 ellipsisPosition);
     impl.mIsAutoScrollEnabled = isAutoScrollEnabled;
+    layoutTooSmall = !viewUpdated;
 
     viewUpdated = viewUpdated || (newLayoutSize != layoutSize);
 
@@ -830,6 +839,7 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size
   DALI_LOG_INFO(gLogFilter, Debug::Concise, "Controller::Relayouter::DoRelayout [%p] mImpl->mIsTextDirectionRTL[%s] [%s]\n", &impl, (impl.mIsTextDirectionRTL) ? "true" : "false", currentText.c_str());
 #endif
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::Relayouter::DoRelayout, view updated %s\n", (viewUpdated ? "true" : "false"));
+  DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::Relayouter::DoRelayout, layout too small %s\n", (layoutTooSmall ? "true" : "false"));
   return viewUpdated;
 }
 
index 2776778..3f7c3b9 100644 (file)
@@ -97,12 +97,25 @@ struct Controller::Relayouter
    * @param[in] size The size to set
    * @param[in] operationsRequired The operations we need to do
    * @param[in/out] layoutSize The Layout size which can be updated depending on the result of the performed operations
-   * @return
+   * @return whether view updated after relayout
    */
 
   static bool DoRelayout(Controller::Impl& impl, const Size& size, OperationsMask operationsRequired, Size& layoutSize);
 
   /**
+   * @brief Called by the Controller to do certain operations when relayouting.
+   *
+   * @param[in] impl A reference to the controller impl class
+   * @param[in] size The size to set
+   * @param[in] operationsRequired The operations we need to do
+   * @param[in/out] layoutSize The Layout size which can be updated depending on the result of the performed operations
+   * @param[out] layoutTooSmall True if layout is too small to render one glyph, else false.
+   * @return whether view updated after relayout
+   */
+
+  static bool DoRelayout(Controller::Impl& impl, const Size& size, OperationsMask operationsRequired, Size& layoutSize, bool& layoutTooSmall);
+
+  /**
    * @brief Called by the Controller to calculate the veritcal offset give the control size.
    *
    * @param[in] impl A reference to the controller impl class