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-wrapper.cpp;h=7b9b1588f7a7f3b9472346921543c5a83443379b;hp=704c2d1feafe1c49297da94b33f8be8130b53df4;hb=9c6ea1aa6babb4e6e1c59187cad13b44e0639662;hpb=68398f4bf6958cd60f12b930e240d0d75e9e7d29 diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index 704c2d1..7b9b158 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -39,7 +39,6 @@ v8::Persistent ActorWrapper::mActorTemplate; v8::Persistent ActorWrapper::mImageActorTemplate; v8::Persistent ActorWrapper::mCameraActorTemplate; v8::Persistent ActorWrapper::mLayerActorTemplate; -v8::Persistent ActorWrapper::mTextLabelTemplate; namespace { @@ -61,8 +60,7 @@ const ActorTemplate ActorTemplateLookup[]= { &ActorWrapper::mActorTemplate }, // ACTOR { &ActorWrapper::mImageActorTemplate }, // IMAGE_ACTOR { &ActorWrapper::mLayerActorTemplate }, // LAYER_ACTOR - { &ActorWrapper::mCameraActorTemplate}, // CAMERA_ACTOR - { &ActorWrapper::mTextLabelTemplate } + { &ActorWrapper::mCameraActorTemplate} // CAMERA_ACTOR }; /** @@ -89,6 +87,7 @@ struct ActorApiStruct /** * Lookup table to match a actor type with a constructor and supported API's. + * HandleWrapper::ActorType is used to index this table */ const ActorApiStruct ActorApiLookup[]= { @@ -96,8 +95,6 @@ const ActorApiStruct ActorApiLookup[]= {"ImageActor", ActorWrapper::IMAGE_ACTOR, ImageActorApi::New, ACTOR_API | IMAGE_ACTOR_API }, {"Layer", ActorWrapper::LAYER_ACTOR, LayerApi::New, ACTOR_API | LAYER_API }, {"CameraActor",ActorWrapper::CAMERA_ACTOR, CameraActorApi::New, ACTOR_API | CAMERA_ACTOR_API }, - {"TextLabel", ActorWrapper::TEXT_LABEL, TextLabelApi::New, ACTOR_API }, - }; const unsigned int ActorApiLookupCount = sizeof(ActorApiLookup)/sizeof(ActorApiLookup[0]); @@ -118,20 +115,8 @@ Actor CreateActor( const v8::FunctionCallbackInfo< v8::Value >& args, // if we don't currently support the actor type, then use type registry to create it if( actorType == ActorWrapper::UNKNOWN_ACTOR ) { - Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName ); - if( typeInfo ) // handle, check if it has a value - { - Dali::BaseHandle handle = typeInfo.CreateInstance(); - if( handle ) - { - actor = Actor::DownCast( handle ); - } - } - else - { - DALI_SCRIPT_EXCEPTION(args.GetIsolate(),"Unknown actor type"); + DALI_SCRIPT_EXCEPTION( args.GetIsolate(), "Unknown actor type" ); return Actor(); - } } else { @@ -440,6 +425,42 @@ void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args) args.GetReturnValue().Set( localObject ); } +void ActorWrapper::NewControl( 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; + } + + bool found( false ); + std::string controlName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); + + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "missing control name" ); + return; + } + Actor control; + Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( controlName ); + if( typeInfo ) // handle, check if it has a value + { + Dali::BaseHandle handle = typeInfo.CreateInstance(); + if( handle ) + { + control = Actor::DownCast( handle ); + } + } + + v8::Local localObject = WrapActor( isolate, control, ACTOR ); + + args.GetReturnValue().Set( localObject ); +} + + /** * given an actor type name, e.g. ImageActor returns the type, e.g. ActorWrapper::IMAGE_ACTOR */