From: Bowon Ryu Date: Tue, 30 Apr 2024 01:56:04 +0000 (+0900) Subject: [Tizen] Fix text autoscroll multi line issue X-Git-Tag: accepted/tizen/8.0/unified/20240509.175902~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6a3af953c5fd5085f2b4c4ab37fb5caae4feb32;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Fix text autoscroll multi line issue This patch fixes issues that arise when relayout is executed during auto-scrolling. - relayout not executed after the scroll finish callback - stop scrolling fails in certain situations in finish loop mode - scroll finish being called twice during immediate mode stop Change-Id: Ib44883380a79ad13c576d18c11171ae9f1f670c3 Signed-off-by: Bowon Ryu --- 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 262c5cc..a860dc8 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -1082,10 +1082,13 @@ void TextLabel::OnSceneDisconnection() mLastAutoScrollEnabled = false; } - const Toolkit::TextLabel::AutoScrollStopMode::Type stopMode = mTextScroller->GetStopMode(); - mTextScroller->SetStopMode(Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE); - mTextScroller->StopScrolling(); - mTextScroller->SetStopMode(stopMode); + if(mTextScroller->IsScrolling()) + { + const Toolkit::TextLabel::AutoScrollStopMode::Type stopMode = mTextScroller->GetStopMode(); + mTextScroller->SetStopMode(Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE); + mTextScroller->StopScrolling(); + mTextScroller->SetStopMode(stopMode); + } } Control::OnSceneDisconnection(); } @@ -1094,6 +1097,12 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container) { DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::OnRelayout\n"); + if(mTextScroller && mTextScroller->IsStop()) + { + // When auto scroll is playing, it triggers a relayout only when an update is absolutely necessary. + return; + } + Actor self = Self(); Extents padding; @@ -1262,12 +1271,8 @@ void TextLabel::ScrollingFinished() { // Pure Virtual from TextScroller Interface DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::ScrollingFinished\n"); - - if(mController->IsAutoScrollEnabled() || !mController->IsMultiLineEnabled()) - { - mController->SetAutoScrollEnabled(false); - RequestTextRelayout(); - } + mController->SetAutoScrollEnabled(false); + RequestTextRelayout(); } void TextLabel::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type) diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index 59bb09f..08e08c8 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -144,18 +144,19 @@ void TextScroller::SetStopMode(TextLabel::AutoScrollStopMode::Type stopMode) void TextScroller::StopScrolling() { - if(mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING) + if(IsScrolling()) { switch(mStopMode) { case TextLabel::AutoScrollStopMode::IMMEDIATE: { + mIsStop = true; mScrollAnimation.Stop(); - mScrollerInterface.ScrollingFinished(); break; } case TextLabel::AutoScrollStopMode::FINISH_LOOP: { + mIsStop = true; mScrollAnimation.SetLoopCount(1); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way break; } @@ -171,6 +172,16 @@ void TextScroller::StopScrolling() } } +bool TextScroller::IsStop() +{ + return mIsStop; +} + +bool TextScroller::IsScrolling() +{ + return (mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING); +} + TextLabel::AutoScrollStopMode::Type TextScroller::GetStopMode() const { return mStopMode; @@ -183,7 +194,8 @@ TextScroller::TextScroller(ScrollerInterface& scrollerInterface) mLoopCount(1), mLoopDelay(0.0f), mWrapGap(0.0f), - mStopMode(TextLabel::AutoScrollStopMode::FINISH_LOOP) + mStopMode(TextLabel::AutoScrollStopMode::FINISH_LOOP), + mIsStop(false) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextScroller Default Constructor\n"); } @@ -195,7 +207,6 @@ TextScroller::~TextScroller() void TextScroller::SetParameters(Actor scrollingTextActor, Renderer renderer, TextureSet textureSet, const Size& controlSize, const Size& textureSize, const float wrapGap, CharacterDirection direction, HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextScroller::SetParameters controlSize[%f,%f] textureSize[%f,%f] direction[%d]\n", controlSize.x, controlSize.y, textureSize.x, textureSize.y, direction); - mRenderer = renderer; float animationProgress = 0.0f; @@ -209,7 +220,7 @@ void TextScroller::SetParameters(Actor scrollingTextActor, Renderer renderer, Te if(mLoopCount > 0) // If not a ininity loop, then calculate remained loop { remainedLoop = mLoopCount - (mScrollAnimation.GetCurrentLoop()); - remainedLoop = (remainedLoop <= 0 ? 1 : remainedLoop); + remainedLoop = mIsStop ? 1 : (remainedLoop <= 0 ? 1 : remainedLoop); } } mScrollAnimation.Clear(); @@ -269,6 +280,7 @@ void TextScroller::SetParameters(Actor scrollingTextActor, Renderer renderer, Te void TextScroller::AutoScrollAnimationFinished(Dali::Animation& animation) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextScroller::AutoScrollAnimationFinished\n"); + mIsStop = false; mScrollerInterface.ScrollingFinished(); // Revert to the original shader and texture after scrolling @@ -282,7 +294,6 @@ void TextScroller::AutoScrollAnimationFinished(Dali::Animation& animation) void TextScroller::StartScrolling(Actor scrollingTextActor, float scrollAmount, float scrollDuration, int loopCount) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextScroller::StartScrolling scrollAmount[%f] scrollDuration[%f], loop[%d] speed[%d]\n", scrollAmount, scrollDuration, loopCount, mScrollSpeed); - Shader shader = mRenderer.GetShader(); mScrollAnimation = Animation::New(scrollDuration); mScrollAnimation.AnimateTo(Property(shader, mScrollDeltaIndex), scrollAmount, TimePeriod(mLoopDelay, scrollDuration)); @@ -290,6 +301,8 @@ void TextScroller::StartScrolling(Actor scrollingTextActor, float scrollAmount, mScrollAnimation.SetLoopCount(loopCount); mScrollAnimation.FinishedSignal().Connect(this, &TextScroller::AutoScrollAnimationFinished); mScrollAnimation.Play(); + + mIsStop = false; } } // namespace Text diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index b93c2d2..99a4936 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -129,6 +129,16 @@ public: void StopScrolling(); /** + * @brief Whether the stop scrolling has been triggered or not. + */ + bool IsStop(); + + /** + * @brief Whether the scroll animation is playing or not. + */ + bool IsScrolling(); + + /** * @brief Get the mode of scrolling stop * @return stopMode type when text scrolling is stoped. */ @@ -179,6 +189,7 @@ private: float mLoopDelay; ///< Time delay of loop start float mWrapGap; ///< Gap before text wraps around when scrolling TextLabel::AutoScrollStopMode::Type mStopMode; ///< Stop mode of scrolling text, when loop count is 0. + bool mIsStop : 1; ///< Whether the stop scrolling has been triggered or not. }; // TextScroller class