Merge "Add Text font size conversion description in documentation" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / control / control-data-impl.cpp
index b04aa2a..81fa035 100644 (file)
@@ -37,6 +37,7 @@
 #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
 {
@@ -387,7 +388,7 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
   RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::NOT_SET );
 }
 
-void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, float depthIndex )
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
 {
   RegisterVisual( index, visual, VisualState::ENABLED, DepthIndexValue::SET, depthIndex );
 }
@@ -397,12 +398,12 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
   RegisterVisual( index, visual, ( enabled ? VisualState::ENABLED : VisualState::DISABLED ), DepthIndexValue::NOT_SET );
 }
 
-void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled, float depthIndex )
+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, float 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();
@@ -420,9 +421,9 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
 
       // 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 ) &&
-          EqualsZero( visual.GetDepthIndex() ) )
+          ( visual.GetDepthIndex() == 0 ) )
       {
-        const float currentDepthIndex = (*iter)->visual.GetDepthIndex();
+        const int currentDepthIndex = (*iter)->visual.GetDepthIndex();
         visual.SetDepthIndex( currentDepthIndex );
       }
 
@@ -439,21 +440,20 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
   // ( 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
@@ -466,15 +466,15 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base
     // 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 ) &&
-        EqualsZero( visual.GetDepthIndex() ) )
+        ( visual.GetDepthIndex() == 0 ) )
     {
-      float maxDepthIndex = std::numeric_limits< float >::min();
+      int maxDepthIndex = std::numeric_limits< int >::min();
 
       RegisteredVisualContainer::ConstIterator iter;
       const RegisteredVisualContainer::ConstIterator endIter = mVisuals.End();
       for ( iter = mVisuals.Begin(); iter != endIter; iter++ )
       {
-        const float visualDepthIndex = (*iter)->visual.GetDepthIndex();
+        const int visualDepthIndex = (*iter)->visual.GetDepthIndex();
         if ( visualDepthIndex > maxDepthIndex )
         {
           maxDepthIndex = visualDepthIndex;
@@ -603,11 +603,23 @@ Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData&
 
       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 )
@@ -793,7 +805,7 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons
           Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
           if( visual )
           {
-            controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, float( DepthIndex::BACKGROUND ) );
+            controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
           }
         }
         else if( value.Get( color ) )