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