(Control) Fix some SVACE issues in Transition
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / control / control-data-impl.cpp
index c50cd20..33670d6 100644 (file)
@@ -1456,10 +1456,10 @@ Dali::Accessibility::ReadingInfoTypes Control::Impl::GetAccessibilityReadingInfo
   else
   {
     Dali::Accessibility::ReadingInfoTypes types;
-    types[Dali::Accessibility::ReadingInfoType::NAME] = true;
-    types[Dali::Accessibility::ReadingInfoType::ROLE] = true;
+    types[Dali::Accessibility::ReadingInfoType::NAME]        = true;
+    types[Dali::Accessibility::ReadingInfoType::ROLE]        = true;
     types[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = true;
-    types[Dali::Accessibility::ReadingInfoType::STATE] = true;
+    types[Dali::Accessibility::ReadingInfoType::STATE]       = true;
     return types;
   }
 
@@ -1821,6 +1821,78 @@ Dali::Property Control::Impl::GetVisualProperty(Dali::Property::Index index, Dal
   return Dali::Property(handle, Property::INVALID_INDEX);
 }
 
+void Control::Impl::MakeVisualTransition(Dali::Animation& animation, Dali::Toolkit::Control source, Dali::Property::Index visualIndex, AlphaFunction alphaFunction, TimePeriod timePeriod)
+{
+  Dali::Toolkit::Control sourceHandle      = Dali::Toolkit::Control::DownCast(source);
+  Property::Map          sourceMap         = sourceHandle.GetProperty<Property::Map>(visualIndex);
+  Dali::Toolkit::Control destinationHandle = Dali::Toolkit::Control::DownCast(mControlImpl.Self());
+  Property::Map          destinationMap    = destinationHandle.GetProperty<Property::Map>(visualIndex);
+
+  Vector4 mixColor(1.0f, 1.0f, 1.0f, 1.0f);
+  Vector4 cornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
+
+  if(!destinationMap.Empty())
+  {
+    static auto findValue = [](const Property::Map& map, Property::Index index) -> Vector4 {
+      Property::Value* propertyValue = map.Find(index);
+      if(propertyValue)
+      {
+        return propertyValue->Get<Vector4>();
+      }
+      return Vector4{};
+    };
+
+    mixColor     = findValue(destinationMap, Dali::Toolkit::Visual::Property::MIX_COLOR);
+    cornerRadius = findValue(destinationMap, Toolkit::DevelVisual::Property::CORNER_RADIUS);
+
+    if(sourceMap.Empty())
+    {
+      sourceMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+      sourceMap.Insert(Dali::Toolkit::Visual::Property::MIX_COLOR, Color::TRANSPARENT);
+      sourceMap.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
+    }
+
+    Vector4 sourceMixColor     = findValue(sourceMap, Dali::Toolkit::Visual::Property::MIX_COLOR);
+    Vector4 sourceCornerRadius = findValue(sourceMap, Toolkit::DevelVisual::Property::CORNER_RADIUS);
+
+    std::vector<Dali::Property>                              properties;
+    std::vector<std::pair<Property::Value, Property::Value>> values;
+
+    if(Vector3(sourceMixColor) != Vector3(mixColor))
+    {
+      properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::MIX_COLOR));
+      values.push_back(std::make_pair(Vector3(sourceMixColor), Vector3(mixColor)));
+    }
+
+    if(std::abs(sourceMixColor.a - mixColor.a) > Math::MACHINE_EPSILON_1)
+    {
+      properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::OPACITY));
+      values.push_back(std::make_pair(sourceMixColor.a, mixColor.a));
+    }
+
+    if(sourceCornerRadius != cornerRadius)
+    {
+      properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS));
+      values.push_back(std::make_pair(sourceCornerRadius, cornerRadius));
+    }
+
+    for(uint32_t i = 0; i < properties.size(); ++i)
+    {
+      if(timePeriod.delaySeconds > 0.0f)
+      {
+        Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New();
+        initialKeyframes.Add(0.0f, values[i].first);
+        initialKeyframes.Add(1.0f, values[i].first);
+        animation.AnimateBetween(properties[i], initialKeyframes, TimePeriod(timePeriod.delaySeconds));
+      }
+      Dali::KeyFrames keyframes = Dali::KeyFrames::New();
+      keyframes.Add(0.0f, values[i].first);
+      keyframes.Add(1.0f, values[i].second);
+      animation.AnimateBetween(properties[i], keyframes, alphaFunction, timePeriod);
+    }
+  }
+}
+
 void Control::Impl::EmitResourceReadySignal()
 {
   if(!mIsEmittingResourceReadySignal)