DALi Version 2.0.5
[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.
111    * @SINCE_1_2.60
112    * @note Optional
113    */
114   MIX_COLOR,
115
116   /**
117    * @brief Opacity is the alpha component of the mixColor, above.
118    * @details Name "opacity", type Property::FLOAT.
119    * @SINCE_1_2.60
120    * @note Optional
121    */
122   OPACITY,
123 };
124
125 } // namespace Property
126
127 /**
128  * @brief Visual Transform for the offset or size.
129  * @SINCE_1_2.60
130  */
131 namespace Transform
132 {
133 /**
134  * @brief Policies used by the transform for the offset or size.
135  * @SINCE_1_2.60
136  */
137 namespace Policy
138 {
139 /**
140  * @brief Enumeration for the type of Transform Policy.
141  * @SINCE_1_2.60
142  */
143 enum Type
144 {
145   RELATIVE = 0, ///< Relative to the control (percentage [0.0f to 1.0f] of the control). @SINCE_1_2.60
146   ABSOLUTE = 1  ///< Absolute value in world units. @SINCE_1_2.60
147 };
148
149 } // namespace Policy
150
151 /**
152  * @brief Visual Transform Property.
153  * @SINCE_1_2.60
154  */
155 namespace Property
156 {
157 /**
158  * @brief Enumeration for the type of Transform Property.
159  * @SINCE_1_2.60
160  */
161 enum Type
162 {
163   /**
164    * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
165    * @details Name "offset", type Property::VECTOR2.
166    * @SINCE_1_2.60
167    *
168    * @see OFFSET_POLICY
169    */
170   OFFSET,
171
172   /**
173    * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
174    * @details Name "size", type Property::VECTOR2.
175    * @see SIZE_POLICY
176    */
177   SIZE,
178
179   /**
180    * @brief The origin of the visual within its control area.
181    * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING.
182    * @see Toolkit::Align
183    * @SINCE_1_2.60
184    * @note The default is Align::TOP_BEGIN.
185    */
186   ORIGIN,
187
188   /**
189    * @brief The anchor-point of the visual
190    * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING.
191    * @see Toolkit::Align
192    * @SINCE_1_2.60
193    * @note The default is Align::TOP_BEGIN.
194    */
195   ANCHOR_POINT,
196
197   /**
198    * @brief Whether the x or y OFFSET values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
199    * @details Name "offsetPolicy", type Vector2 or Property::ARRAY of Property::STRING.
200    *          If Property::ARRAY then 2 strings expected for the x and y.
201    *
202    * C++:
203    * @code
204    * control.SetProperty( ..., // Some visual based property
205    *                      Property::Map().Add( ... ) // Properties to set up visual
206    *                                     .Add( Visual::Property::TRANSFORM,
207    *                                           Property::Array().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) )
208    *                                                            .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) );
209    * @endcode
210    *
211    * JSON:
212    * @code
213    * {
214    *   ...
215    *   "transition":
216    *   {
217    *     "offsetPolicy" : [ "ABSOLUTE", "RELATIVE" ],
218    *     "offset" : [ 10, 1.0 ]
219    *   }
220    *   ...
221    * }
222    *
223    * @endcode
224    * @see Policy::Type
225    * @SINCE_1_2.60
226    * @note By default, both the x and the y offset is RELATIVE.
227    */
228   OFFSET_POLICY,
229
230   /**
231    * @brief Whether the width or height SIZE values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
232    * @details Name "sizePolicy", type Vector2 or Property::ARRAY of Property::STRING.
233    *          If Property::ARRAY then 2 strings expected for the width and height.
234    *
235    * @see Policy::Type
236    * @see OFFSET_POLICY for example
237    * @SINCE_1_2.60
238    * @note By default, both the width and the height is RELATIVE to the control's size.
239    */
240   SIZE_POLICY,
241 };
242
243 } // namespace Property
244
245 } // namespace Transform
246
247 /**
248  * @brief Shader for Visuals.
249  * @SINCE_1_1.45
250  */
251 namespace Shader
252 {
253 /**
254  * @brief Shader Property.
255  * @SINCE_1_1.45
256  */
257 namespace Property
258 {
259 /**
260  * @brief The type of Shader.
261  * @SINCE_1_1.45
262  */
263 enum
264 {
265   /**
266    * @brief The vertex shader.
267    * @details Name "vertexShader", type Property::STRING or Property::ARRAY of Property::STRING.
268    *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
269    * @SINCE_1_1.45
270    * @note Optional
271    * @note If not supplied, the visual's already set vertex shader is used.
272    */
273   VERTEX_SHADER,
274
275   /**
276    * @brief The fragment shader.
277    * @details Name "fragmentShader", type Property::STRING or Property::ARRAY of Property::STRING.
278    *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
279    * @SINCE_1_1.45
280    * @note Optional
281    * @note If not supplied, the visual's already set fragment shader is used.
282    */
283   FRAGMENT_SHADER,
284
285   /**
286    * @brief How to subdivide the grid along the X-Axis.
287    * @details Name "subdivideGridX", type Property::INTEGER.
288    * @SINCE_1_1.45
289    * @note Optional
290    * @note If not supplied, the default is 1.
291    * @note Value should be greater than or equal to 1.
292    */
293   SUBDIVIDE_GRID_X,
294
295   /**
296    * @brief How to subdivide the grid along the Y-Axis.
297    * @details Name "subdivideGridY", type Property::INTEGER.
298    * @SINCE_1_1.45
299    * @note Optional
300    * @note If not supplied, the default is 1.
301    * @note Value should be greater than or equal to 1.
302    */
303   SUBDIVIDE_GRID_Y,
304
305   /**
306    * @brief Hints for rendering.
307    * @details Name "hints", type Dali::Shader::Hint (Property::INTEGER), Property::STRING or Property::ARRAY of Property::STRING.
308    * @SINCE_1_1.45
309    * @note Optional
310    * @note If not supplied, the default is Dali::Shader::Hint::NONE.
311    */
312   HINTS,
313 };
314
315 } // namespace Property
316
317 } // namespace Shader
318
319 /**
320  * @brief Status of resource which is used for visual.
321  * @SINCE_1_3_5
322  */
323 enum class ResourceStatus
324 {
325   PREPARING, /// Resource is prepared.    @SINCE_1_3_5
326   READY,     /// Resource is ready.       @SINCE_1_3_5
327   FAILED     /// Resource is fail to load @SINCE_1_3_5
328 };
329
330 } // namespace Visual
331
332 /**
333  * @}
334  */
335
336 } // namespace Toolkit
337
338 } // namespace Dali
339
340 #endif // DALI_TOOLKIT_VISUAL_PROPERTIES_H