Added Devel Animated with Default Property Reg macro
[platform/core/uifw/dali-core.git] / dali / devel-api / object / property-helper-devel.h
1 #ifndef __DALI_PROPERTY_HELPER_DEVEL_H__
2 #define __DALI_PROPERTY_HELPER_DEVEL_H__
3
4 /*
5  * Copyright (c) 2017 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
22 #include <dali/public-api/object/type-registry-helper.h>
23
24 /**
25  * @brief These macros are used internally by the property macros.
26  * Use the the property macros in the section below this one (without the _INTERNAL postfix) when defining properties.
27  * These internal macros exist as to perform the compile-time check on the enumeration order, the __COUNTER__ macro is used twice.
28  * Using it twice within the same macro would result in two different values.
29  */
30 #define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex ) \
31   Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace:: develNamespace ::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty ); \
32   DALI_COMPILE_TIME_ASSERT( ( objectNamespace:: develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count );
33
34 #define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex ) \
35   Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace:: develNamespace ::Property::enumIndex, Dali::Property::valueType, NULL, &objectType::GetProperty ); \
36   DALI_COMPILE_TIME_ASSERT( ( objectNamespace:: develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count );
37
38 #define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex) \
39   Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace:: develNamespace::Property::enumIndex, Dali::Property::valueType );
40
41 #define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, value, enumIndex) \
42   Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, value );
43
44
45 /**
46  * @brief These macros are used to define properties for implementations of CustomActor.
47  *
48  * These macros should be used when defining devel properties
49  * They provide the following benefits:
50  * - A standard and consistent way to define properties.
51  * - Concise definition promotes readability, especially with large numbers of properties.
52  * - Provides a built-in compile-time check. This checks the order of the properties within the enumeration match the order of the property macros. Note: This check is not performed for animatable properties.
53  * - Enforces how properties are enumerated in the object handles header file.
54  *
55  * Note: The compile-type check will produce the following message on failure:
56  *       error: invalid application of 'sizeof' to incomplete type 'Dali::CompileTimeAssertBool<false>'
57  *
58  * Macro usage example:
59  *
60  * Within the your object's implementation cpp:
61  * @code
62  * #include <dali/public-api/object/devel-property-helper.h>
63  * ...
64  * DALI_TYPE_REGISTRATION_BEGIN( MyApp::MyCustomActor, Dali::CustomActor, Create )
65  * DALI_DEVEL_PROPERTY_REGISTRATION( MyApp, MyCustomActor, "myProperty", INTEGER, MY_DEVEL_PROPERTY )
66  * DALI_TYPE_REGISTRATION_END()
67  * @endcode
68  *
69  * Within your handle's header:
70  *
71  * @code
72  * #include <dali/public-api/common/dali-common.h>
73  *
74  *
75  * ///< @brief The start and end property ranges for this control.
76  * enum PropertyRange
77  * {
78  *   PROPERTY_START_INDEX = Dali::PROPERTY_REGISTRATION_START_INDEX,
79  *   PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000
80  * };
81  *
82  * ///< @brief An enumeration of properties belonging to the Button class.
83  * struct Property
84  * {
85  *   enum
86  *   {
87  *     MY_PROPERTY = PROPERTY_START_INDEX    ///< @brief name "myProperty", type Integer
88  *   };
89  * };
90  * @endcode
91  *
92  * Using these macros have certain prerequisites on how the property enumeration is defined.
93  * Please see the Programming Guide (within the generated Doxygen) for full details.
94  */
95 #define DALI_DEVEL_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \
96   DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex  )
97
98 /**
99  * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION
100  *
101  * @note For Read Only properties
102  */
103 #define DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( objectNamespace, objectType, text, valueType, enumIndex ) \
104   DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex  )
105
106 /**
107  * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION
108  *
109  * @note Animatible property registration
110  */
111 #define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \
112   DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex )
113
114 /**
115  * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION
116  *
117  * @note Animatible property registration with default value
118  *
119  */
120 #define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( objectNamespace, objectType, text, value, enumIndex ) \
121   DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, DALI_TOKEN_PASTE( Devel, objectType ) , text, value, enumIndex )
122
123
124 #endif // __DALI_PROPERTY_HELPER_DEVEL_H__