[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / visuals / visual-properties.h
1 #ifndef DALI_TOOLKIT_VISUAL_PROPERTIES_H
2 #define DALI_TOOLKIT_VISUAL_PROPERTIES_H
3
4 /*
5  * Copyright (c) 2020 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-toolkit/public-api/toolkit-property-index-ranges.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 /**
29  * @addtogroup dali_toolkit_visuals
30  * @{
31  */
32
33 /**
34  * @brief All the visual types.
35  * @SINCE_1_1.45
36  */
37 namespace Visual
38 {
39 /**
40  * @brief All the visual types.
41  * @SINCE_1_1.45
42  */
43 enum Type
44 {
45   BORDER,         ///< Renders a solid color as an internal border to the control's quad. @SINCE_1_1.45
46   COLOR,          ///< Renders a solid color to the control's quad. @SINCE_1_1.45
47   GRADIENT,       ///< Renders a smooth transition of colors to the control's quad. @SINCE_1_1.45
48   IMAGE,          ///< Renders an image into the control's quad. @SINCE_1_1.45
49   MESH,           ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45
50   PRIMITIVE,      ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45
51   WIREFRAME,      ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2
52   TEXT,           ///< Renders text @SINCE_1_2.60
53   N_PATCH,        ///< Renders an n-patch image. @SINCE_1_2.60
54   SVG,            ///< Renders an SVG image. @SINCE_1_2.60
55   ANIMATED_IMAGE, ///< Renders a animated image. @SINCE_1_2.60
56 };
57
58 /**
59  * @brief Visual Property.
60  * @SINCE_1_1.45
61  */
62 namespace Property
63 {
64 /**
65  * @brief Enumeration for the instance of properties belonging to the Visual Property.
66  * @SINCE_1_1.45
67  */
68 enum
69 {
70   /**
71    * @brief The index for the visual type.
72    * @details Name "visualType", type [Type](Dali::Toolkit::Visual::Type) (Property::INTEGER) or Property::STRING.
73    * @SINCE_1_1.45
74    * @note Mandatory.
75    * @see Type
76    */
77   TYPE = VISUAL_PROPERTY_BASE_START_INDEX,
78
79   /**
80    * @brief The shader to use in the visual.
81    * @details Name "shader", type Property::MAP.
82    * @SINCE_1_1.45
83    * @note Optional.
84    * @note Will override the existing shaders.
85    * @see Shader::Property
86    */
87   SHADER,
88
89   /**
90    * @brief The transform used by the visual.
91    * @details Name "transform", type Property::MAP.
92    * @SINCE_1_2.60
93    * @note Optional.
94    * @see Toolkit::Visual::Transform::Property
95    */
96   TRANSFORM,
97
98   /**
99    * @brief Enables/disables premultiplied alpha.
100    * @details Name "premultipliedAlpha", type Property::BOOLEAN.
101    * @SINCE_1_2.60
102    * @note Optional.
103    * @note The premultiplied alpha is false by default unless this behaviour is modified
104    * by the derived Visual type.
105    */
106   PREMULTIPLIED_ALPHA,
107
108   /**
109    * @brief Mix color is a blend color for any visual.
110    * @details Name "mixColor", type Property::VECTOR3 or Property::VECTOR4, animatable
111    * @SINCE_1_2.60
112    * @note Optional
113    * @note To animate an opacity, OPACITY property should be used.
114    */
115   MIX_COLOR,
116
117   /**
118    * @brief Opacity is the alpha component of the mixColor, above.
119    * @details Name "opacity", type Property::FLOAT, animatable
120    * @SINCE_1_2.60
121    * @note Optional
122    */
123   OPACITY,
124 };
125
126 } // namespace Property
127
128 /**
129  * @brief Visual Transform for the offset or size.
130  * @SINCE_1_2.60
131  */
132 namespace Transform
133 {
134 /**
135  * @brief Policies used by the transform for the offset or size.
136  * @SINCE_1_2.60
137  */
138 namespace Policy
139 {
140 /**
141  * @brief Enumeration for the type of Transform Policy.
142  * @SINCE_1_2.60
143  */
144 enum Type
145 {
146   RELATIVE = 0, ///< Relative to the control (percentage [0.0f to 1.0f] of the control). @SINCE_1_2.60
147   ABSOLUTE = 1  ///< Absolute value in world units. @SINCE_1_2.60
148 };
149
150 } // namespace Policy
151
152 /**
153  * @brief Visual Transform Property.
154  * @SINCE_1_2.60
155  */
156 namespace Property
157 {
158 /**
159  * @brief Enumeration for the type of Transform Property.
160  * @SINCE_1_2.60
161  */
162 enum Type
163 {
164   /**
165    * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
166    * @details Name "offset", type Property::VECTOR2, animatable.
167    * @SINCE_1_2.60
168    *
169    * @see OFFSET_POLICY
170    */
171   OFFSET,
172
173   /**
174    * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
175    * @details Name "size", type Property::VECTOR2, animatable.
176    * @see SIZE_POLICY
177    */
178   SIZE,
179
180   /**
181    * @brief The origin of the visual within its control area.
182    * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING.
183    * @see Toolkit::Align
184    * @SINCE_1_2.60
185    * @note The default is Align::TOP_BEGIN.
186    */
187   ORIGIN,
188
189   /**
190    * @brief The anchor-point of the visual
191    * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING.
192    * @see Toolkit::Align
193    * @SINCE_1_2.60
194    * @note The default is Align::TOP_BEGIN.
195    */
196   ANCHOR_POINT,
197
198   /**
199    * @brief Whether the x or y OFFSET values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
200    * @details Name "offsetPolicy", type Vector2 or Property::ARRAY of Property::STRING.
201    *          If Property::ARRAY then 2 strings expected for the x and y.
202    *
203    * C++:
204    * @code
205    * control.SetProperty( ..., // Some visual based property
206    *                      Property::Map().Add( ... ) // Properties to set up visual
207    *                                     .Add( Visual::Property::TRANSFORM,
208    *                                           Property::Array().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) )
209    *                                                            .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) );
210    * @endcode
211    *
212    * JSON:
213    * @code
214    * {
215    *   ...
216    *   "transition":
217    *   {
218    *     "offsetPolicy" : [ "ABSOLUTE", "RELATIVE" ],
219    *     "offset" : [ 10, 1.0 ]
220    *   }
221    *   ...
222    * }
223    *
224    * @endcode
225    * @see Policy::Type
226    * @SINCE_1_2.60
227    * @note By default, both the x and the y offset is RELATIVE.
228    */
229   OFFSET_POLICY,
230
231   /**
232    * @brief Whether the width or height SIZE values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
233    * @details Name "sizePolicy", type Vector2 or Property::ARRAY of Property::STRING.
234    *          If Property::ARRAY then 2 strings expected for the width and height.
235    *
236    * @see Policy::Type
237    * @see OFFSET_POLICY for example
238    * @SINCE_1_2.60
239    * @note By default, both the width and the height is RELATIVE to the control's size.
240    */
241   SIZE_POLICY,
242 };
243
244 } // namespace Property
245
246 } // namespace Transform
247
248 /**
249  * @brief Shader for Visuals.
250  * @SINCE_1_1.45
251  */
252 namespace Shader
253 {
254 /**
255  * @brief Shader Property.
256  * @SINCE_1_1.45
257  */
258 namespace Property
259 {
260 /**
261  * @brief The type of Shader.
262  * @SINCE_1_1.45
263  */
264 enum
265 {
266   /**
267    * @brief The vertex shader.
268    * @details Name "vertexShader", type Property::STRING or Property::ARRAY of Property::STRING.
269    *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
270    * @SINCE_1_1.45
271    * @note Optional
272    * @note If not supplied, the visual's already set vertex shader is used.
273    */
274   VERTEX_SHADER,
275
276   /**
277    * @brief The fragment shader.
278    * @details Name "fragmentShader", type Property::STRING or Property::ARRAY of Property::STRING.
279    *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
280    * @SINCE_1_1.45
281    * @note Optional
282    * @note If not supplied, the visual's already set fragment shader is used.
283    */
284   FRAGMENT_SHADER,
285
286   /**
287    * @brief How to subdivide the grid along the X-Axis.
288    * @details Name "subdivideGridX", type Property::INTEGER.
289    * @SINCE_1_1.45
290    * @note Optional
291    * @note If not supplied, the default is 1.
292    * @note Value should be greater than or equal to 1.
293    */
294   SUBDIVIDE_GRID_X,
295
296   /**
297    * @brief How to subdivide the grid along the Y-Axis.
298    * @details Name "subdivideGridY", type Property::INTEGER.
299    * @SINCE_1_1.45
300    * @note Optional
301    * @note If not supplied, the default is 1.
302    * @note Value should be greater than or equal to 1.
303    */
304   SUBDIVIDE_GRID_Y,
305
306   /**
307    * @brief Hints for rendering.
308    * @details Name "hints", type Dali::Shader::Hint (Property::INTEGER), Property::STRING or Property::ARRAY of Property::STRING.
309    * @SINCE_1_1.45
310    * @note Optional
311    * @note If not supplied, the default is Dali::Shader::Hint::NONE.
312    */
313   HINTS,
314 };
315
316 } // namespace Property
317
318 } // namespace Shader
319
320 /**
321  * @brief Status of resource which is used for visual.
322  * @SINCE_1_3_5
323  */
324 enum class ResourceStatus
325 {
326   PREPARING, /// Resource is prepared.    @SINCE_1_3_5
327   READY,     /// Resource is ready.       @SINCE_1_3_5
328   FAILED     /// Resource is fail to load @SINCE_1_3_5
329 };
330
331 } // namespace Visual
332
333 /**
334  * @}
335  */
336
337 } // namespace Toolkit
338
339 } // namespace Dali
340
341 #endif // DALI_TOOLKIT_VISUAL_PROPERTIES_H