[Tizen] stop text scrolling when label is disconnected from scene 51/280051/1
authorBowon Ryu <bowon.ryu@samsung.com>
Sun, 21 Aug 2022 22:59:26 +0000 (07:59 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 23 Aug 2022 02:32:15 +0000 (11:32 +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 dd50efa..db0edf2 100644 (file)
@@ -354,7 +354,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
@@ -945,6 +945,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");
@@ -1115,7 +1134,8 @@ void TextLabel::EmitTextFitChangedSignal()
 TextLabel::TextLabel()
 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
   mRenderingBackend(DEFAULT_RENDERING_BACKEND),
-  mTextUpdateNeeded(false)
+  mTextUpdateNeeded(false),
+  mLastAutoScrollEnabled(false)
 {
 }
 
index d345d21..526b197 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
@@ -134,6 +135,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
 
   /**
@@ -211,6 +222,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