$(v8_plugin_dir)/constants/constants-wrapper.cpp \
$(v8_plugin_dir)/animation/animation-api.cpp \
$(v8_plugin_dir)/animation/animation-wrapper.cpp \
+ $(v8_plugin_dir)/animation/constrainer-api.cpp \
+ $(v8_plugin_dir)/animation/linear-constrainer-wrapper.cpp \
$(v8_plugin_dir)/animation/path-api.cpp \
- $(v8_plugin_dir)/animation/path-constraint-wrapper.cpp \
+ $(v8_plugin_dir)/animation/path-constrainer-wrapper.cpp \
$(v8_plugin_dir)/animation/path-wrapper.cpp \
$(v8_plugin_dir)/stage/stage-wrapper.cpp \
$(v8_plugin_dir)/events/event-object-generator.cpp \
// INTERNAL INCLUDES
#include <v8-utils.h>
#include <actors/actor-wrapper.h>
-#include <animation/path-constraint-wrapper.h>
+#include <animation/path-constrainer-wrapper.h>
namespace Dali
{
actor.ScaleBy( vector );
}
-void ActorApi::ApplyPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- //Get target actor
- Actor targetActor = GetActor( isolate, args );
-
- //Get PathConstraint
- bool found(false);
- Handle pathConstraintHandle = V8Utils::GetHandleParameter(PARAMETER_0, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (PathConstraint)" );
- return;
- }
- PathConstraint pathConstraint = PathConstraint::DownCast(pathConstraintHandle);
-
- //Get target property
- std::string propertyName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
- if(!found)
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 1 (Property name)" );
- return;
- }
-
- // try both properties with dashes and without
- Property::Index targetPropertyIndex = targetActor.GetPropertyIndex( propertyName );
- if( targetPropertyIndex == Property::INVALID_INDEX )
- {
- std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
- targetPropertyIndex = targetActor.GetPropertyIndex( convertedName );
-
- if( targetPropertyIndex == Property::INVALID_INDEX )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "Property not found" );
- }
- }
-
- //Get source actor
- Actor sourceActor = V8Utils::GetActorParameter( PARAMETER_2, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 2 (Actor)" );
- }
-
- // try both properties with dashes and without
- propertyName = V8Utils::GetStringParameter( PARAMETER_3, found, isolate, args );
- if(!found)
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 3 (Property name)" );
- return;
- }
-
- Property::Index sourcePropertyIndex = sourceActor.GetPropertyIndex( propertyName );
- if( sourcePropertyIndex == Property::INVALID_INDEX )
- {
- std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
- sourcePropertyIndex = sourceActor.GetPropertyIndex( convertedName );
-
- if( sourcePropertyIndex == Property::INVALID_INDEX )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "Property not found" );
- return;
- }
- }
-
- //Check if forward vector is specified
- Vector3 forward( 0.0f,0.0f,0.0f);
- if( args.Length() > 4 )
- {
- forward = V8Utils::GetVector3Parameter( PARAMETER_4, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 4 (Vector3)" );
- return;
- }
- }
-
- pathConstraint.Apply( Dali::Property(sourceActor,sourcePropertyIndex),
- Dali::Property(targetActor,targetPropertyIndex),
- forward );
-
-}
-
-void ActorApi::RemovePathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- //Get target actor
- Actor actor = GetActor( isolate, args );
-
- //Get PathConstraint
- bool found(false);
- Handle pathConstraintHandle = V8Utils::GetHandleParameter(PARAMETER_0, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (PathConstraint)" );
- return;
- }
- PathConstraint pathConstraint = PathConstraint::DownCast(pathConstraintHandle);
- pathConstraint.Remove(actor);
-}
-
} // namespace V8Plugin
} // namespace Dali
void RotateBy( const v8::FunctionCallbackInfo< v8::Value >& args );
void ScaleBy( const v8::FunctionCallbackInfo< v8::Value >& args );
- // new function just for JavaScript API, to apply a PathConstraint to an actor
- void ApplyPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args );
-
- // new function just for JavaScript API, to remove a PathConstraint from an actor
- void RemovePathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args );
-
// new function just for JavaScript API, to help developers know what type of actor
// they're dealing with, returns actor name as a string
void GetActorType( const v8::FunctionCallbackInfo< v8::Value >& args );
{ "FindChildById", ActorApi::FindChildById, ACTOR_API },
{ "GetParent" , ActorApi::GetParent, ACTOR_API },
{ "GetActorType" , ActorApi::GetActorType, ACTOR_API }, // custom for javascript
- { "ApplyPathConstraint", ActorApi::ApplyPathConstraint, ACTOR_API }, // custom for javascript
- { "RemovePathConstraint", ActorApi::RemovePathConstraint, ACTOR_API }, // custom for javascript
// ignore. SetParentOrigin() use Actor.parentOrigin
// ignore. GetCurrentParentOrigin() use Actor.parentOrigin
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// CLASS HEADER
+#include "constrainer-api.h"
+
+//EXTERNAL INCLUDES
+#include <cfloat> //For FLT_MAX
+
+// INTERNAL INCLUDES
+#include <animation/linear-constrainer-wrapper.h>
+#include <animation/path-constrainer-wrapper.h>
+#include <object/property-value-wrapper.h>
+#include <v8-utils.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace // un named namespace
+{
+
+PathConstrainer GetPathConstrainer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField( 0 ) );
+ void* ptr = field->Value();
+
+ PathConstrainerWrapper* wrapper = static_cast<PathConstrainerWrapper *>( ptr );
+ return wrapper->GetPathConstrainer();
+}
+
+LinearConstrainer GetLinearConstrainer( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField( 0 ) );
+ void* ptr = field->Value();
+
+ LinearConstrainerWrapper* wrapper = static_cast<LinearConstrainerWrapper *>( ptr );
+ return wrapper->GetLinearConstrainer();
+}
+
+bool GetApplyParameters( const v8::FunctionCallbackInfo< v8::Value >& args, Actor& targetActor, Property::Index& targetPropertyIndex,
+ Actor& sourceActor, Property::Index& sourcePropertyIndex, Vector2& range, Vector2& wrap )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ if( args[0]->IsObject() )
+ {
+ bool found(false);
+
+ v8::Local<v8::Object> obj = args[0]->ToObject();
+ v8::Local<v8::Value> member = obj->Get( v8::String::NewFromUtf8( isolate, "target" ) );
+
+ //Get target actor
+ if( member->IsObject() )
+ {
+ v8::Local<v8::Object> targetActorObject = member->ToObject();
+ targetActor = V8Utils::GetActorFromObject( isolate, found, targetActorObject );
+ if( !targetActor )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Target actor not found" );
+ return false;
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Target actor not specified" );
+ return false;
+ }
+
+ //Get source actor
+ member = obj->Get( v8::String::NewFromUtf8( isolate, "source" ) );
+ if( member->IsObject() )
+ {
+ v8::Local<v8::Object> sourceActorObject = member->ToObject();
+ sourceActor = V8Utils::GetActorFromObject( isolate, found, sourceActorObject );
+ if( !sourceActor )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Source actor not found" );
+ return false;
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Source actor not specified" );
+ return false;
+ }
+
+ //Get target property
+ member = obj->Get( v8::String::NewFromUtf8( isolate, "targetProperty" ) );
+ if( member->IsString() )
+ {
+ std::string propertyName = V8Utils::v8StringToStdString( member );
+ targetPropertyIndex = targetActor.GetPropertyIndex( propertyName );
+ if( targetPropertyIndex == Property::INVALID_INDEX )
+ {
+ std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
+ targetPropertyIndex = targetActor.GetPropertyIndex( convertedName );
+
+ if( targetPropertyIndex == Property::INVALID_INDEX )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Target property not found" );
+ return false;
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Target property not specified" );
+ return false;
+ }
+
+ //Get source property
+ member = obj->Get( v8::String::NewFromUtf8( isolate, "sourceProperty" ) );
+ if( member->IsString() )
+ {
+ std::string propertyName = V8Utils::v8StringToStdString( member );
+ sourcePropertyIndex = targetActor.GetPropertyIndex( propertyName );
+ if( sourcePropertyIndex == Property::INVALID_INDEX )
+ {
+ std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
+ sourcePropertyIndex = targetActor.GetPropertyIndex( convertedName );
+
+ if( sourcePropertyIndex == Property::INVALID_INDEX )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Source property not found" );
+ return false;
+ }
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Source property not specified" );
+ return false;
+ }
+
+ //Get range
+ member = obj->Get( v8::String::NewFromUtf8( isolate, "range" ) );
+ if( member->IsObject() )
+ {
+ v8::Local<v8::Object> rangeObject = member->ToObject();
+ Property::Value value = V8Utils::GetPropertyValueFromObject( found, isolate, rangeObject );
+ value.Get( range );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Range not specified" );
+ return false;
+ }
+
+ //Get wrap range
+ member = obj->Get( v8::String::NewFromUtf8( isolate, "wrap" ) );
+ if( member->IsObject() )
+ {
+ v8::Local<v8::Object> wrapObject = member->ToObject();
+ Property::Value value = V8Utils::GetPropertyValueFromObject( found, isolate, wrapObject );
+ value.Get( wrap );
+ }
+ else
+ {
+ wrap = Vector2(-FLT_MAX, FLT_MAX);
+ }
+
+ return true;
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "Bad parameter (Object)" );
+ return false;
+ }
+}
+
+} // un-named namespace
+
+/**
+ * Apply the constraint
+ * @method applyConstraint
+ * @for PathConstrainer and LinearConstrainer
+ * @param {Object} Constraint
+ * @param {Object} Constraint.targetActor
+ * @param {String} Constraint.targetProperty
+ * @param {String} Constraint.sourceProperty
+ * @param {Vector2} Constraint.range
+ * @param {Vector2} Constraint.wrap
+ *
+ * @example
+ *
+ * var constraintPosition = { "target":targetActor,
+ * "targetProperty":"position",
+ * "source":sourceActor,
+ * "sourceProperty":"color-alpha",
+ * "range":range
+ * "wrap":wrap
+ * };
+ * pathConstrainer.applyConstraint( constraintPosition );
+ */
+void ConstrainerApi::Apply( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Actor target, source;
+ Property::Index targetPropertyIndex = Property::INVALID_INDEX;
+ Property::Index sourcePropertyIndex = Property::INVALID_INDEX;
+
+ Vector2 range, wrap;
+ if( GetApplyParameters(args, target, targetPropertyIndex, source, sourcePropertyIndex, range, wrap ) )
+ {
+
+ PathConstrainer pathConstrainer = GetPathConstrainer( isolate, args );
+ if( pathConstrainer )
+ {
+ pathConstrainer.Apply( Property(target, targetPropertyIndex),
+ Property(source, sourcePropertyIndex),
+ range, wrap );
+ }
+ else
+ {
+ LinearConstrainer linearConstrainer = GetLinearConstrainer( isolate, args );
+ if( linearConstrainer )
+ {
+ linearConstrainer.Apply( Property(target, targetPropertyIndex),
+ Property(source, sourcePropertyIndex),
+ range, wrap );
+ }
+ }
+ }
+}
+
+/**
+ * Remove the constraint
+ * @method remove
+ * @for PathConstrainer
+ * @param {Object} Actor
+ * @example
+ * pathConstrainer.remove( targetActor );
+ */
+void ConstrainerApi::Remove( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ //Get target actor
+ bool found( false );
+ Actor targetActor = V8Utils::GetActorParameter( PARAMETER_0, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (Actor)" );
+ return;
+ }
+
+
+ PathConstrainer pathConstrainer = GetPathConstrainer( isolate, args );
+ if( pathConstrainer )
+ {
+ pathConstrainer.Remove(targetActor);
+ }
+ else
+ {
+ LinearConstrainer linearConstrainer = GetLinearConstrainer( isolate, args );
+ if( linearConstrainer )
+ {
+ linearConstrainer.Remove(targetActor);
+ }
+ }
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_CONSTRAINER_API_H__
+#define __DALI_V8PLUGIN_CONSTRAINER_API_H__
+
+/*
+ * Copyright (c) 2015 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 <v8.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace ConstrainerApi
+{
+ /**
+ * Constrainer API see constrainer.h for a description
+ */
+ void Apply( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void Remove( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace ConstrainerApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_PATH_CONSTRAINER_API_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// CLASS HEADER
+#include "linear-constrainer-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <animation/constrainer-api.h>
+#include <dali-wrapper.h>
+#include <shared/object-template-helper.h>
+#include <v8-utils.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace
+{
+
+const ApiFunction ConstrainerFunctions[]=
+{
+ { "ApplyConstraint", ConstrainerApi::Apply },
+ { "RemoveConstraint", ConstrainerApi::Remove }
+};
+const unsigned int ConstrainerFunctionTableCount = sizeof(ConstrainerFunctions)/sizeof(ConstrainerFunctions[0]);
+
+} //un-named space
+
+LinearConstrainerWrapper::LinearConstrainerWrapper( LinearConstrainer linearConstrainer, GarbageCollectorInterface& gc )
+:HandleWrapper( BaseWrappedObject::LINEAR_CONSTRAINER, linearConstrainer, gc ),
+ mLinearConstrainer( linearConstrainer )
+{
+}
+
+v8::Handle<v8::ObjectTemplate> LinearConstrainerWrapper::MakeLinearConstrainerTemplate( v8::Isolate* isolate )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+
+ v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+ objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, ConstrainerFunctions, ConstrainerFunctionTableCount );
+
+ // property handle intercepts property getters and setters and signals
+ HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+ return handleScope.Escape( objTemplate );
+}
+
+v8::Handle<v8::Object> LinearConstrainerWrapper::WrapLinearConstrainer( v8::Isolate* isolate, LinearConstrainer linearConstrainer )
+{
+ v8::EscapableHandleScope handleScope( isolate );
+ v8::Local<v8::ObjectTemplate> objectTemplate;
+
+ objectTemplate = MakeLinearConstrainerTemplate( isolate );
+
+ // create an instance of the template
+ v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+ // create the pathconstrainer object
+ LinearConstrainerWrapper* pointer = new LinearConstrainerWrapper( linearConstrainer, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+ // assign the JavaScript object to the wrapper.
+ // This also stores Dali object, in an internal field inside the JavaScript object.
+ pointer->SetJavascriptObject( isolate, localObject );
+
+ return handleScope.Escape( localObject );
+}
+
+LinearConstrainer LinearConstrainerWrapper::GetLinearConstrainer()
+{
+ return mLinearConstrainer;
+}
+
+/**
+ * Create an initialized PathConstrainer handle.
+ * @constructor
+ * @for PathConstrainer
+ * @method PathConstrainer
+ */
+void LinearConstrainerWrapper::NewLinearConstrainer( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ if( !args.IsConstructCall() )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
+ return;
+ }
+
+ LinearConstrainer linearConstrainer = LinearConstrainer::New();
+ v8::Local<v8::Object> localObject = WrapLinearConstrainer( isolate, linearConstrainer );
+ args.GetReturnValue().Set( localObject );
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_LINEAR_CONSTRAINER_WRAPPER_H__
+#define __DALI_V8PLUGIN_LINEAR_CONSTRAINER_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 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/public-api/animation/linear-constrainer.h>
+#include <v8.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * Wraps a LinearConstrainer.
+ */
+class LinearConstrainerWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * Constructor
+ */
+ LinearConstrainerWrapper( LinearConstrainer linearConstrainer, GarbageCollectorInterface& gc );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~LinearConstrainerWrapper(){};
+
+ /**
+ * Creates a new PathConstrainer wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewLinearConstrainer( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a PathConstrainer inside a Javascript object
+ */
+ static v8::Handle<v8::Object> WrapLinearConstrainer(v8::Isolate* isolate, LinearConstrainer pathConstrainer );
+
+ /*
+ * Get the wrapped PathConstrainer
+ */
+ LinearConstrainer GetLinearConstrainer();
+
+private:
+
+ /**
+ * Create a v8 object template for the PathConstrainer
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeLinearConstrainerTemplate( v8::Isolate* isolate );
+
+ Dali::LinearConstrainer mLinearConstrainer;
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header
*/
// CLASS HEADER
-#include "path-constraint-wrapper.h"
+#include "path-constrainer-wrapper.h"
// INTERNAL INCLUDES
-#include <v8-utils.h>
+#include <animation/constrainer-api.h>
#include <dali-wrapper.h>
#include <shared/object-template-helper.h>
+#include <v8-utils.h>
namespace Dali
{
namespace V8Plugin
{
-PathConstraintWrapper::PathConstraintWrapper( PathConstraint pathConstraint, GarbageCollectorInterface& gc )
-:HandleWrapper( BaseWrappedObject::PATH_CONSTRAINT, pathConstraint, gc ),
- mPathConstraint( pathConstraint )
+namespace
+{
+
+const ApiFunction ConstrainerFunctions[]=
+{
+ { "ApplyConstraint", ConstrainerApi::Apply },
+ { "RemoveConstraint", ConstrainerApi::Remove }
+};
+const unsigned int ConstrainerFunctionTableCount = sizeof(ConstrainerFunctions)/sizeof(ConstrainerFunctions[0]);
+
+} //un-named space
+
+PathConstrainerWrapper::PathConstrainerWrapper( PathConstrainer pathConstrainer, GarbageCollectorInterface& gc )
+:HandleWrapper( BaseWrappedObject::PATH_CONSTRAINER, pathConstrainer, gc ),
+ mPathConstrainer( pathConstrainer )
{
}
-v8::Handle<v8::ObjectTemplate> PathConstraintWrapper::MakePathConstraintTemplate( v8::Isolate* isolate )
+v8::Handle<v8::ObjectTemplate> PathConstrainerWrapper::MakePathConstrainerTemplate( v8::Isolate* isolate )
{
v8::EscapableHandleScope handleScope( isolate );
v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+ // add our function properties
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, ConstrainerFunctions, ConstrainerFunctionTableCount );
+
// property handle intercepts property getters and setters and signals
HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
return handleScope.Escape( objTemplate );
}
-v8::Handle<v8::Object> PathConstraintWrapper::WrapPathConstraint( v8::Isolate* isolate, PathConstraint pathConstraint )
+v8::Handle<v8::Object> PathConstrainerWrapper::WrapPathConstrainer( v8::Isolate* isolate, PathConstrainer pathConstrainer )
{
v8::EscapableHandleScope handleScope( isolate );
v8::Local<v8::ObjectTemplate> objectTemplate;
- objectTemplate = MakePathConstraintTemplate( isolate );
+ objectTemplate = MakePathConstrainerTemplate( isolate );
// create an instance of the template
v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
- // create the pathconstraint object
- PathConstraintWrapper* pointer = new PathConstraintWrapper( pathConstraint, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+ // create the pathconstrainer object
+ PathConstrainerWrapper* pointer = new PathConstrainerWrapper( pathConstrainer, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
// assign the JavaScript object to the wrapper.
// This also stores Dali object, in an internal field inside the JavaScript object.
return handleScope.Escape( localObject );
}
-PathConstraint PathConstraintWrapper::GetPathConstraint()
+PathConstrainer PathConstrainerWrapper::GetPathConstrainer()
{
- return mPathConstraint;
+ return mPathConstrainer;
}
/**
- * Create an initialized PathConstraint handle.
+ * Create an initialized PathConstrainer handle.
* @constructor
- * @for Path
- * @method Path
+ * @for PathConstrainer
+ * @method PathConstrainer
*/
-void PathConstraintWrapper::NewPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args)
+void PathConstrainerWrapper::NewPathConstrainer( const v8::FunctionCallbackInfo< v8::Value >& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
return;
}
- //Extract Path Handle
- bool parameterFound;
- Handle pathHandle = V8Utils::GetHandleParameter( PARAMETER_0, parameterFound, isolate, args );
- if( !parameterFound )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (Path)" );
- return;
- }
- Dali::Path path = Path::DownCast(pathHandle);
-
- //Extract range
- Vector2 range = V8Utils::GetVector2Parameter( PARAMETER_1, parameterFound, isolate, args );
- if( !parameterFound )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 1 (Range)" );
- return;
- }
-
- PathConstraint pathConstraint = PathConstraint::New(path, range );
- v8::Local<v8::Object> localObject = WrapPathConstraint( isolate, pathConstraint );
+ PathConstrainer pathConstrainer = PathConstrainer::New();
+ v8::Local<v8::Object> localObject = WrapPathConstrainer( isolate, pathConstrainer );
args.GetReturnValue().Set( localObject );
}
-
} // namespace V8Plugin
} // namespace Dali
-#ifndef __DALI_V8PLUGIN_PATH_CONSTRAINT_WRAPPER_H__
-#define __DALI_V8PLUGIN_PATH_CONSTRAINT_WRAPPER_H__
+#ifndef __DALI_V8PLUGIN_PATH_CONSTRAINER_WRAPPER_H__
+#define __DALI_V8PLUGIN_PATH_CONSTRAINER_WRAPPER_H__
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/animation/path-constrainer.h>
#include <v8.h>
-#include <dali/public-api/animation/path-constraint.h>
// INTERNAL INCLUDES
#include <object/handle-wrapper.h>
{
/**
- * Wraps a Path.
+ * Wraps a PathConstrainer.
*/
-class PathConstraintWrapper : public HandleWrapper
+class PathConstrainerWrapper : public HandleWrapper
{
public:
/**
* Constructor
*/
- PathConstraintWrapper( PathConstraint pathConstraint, GarbageCollectorInterface& gc );
+ PathConstrainerWrapper( PathConstrainer pathConstrainer, GarbageCollectorInterface& gc );
/**
* Virtual destructor
*/
- virtual ~PathConstraintWrapper(){};
+ virtual ~PathConstrainerWrapper(){};
/**
- * Creates a new PathConstraint wrapped inside a Javascript Object.
+ * Creates a new PathConstrainer wrapped inside a Javascript Object.
* @param[in] args v8 function call arguments interpreted
*/
- static void NewPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args);
+ static void NewPathConstrainer( const v8::FunctionCallbackInfo< v8::Value >& args);
/**
- * Wraps a PathConstraint inside a Javascript object
+ * Wraps a PathConstrainer inside a Javascript object
*/
- static v8::Handle<v8::Object> WrapPathConstraint(v8::Isolate* isolate, PathConstraint pathConstraint );
+ static v8::Handle<v8::Object> WrapPathConstrainer(v8::Isolate* isolate, PathConstrainer pathConstrainer );
/*
- * Get the wrapped PathConstraint
+ * Get the wrapped PathConstrainer
*/
- PathConstraint GetPathConstraint();
+ PathConstrainer GetPathConstrainer();
private:
/**
- * Create a v8 object template for the PathConstraint
+ * Create a v8 object template for the PathConstrainer
*/
- static v8::Handle<v8::ObjectTemplate> MakePathConstraintTemplate( v8::Isolate* isolate );
+ static v8::Handle<v8::ObjectTemplate> MakePathConstrainerTemplate( v8::Isolate* isolate );
- PathConstraint mPathConstraint;
+ Dali::PathConstrainer mPathConstrainer;
};
} // namespace V8Plugin
#include <actors/actor-wrapper.h>
#include <stage/stage-wrapper.h>
#include <image/image-wrapper.h>
+#include <animation/linear-constrainer-wrapper.h>
+#include <animation/path-constrainer-wrapper.h>
#include <animation/path-wrapper.h>
-#include <animation/path-constraint-wrapper.h>
#include <animation/animation-wrapper.h>
#include <events/pan-gesture-detector-wrapper.h>
#include <shader-effects/shader-effect-wrapper.h>
{ "Rotation", PropertyValueWrapper::NewRotation},
{ "Matrix", PropertyValueWrapper::NewMatrix},
{ "Path", PathWrapper::NewPath },
- { "PathConstraint", PathConstraintWrapper::NewPathConstraint },
+ { "PathConstrainer", PathConstrainerWrapper::NewPathConstrainer},
+ { "LinearConstrainer", LinearConstrainerWrapper::NewLinearConstrainer},
{ "Actor", ActorWrapper::NewActor },
{ "TextActor", ActorWrapper::NewActor },
{ "ImageActor", ActorWrapper::NewActor },
CONNECTION,
ANIMATION,
PATH,
- PATH_CONSTRAINT,
+ PATH_CONSTRAINER,
+ LINEAR_CONSTRAINER,
BUILDER,
STAGE,
FONT,