Merge "Add SetProperty and GetProperty to Visuals." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-impl.cpp
index 58e4d38..32f8b8d 100644 (file)
@@ -105,12 +105,12 @@ float Visual::Base::GetDepthIndex() const
 
 void Visual::Base::SetOnStage( Actor& actor )
 {
+  // To display the actor correctly, renderer should not be added to actor until all required resources are ready.
+  // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
   DoSetOnStage( actor );
 
   mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
   mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
-  actor.AddRenderer( mImpl->mRenderer );
-
   mImpl->mFlags |= Impl::IS_ON_STAGE;
 }
 
@@ -146,10 +146,6 @@ bool Visual::Base::IsPreMultipliedAlphaEnabled() const
   return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
 }
 
-void Visual::Base::DoSetOnStage( Actor& actor )
-{
-}
-
 void Visual::Base::DoSetOffStage( Actor& actor )
 {
   actor.RemoveRenderer( mImpl->mRenderer );
@@ -176,6 +172,42 @@ bool Visual::Base::GetIsFromCache() const
   return mImpl->mFlags & Impl::IS_FROM_CACHE;
 }
 
+void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+  DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) &&
+                      ( index > VISUAL_PROPERTY_BASE_START_INDEX ) && // Change the type of visual is not allowed.
+                      "Property index is out of bounds" );
+
+  if( index < VISUAL_PROPERTY_START_INDEX )
+  {
+    // TODO set the properties of the visual base.
+  }
+  else
+  {
+    DoSetProperty( index, propertyValue );
+  }
+}
+
+Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index )
+{
+  DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) &&
+                      ( index >= VISUAL_PROPERTY_BASE_START_INDEX ) &&
+                      "Property index is out of bounds" );
+
+  Dali::Property::Value value;
+
+  if( index < VISUAL_PROPERTY_START_INDEX )
+  {
+    // TODO retrieve the properties of the visual base.
+  }
+  else
+  {
+    value = DoGetProperty( index );
+  }
+
+  return value;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit