From 0c17fedc6fae9c4ca443b1eda9eab846215ca518 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Tue, 2 Jun 2020 15:29:18 +0900 Subject: [PATCH] Return Animation information Change-Id: Icc69c676d45ae5205bfa8a30bdae83aa9bff01a4 Signed-off-by: Seungho, Baek --- automated-tests/src/dali/utc-Dali-Animation.cpp | 39 ++++++++++++++++++++++ dali/devel-api/animation/animation-devel.cpp | 16 ++++++++- dali/devel-api/animation/animation-devel.h | 18 ++++++++-- .../event/animation/animation-playlist.cpp | 17 +++++++++- dali/internal/event/animation/animation-playlist.h | 17 +++++++++- 5 files changed, 102 insertions(+), 5 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index e4c695e..6a67e8d 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -13528,3 +13528,42 @@ int UtcDaliAnimationCombineToAndByWithStop(void) END_TEST; } + +int UtcDaliAnimationCountAndGetAnimationAt(void) +{ + tet_infoline( "UtcDaliAnimationCountAndGetAnimationAt"); + + TestApplication application; + + auto actor = Actor::New(); + actor.SetPosition( 100.0f, 100.0f ); + Stage::GetCurrent().Add( actor ); + + auto animation = Animation::New( 1.0f ); + const float origY = actor.GetProperty( Actor::Property::POSITION_Y ).Get< float >(); + animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 150.0f, origY, 0.0f ), TimePeriod( 1.0f ) ); + animation.Play(); + + application.SendNotification(); + application.Render( 500 ); + + uint32_t animationCount = Dali::DevelAnimation::GetAnimationCount(); + DALI_TEST_EQUALS( animationCount, 1, TEST_LOCATION ); + + DALI_TEST_CHECK( !Dali::DevelAnimation::GetAnimationAt( 5 ) ); + + Dali::Animation animationReturned = Dali::DevelAnimation::GetAnimationAt( 0 ); + DALI_TEST_EQUALS( animationReturned.GetState(), Dali::Animation::State::PLAYING, TEST_LOCATION ); + + DALI_TEST_EQUALS( animation.GetDuration(), animationReturned.GetDuration(), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetLoopCount(), animationReturned.GetLoopCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.IsLooping(), animationReturned.IsLooping(), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetEndAction(), animationReturned.GetEndAction(), TEST_LOCATION ); + DALI_TEST_EQUALS( animation.GetState(), animationReturned.GetState(), TEST_LOCATION ); + + // Stop and clear the animation using the current values + animation.Stop(); + animation.Clear(); + + END_TEST; +} diff --git a/dali/devel-api/animation/animation-devel.cpp b/dali/devel-api/animation/animation-devel.cpp index 0840ae7..4fba68b 100644 --- a/dali/devel-api/animation/animation-devel.cpp +++ b/dali/devel-api/animation/animation-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ // INTERNAL INCLUDES #include #include +#include +#include namespace Dali { @@ -40,6 +42,18 @@ Animation::AnimationSignalType& ProgressReachedSignal( Animation animation ) return GetImplementation( animation ).ProgressReachedSignal(); } +uint32_t GetAnimationCount() +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.GetAnimationPlaylist().GetAnimationCount(); +} + +Animation GetAnimationAt( uint32_t index ) +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.GetAnimationPlaylist().GetAnimationAt( index ); +} + } // namespace DevelAnimation } // namespace Dali diff --git a/dali/devel-api/animation/animation-devel.h b/dali/devel-api/animation/animation-devel.h index f003075..b7b6019 100644 --- a/dali/devel-api/animation/animation-devel.h +++ b/dali/devel-api/animation/animation-devel.h @@ -2,7 +2,7 @@ #define DALI_ANIMATION_DEVEL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,10 +47,24 @@ DALI_CORE_API float GetProgressNotification( Animation animation ); * @brief Connects to this signal to be notified when an Animation's animations have reached set progress. * * @return A signal object to connect with - * */ DALI_CORE_API Animation::AnimationSignalType& ProgressReachedSignal( Animation animation ); +/** + * @brief Retrive the number of Animations. + * + * @return The number of Animations. + */ +DALI_CORE_API uint32_t GetAnimationCount(); + +/** + * @brief Retrieve an Animation by index. + * + * @param[in] index The index of the Animation to retrieve + * @return The animation for the given index or empty handle + */ +DALI_CORE_API Animation GetAnimationAt( uint32_t index ); + } // namespace DevelAnimation } // namespace Dali diff --git a/dali/internal/event/animation/animation-playlist.cpp b/dali/internal/event/animation/animation-playlist.cpp index 55c9b91..c39385f 100644 --- a/dali/internal/event/animation/animation-playlist.cpp +++ b/dali/internal/event/animation/animation-playlist.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,6 +127,21 @@ void AnimationPlaylist::NotifyProgressReached( const SceneGraph::Animation* scen } } +uint32_t AnimationPlaylist::GetAnimationCount() +{ + return mAnimations.Size(); +} + +Dali::Animation AnimationPlaylist::GetAnimationAt( uint32_t index ) +{ + if( index >= mAnimations.Size() ) + { + DALI_LOG_ERROR( "Animation index is out of bounds.\n" ); + return Dali::Animation(); + } + return Dali::Animation( mAnimations[index] ); +} + } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/animation/animation-playlist.h b/dali/internal/event/animation/animation-playlist.h index 2fa0787..c31c11d 100644 --- a/dali/internal/event/animation/animation-playlist.h +++ b/dali/internal/event/animation/animation-playlist.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ANIMATION_PLAYLIST_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,6 +81,21 @@ public: */ void NotifyProgressReached( const SceneGraph::Animation* sceneGraphAnimation ); + /** + * @brief Retrive the number of Animations. + * + * @return The number of Animations. + */ + uint32_t GetAnimationCount(); + + /** + * @brief Retrieve an Animation by index. + * + * @param[in] index The index of the Animation to retrieve + * @return The Dali::Animation for the given index or empty handle + */ + Dali::Animation GetAnimationAt( uint32_t index ); + private: /** -- 2.7.4