UpdateProperty action set some missed DecoratedVisualRenderer properties
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-impl.cpp
index b50cc59..55610ec 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/public-api/rendering/visual-renderer.h>
 
 //INTERNAL HEARDER
+#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/helpers/property-helper.h>
@@ -295,7 +296,7 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           mImpl->mBorderlineWidth = width;
         }
 
-        if(DALI_UNLIKELY(mImpl->mRenderer))
+        if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
         {
           // Unusual case. SetProperty called after OnInitialize().
           // Assume that DoAction call UPDATE_PROPERTY.
@@ -305,6 +306,10 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           // Check whether we must update shader.
           if(!mImpl->mAlwaysUsingBorderline && IsBorderlineRequired())
           {
+            // Required to change shader mean, we didn't setup BORDERLINE_COLOR and BORDERLINE_OFFSET into mRenderer before. Set property now.
+            mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
+            mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
+
             // Make Blend mode ON_WITHOUT_CULL for transparent mix color.
             mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
 
@@ -328,7 +333,7 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           mImpl->mBorderlineColor = color;
         }
 
-        if(DALI_UNLIKELY(mImpl->mRenderer))
+        if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
         {
           // Unusual case. SetProperty called after OnInitialize().
           // Assume that DoAction call UPDATE_PROPERTY.
@@ -344,7 +349,7 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           mImpl->mBorderlineOffset = offset;
         }
 
-        if(DALI_UNLIKELY(mImpl->mRenderer))
+        if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
         {
           // Unusual case. SetProperty called after OnInitialize().
           // Assume that DoAction call UPDATE_PROPERTY.
@@ -376,7 +381,7 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           }
         }
 
-        if(DALI_UNLIKELY(mImpl->mRenderer))
+        if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForCornerRadius(mImpl->mType)))
         {
           // Unusual case. SetProperty called after OnInitialize().
           // Assume that DoAction call UPDATE_PROPERTY.
@@ -386,6 +391,9 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           // Check whether we must update shader.
           if(!mImpl->mAlwaysUsingCornerRadius && IsRoundedCornerRequired())
           {
+            // Required to change shader mean, we didn't setup CORNER_RADIUS_POLICY into mRenderer before. Set property now.
+            mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
+
             // Change the shader must not be occured many times. we always have to use corner radius feature.
             mImpl->mAlwaysUsingCornerRadius = true;
 
@@ -516,6 +524,11 @@ void Visual::Base::DoAction(const Property::Index actionId, const Property::Valu
   }
 }
 
+void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const Dali::Any attributes)
+{
+  OnDoActionExtension(actionId, attributes);
+}
+
 void Visual::Base::SetDepthIndex(int index)
 {
   mImpl->mDepthIndex = index;
@@ -568,11 +581,11 @@ void Visual::Base::CreatePropertyMap(Property::Map& map) const
     mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
     mImpl->mTransform.mSize   = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
 
-    if(IsTypeAvailableForCornerRadius(mImpl->mType))
+    if(IsRoundedCornerRequired())
     {
       mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
     }
-    if(IsTypeAvailableForBorderline(mImpl->mType))
+    if(IsBorderlineRequired())
     {
       mImpl->mBorderlineWidth  = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
       mImpl->mBorderlineColor  = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
@@ -697,6 +710,11 @@ void Visual::Base::OnDoAction(const Property::Index actionId, const Property::Va
   // May be overriden by derived class
 }
 
+void Visual::Base::OnDoActionExtension(const Property::Index actionId, const Dali::Any attributes)
+{
+  // May be overriden by derived class
+}
+
 void Visual::Base::RegisterMixColor()
 {
   if(mImpl->mRenderer)
@@ -1233,18 +1251,34 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
       }
       break;
     }
-    // Special case for MIX_COLOR
     default:
     {
+      // Special case for MIX_COLOR
       if(key.type == Property::Key::INDEX &&
          ((mImpl->mType == Toolkit::Visual::COLOR && key.indexKey == ColorVisual::Property::MIX_COLOR) ||
           (mImpl->mType == Toolkit::Visual::PRIMITIVE && key.indexKey == PrimitiveVisual::Property::MIX_COLOR)))
       {
         return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
       }
+
+      // Special case for BLUR_RADIUS
+      if(mImpl->mType == Toolkit::Visual::COLOR &&
+         ((key.type == Property::Key::INDEX && key.indexKey == DevelColorVisual::Property::BLUR_RADIUS) ||
+          (key.type == Property::Key::STRING && key.stringKey == BLUR_RADIUS_NAME)))
+      {
+        // Request to color-visual class
+        return OnGetPropertyObject(key);
+      }
     }
   }
 
+  // If it is not VisualRenderer property, check registered Renderer and Shader property.
+  Property::Index index = GetPropertyIndex(key);
+  if(index != Property::INVALID_INDEX)
+  {
+    return Dali::Property(mImpl->mRenderer, index);
+  }
+
   // We can't find the property in the base class.
   // Request to child class
   return OnGetPropertyObject(key);