Fix text AutoScroll ellipsis issue 97/275997/1
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 7 Jun 2022 16:19:50 +0000 (01:19 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Wed, 8 Jun 2022 07:56:26 +0000 (16:56 +0900)
Text should ellipsis while AutoScroll is running
when text length is bigger than MaxTextureSize.

this issue occurs as a side effect of another patch.
74f7af1b08ce65dde5959d22b2d533cbc64b9d2e

the height comparison condition is for another AutoScroll ellipsis issue
and this should not be removed.

Change-Id: I18a4011bec882e483bc0c184417403661a9fa635
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp [changed mode: 0755->0644]
dali-toolkit/devel-api/text/text-utils-devel.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-engine.h
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller-relayouter.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h

index e8bbb21..5b8469d 100644 (file)
@@ -351,11 +351,13 @@ void CreateTextModel(const std::string&                text,
   layoutParameters.startLineIndex         = 0u;
   layoutParameters.estimatedNumberOfLines = logicalModel->mParagraphInfo.Count();
 
-  bool isAutoScroll = false;
+  bool isAutoScroll                   = false;
+  bool isAutoScrollMaxTextureExceeded = false;
   layoutEngine.LayoutText(layoutParameters,
                           layoutSize,
                           false,
                           isAutoScroll,
+                          isAutoScrollMaxTextureExceeded,
                           ellipsisPosition);
 
   if(options.align)
index f636a19..5a15b09 100644 (file)
@@ -180,11 +180,13 @@ bool LayoutTextTest(const LayoutTextData& data)
 
   layoutSize = Vector2::ZERO;
 
-  bool       isAutoScroll = false;
-  const bool updated      = engine.LayoutText(layoutParameters,
+  bool       isAutoScroll                   = false;
+  bool       isAutoScrollMaxTextureExceeded = false;
+  const bool updated                        = engine.LayoutText(layoutParameters,
                                          layoutSize,
                                          data.ellipsis,
                                          isAutoScroll,
+                                         isAutoScrollMaxTextureExceeded,
                                          DevelText::EllipsisPosition::END);
 
   // 4) Compare the results.
old mode 100755 (executable)
new mode 100644 (file)
index 9b71156..6ec3bfe
@@ -180,11 +180,13 @@ bool LayoutTextTest(const LayoutTextData& data)
 
   layoutSize = Vector2::ZERO;
 
-  bool       isAutoScroll = false;
-  const bool updated      = engine.LayoutText(layoutParameters,
+  bool       isAutoScroll                   = false;
+  bool       isAutoScrollMaxTextureExceeded = false;
+  const bool updated                        = engine.LayoutText(layoutParameters,
                                          layoutSize,
                                          data.ellipsis,
                                          isAutoScroll,
+                                         isAutoScrollMaxTextureExceeded,
                                          data.ellipsisPosition);
 
   // 4) Compare the results.
index c9ab7b5..d1d6900 100644 (file)
@@ -1065,11 +1065,14 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR
 
   // Update the visual model.
   Size newLayoutSize;
-  bool isAutoScrollEnabled = false;
+  bool isAutoScrollEnabled            = false;
+  bool isAutoScrollMaxTextureExceeded = false;
+
   layoutEngine.LayoutText(layoutParameters,
                           newLayoutSize,
                           textParameters.ellipsisEnabled,
                           isAutoScrollEnabled,
+                          isAutoScrollMaxTextureExceeded,
                           ellipsisPosition);
 
   return newLayoutSize;
index 76d0ee2..97ccc81 100644 (file)
@@ -1125,6 +1125,7 @@ void TextLabel::SetUpAutoScrolling()
     if(textNaturalSize.width > maxTextureSize)
     {
       mController->SetTextElideEnabled(true);
+      mController->SetAutoScrollMaxTextureExceeded(true);
     }
     GetHeightForWidth(maxTextureSize);
     wrapGap = std::max(maxTextureSize - textNaturalSize.width, 0.0f);
@@ -1152,6 +1153,7 @@ void TextLabel::SetUpAutoScrolling()
   Renderer renderer = static_cast<Internal::Visual::Base&>(GetImplementation(mVisual)).GetRenderer();
   mTextScroller->SetParameters(Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment());
   mController->SetTextElideEnabled(actualellipsis);
+  mController->SetAutoScrollMaxTextureExceeded(false);
 }
 
 void TextLabel::ScrollingFinished()
index 41e41a9..39af47c 100644 (file)
@@ -1260,16 +1260,22 @@ struct Engine::Impl
                     Length&                           numberOfLines,
                     float                             penY,
                     bool&                             isAutoScrollEnabled,
+                    bool                              isAutoScrollMaxTextureExceeded,
                     DevelText::EllipsisPosition::Type ellipsisPosition,
                     bool                              enforceEllipsisInSingleLine)
   {
-    const bool ellipsis    = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? (penY - layout.descender > layoutParameters.boundingBox.height) : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width))));
+    const bool ellipsis    = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? isAutoScrollMaxTextureExceeded : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width))));
     const bool isMultiline = !enforceEllipsisInSingleLine && (mLayout == MULTI_LINE_BOX);
     if(ellipsis && (ellipsisPosition == DevelText::EllipsisPosition::END || !isMultiline))
     {
-      isAutoScrollEnabled = false;
-      // Do not layout more lines if ellipsis is enabled.
+      if(penY - layout.descender > layoutParameters.boundingBox.height)
+      {
+        // Even if auto scroll is enabled and text is bigger than max texture size,
+        // if the the height is small, auto scroll should not work.
+        isAutoScrollEnabled = false;
+      }
 
+      // Do not layout more lines if ellipsis is enabled.
       // The last line needs to be completely filled with characters.
       // Part of a word may be used.
 
@@ -1601,6 +1607,7 @@ struct Engine::Impl
                   Size&                             layoutSize,
                   bool                              elideTextEnabled,
                   bool&                             isAutoScrollEnabled,
+                  bool                              isAutoScrollMaxTextureExceeded,
                   DevelText::EllipsisPosition::Type ellipsisPosition)
   {
     DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->LayoutText\n");
@@ -1801,7 +1808,7 @@ struct Engine::Impl
       CharacterIndex lastCharacterInParagraph = currentParagraphRun.characterRun.characterIndex + currentParagraphRun.characterRun.numberOfCharacters - 1;
 
       //check if this is the last line in paragraph, if false we should use the default relative line size (the one set using the property)
-      if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex+layout.numberOfCharacters)
+      if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex + layout.numberOfCharacters)
       {
         layout.relativeLineSize = mRelativeLineSize;
       }
