Dali 3D User Interface Engine
scripting.h
Go to the documentation of this file.
1 #ifndef __DALI_SCRIPTING_H__
2 #define __DALI_SCRIPTING_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 
21 // INTERNAL INCLUDES
29 
30 namespace Dali
31 {
32 
33 class Actor;
34 
38 namespace Scripting
39 {
40 
44 struct StringEnum
45 {
46  const char* string;
47  const int value;
48 };
49 
58 DALI_IMPORT_API unsigned int FindEnumIndex( const char* value, const StringEnum* table, unsigned int tableCount );
59 
71 DALI_IMPORT_API bool EnumStringToInteger( const char* const value, const StringEnum* const table, unsigned int tableCount, unsigned int& integerEnum );
72 
83 template< typename T >
84 bool GetEnumeration( const char* value, const StringEnum* table, unsigned int tableCount, T& result )
85 {
86  bool retVal( false );
87  if( table )
88  {
89  unsigned int integerEnum = 0;
90  // check to avoid crash, not asserting on purpose, error is logged instead
91  if( EnumStringToInteger( value, table, tableCount, integerEnum ) )
92  {
93  result = static_cast<T>( integerEnum );
94  retVal = true;
95  }
96  }
97  return retVal;
98 }
99 
111 template< typename T >
112 const char* GetEnumerationName( T value, const StringEnum* table, unsigned int tableCount )
113 {
114  if( table )
115  {
116  for ( unsigned int i = 0; i < tableCount; ++i )
117  {
118  if ( value == T(table[ i ].value) )
119  {
120  return table[ i ].string;
121  }
122  }
123  }
124  return NULL;
125 }
126 
139 template< typename T >
140 const char * GetLinearEnumerationName( T value, const StringEnum* table, unsigned int tableCount )
141 {
142  if ( table && ( value > 0 || value <= (int)tableCount ) )
143  {
144  return table[value].string;
145  }
146  return NULL;
147 }
148 
155 DALI_IMPORT_API ColorMode GetColorMode( const std::string& value );
156 
163 DALI_IMPORT_API std::string GetColorMode( ColorMode value );
164 
172 
180 
187 DALI_IMPORT_API DrawMode::Type GetDrawMode( const std::string& value );
188 
195 DALI_IMPORT_API std::string GetDrawMode( DrawMode::Type value );
196 
203 DALI_IMPORT_API Vector3 GetAnchorConstant( const std::string& value );
204 
225 DALI_IMPORT_API Image NewImage( const Property::Value& property );
226 
259 
285 
293 
301 
308 DALI_IMPORT_API void NewAnimation( const Property::Map& map, Dali::AnimationData& outputAnimationData );
309 
310 } // namespace Scripting
311 
312 } // namespace Dali
313 
314 #endif // __DALI_SCRIPTING_H__
Dali Docs Home
Read more about Dali