From: Jinho, Lee Date: Thu, 20 Apr 2017 06:55:37 +0000 (+0900) Subject: Support stop mode(FINISH_LOOP, IMMEDIATE) of auto scroll X-Git-Tag: dali_1.2.40~9^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=6efee146b4c4e40df991b9e3425f97c66150df10 Support stop mode(FINISH_LOOP, IMMEDIATE) of auto scroll Change-Id: Ia8283c43aff92a6b88c30cd5507c70b7ee9e0af0 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 9dda787..5671523 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -350,6 +350,9 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) const int SCROLL_LOOPS = 4; const float SCROLL_GAP = 50.0f; const float SCROLL_LOOP_DELAY = 0.3f; + const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" ); + const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" ); + 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 ); @@ -363,6 +366,14 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) 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 autoscroll stop type property + label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION ); + + label.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION ); + + // Check the line spacing property DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f ); @@ -547,23 +558,44 @@ int UtcDaliToolkitTextlabelScrollingP(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextLabelScrollingP"); - TextLabel label = TextLabel::New("Some text to scroll"); - DALI_TEST_CHECK( label ); + TextLabel labelImmediate = TextLabel::New("Some text to scroll"); + TextLabel labelFinished = TextLabel::New("Some text to scroll"); + + DALI_TEST_CHECK( labelImmediate ); + DALI_TEST_CHECK( labelFinished ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - Stage::GetCurrent().Add( label ); + Stage::GetCurrent().Add( labelImmediate ); // Turn on all the effects - label.SetProperty( TextLabel::Property::MULTI_LINE, false ); - label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); - label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); - label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelImmediate.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + + Stage::GetCurrent().Add( labelFinished ); + // Turn on all the effects + labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelFinished.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + + try { // Render some text with the shared atlas backend - label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); application.SendNotification(); application.Render(); + + labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + application.SendNotification(); + application.Render(); + } catch( ... ) { 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 f4698f6..40c6c70 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 @@ -76,9 +76,31 @@ namespace Property * @details name "autoScrollLoopDelay", type float. */ AUTO_SCROLL_LOOP_DELAY = OUTLINE + 3, + + /** + * @brief Auto scrolling stop behaviour. + * @details name "autoScrollStopMode", type [Type](@ref Dali::Toolkit::DevelTextLabel::AutoScrollStopMode::Type) (Property::INTEGER) or Property::STRING. + * values FINISH_LOOP, IMMEDIATE, defualt FINISH_LOOP + */ + AUTO_SCROLL_STOP_MODE = OUTLINE + 4, }; } // namespace Property +/** +* @brief The type for TextLabel::Property::AUTO_SCROLL_STOP_MODE +*/ +namespace AutoScrollStopMode +{ +/** +* @ref Dali::Toolkit::DevelTextLabel::AutoScrollStopMode +*/ +enum Type +{ + FINISH_LOOP = 0, ///< stop animation after current loop finished. + IMMEDIATE ///< stop animation immediatly and reset position. +}; +} // namespace AutoScrollStopMode + } // namespace DevelText } // namespace Toolkit 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 22ea18a..b1c031c 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -58,6 +58,13 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif +const Scripting::StringEnum AUTO_SCROLL_STOP_MODE_TABLE[] = +{ + { "IMMEDIATE", Toolkit::DevelTextLabel::AutoScrollStopMode::IMMEDIATE }, + { "FINISH_LOOP", Toolkit::DevelTextLabel::AutoScrollStopMode::FINISH_LOOP }, +}; +const unsigned int AUTO_SCROLL_STOP_MODE_TABLE_COUNT = sizeof( AUTO_SCROLL_STOP_MODE_TABLE ) / sizeof( AUTO_SCROLL_STOP_MODE_TABLE[0] ); + const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] = { { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN }, @@ -83,33 +90,34 @@ BaseHandle Create() // Setup properties, signals and actions using the type-registry. DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create ); -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "renderingBackend", INTEGER, RENDERING_BACKEND ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "text", STRING, TEXT ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "fontFamily", STRING, FONT_FAMILY ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "fontStyle", MAP, FONT_STYLE ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "pointSize", FLOAT, POINT_SIZE ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "multiLine", BOOLEAN, MULTI_LINE ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalAlignment", STRING, VERTICAL_ALIGNMENT ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textColor", VECTOR4, TEXT_COLOR ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowOffset", VECTOR2, SHADOW_OFFSET ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowColor", VECTOR4, SHADOW_COLOR ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineEnabled", BOOLEAN, UNDERLINE_ENABLED ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineColor", VECTOR4, UNDERLINE_COLOR ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineHeight", FLOAT, UNDERLINE_HEIGHT ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableMarkup", BOOLEAN, ENABLE_MARKUP ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableAutoScroll", BOOLEAN, ENABLE_AUTO_SCROLL ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollSpeed", INTEGER, AUTO_SCROLL_SPEED ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopCount", INTEGER, AUTO_SCROLL_LOOP_COUNT ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollGap", FLOAT, AUTO_SCROLL_GAP ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineSpacing", FLOAT, LINE_SPACING ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underline", MAP, UNDERLINE ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadow", MAP, SHADOW ) -DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "emboss", MAP, EMBOSS ) -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_PROPERTY_REGISTRATION( Toolkit, TextLabel, "renderingBackend", INTEGER, RENDERING_BACKEND ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "text", STRING, TEXT ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "fontFamily", STRING, FONT_FAMILY ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "fontStyle", MAP, FONT_STYLE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "pointSize", FLOAT, POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "multiLine", BOOLEAN, MULTI_LINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalAlignment", STRING, VERTICAL_ALIGNMENT ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textColor", VECTOR4, TEXT_COLOR ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowOffset", VECTOR2, SHADOW_OFFSET ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowColor", VECTOR4, SHADOW_COLOR ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineEnabled", BOOLEAN, UNDERLINE_ENABLED ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineColor", VECTOR4, UNDERLINE_COLOR ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineHeight", FLOAT, UNDERLINE_HEIGHT ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableMarkup", BOOLEAN, ENABLE_MARKUP ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableAutoScroll", BOOLEAN, ENABLE_AUTO_SCROLL ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollSpeed", INTEGER, AUTO_SCROLL_SPEED ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopCount", INTEGER, AUTO_SCROLL_LOOP_COUNT ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollGap", FLOAT, AUTO_SCROLL_GAP ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineSpacing", FLOAT, LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underline", MAP, UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadow", MAP, SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "emboss", MAP, EMBOSS ) +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_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) DALI_TYPE_REGISTRATION_END() @@ -354,6 +362,22 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE: + { + if( !impl.mTextScroller ) + { + impl.mTextScroller = Text::TextScroller::New( impl ); + } + DevelTextLabel::AutoScrollStopMode::Type stopMode = impl.mTextScroller->GetStopMode(); + if( Scripting::GetEnumerationProperty< Toolkit::DevelTextLabel::AutoScrollStopMode::Type >( value, + AUTO_SCROLL_STOP_MODE_TABLE, + AUTO_SCROLL_STOP_MODE_TABLE_COUNT, + stopMode ) ) + { + impl.mTextScroller->SetStopMode( stopMode ); + } + break; + } case Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED: { if( !impl.mTextScroller ) @@ -612,6 +636,20 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE: + { + if( impl.mTextScroller ) + { + const char* mode = Scripting::GetEnumerationName< Toolkit::DevelTextLabel::AutoScrollStopMode::Type >( impl.mTextScroller->GetStopMode(), + AUTO_SCROLL_STOP_MODE_TABLE, + AUTO_SCROLL_STOP_MODE_TABLE_COUNT ); + if( mode ) + { + value = std::string( mode ); + } + } + break; + } case Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED: { TextLabel& impl( GetImpl( label ) ); diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index ac2af53..c80cf7d 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -234,7 +234,23 @@ void TextScroller::SetLoopCount( int loopCount ) if ( loopCount == 0 ) // Request to stop looping { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount Single loop forced\n" ); - mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way + switch( mStopMode ) + { + case DevelTextLabel::AutoScrollStopMode::IMMEDIATE: + { + mScrollAnimation.Stop(); + break; + } + case DevelTextLabel::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" ); + } + } } } DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount [%d] Status[%s]\n", mLoopCount, (loopCount)?"looping":"stop" ); @@ -255,6 +271,17 @@ float TextScroller::GetLoopDelay() const return mLoopDelay; } +void TextScroller::SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMode ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetAutoScrollStopMode [%s]\n",(stopMode == DevelTextLabel::AutoScrollStopMode::IMMEDIATE)?"IMMEDIATE":"FINISH_LOOP" ); + mStopMode = stopMode; +} + +DevelTextLabel::AutoScrollStopMode::Type TextScroller::GetStopMode() const +{ + return mStopMode; +} + Actor TextScroller::GetSourceCamera() const { return mOffscreenCameraActor; @@ -270,7 +297,8 @@ TextScroller::TextScroller( ScrollerInterface& scrollerInterface ) : mScrollerIn mScrollSpeed( MINIMUM_SCROLL_SPEED ), mLoopCount( 1 ), mLoopDelay( 0.0f ), - mWrapGap( 0.0f ) + mWrapGap( 0.0f ), + mStopMode( DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller Default Constructor\n" ); } diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index 7804a40..f6c0b87 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -22,6 +22,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -116,6 +117,18 @@ public: float GetLoopDelay() const; /** + * @brief Set the mode of scrolling stop + * @param[in] stopMode type when text scrolling is stoped. + */ + void SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMode ); + + /** + * @brief Get the mode of scrolling stop + * @return stopMode type when text scrolling is stoped. + */ + DevelTextLabel::AutoScrollStopMode::Type GetStopMode() const; + + /** * @brief Get the camera used to look at source, should be added to the parent of target actor. * @return camera Actor */ @@ -173,10 +186,11 @@ private: Property::Index mScrollDeltaIndex; // Property used by shader to represent distance to scroll Animation mScrollAnimation; // Animation used to update the mScrollDeltaIndex - 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 + 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 + DevelTextLabel::AutoScrollStopMode::Type mStopMode; ///< Stop mode of scrolling text, when loop count is 0. }; // TextScroller class