From 4102d794f59f5a91d9bbfecf787bc27c054895f8 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 24 Aug 2022 08:15:20 +0900 Subject: [PATCH] [Tizen] cleanup auto scroll in text label 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 --- .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 39 ++++++++++++++++++++++ .../controls/text-controls/text-label-impl.cpp | 14 ++++++-- dali-toolkit/internal/text/text-scroller.cpp | 29 +++++++++------- dali-toolkit/internal/text/text-scroller.h | 3 +- 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index b0f9764..18246ae 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1223,6 +1223,45 @@ int UtcDaliToolkitTextlabelScrollingN(void) const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get(); 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()); + + 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()); + + 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()); + } + catch(...) + { + tet_result(TET_FAIL); + } + END_TEST; } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index db0edf2..dccafce 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -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(); + 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(); } diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index b97e502..cec4081 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -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 diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index 01816ac..b93c2d2 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -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 -- 2.7.4