X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Factors%2Factor-api.cpp;h=926c5cd4d50288366437f3d619eb21af12972ab7;hp=4027a1bf11f4c63552da5c02e29fd727a8a67a57;hb=d04c5bdbb95cc98f90848c7a98b0b2804df6e5b8;hpb=6b7d48695715c6f2292338fccbeeb02873d1f89d diff --git a/plugins/dali-script-v8/src/actors/actor-api.cpp b/plugins/dali-script-v8/src/actors/actor-api.cpp index 4027a1b..926c5cd 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.cpp +++ b/plugins/dali-script-v8/src/actors/actor-api.cpp @@ -19,11 +19,12 @@ #include "actor-api.h" // EXTERNAL INCLUDES -#include +#include // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -41,11 +42,11 @@ Actor GetActor( v8::Isolate* isolate, const v8::FunctionCallbackInfo& } //unanmed namespace -namespace TextViewApi +namespace TextLabelApi { Actor New( const v8::FunctionCallbackInfo< v8::Value >& args ) { - return Dali::Toolkit::TextView::New(); + return Dali::Toolkit::TextLabel::New(); } } @@ -485,7 +486,7 @@ void ActorApi::IsKeyboardFocusable( const v8::FunctionCallbackInfo& a * * @for Actor * @method getActorType - * @return {String} Actor, ImageActor, TextActor, MeshActor, Layer, CameraActor ... + * @return {String} Actor, ImageActor, MeshActor, Layer, CameraActor ... */ void ActorApi::GetActorType( const v8::FunctionCallbackInfo& args ) { @@ -557,7 +558,7 @@ void ActorApi::RotateBy( const v8::FunctionCallbackInfo& args ) bool found( false ); Property::Value rotation = V8Utils::GetPropertyValueParameter( PARAMETER_0, found, isolate, args ); - if( rotation.GetType() != Property::ORIENTATION ) + if( rotation.GetType() != Property::ROTATION ) { DALI_SCRIPT_EXCEPTION( isolate, "Rotation parameter missing" ); return; @@ -609,6 +610,111 @@ void ActorApi::ScaleBy( const v8::FunctionCallbackInfo& args ) 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