@@ -1840,6 +1847,7 @@ struct Engine::Impl
                                 numberOfLines,
                                 penY,
                                 isAutoScrollEnabled,
+                                isAutoScrollMaxTextureExceeded,
                                 ellipsisPosition,
                                 false);
       }
@@ -1858,6 +1866,7 @@ struct Engine::Impl
                                   numberOfLines,
                                   penY,
                                   isAutoScrollEnabled,
+                                  isAutoScrollMaxTextureExceeded,
                                   ellipsisPosition,
                                   true);
         }
@@ -2252,12 +2261,14 @@ bool Engine::LayoutText(Parameters&                       layoutParameters,
                         Size&                             layoutSize,
                         bool                              elideTextEnabled,
                         bool&                             isAutoScrollEnabled,
+                        bool                              isAutoScrollMaxTextureExceeded,
                         DevelText::EllipsisPosition::Type ellipsisPosition)
 {
   return mImpl->LayoutText(layoutParameters,
                            layoutSize,
                            elideTextEnabled,
                            isAutoScrollEnabled,
+                           isAutoScrollMaxTextureExceeded,
                            ellipsisPosition);
 }
 
index 6b78e87..9fa22c6 100644 (file)
@@ -107,6 +107,7 @@ public:
    * @param[out] layoutSize The size of the text after it has been laid-out.
    * @param[in] elideTextEnabled Whether the text elide is enabled.
    * @param[in,out] isAutoScrollEnabled If the isAutoScrollEnabled is true and the height of the text exceeds the boundaries of the control the text is elided and the isAutoScrollEnabled is set to false to disable the autoscroll
+   * @param[in] isAutoScrollMaxTextureExceeded If isAutoScrollMaxTextureExceeded is true, enable ellipsis during auro scroll.
    * @param[in] ellipsisPosition The location of the text ellipsis
    *
    * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
@@ -115,6 +116,7 @@ public:
                   Size&                             layoutSize,
                   bool                              elideTextEnabled,
                   bool&                             isAutoScrollEnabled,
