}
AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
+: Visual::Base( factoryCache, Visual::FittingMode::FIT_KEEP_ASPECT_RATIO ),
mFrameDelayTimer(),
mPlacementActor(),
mPixelArea( FULL_TEXTURE_RECT ),
mImageSize(),
mWrapModeU( WrapMode::DEFAULT ),
mWrapModeV( WrapMode::DEFAULT ),
+ mActionStatus( DevelAnimatedImageVisual::Action::PLAY ),
mStartFirstFrame(false)
{}
// Do nothing
}
+void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, const Dali::Property::Value& attributes )
+{
+ // Check if action is valid for this visual type and perform action if possible
+
+ switch ( actionId )
+ {
+ case DevelAnimatedImageVisual::Action::PAUSE:
+ {
+ // Pause will be executed on next timer tick
+ mActionStatus = DevelAnimatedImageVisual::Action::PAUSE;
+ break;
+ }
+ case DevelAnimatedImageVisual::Action::PLAY:
+ {
+ if( IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
+ {
+ mFrameDelayTimer.Start();
+ }
+ mActionStatus = DevelAnimatedImageVisual::Action::PLAY;
+ break;
+ }
+ case DevelAnimatedImageVisual::Action::STOP:
+ {
+ // STOP reset functionality will actually be done in a future change
+ // Stop will be executed on next timer tick
+ mCurrentFrameIndex = 0;
+ mActionStatus = DevelAnimatedImageVisual::Action::STOP;
+ break;
+ }
+ }
+}
+
void AnimatedImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
// url[s] already passed in from constructor
{
mImageCache = new RollingGifImageCache( textureManager, *mGifLoading, mFrameCount, *this, cacheSize, batchSize );
}
- else if( batchSize > 0 && cacheSize > 0 )
+ else if( mImageUrls )
{
- if( cacheSize < numUrls )
+ if( batchSize > 0 && cacheSize > 0 )
{
- mImageCache = new RollingImageCache( textureManager, *mImageUrls, *this, cacheSize, batchSize );
+ if( cacheSize < numUrls )
+ {
+ mImageCache = new RollingImageCache( textureManager, *mImageUrls, *this, cacheSize, batchSize );
+ }
+ else
+ {
+ mImageCache = new FixedImageCache( textureManager, *mImageUrls, *this, batchSize );
+ }
}
else
{
- mImageCache = new FixedImageCache( textureManager, *mImageUrls, *this, batchSize );
+ mImageCache = new RollingImageCache( textureManager, *mImageUrls, *this, 1, 1 );
}
}
- else
- {
- mImageCache = new RollingImageCache( textureManager, *mImageUrls, *this, 1, 1 );
- }
+
if (!mImageCache)
{
DALI_LOG_ERROR("mImageCache is null");
bool AnimatedImageVisual::DisplayNextFrame()
{
+ if( mActionStatus == DevelAnimatedImageVisual::Action::STOP || mActionStatus == DevelAnimatedImageVisual::Action::PAUSE )
+ {
+ return false;
+ }
if( mFrameCount > 1 )
{
// Wrap the frame index
}
TextureSet textureSet;
- if (mImageCache)
- textureSet = mImageCache->NextFrame();
- if( textureSet )
+ if( mImageCache )
{
- SetImageSize( textureSet );
- mImpl->mRenderer.SetTextures( textureSet );
+ textureSet = mImageCache->NextFrame();
+ if( textureSet )
+ {
+ SetImageSize( textureSet );
+ mImpl->mRenderer.SetTextures( textureSet );
+ }
}
// Keep timer ticking