// EXTERNAL INCLUDES
#include <sys/stat.h>
-#include <boost/function.hpp>
#include <sstream>
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/public-api/object/type-info.h>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/camera-actor.h>
#include <dali/devel-api/scripting/scripting.h>
+#include <dali/public-api/signals/functor-delegate.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value, const Replacement& replacements );
extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value );
extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, const Replacement& replacements );
-extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder);
-extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder);
+extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder);
+extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder);
extern Actor SetupActor( const TreeNode& node, Actor& actor, const Replacement& constant );
#if defined(DEBUG_ENABLED)
}
}
-struct QuitAction
-{
-public:
- QuitAction( Builder& builder )
- : mBuilder( builder )
- {
- }
-
- void operator()(void)
- {
- mBuilder.EmitQuitSignal();
- }
-
-private:
- Builder& mBuilder;
-};
} // namespace anon
SetupActor( node, actor, constant );
// add signals
- QuitAction quitAction( *this );
- SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, quitAction, this );
- SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, quitAction, this );
+ SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, this );
+ SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, this );
}
}
else
*/
// EXTERNAL INCLUDES
-#include <boost/function.hpp>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/type-info.h>
#include <dali/public-api/object/property-notification.h>
+
#include <dali/integration-api/debug.h>
#include <limits>
};
};
+struct QuitAction
+{
+ Dali::IntrusivePtr<Dali::Toolkit::Internal::Builder> builder;
+
+ void operator()(void)
+ {
+ builder->EmitQuitSignal();
+ }
+};
+
// Delay an animation play; ie wait as its not on stage yet
struct DelayedAnimationPlay
{
}
}
-void DoNothing(void) {};
+// Shim for the property notifcation signal
+template <typename T>
+struct PropertyNotifcationSignalShim
+{
+ T mFunctor;
+
+ PropertyNotifcationSignalShim(T& functor) : mFunctor(functor) {}
+
+ void operator()(PropertyNotification& /* source */)
+ {
+ mFunctor();
+ }
+};
+
+// Specializations for the different signal connection calls between actor & PropertyNotification
+template <typename T>
+struct SignalConnector {};
+
+// Actor specialization
+template <>
+struct SignalConnector<Actor> {
+ Actor& mActor;
+ ConnectionTracker* mTracker;
+ const std::string& mName;
+
+ SignalConnector<Actor>(ConnectionTracker* tracker, Actor& actor, const std::string& name)
+ : mActor(actor), mTracker(tracker), mName(name) {}
+
+ template <typename T>
+ void Connect(T& functor)
+ {
+ mActor.ConnectSignal( mTracker, mName, functor);
+ }
+};
+
+// PropertyNotification specialization
+template <>
+struct SignalConnector<PropertyNotification>
+{
+ PropertyNotification& mNotification;
+ ConnectionTracker* mTracker;
+
+ SignalConnector<PropertyNotification>(ConnectionTracker* tracker, PropertyNotification ¬ification)
+ : mNotification(notification), mTracker(tracker) {}
+
+ template <typename T>
+ void Connect(T& functor)
+ {
+ mNotification.NotifySignal().Connect( mTracker, PropertyNotifcationSignalShim<T>(functor) );
+ }
+};
/**
- * Get an action as boost function callback
+ * Set an action functor on a signal
*/
-boost::function<void (void)> GetAction(const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder)
+template <typename T>
+void SetActionOnSignal(const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder, SignalConnector<T>& connector)
{
OptionalString childActorName(IsString( IsChild(&child, "child-actor")) );
OptionalString actorName(IsString( IsChild(&child, "actor")) );
OptionalString actionName = IsString( IsChild(&child, "action") );
DALI_ASSERT_ALWAYS(actionName && "Signal must have an action");
- boost::function<void(void)> callback = DoNothing;
-
if(childActorName)
{
ChildActorAction action;
action.childName = *childActorName;
action.actionName = *actionName;
GetParameters(child, action.parameters);
- callback = action;
+ connector.Connect( action );
}
else if(actorName)
{
{
DALI_SCRIPT_WARNING("Cannot set property for set property action\n");
}
- callback = action;
+ connector.Connect( action );
}
else
{
action.actorName = *actorName;
action.actionName = *actionName;
GetParameters(child, action.parameters);
- callback = action;
+ connector.Connect( action );
}
}
else if("quit" == *actionName)
{
- callback = quitAction;
+ QuitAction action;
+ action.builder = builder;
+ connector.Connect( action );
}
else if("play" == *actionName)
{
action.animNode = animNode;
action.builder = builder;
// @todo; put constants into the map
- callback = action;
+ connector.Connect( action );
}
else
{
action.ranges.push_back(*range);
action.wrapRanges.push_back(wrap);
}
-
- callback = action;
+ connector.Connect(action);
}
}
-
-
}
else if("removeConstraints" == *actionName )
{
}
}
}
- callback = action;
+ connector.Connect(action);
}
}
else
action.actorName = actor.GetName();
action.actionName = *actionName;
GetParameters(child, action.parameters);
- callback = action;
+ connector.Connect( action );
}
-
- return callback;
}
/**
* Setup signals and actions on an actor
*/
-Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder )
+Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder )
{
DALI_ASSERT_ALWAYS(actor);
OptionalString name( IsString( IsChild( key_child.second, "name")) );
DALI_ASSERT_ALWAYS(name && "Signal must have a name");
- boost::function<void (void)> callback = GetAction(root, key_child.second, actor, quitAction, builder );
-
- actor.ConnectSignal(tracker, *name, callback);
+ SignalConnector<Actor> connector(tracker, actor, *name);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
}
/**
* Setup Property notifications for an actor
*/
-Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder )
+Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder )
{
DALI_ASSERT_ALWAYS(actor);
{
const TreeNode::KeyNodePair& key_child = *iter;
- // Actor actions reference by pointer because of circular reference actor->signal
- // So this callback should only go onto the actor maintained list.
- boost::function<void (void)> callback = GetAction(root, key_child.second, actor, quitAction, builder );
-
OptionalString prop(IsString( IsChild(key_child.second, "property")) );
DALI_ASSERT_ALWAYS(prop && "Notification signal must specify a property");
{
PropertyNotification notification = actor.AddPropertyNotification( actor.GetPropertyIndex(*prop),
LessThanCondition(1.f) );
- notification.NotifySignal().Connect( tracker, FunctorDelegate::New(callback) );
+ SignalConnector<PropertyNotification> connector(tracker, notification);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
else if("LessThan" == *cond)
{
PropertyNotification notification = actor.AddPropertyNotification( actor.GetPropertyIndex(*prop),
LessThanCondition(GetConditionArg0(key_child.second)) );
- notification.NotifySignal().Connect( tracker, FunctorDelegate::New(callback) );
+ SignalConnector<PropertyNotification> connector(tracker, notification);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
else if("GreaterThan" == *cond)
{
PropertyNotification notification = actor.AddPropertyNotification( actor.GetPropertyIndex(*prop),
GreaterThanCondition(GetConditionArg0(key_child.second)) );
- notification.NotifySignal().Connect( tracker, FunctorDelegate::New(callback) );
+ SignalConnector<PropertyNotification> connector(tracker, notification);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
else if("Inside" == *cond)
{
PropertyNotification notification = actor.AddPropertyNotification( actor.GetPropertyIndex(*prop),
InsideCondition(GetConditionArg0(key_child.second),
GetConditionArg1(key_child.second)) );
- notification.NotifySignal().Connect( tracker, FunctorDelegate::New(callback) );
+ SignalConnector<PropertyNotification> connector(tracker, notification);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
else if("Outside" == *cond)
{
PropertyNotification notification = actor.AddPropertyNotification( actor.GetPropertyIndex(*prop),
OutsideCondition(GetConditionArg0(key_child.second),
GetConditionArg1(key_child.second)) );
- notification.NotifySignal().Connect( tracker, FunctorDelegate::New(callback) );
+ SignalConnector<PropertyNotification> connector(tracker, notification);
+ SetActionOnSignal(root, key_child.second, actor, builder, connector);
}
else
{