+// Delay a pathConstrainer apply
+struct DelayedConstrainerApply
+{
+ std::string constrainerName;
+
+ std::vector<std::string> targetActorNames;
+ std::vector<std::string> sourceActorNames;
+ std::vector<std::string> targetPropertyNames;
+ std::vector<std::string> sourcePropertyNames;
+ std::vector<Vector2> ranges;
+ std::vector<Vector2> wrapRanges;
+
+ Dali::IntrusivePtr<Dali::Toolkit::Internal::Builder> builder;
+
+ /*
+ * Helper function to get the parameters to apply each constraint
+ * @param[in] i i-essim element
+ * @param[out] tagetActor Target actor for the constraint
+ * @param[out] tagetPropertyIndex Target property index for the constraint
+ * @param[out] sourceActor Source actor for the constraint
+ * @param[out] sourcePropertyIndex Source property index for the constraint
+ */
+ bool GetApplyParameters(size_t i,
+ Actor& targetActor,
+ Property::Index& targetPropertyIndex,
+ Actor& sourceActor,
+ Property::Index& sourcePropertyIndex)
+ {
+ targetActor = Stage::GetCurrent().GetRootLayer().FindChildByName(targetActorNames[i]);
+ targetPropertyIndex = Property::INVALID_INDEX;
+ if(targetActor)
+ {
+ targetPropertyIndex = targetActor.GetPropertyIndex(targetPropertyNames[i]);
+ if(targetPropertyIndex == Property::INVALID_INDEX)
+ {
+ DALI_SCRIPT_WARNING("Property '%s' not founded in actor '%s'\n", targetPropertyNames[i].c_str(), targetActorNames[i].c_str());
+ return false;
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Actor '%s' not founded\n", targetActorNames[i].c_str());
+ return false;
+ }
+
+ sourceActor = Stage::GetCurrent().GetRootLayer().FindChildByName(sourceActorNames[i]);
+ sourcePropertyIndex = Property::INVALID_INDEX;
+ if(sourceActor)
+ {
+ sourcePropertyIndex = sourceActor.GetPropertyIndex(sourcePropertyNames[i]);
+ if(sourcePropertyIndex == Property::INVALID_INDEX)
+ {
+ DALI_SCRIPT_WARNING("Property '%s' not founded in actor '%s'\n", sourcePropertyNames[i].c_str(), sourceActorNames[i].c_str());
+ return false;
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Actor '%s' not founded\n", targetActorNames[i].c_str());
+ return false;
+ }
+ return true;
+ }
+
+ void operator()(void)
+ {
+ Actor sourceActor, targetActor;
+ Property::Index targetPropertyIndex(Property::INVALID_INDEX);
+ Property::Index sourcePropertyIndex(Property::INVALID_INDEX);
+ size_t actorCount(targetActorNames.size());
+ if(builder.Get()->IsPathConstrainer(constrainerName))
+ {
+ PathConstrainer constrainer = builder.Get()->GetPathConstrainer(constrainerName);
+ if(constrainer)
+ {
+ for(size_t i(0); i < actorCount; ++i)
+ {
+ if(GetApplyParameters(i, targetActor, targetPropertyIndex, sourceActor, sourcePropertyIndex))
+ {
+ constrainer.Apply(Property(targetActor, targetPropertyIndex),
+ Property(sourceActor, sourcePropertyIndex),
+ ranges[i],
+ wrapRanges[i]);
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s not found\n", constrainerName.c_str());
+ }
+ }
+ else if(builder.Get()->IsLinearConstrainer(constrainerName))
+ {
+ Dali::LinearConstrainer constrainer(builder.Get()->GetLinearConstrainer(constrainerName));
+ if(constrainer)
+ {
+ for(size_t i(0); i < actorCount; ++i)
+ {
+ if(GetApplyParameters(i, targetActor, targetPropertyIndex, sourceActor, sourcePropertyIndex))
+ {
+ constrainer.Apply(Property(targetActor, targetPropertyIndex),
+ Property(sourceActor, sourcePropertyIndex),
+ ranges[i],
+ wrapRanges[i]);
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s not found\n", constrainerName.c_str());
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s is not of a valid type\n", constrainerName.c_str());
+ }
+ }
+};
+
+// Delay a pathConstrainer remove
+struct DelayedConstrainerRemove
+{
+ std::string constrainerName;
+ std::vector<std::string> targetActorNames;
+ Dali::IntrusivePtr<Dali::Toolkit::Internal::Builder> builder;
+
+ void operator()(void)
+ {
+ size_t actorCount(targetActorNames.size());
+ if(builder.Get()->IsPathConstrainer(constrainerName))
+ {
+ PathConstrainer constrainer = builder.Get()->GetPathConstrainer(constrainerName);
+ if(constrainer)
+ {
+ for(size_t i(0); i < actorCount; ++i)
+ {
+ Actor targetActor = Stage::GetCurrent().GetRootLayer().FindChildByName(targetActorNames[i]);
+ if(targetActor)
+ {
+ constrainer.Remove(targetActor);
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s not found\n", constrainerName.c_str());
+ }
+ }
+ else if(builder.Get()->IsLinearConstrainer(constrainerName))
+ {
+ LinearConstrainer constrainer = builder.Get()->GetLinearConstrainer(constrainerName);
+ if(constrainer)
+ {
+ for(size_t i(0); i < actorCount; ++i)
+ {
+ Actor targetActor = Stage::GetCurrent().GetRootLayer().FindChildByName(targetActorNames[i]);
+ if(targetActor)
+ {
+ constrainer.Remove(targetActor);
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s not found\n", constrainerName.c_str());
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer %s is not of a valid type\n", constrainerName.c_str());
+ }
+ }
+};
+