+ // If we've not set the depth-index value, we have more than one visual and the visual does not have a depth index, then set it to be the highest
+ if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
+ ( mVisuals.Size() > 1 ) &&
+ ( visual.GetDepthIndex() == 0 ) )
+ {
+ int maxDepthIndex = std::numeric_limits< int >::min();
+
+ RegisteredVisualContainer::ConstIterator iter;
+ const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
+ for ( iter = mVisuals.Begin(); iter != endIter; iter++ )
+ {
+ const int visualDepthIndex = (*iter)->visual.GetDepthIndex();
+ if ( visualDepthIndex > maxDepthIndex )
+ {
+ maxDepthIndex = visualDepthIndex;
+ }
+ }
+
+ ++maxDepthIndex; // Add one to the current maximum depth index so that our added visual appears on top
+ visual.SetDepthIndex( maxDepthIndex );
+ }