-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <boost/function.hpp>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/builder/builder-impl.h>
{
namespace Internal
{
-extern Animation CreateAnimation( const TreeNode& child );
+extern Animation CreateAnimation( const TreeNode& child, Dali::Toolkit::Internal::Builder* const builder );
extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value );
}
}
// Signal Actions
//
-// Action quit; connected to signals
-// TODO: MOVE TO BUILDER TEMPLATE
-struct ActionQuit
-{
- ActionQuit(void) {};
-
- void operator()(void) {
- // Dali::Application::Get().Quit();
- };
-};
-
// Action on child actor. The child is found by alias so can be 'previous' etc.
struct ChildActorAction
{
std::string actorName;
std::string actionName;
std::string childAlias;
- std::vector<Property::Value> parameters;
+ PropertyValueContainer parameters;
void operator()(void)
{
if( idx != Property::INVALID_INDEX )
{
- actor.SetProperty( idx, value );
+ if( actor.GetPropertyType(idx) != value.GetType() )
+ {
+ DALI_SCRIPT_WARNING("Set property action has different type for property '%s'\n", propertyName.c_str());
+ }
+ else
+ {
+ actor.SetProperty( idx, value );
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Set property action cannot find property '%s'\n", propertyName.c_str());
}
}
};
{
std::string actorName;
std::string actionName;
- std::vector<Property::Value> parameters;
+ PropertyValueContainer parameters;
void operator()(void)
{
// Delay an animation play; ie wait as its not on stage yet
struct DelayedAnimationPlay
{
- Toolkit::JsonParser memento;
+ OptionalChild animNode;
+ Dali::IntrusivePtr<Dali::Toolkit::Internal::Builder> builder;
void operator()(void)
{
- Animation anim = Toolkit::Internal::CreateAnimation(*memento.GetRoot());
+ Animation anim = Toolkit::Internal::CreateAnimation(*animNode, builder.Get() );
if(anim)
{
anim.Play();
* Gets Parmeter list from child
* params is be cleared before insertion
*/
-void GetParameters(const TreeNode &child, std::vector<Property::Value> ¶ms)
+void GetParameters(const TreeNode& child, PropertyValueContainer& params)
{
if( OptionalChild c = IsChild(child, "parameters") )
{
/**
* Get an action as boost function callback
*/
-boost::function<void (void)> GetAction(const TreeNode &root, const TreeNode &child, Actor actor)
+boost::function<void (void)> GetAction(const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder)
{
OptionalString childActorName(IsString( IsChild(&child, "child-actor")) );
OptionalString actorName(IsString( IsChild(&child, "actor")) );
OptionalString propertyName(IsString( IsChild(&child, "property")) );
- OptionalString valueChild(IsString( IsChild(&child, "value")) );
+ OptionalChild valueChild( IsChild(&child, "value") );
OptionalString actionName = IsString( IsChild(&child, "action") );
DALI_ASSERT_ALWAYS(actionName && "Signal must have an action");
}
else if(actorName)
{
- if(propertyName && valueChild)
+ if(propertyName && valueChild && ("set" == *actionName) )
{
PropertySetAction action;
action.actorName = *actorName;
action.propertyName = *propertyName;
+ // actor may not exist yet so we can't check the property type
+ if( !Dali::Toolkit::Internal::SetPropertyFromNode( *valueChild, action.value ) )
+ {
+ DALI_SCRIPT_WARNING("Cannot set property for set property action\n");
+ }
callback = action;
}
else
}
else if("quit" == *actionName)
{
- callback = ActionQuit();
+ callback = quitAction;
}
else if("play" == *actionName)
{
if( OptionalChild animNode = IsChild(*animations, *animationName) )
{
DelayedAnimationPlay action;
- action.memento = Toolkit::JsonParser::New(*animNode);
+ action.animNode = animNode;
+ action.builder = builder;
+ // @todo; put constants into the map
callback = action;
}
else
{
f = IsFloat( IsChild(child, "min") );
}
+
DALI_ASSERT_ALWAYS(f && "Notification condition for arg0 not specified");
- if(f)
- {
- return *f;
- }
- else
- {
- return 0.f;
- }
+
+ return *f;
}
/**
{
f = IsFloat( IsChild(child, "max") );
}
+
DALI_ASSERT_ALWAYS(f && "Notification condition for arg1 not specified");
- if(f)
- {
- return *f;
- }
- else
- {
- return 0.f;
- }
+
+ return *f;
}
namespace Internal
{
-Actor SetupSignalAction(const TreeNode &child, Actor actor);
-Actor SetupPropertyNotification(const TreeNode &child, Actor actor);
+Actor SetupSignalAction(const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder );
+Actor SetupPropertyNotification(const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder );
/**
* Setup signals and actions on an actor
*/
-Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor)
+Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, 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);
+ boost::function<void (void)> callback = GetAction(root, key_child.second, actor, quitAction, builder );
actor.ConnectSignal(tracker, *name, callback);
}
/**
* Setup Property notifications for an actor
*/
-Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor)
+Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, boost::function<void (void)> quitAction, Dali::Toolkit::Internal::Builder* const builder )
{
DALI_ASSERT_ALWAYS(actor);
// 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);
+ 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");