X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Factors%2Factor-wrapper.cpp;h=a1c0f78f202249eef745c9bdfc6aa9a78775caff;hb=62f4bf2995acd0c3a386975f4c38f95cbdd507e3;hp=7b9b1588f7a7f3b9472346921543c5a83443379b;hpb=a63af0b21a2d5712352d5fa7b52f828c27a05867;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index 7b9b158..a1c0f78 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -20,11 +20,11 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include #include -#include #include #include #include @@ -36,7 +36,6 @@ namespace V8Plugin { v8::Persistent ActorWrapper::mActorTemplate; -v8::Persistent ActorWrapper::mImageActorTemplate; v8::Persistent ActorWrapper::mCameraActorTemplate; v8::Persistent ActorWrapper::mLayerActorTemplate; @@ -58,7 +57,6 @@ struct ActorTemplate const ActorTemplate ActorTemplateLookup[]= { { &ActorWrapper::mActorTemplate }, // ACTOR - { &ActorWrapper::mImageActorTemplate }, // IMAGE_ACTOR { &ActorWrapper::mLayerActorTemplate }, // LAYER_ACTOR { &ActorWrapper::mCameraActorTemplate} // CAMERA_ACTOR }; @@ -69,9 +67,8 @@ const ActorTemplate ActorTemplateLookup[]= enum ActorApiBitMask { ACTOR_API = 1 << 0, - IMAGE_ACTOR_API = 1 << 1, - LAYER_API = 1 << 2, - CAMERA_ACTOR_API = 1 << 3, + LAYER_API = 1 << 1, + CAMERA_ACTOR_API = 1 << 2, }; /** @@ -87,12 +84,11 @@ struct ActorApiStruct /** * Lookup table to match a actor type with a constructor and supported API's. - * HandleWrapper::ActorType is used to index this table + * ActorWrapper::ActorType is used to index this table */ const ActorApiStruct ActorApiLookup[]= { {"Actor", ActorWrapper::ACTOR, ActorApi::New, ACTOR_API }, - {"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 }, }; @@ -121,7 +117,7 @@ Actor CreateActor( const v8::FunctionCallbackInfo< v8::Value >& args, else { // run the constructor for this type of actor so it can pull out - // custom parameters, e.g. new ImageActor( MyImage ); + // custom parameters; actor = (ActorApiLookup[actorType].constructor)( args ); } return actor; @@ -182,6 +178,9 @@ const ActorFunctions ActorFunctionTable[]= // ignore. GetCurrentAnchorPoint() use Actor.anchorPoint // ignore. SetSize() use Actor.size // ignore. GetCurrentSize() use Actor.size + { "GetNaturalSize", ActorApi::GetNaturalSize, ACTOR_API }, + { "GetWidthForHeight",ActorApi::GetWidthForHeight, ACTOR_API }, + { "GetHeightForWidth",ActorApi::GetHeightForWidth, ACTOR_API }, // ignore. SetPosition(....) use Actor.position // ignore. SetX, SetY, SetZ, use Actor.position.x, Actor.position.y, Actor.position.z { "TranslateBy", ActorApi::TranslateBy, ACTOR_API }, @@ -211,8 +210,6 @@ const ActorFunctions ActorFunctionTable[]= // ignore SetColorMode() use Actor.colorMode // ignore GetColorMode() use Actor.colorMode // ignore GetCurrentWorldColor() use Actor.worldColor - // ignore SetInheritShaderEffect() use Actor.inheritShaderEffect - // ignore GetInheritShaderEffect() use Actor.inheritShaderEffect // ignore SetDrawMode() use Actor.drawMode // ignore GetDrawMode() use Actor.drawMode // ignore SetSensitive() use Actor.sensitve @@ -223,6 +220,11 @@ const ActorFunctions ActorFunctionTable[]= { "SetKeyboardFocusable", ActorApi::SetKeyboardFocusable, ACTOR_API }, //-- should this be a property??? { "IsKeyboardFocusable" , ActorApi::IsKeyboardFocusable, ACTOR_API }, //-- should this be a property??? + { "AddRenderer", ActorApi::AddRenderer, ACTOR_API }, + { "GetRendererCount", ActorApi::GetRendererCount, ACTOR_API }, + { "GetRendererAt" , ActorApi::GetRendererAt, ACTOR_API }, + { "RemoveRenderer" , ActorApi::RemoveRenderer, ACTOR_API }, + /************************************** * Layer API (in order of layer.h) **************************************/ @@ -230,9 +232,9 @@ const ActorFunctions ActorFunctionTable[]= { "Raise", LayerApi::Raise, LAYER_API }, { "Lower", LayerApi::Lower, LAYER_API }, { "RaiseAbove", LayerApi::RaiseAbove, LAYER_API }, - { "RaiseBelow", LayerApi::LowerBelow, LAYER_API }, + { "LowerBelow", LayerApi::LowerBelow, LAYER_API }, { "RaiseToTop", LayerApi::RaiseToTop, LAYER_API }, - { "LowerToBottom", LayerApi::ToBottom, LAYER_API }, + { "LowerToBottom", LayerApi::LowerToBottom, LAYER_API }, { "MoveAbove", LayerApi::MoveAbove, LAYER_API }, { "MoveBelow", LayerApi::MoveBelow, LAYER_API }, // ignore SetClipping, use layer.clippingEnable @@ -243,44 +245,6 @@ const ActorFunctions ActorFunctionTable[]= // @todo SetSortFunction /************************************** - * Image Actor API (in order of image-actor.h) - **************************************/ - - { "SetImage", ImageActorApi::SetImage, IMAGE_ACTOR_API }, - { "GetImage", ImageActorApi::GetImage, IMAGE_ACTOR_API }, - // ignore SetPixelArea, use imageActor.pixelArea - // ignore GetPixelArea, use imageActor.pixelArea - // ignore SetStyle, use imageActor.style - // ignore GetStyle, use imageActor.style - // ignore SetNinePatchBorder use imageActor.border - // ignore GetNinePatchBorder use imageActor.border - { "SetSortModifier", ImageActorApi::SetSortModifier, IMAGE_ACTOR_API }, - { "GetSortModifier", ImageActorApi::GetSortModifier, IMAGE_ACTOR_API }, - { "SetCullFace", ImageActorApi::SetCullFace, IMAGE_ACTOR_API }, - { "GetCullFace", ImageActorApi::GetCullFace, IMAGE_ACTOR_API }, - { "SetBlendMode", ImageActorApi::SetBlendMode, IMAGE_ACTOR_API }, - { "GetBlendMode", ImageActorApi::GetBlendMode, IMAGE_ACTOR_API }, - { "SetBlendFunc", ImageActorApi::SetBlendFunc, IMAGE_ACTOR_API }, - { "GetBlendFunc", ImageActorApi::GetBlendFunc, IMAGE_ACTOR_API }, - { "SetShaderEffect", ImageActorApi::SetShaderEffect, IMAGE_ACTOR_API }, - { "GetShaderEffect", ImageActorApi::GetShaderEffect, IMAGE_ACTOR_API }, - { "RemoveShaderEffect", ImageActorApi::RemoveShaderEffect,IMAGE_ACTOR_API }, - // ignore SetFadeIn use imageActor.fadeIn - // ignore GetFadeIn use imageActor.fadeIn - // ignore SetFadeInDuration use imageActor.fadeInDuration - // ignore GetFadeInDuration use imageActor.fadeInDuration - //{ "GetCurrentImageSize", ImageActorApi::GetCurrentImageSize, IMAGE_ACTOR_API }, - - /************************************** - * Mesh Actor API (in order of mesh-actor.h) - **************************************/ - // @todo a version of MeshActor::New( mesh ) - // @todo a version of MeshActor::New( AnimatableMesh ) - // @todo SetMaterial - // @todo GetMaterial - // @todo BindBonesToMesh - - /************************************** * Camera Actor API (in order of camera.h) **************************************/ // ignore SetType use camera.type @@ -318,7 +282,10 @@ ActorWrapper::ActorWrapper( Actor actor, v8::Handle ActorWrapper::WrapActor(v8::Isolate* isolate, Actor actor ) { v8::EscapableHandleScope handleScope( isolate ); - v8::Local object = WrapActor( isolate, actor, GetActorType( actor.GetTypeName() ) ); + + // Check whether the actor is a Control + ActorWrapper::ActorType type = Toolkit::Control::DownCast(actor) ? ACTOR : GetActorType( actor.GetTypeName() ); + v8::Local object = WrapActor( isolate, actor, type ); return handleScope.Escape( object ); } @@ -338,7 +305,7 @@ v8::Handle ActorWrapper::WrapActor( v8::Isolate* isolate, Actor acto // create an instance of the template v8::Local localObject = objectTemplate->NewInstance(); - // create teh actor object + // create the actor object ActorWrapper* pointer = new ActorWrapper( actor, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() ); // assign the JavaScript object to the wrapper. @@ -384,7 +351,7 @@ v8::Handle ActorWrapper::MakeDaliActorTemplate( v8::Isolate* const ActorFunctions property = ActorFunctionTable[i]; // check to see if the actor supports a certain type of API - // e.g. ImageActor will support ACTOR_API, RENDERABLE_API and IMAGE_ACTOR_API + // e.g. Layer will support ACTOR_API and LAYER_API if( supportApis & property.api ) { std::string funcName = V8Utils::GetJavaScriptFunctionName( property.name); @@ -412,7 +379,7 @@ void ActorWrapper::NewActor( const v8::FunctionCallbackInfo< v8::Value >& args) return; } - // find out the callee function name...e.g. ImageActor, MeshActor + // find out the callee function name...e.g. CameraActor v8::Local callee = args.Callee(); v8::Local v8String = callee->GetName(); std::string typeName = V8Utils::v8StringToStdString( v8String ); @@ -425,44 +392,8 @@ 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 + * given an actor type name, e.g. CameraActor returns the type, e.g. ActorWrapper::CAMERA_ACTOR */ ActorWrapper::ActorType ActorWrapper::GetActorType( const std::string& name ) { @@ -476,8 +407,6 @@ ActorWrapper::ActorType ActorWrapper::GetActorType( const std::string& name ) return ActorWrapper::UNKNOWN_ACTOR; } - - } // namespace V8Plugin } // namespace Dali