1 #ifndef __DALI_V8PLUGIN_CONTROL_WRAPPER_H__
2 #define __DALI_V8PLUGIN_CONTROL_WRAPPER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali-toolkit/public-api/controls/control.h>
27 #include <actors/actor-wrapper.h>
37 * Wraps a Dali Control.
39 class ControlWrapper : public ActorWrapper
45 * Control type used an index.
46 * These enums are used to index the ControlApiLookup table in control-wrapper.cpp.
47 * Any changes made must be reflected in the ControlApiLookup otherwise it may segfault when creating a control
59 * @param control DALi control
60 * @param gc garbage collection interface
62 ControlWrapper( Toolkit::Control control,
63 GarbageCollectorInterface& gc );
68 virtual ~ControlWrapper();
71 * @brief Creates a new Control wrapped inside a Javascript Object.
72 * @note: the control type is passed as a parameter e.g. 'ItemView'
73 * @param[in] args v8 function call arguments interpreted
75 static void NewControl( const v8::FunctionCallbackInfo< v8::Value >& args);
78 * @brief Wraps a control of a given type
80 static v8::Handle<v8::Object> WrapControl(v8::Isolate* isolate, Toolkit::Control control, ControlType controlType);
83 * @brief Wraps a control, the type is looked up from the control
85 static v8::Handle<v8::Object> WrapControl(v8::Isolate* isolate, Toolkit::Control control );
87 // The Control ObjectTemplates.
88 static v8::Persistent<v8::ObjectTemplate> mControlTemplate;
89 static v8::Persistent<v8::ObjectTemplate> mItemViewTemplate;
90 static v8::Persistent<v8::ObjectTemplate> mScrollViewTemplate;
93 * @return the wrapped control
95 Toolkit::Control GetControl();
98 * @return the control type
100 static ControlWrapper::ControlType GetControlType( const std::string& name );
103 * @brief Register the garbage to be released when the wrapped control is deleted.
105 static void RegisterGarbage(void* garbage);
110 * Helper to make the control template
112 static v8::Handle<v8::ObjectTemplate> MakeDaliControlTemplate( v8::Isolate* isolate, ControlType controlType );
115 * Helper, get a control template given a control type
117 static v8::Local<v8::ObjectTemplate> GetControlTemplate( v8::Isolate* isolate, ControlType type );
119 Toolkit::Control mControl;
120 static Vector< void* > mControlGarbageContainer;
124 } // namespace V8Plugin