+                  bool                              isAutoScrollMaxTextureExceeded,
                   DevelText::EllipsisPosition::Type ellipsisPosition);
 
   /**
index 5e28f9c..7eaf5ee 100644 (file)
@@ -346,6 +346,7 @@ struct Controller::Impl
     mMarkupProcessorEnabled(false),
     mClipboardHideEnabled(true),
     mIsAutoScrollEnabled(false),
+    mIsAutoScrollMaxTextureExceeded(false),
     mUpdateTextDirection(true),
     mIsTextDirectionRTL(false),
     mUnderlineSetByString(false),
@@ -1000,12 +1001,13 @@ public:
   std::unique_ptr<InputFilter> mInputFilter;                ///< Avoid allocating this when the user does not specify input filter mode.
   Vector2                      mTextFitContentSize;         ///< Size of Text fit content
 
-  bool               mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated.
-  bool               mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled.
-  bool               mClipboardHideEnabled : 1;   ///< Whether the ClipboardHide function work or not
-  bool               mIsAutoScrollEnabled : 1;    ///< Whether auto text scrolling is enabled.
-  bool               mUpdateTextDirection : 1;    ///< Whether the text direction needs to be updated.
-  CharacterDirection mIsTextDirectionRTL : 1;     ///< Whether the text direction is right to left or not
+  bool               mRecalculateNaturalSize : 1;         ///< Whether the natural size needs to be recalculated.
+  bool               mMarkupProcessorEnabled : 1;         ///< Whether the mark-up procesor is enabled.
+  bool               mClipboardHideEnabled : 1;           ///< Whether the ClipboardHide function work or not
+  bool               mIsAutoScrollEnabled : 1;            ///< Whether auto text scrolling is enabled.
+  bool               mIsAutoScrollMaxTextureExceeded : 1; ///< Whether auto text scrolling is exceed max texture size.
+  bool               mUpdateTextDirection : 1;            ///< Whether the text direction needs to be updated.
+  CharacterDirection mIsTextDirectionRTL : 1;             ///< Whether the text direction is right to left or not
 
   bool                  mUnderlineSetByString : 1;     ///< Set when underline is set by string (legacy) instead of map
   bool                  mShadowSetByString : 1;        ///< Set when shadow is set by string (legacy) instead of map
index 42199ad..b9b4f56 100644 (file)
@@ -67,7 +67,7 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control
                                                                         SHAPE_TEXT |
                                                                         GET_GLYPH_METRICS);
 
-  const OperationsMask sizeOperations     = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
+  const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
 
   // Set the update info to relayout the whole text.
   TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
@@ -93,6 +93,12 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control
   {
     impl.UpdateModel(onlyOnceOperations);
 
+    if(impl.mIsAutoScrollEnabled)
+    {
+      // Layout the text for the new width.
+      operationsPending = static_cast<OperationsMask>(operationsPending | requestedOperationsMask);
+    }
+
     DoRelayout(impl,
                requestedControllerSize,
                static_cast<OperationsMask>(onlyOnceOperations | requestedOperationsMask),
@@ -619,12 +625,15 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size
     }
 
     // Update the visual model.
-    bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled;
+    bool isAutoScrollEnabled            = impl.mIsAutoScrollEnabled;
+    bool isAutoScrollMaxTextureExceeded = impl.mIsAutoScrollMaxTextureExceeded;
+
     Size newLayoutSize;
     viewUpdated               = impl.mLayoutEngine.LayoutText(layoutParameters,
                                                 newLayoutSize,
                                                 elideTextEnabled,
                                                 isAutoScrollEnabled,
+                                                isAutoScrollMaxTextureExceeded,
                                                 ellipsisPosition);
     impl.mIsAutoScrollEnabled = isAutoScrollEnabled;
 
@@ -798,13 +807,13 @@ void Controller::Relayouter::DoRelayoutHorizontalAlignment(Controller::Impl&
 
 void Controller::Relayouter::CalculateVerticalOffset(Controller::Impl& impl, const Size& controlSize)
 {
-  ModelPtr&         model                 = impl.mModel;
-  VisualModelPtr&   visualModel           = model->mVisualModel;
-  Size              layoutSize            = model->mVisualModel->GetLayoutSize();
-  Size              oldLayoutSize         = layoutSize;
-  float             offsetY               = 0.f;
-  bool              needRecalc            = false;
-  float             defaultFontLineHeight = impl.GetDefaultFontLineHeight();
+  ModelPtr&       model                 = impl.mModel;
+  VisualModelPtr& visualModel           = model->mVisualModel;
+  Size            layoutSize            = model->mVisualModel->GetLayoutSize();
+  Size            oldLayoutSize         = layoutSize;
+  float           offsetY               = 0.f;
+  bool            needRecalc            = false;
+  float           defaultFontLineHeight = impl.GetDefaultFontLineHeight();
 
   if(fabsf(layoutSize.height) < Math::MACHINE_EPSILON_1000)
   {
index bf92f6a..7cc8831 100644 (file)
@@ -172,6 +172,11 @@ void Controller::SetAutoScrollEnabled(bool enable)
   mImpl->SetAutoScrollEnabled(enable);
 }
 
+void Controller::SetAutoScrollMaxTextureExceeded(bool exceed)
+{
+  mImpl->mIsAutoScrollMaxTextureExceeded = exceed;
+}
+
 bool Controller::IsAutoScrollEnabled() const
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::IsAutoScrollEnabled[%s]\n", mImpl->mIsAutoScrollEnabled ? "true" : "false");
index 3e987dd..0def96f 100644 (file)
@@ -257,6 +257,15 @@ public: // Configure the text controller.
   void SetAutoScrollEnabled(bool enable);
 
   /**
+   * @brief Whether the auto scrolling texture exceed max texture.
+   *
+   * By default is false.
+   *
+   * @param[in] exceed Whether the auto scrolling texture exceed max texture.
+   */
+  void SetAutoScrollMaxTextureExceeded(bool exceed);
+
+  /**
    * @brief Retrieves whether auto text scrolling is enabled.
    *
    * By default is disabled.