2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "pan-gesture-detector-api.h"
22 #include <events/pan-gesture-detector-wrapper.h>
23 #include <object/property-value-wrapper.h>
32 namespace // unnamed namespace
35 PanGestureDetector GetPanGestureDetector( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
37 v8::HandleScope handleScope( isolate );
39 v8::Local<v8::Object> object = args.This();
40 v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField( 0 ) );
41 void* ptr = field->Value();
43 PanGestureDetectorWrapper* wrapper = static_cast<PanGestureDetectorWrapper *>( ptr );
44 return wrapper->GetPanGestureDetector();
47 } // unnamed namespace
53 * @for PanGestureDetector
54 * @method PanGestureDetector
56 PanGestureDetector PanGestureDetectorApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
58 return PanGestureDetector::New();
62 * Attaches an actor to the pan gesture.
64 * The pan-detected signal will be dispatched when the pan gesture occurs on
65 * the attached actor. You can attach several actors to a pan gesture detector.
67 * @for PanGestureDetector
68 * @param {Actor} actor The actor to attach to the pan gesture detector
70 * panGestureDetector.attach(actor);
72 void PanGestureDetectorApi::Attach( const v8::FunctionCallbackInfo< v8::Value >& args )
74 v8::Isolate* isolate = args.GetIsolate();
75 v8::HandleScope handleScope( isolate );
78 Dali::Actor actor = V8Utils::GetActorParameter( PARAMETER_0, found, isolate, args );
81 PanGestureDetector panGestureDetector = GetPanGestureDetector( isolate, args );
82 panGestureDetector.Attach( actor );
86 DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" );
92 * Detaches the attached actor from the pan gesture detector.
94 * The specified actor should have been attached to the pan gesture detector
96 * @for PanGestureDetector
97 * @param {Actor} actor The actor to detach from the pan gesture detector
99 * panGestureDetector.detach(actor);
101 void PanGestureDetectorApi::Detach( const v8::FunctionCallbackInfo< v8::Value >& args )
103 v8::Isolate* isolate = args.GetIsolate();
104 v8::HandleScope handleScope( isolate );
107 Dali::Actor actor = V8Utils::GetActorParameter( PARAMETER_0, found, isolate, args );
110 PanGestureDetector panGestureDetector = GetPanGestureDetector( isolate, args );
111 panGestureDetector.Detach( actor );
115 DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" );
120 } // namespace V8Plugin