TypeRegistration mType(typeid(Dali::DecoratedVisualRenderer), typeid(Dali::VisualRenderer), Create, DecoratedVisualRendererDefaultProperties);
+/**
+ * Sets both the cached value of a property and sends a message to set the animatable property in the Update thread.
+ * @tparam T The property type
+ * @param eventThreadServices The event thread services
+ * @param propertyValue The new property value given
+ * @param cachedValue The local cached value of the property
+ * @param animatableProperty The animatable property to set on the update-thread
+ */
+template<typename T>
+void SetValue(EventThreadServices& eventThreadServices, const Property::Value& propertyValue, T& cachedValue, const SceneGraph::AnimatableProperty<T>& animatableProperty)
+{
+ if(propertyValue.Get(cachedValue))
+ {
+ BakeMessage<T>(eventThreadServices, animatableProperty, cachedValue);
+ }
+}
+
} // unnamed namespace
DecoratedVisualRendererPtr DecoratedVisualRenderer::New()
{
}
-DecoratedVisualRenderer::~DecoratedVisualRenderer()
-{
- // The scene object will be deleted by ~VisualRenderer
-}
+DecoratedVisualRenderer::~DecoratedVisualRenderer() = default; // The scene object will be deleted by ~VisualRenderer
void DecoratedVisualRenderer::SetDefaultProperty(Property::Index index,
const Property::Value& propertyValue)
}
else
{
- switch(index)
+ const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
+ auto visualProperties = sceneObject.GetVisualProperties();
+
+ if(visualProperties)
{
- case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS:
+ auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
+
+ if(decoratedVisualProperties)
{
- if(propertyValue.Get(mDecoratedPropertyCache.mCornerRadius))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
- if(visualProperties)
+ switch(index)
+ {
+ case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<Vector4>(GetEventThreadServices(), decoratedVisualProperties->mCornerRadius, mDecoratedPropertyCache.mCornerRadius);
- }
+ SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mCornerRadius, decoratedVisualProperties->mCornerRadius);
+ break;
}
- }
- break;
- }
-
- case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY:
- {
- if(propertyValue.Get(mDecoratedPropertyCache.mCornerRadiusPolicy))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
+ case Dali::DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<float>(GetEventThreadServices(), decoratedVisualProperties->mCornerRadiusPolicy, mDecoratedPropertyCache.mCornerRadiusPolicy);
- }
+ SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mCornerRadiusPolicy, decoratedVisualProperties->mCornerRadiusPolicy);
+ break;
}
- }
- break;
- }
-
- case Dali::DecoratedVisualRenderer::Property::BORDERLINE_WIDTH:
- {
- if(propertyValue.Get(mDecoratedPropertyCache.mBorderlineWidth))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
+ case Dali::DecoratedVisualRenderer::Property::BORDERLINE_WIDTH:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<float>(GetEventThreadServices(), decoratedVisualProperties->mBorderlineWidth, mDecoratedPropertyCache.mBorderlineWidth);
- }
+ SetValue(eventThreadServices, propertyValue, mDecoratedPropertyCache.mBorderlineWidth, decoratedVisualProperties->mBorderlineWidth);
+ break;
}
- }
- break;
- }
-
- case Dali::DecoratedVisualRenderer::Property::BORDERLINE_COLOR:
- {
- if(propertyValue.Get(mDecoratedPropertyCache.mBorderlineColor))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
+ case Dali::DecoratedVisualRenderer::Property::BORDERLINE_COLOR:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<Vector4>(GetEventThreadServices(), decoratedVisualProperties->mBorderlineColor, mDecoratedPropertyCache.mBorderlineColor);
- }
+ SetValue(eventThreadServices, propertyValue,mDecoratedPropertyCache.mBorderlineColor, decoratedVisualProperties->mBorderlineColor);
+ break;
}
- }
- break;
- }
- case Dali::DecoratedVisualRenderer::Property::BORDERLINE_OFFSET:
- {
- if(propertyValue.Get(mDecoratedPropertyCache.mBorderlineOffset))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
-
- if(visualProperties)
+ case Dali::DecoratedVisualRenderer::Property::BORDERLINE_OFFSET:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<float>(GetEventThreadServices(), decoratedVisualProperties->mBorderlineOffset, mDecoratedPropertyCache.mBorderlineOffset);
- }
+ SetValue(eventThreadServices, propertyValue,mDecoratedPropertyCache.mBorderlineOffset, decoratedVisualProperties->mBorderlineOffset);
+ break;
}
- }
- break;
- }
-
- case Dali::DecoratedVisualRenderer::Property::BLUR_RADIUS:
- {
- if(propertyValue.Get(mDecoratedPropertyCache.mBlurRadius))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
+ case Dali::DecoratedVisualRenderer::Property::BLUR_RADIUS:
{
- auto decoratedVisualProperties = static_cast<AnimatableDecoratedVisualProperties*>(visualProperties->mExtendedProperties);
- if(decoratedVisualProperties)
- {
- BakeMessage<float>(GetEventThreadServices(), decoratedVisualProperties->mBlurRadius, mDecoratedPropertyCache.mBlurRadius);
- }
+ SetValue(eventThreadServices, propertyValue,mDecoratedPropertyCache.mBlurRadius, decoratedVisualProperties->mBlurRadius);
+ break;
}
}
- break;
}
}
}