stop text scrolling when label is disconnected from scene 75/279975/5
authorBowon Ryu <bowon.ryu@samsung.com>
Sun, 21 Aug 2022 22:59:26 +0000 (07:59 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Mon, 22 Aug 2022 04:34:53 +0000 (13:34 +0900)
Change-Id: I8909dc858467d85574310ba50c30ffa143b2eb8d
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/text/text-scroller.h

index 2d2368b..8ba54b7 100644 (file)
@@ -359,7 +359,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
           {
             if(impl.mTextScroller)
             {
-              impl.mTextScroller->StopScrolling();
+              impl.mTextScroller->StopScrolling(false);
             }
           }
           // If request is enable (true) then start autoscroll as not already running
@@ -1008,6 +1008,25 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
   }
 }
 
+void TextLabel::OnSceneConnection(int depth)
+{
+  if(mController->IsAutoScrollEnabled() || mLastAutoScrollEnabled)
+  {
+    mController->SetAutoScrollEnabled(true);
+  }
+  Control::OnSceneConnection(depth);
+}
+
+void TextLabel::OnSceneDisconnection()
+{
+  if(mTextScroller)
+  {
+    mLastAutoScrollEnabled = mController->IsAutoScrollEnabled();
+    mTextScroller->StopScrolling(true);
+  }
+  Control::OnSceneDisconnection();
+}
+
 void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
   DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::OnRelayout\n");
@@ -1190,7 +1209,8 @@ void TextLabel::OnAccessibilityStatusChanged()
 TextLabel::TextLabel(ControlBehaviour additionalBehavior)
 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehavior)),
   mRenderingBackend(DEFAULT_RENDERING_BACKEND),
-  mTextUpdateNeeded(false)
+  mTextUpdateNeeded(false),
+  mLastAutoScrollEnabled(false)
 {
 }
 
index f4dac1d..31167d8 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/atspi-interfaces/hypertext.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/public-api/object/property-map.h>
@@ -165,6 +166,16 @@ private: // From Control
    */
   void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
 
+  /**
+   * @copydoc Control::OnSceneConnection()
+   */
+  void OnSceneConnection(int depth) override;
+
+  /**
+   * @copydoc Control::OnSceneDisconnection()
+   */
+  void OnSceneDisconnection() override;
+
   // From ControlInterface
 
   /**
@@ -247,6 +258,7 @@ private: // Data
 
   int  mRenderingBackend;
   bool mTextUpdateNeeded : 1;
+  bool mLastAutoScrollEnabled : 1;
 
 protected:
   /**
index cec4081..b97e502 100644 (file)
@@ -142,27 +142,22 @@ void TextScroller::SetStopMode(TextLabel::AutoScrollStopMode::Type stopMode)
   mStopMode = stopMode;
 }
 
-void TextScroller::StopScrolling()
+void TextScroller::StopScrolling(bool immediate)
 {
   if(mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING)
   {
-    switch(mStopMode)
+    if(mStopMode == TextLabel::AutoScrollStopMode::IMMEDIATE || immediate)
     {
-      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");
-      }
+      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");
     }
   }
   else
index b93c2d2..01816ac 100644 (file)
@@ -125,8 +125,9 @@ public:
 
   /**
    * @brief Stop the auto scrolling.
+   * @param[in] immediate Stop scrolling immediately.
    */
-  void StopScrolling();
+  void StopScrolling(bool immediate);
 
   /**
    * @brief Get the mode of scrolling stop