#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <cstring>
+#include <limits>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
namespace Dali
{
void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
{
- RegisterVisual( index, visual, true );
+ RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
+{
+ RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::SET, depthIndex );
}
void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
{
+ RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::NOT_SET );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
+{
+ RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::SET, depthIndex );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex )
+{
bool visualReplaced ( false );
Actor self = mControlImpl.Self();
Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
}
+ // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
+ if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
+ ( visual.GetDepthIndex() == 0 ) )
+ {
+ const int currentDepthIndex = (*iter)->visual.GetDepthIndex();
+ visual.SetDepthIndex( currentDepthIndex );
+ }
+
StopObservingVisual( (*iter)->visual );
StartObservingVisual( visual );
(*iter)->visual = visual;
+ (*iter)->enabled = ( enabled == VisualState::ENABLED ) ? true : false;
visualReplaced = true;
}
}
// ( If the control has been type registered )
if( visual.GetName().empty() )
{
- // Check if the control has been type registered:
- TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid( mControlImpl ) );
- if( typeInfo )
+ try
{
- // Check if the property index has been registered:
- Property::IndexContainer indices;
- typeInfo.GetPropertyIndices( indices );
- Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
- if( iter != indices.End() )
+ std::string visualName = self.GetPropertyName( index );
+ if( !visualName.empty() )
{
- // If it has, then get it's name and use that for the visual
- std::string visualName = typeInfo.GetPropertyName( index );
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n",
+ index, visualName.c_str() );
visual.SetName( visualName );
}
}
+ catch( Dali::DaliException e )
+ {
+ DALI_LOG_WARNING( "Attempting to register visual without a registered property, index: %d\n", index );
+ }
}
if( !visualReplaced ) // New registration entry
{
- mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
+ mVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
// monitor when the visuals resources are ready
StartObservingVisual( visual );
+ // 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 );
+ }
}
- if( visual && self.OnStage() && enabled )
+ if( visual )
{
- Toolkit::GetImplementation(visual).SetOnStage( self );
+ // If the caller has set the depth-index, then set it here
+ if( depthIndexValueSet == DepthIndexValue::SET )
+ {
+ visual.SetDepthIndex( depthIndex );
+ }
+
+ // Put on stage if enabled and the control is already on the stage
+ if( ( enabled == VisualState::ENABLED ) && self.OnStage() )
+ {
+ Toolkit::GetImplementation(visual).SetOnStage( self );
+ }
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n", visual.GetName().c_str(), index, enabled?"T":"F" );
if( visual )
{
+#if defined(DEBUG_ENABLED)
+ Dali::TypeInfo typeInfo;
+ ControlWrapper* controlWrapperImpl = dynamic_cast<ControlWrapper*>(&mControlImpl);
+ if( controlWrapperImpl )
+ {
+ typeInfo = controlWrapperImpl->GetTypeInfo();
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Found %s visual for %s\n",
+ visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" );
+#endif
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
visualImpl.AnimateProperty( transition, *animator );
}
else
{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Could not find visual. Trying actors");
// Otherwise, try any actor children of control (Including the control)
Actor child = mControlImpl.Self().FindChildByName( animator->objectName );
if( child )
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
if( visual )
{
- controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
- visual.SetDepthIndex( DepthIndex::BACKGROUND );
+ controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
}
}
else if( value.Get( color ) )