X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Fanimation-playlist.cpp;h=c39385f7fef20f962f6088aaa295cd3c59a40556;hb=0c17fedc6fae9c4ca443b1eda9eab846215ca518;hp=a1f8c4ca87e0f36d1c2a236caa42def9159ee0a1;hpb=5c66381841dd4dfd82c5a118d34104a00a2e0e1c;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/animation/animation-playlist.cpp b/dali/internal/event/animation/animation-playlist.cpp index a1f8c4c..c39385f 100644 --- a/dali/internal/event/animation/animation-playlist.cpp +++ b/dali/internal/event/animation/animation-playlist.cpp @@ -1,18 +1,19 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include @@ -20,7 +21,6 @@ // INTERNAL INCLUDES #include -#include #include @@ -45,34 +45,41 @@ AnimationPlaylist::~AnimationPlaylist() void AnimationPlaylist::AnimationCreated( Animation& animation ) { - mAnimations.insert( &animation ); + mAnimations.PushBack( &animation ); } void AnimationPlaylist::AnimationDestroyed( Animation& animation ) { - std::set< Animation* >::iterator iter = find( mAnimations.begin(), mAnimations.end(), &animation ); - DALI_ASSERT_ALWAYS( iter != mAnimations.end() && "Animation not found" ); + Dali::Vector< Animation* >::Iterator iter = std::find( mAnimations.Begin(), mAnimations.End(), &animation ); + DALI_ASSERT_ALWAYS( iter != mAnimations.End() && "Animation not found" ); - mAnimations.erase( iter ); + mAnimations.Remove( iter ); } void AnimationPlaylist::OnPlay( Animation& animation ) { - mPlaylist.insert( Dali::Animation(&animation) ); + mPlaylist.push_back( Dali::Animation(&animation) ); } void AnimationPlaylist::OnClear( Animation& animation ) { - mPlaylist.erase( Dali::Animation(&animation) ); + std::vector< Dali::Animation >::iterator iter = std::find( mPlaylist.begin(), mPlaylist.end(), Dali::Animation(&animation) ); + std::vector< Dali::Animation >::iterator last = mPlaylist.end(); + if( iter != last ) + { + --last; // move to real last + std::swap( *iter, *last ); // swap + mPlaylist.resize( mPlaylist.size() - 1u ); + } } -void AnimationPlaylist::NotifyFinishedAnimations() +void AnimationPlaylist::NotifyCompleted() { std::vector< Dali::Animation > finishedAnimations; // Since animations can be unreferenced during the signal emissions, iterators into animationPointers may be invalidated. // First copy and reference the finished animations, then emit signals - for ( std::set< Animation* >::iterator iter = mAnimations.begin(); iter != mAnimations.end(); ++iter ) + for ( Dali::Vector< Animation* >::Iterator iter = mAnimations.Begin(); iter != mAnimations.End(); ++iter ) { Animation* animation = *iter; @@ -82,7 +89,9 @@ void AnimationPlaylist::NotifyFinishedAnimations() // The animation may be present in mPlaylist - remove if necessary // Note that the animation "Finish" signal is emitted after Stop() has been called - mPlaylist.erase( Dali::Animation(animation) ); + std::vector< Dali::Animation >::iterator iter = std::find( mPlaylist.begin(), mPlaylist.end(), Dali::Animation(animation) ); + DALI_ASSERT_DEBUG(iter != mPlaylist.end()); + mPlaylist.erase( iter ); } } @@ -95,6 +104,44 @@ void AnimationPlaylist::NotifyFinishedAnimations() } } +void AnimationPlaylist::NotifyProgressReached( const SceneGraph::Animation* sceneGraphAnimation ) +{ + std::vector< Dali::Animation > notifyProgressAnimations; // Will own animations until all emits have been done + + for ( Dali::Vector< Animation* >::Iterator iter = mAnimations.Begin(); iter != mAnimations.End(); ++iter ) + { + Animation* animation = *iter; + + if ( ( animation->GetSceneObject() ) == sceneGraphAnimation ) + { + // Store handles to animations that need signals emitted in the case of an animation being cleared in-between emits + notifyProgressAnimations.push_back( Dali::Animation( animation ) ); + } + } + + for ( std::vector< Dali::Animation >::iterator iter = notifyProgressAnimations.begin(); iter != notifyProgressAnimations.end(); ++iter ) + { + Dali::Animation& handle = *iter; + + GetImplementation(handle).EmitSignalProgressReached(); + } +} + +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