-// Called by a Visual when it's resource is ready
-void Control::Impl::ResourceReady( Visual::Base& object)
-{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady \n");
-
- // A resource is ready, check if is in the replacement visual container
- // Iterate through all visuals in replacement container and store indexes of ready visuals
- Dali::Vector <Property::Index> readyVisuals;
- Actor self = mControlImpl.Self();
-
- for( auto replacementVisualIter = mReplacementVisuals.Begin();
- replacementVisualIter < mReplacementVisuals.End(); ++replacementVisualIter )
- {
- const Toolkit::Visual::Base replacementVisual = (*replacementVisualIter)->visual;
- const Internal::Visual::Base& replacementVisualImpl = Toolkit::GetImplementation( replacementVisual );
-
- if( replacementVisualImpl.IsResourceReady() )
- {
- // Check if new replacement visual (index) is already queued for replacement and swap old for new.
- RegisteredVisualContainer::Iterator registeredVisualsIter;
- if( FindVisual( (*replacementVisualIter)->index, mVisuals, registeredVisualsIter ) )
- {
- Property::Index readyVisualIndex = (*replacementVisualIter)->index;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Ready to replace\n", readyVisualIndex );
- readyVisuals.PushBack( readyVisualIndex );
- // Remove current shown visual from stage and from registered visuals container
- Toolkit::GetImplementation((*registeredVisualsIter)->visual).SetOffStage( self );
- mVisuals.Erase( registeredVisualsIter );
- }
- }
- }
-
- for( auto readyVisualsIter = readyVisuals.Begin(); readyVisualsIter != readyVisuals.End(); readyVisualsIter++ )
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Matched\n", (*readyVisualsIter) );
- // Move new visual to be shown from replacement container into the control's registered visuals container
- // Replacement visual has already been set on stage when it was added to replacement container
- RegisteredVisualContainer::Iterator readyReplacementVisual;
- if( FindVisual( (*readyVisualsIter) , mReplacementVisuals, readyReplacementVisual ) )
- {
- MoveVisual( readyReplacementVisual, mReplacementVisuals, mVisuals ); // Erases visual from replacement queue
- }
- // A visual has been replaced so control will most likely need relayouting
- mControlImpl.RelayoutRequest();
- }
-
- // Emit signal if all enabled visuals registered by the control are ready.
- // If any visual is registered and enabled but not ready then the control will not be able to emit ReadySignal.
-
- if ( IsResourceReady() )
- {
- Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
- mResourceReadySignal.Emit( handle );
- }
-}
-
-bool Control::Impl::IsResourceReady() const
-{
- // Iterate through and check all the enabled visuals are ready
- for ( auto visualIter = mVisuals.Begin();
- visualIter != mVisuals.End(); ++visualIter )
- {
- const Toolkit::Visual::Base visual = (*visualIter)->visual;
- const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
-
- // one of the enabled visuals is not ready
- if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
- {
- return false;
- }
- }
- return true;
-}
-