[Tizen] cleanup auto scroll in text label 07/280207/1 accepted/tizen/6.5/unified/20220831.133856 submit/tizen_6.5/20220831.054421
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 23 Aug 2022 23:15:20 +0000 (08:15 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Thu, 25 Aug 2022 07:36:17 +0000 (16:36 +0900)
1. fixed a bug where auto scroll did not work
when the property value changed after the label was disconnected from the scene

2. keep StopScrolling() depending only on TextScroller class properties as is

Change-Id: I6f92ded38f9c671787e72798cbc1602f9709f0df
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/text/text-scroller.h

index b0f9764ded9565ac85e444755749a8b7303552dd..18246ae4d61c15c4d1724e4538af1edf87a71279 100644 (file)
@@ -1223,6 +1223,45 @@ int UtcDaliToolkitTextlabelScrollingN(void)
   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
   DALI_TEST_CHECK( !enabled );
 
+
+  label.SetProperty(TextLabel::Property::MULTI_LINE, false);
+  label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
+  label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
+  label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
+
+  try
+  {
+    // Render the text.
+    application.SendNotification();
+    application.Render(1000);
+
+    application.GetScene().Remove(label);
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+
+    label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
+    application.GetScene().Add(label);
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+
+    label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
+    label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+  }
+  catch(...)
+  {
+    tet_result(TET_FAIL);
+  }
+
   END_TEST;
 }
 
index db0edf229200b228cc5170492dafc24bcaa9351e..dccafce9642b4c799b4796c8f3818565b199225f 100644 (file)
@@ -346,6 +346,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
       case Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL:
       {
         const bool enableAutoScroll = value.Get<bool>();
+        impl.mLastAutoScrollEnabled = enableAutoScroll;
         // If request to auto scroll is the same as current state then do nothing.
         if(enableAutoScroll != impl.mController->IsAutoScrollEnabled())
         {
@@ -354,7 +355,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
           {
             if(impl.mTextScroller)
             {
-              impl.mTextScroller->StopScrolling(false);
+              impl.mTextScroller->StopScrolling();
             }
           }
           // If request is enable (true) then start autoscroll as not already running
@@ -958,8 +959,15 @@ void TextLabel::OnSceneDisconnection()
 {
   if(mTextScroller)
   {
-    mLastAutoScrollEnabled = mController->IsAutoScrollEnabled();
-    mTextScroller->StopScrolling(true);
+    if(mLastAutoScrollEnabled && !mController->IsAutoScrollEnabled())
+    {
+      mLastAutoScrollEnabled = false;
+    }
+
+    const Toolkit::TextLabel::AutoScrollStopMode::Type stopMode = mTextScroller->GetStopMode();
+    mTextScroller->SetStopMode(Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE);
+    mTextScroller->StopScrolling();
+    mTextScroller->SetStopMode(stopMode);
   }
   Control::OnSceneDisconnection();
 }
index b97e502189d8aa3a00d12a5f8a9fbefb34aeb44b..cec40817507808b7081ca23d2d6010a578a67194 100644 (file)
@@ -142,22 +142,27 @@ void TextScroller::SetStopMode(TextLabel::AutoScrollStopMode::Type stopMode)
   mStopMode = stopMode;
 }
 
-void TextScroller::StopScrolling(bool immediate)
+void TextScroller::StopScrolling()
 {
   if(mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING)
   {
-    if(mStopMode == TextLabel::AutoScrollStopMode::IMMEDIATE || immediate)
+    switch(mStopMode)
     {
-      mScrollAnimation.Stop();
-      mScrollerInterface.ScrollingFinished();
-    }
-    else if(mStopMode == TextLabel::AutoScrollStopMode::FINISH_LOOP)
-    {
-      mScrollAnimation.SetLoopCount(1); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
-    }
-    else
-    {
-      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n");
+      case TextLabel::AutoScrollStopMode::IMMEDIATE:
+      {
+        mScrollAnimation.Stop();
+        mScrollerInterface.ScrollingFinished();
+        break;
+      }
+      case TextLabel::AutoScrollStopMode::FINISH_LOOP:
+      {
+        mScrollAnimation.SetLoopCount(1); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
+        break;
+      }
+      default:
+      {
+        DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n");
+      }
     }
   }
   else
index 01816acd19d2908151297871559a4edb63a1b594..b93c2d212cb13f1eb0a43ea8bdc6336b3ea3df52 100644 (file)
@@ -125,9 +125,8 @@ public:
 
   /**
    * @brief Stop the auto scrolling.
-   * @param[in] immediate Stop scrolling immediately.
    */
-  void StopScrolling(bool immediate);
+  void StopScrolling();
 
   /**
    * @brief Get the mode of scrolling stop