From 3d0003ca2eba6287c2ea16eef196a74b097f4190 Mon Sep 17 00:00:00 2001 From: "Jinho, Lee" Date: Thu, 11 May 2017 15:38:00 +0900 Subject: [PATCH] add AUTO_SCROLL_LOOP_DELAY property Change-Id: I7ce3249443da519be3d1463a76d34d0e8fe81200 --- .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 5 +++++ .../controls/text-controls/text-label-devel.h | 6 ++++++ .../controls/text-controls/text-label-impl.cpp | 22 ++++++++++++++++++++++ dali-toolkit/internal/text/text-scroller.cpp | 13 ++++++++++++- dali-toolkit/internal/text/text-scroller.h | 13 +++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 85be1e3..9dda787 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -67,6 +67,7 @@ const char* const PROPERTY_NAME_OUTLINE = "outline"; const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize"; const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis"; +const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay"; const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); @@ -209,6 +210,7 @@ int UtcDaliToolkitTextLabelGetPropertyP(void) DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextLabel::Property::PIXEL_SIZE ); DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextLabel::Property::ELLIPSIS ); + DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ); END_TEST; } @@ -347,6 +349,7 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) const int SCROLL_SPEED = 80; const int SCROLL_LOOPS = 4; const float SCROLL_GAP = 50.0f; + const float SCROLL_LOOP_DELAY = 0.3f; label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line DALI_TEST_CHECK( !label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ) ); label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); @@ -357,6 +360,8 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION ); label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP ); DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION ); + label.SetProperty(DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY ); + DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty( DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION ); // Check the line spacing property DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h index 0d0ca82..f4698f6 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -70,6 +70,12 @@ namespace Property * @details name "ellipsis", type bool */ ELLIPSIS = OUTLINE + 2, + + /** + * @brief delay starting time of auto scrolling and further loops + * @details name "autoScrollLoopDelay", type float. + */ + AUTO_SCROLL_LOOP_DELAY = OUTLINE + 3, }; } // namespace Property 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 de5c097..22ea18a 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -109,6 +109,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "emboss", MAP, DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "outline", MAP, OUTLINE ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "pixelSize", FLOAT, PIXEL_SIZE ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "ellipsis", BOOLEAN, ELLIPSIS ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", FLOAT, AUTO_SCROLL_LOOP_DELAY ) DALI_TYPE_REGISTRATION_END() @@ -371,6 +372,15 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr impl.mTextScroller->SetLoopCount( value.Get() ); break; } + case Toolkit::DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY: + { + if( !impl.mTextScroller ) + { + impl.mTextScroller = Text::TextScroller::New( impl ); + } + impl.mTextScroller->SetLoopDelay( value.Get() ); + break; + } case Toolkit::TextLabel::Property::AUTO_SCROLL_GAP: { if( !impl.mTextScroller ) @@ -623,6 +633,18 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY: + { + if( impl.mController ) + { + TextLabel& impl( GetImpl( label ) ); + if ( impl.mTextScroller ) + { + value = impl.mTextScroller->GetLoopDelay(); + } + } + break; + } case Toolkit::TextLabel::Property::AUTO_SCROLL_GAP: { TextLabel& impl( GetImpl( label ) ); diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index a9a7284..ac2af53 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -245,6 +245,16 @@ int TextScroller::GetLoopCount() const return mLoopCount; } +void TextScroller::SetLoopDelay( float delay ) +{ + mLoopDelay = delay; +} + +float TextScroller::GetLoopDelay() const +{ + return mLoopDelay; +} + Actor TextScroller::GetSourceCamera() const { return mOffscreenCameraActor; @@ -259,6 +269,7 @@ TextScroller::TextScroller( ScrollerInterface& scrollerInterface ) : mScrollerIn mScrollDeltaIndex( Property::INVALID_INDEX ), mScrollSpeed( MINIMUM_SCROLL_SPEED ), mLoopCount( 1 ), + mLoopDelay( 0.0f ), mWrapGap( 0.0f ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller Default Constructor\n" ); @@ -333,7 +344,7 @@ void TextScroller::StartScrolling( float scrollAmount, float scrollDuration, int DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::StartScrolling scrollAmount[%f] scrollDuration[%f], loop[%d] speed[%d]\n", scrollAmount, scrollDuration, loopCount, mScrollSpeed ); mScrollAnimation = Animation::New( scrollDuration ); - mScrollAnimation.AnimateTo( Property( mScrollingTextActor, mScrollDeltaIndex ), scrollAmount ); + mScrollAnimation.AnimateTo( Property( mScrollingTextActor, mScrollDeltaIndex ), scrollAmount, TimePeriod( mLoopDelay, scrollDuration ) ); mScrollAnimation.SetEndAction( Animation::Discard ); mScrollAnimation.SetLoopCount( loopCount ); mScrollAnimation.FinishedSignal().Connect( this, &TextScroller::AutoScrollAnimationFinished ); diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index 17824b6..7804a40 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -104,6 +104,18 @@ public: int GetLoopCount() const; /** + * @brief Set the delay time of scroll animation loop + * @param[in] float delay time seconds of loops + */ + void SetLoopDelay( float delay ); + + /** + * @brief Get the delay time of scroll + * @return float delay time seconds of loops + */ + float GetLoopDelay() const; + + /** * @brief Get the camera used to look at source, should be added to the parent of target actor. * @return camera Actor */ @@ -163,6 +175,7 @@ private: int mScrollSpeed; ///< Speed which text should automatically scroll at int mLoopCount; ///< Number of time the text should scroll + float mLoopDelay; ///< Time delay of loop start float mWrapGap; ///< Gap before text wraps around when scrolling }; // TextScroller class -- 2.7.4