Fix async auto scroll issue
authorBowon Ryu <bowon.ryu@samsung.com>
Thu, 20 Jun 2024 04:18:20 +0000 (13:18 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Thu, 20 Jun 2024 04:18:20 +0000 (13:18 +0900)
Fixed the problem of text being drawn outside the text control area
during auto-scroll due to incorrect transform size and natural size calculation.

Change-Id: I866d25326a41b998c136f3a6ec1ed25358c77345
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/text/async-text/async-text-loader-impl.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp

index bc5b702..8fa3e71 100644 (file)
@@ -1102,7 +1102,9 @@ AsyncTextRenderInfo AsyncTextLoader::RenderAutoScroll(AsyncTextParameters& param
   const Size controlSize(static_cast<float>(parameters.textWidth), static_cast<float>(parameters.textHeight));
 
   // As relayout of text may not be done at this point natural size is used to get size. Single line scrolling only.
-  const Size textNaturalSize = CalculateNaturalSize(parameters);
+  Size textNaturalSize = CalculateNaturalSize(parameters);
+  textNaturalSize.width += (parameters.padding.start + parameters.padding.end);
+  textNaturalSize.height += (parameters.padding.top + parameters.padding.bottom);
 
   DALI_LOG_RELEASE_INFO("-->AsyncTextLoader::RenderAutoScroll natural size : %f, %f, control size : %f, %f \n", textNaturalSize.x, textNaturalSize.y, controlSize.x, controlSize.y);
 
index eefa52c..2182dc8 100644 (file)
@@ -741,6 +741,13 @@ void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformati
     // Size of the text control including padding.
     Vector2 textControlSize(static_cast<float>(parameters.textWidth) + (parameters.padding.start + parameters.padding.end), static_cast<float>(parameters.textHeight) + (parameters.padding.top + parameters.padding.bottom));
 
+    if(parameters.isAutoScrollEnabled)
+    {
+      // In case of auto scroll, the layout width (renderInfo's width) is the natural size of the text.
+      // Since the layout size is the size of the visual transform, it should be reset to the text area excluding padding.
+      layoutSize.width = parameters.textWidth;
+    }
+
     Vector2 visualTransformOffset;
     if(renderInfo.isCutout)
     {