Add BuildPickingRay to devel api
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / visual-renderer.h
1 #ifndef DALI_VISUAL_RENDERER_H
2 #define DALI_VISUAL_RENDERER_H
3
4 /*
5  * Copyright (c) 2022 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/rendering/renderer.h>
23
24 namespace Dali
25 {
26 /**
27  * @addtogroup dali_core_rendering_effects
28  * @{
29  */
30
31 namespace Internal DALI_INTERNAL
32 {
33 class VisualRenderer;
34 }
35
36 /**
37  * @brief VisualRenderer is a handle to a Renderer with extra properties for Toolkit::Visuals
38  *
39  * @SINCE_2_1.13
40  */
41 class DALI_CORE_API VisualRenderer : public Renderer
42 {
43 public:
44   /**
45    * @brief Policies used by the transform for the offset or size.
46    * @SINCE_2_1.13
47    */
48   struct TransformPolicy
49   {
50     /**
51      * @brief Enumeration for the type of Transform Policy.
52      * @SINCE_2_1.13
53      */
54     enum Type
55     {
56       RELATIVE = 0, ///< Relative to the control (percentage [0.0f to 1.0f] of the control). @SINCE_2_1.13
57       ABSOLUTE = 1  ///< Absolute value in world units. @SINCE_2_1.13
58     };
59   };
60
61   /**
62    * @brief Enumeration for instances of properties belonging to the VisualRenderer class.
63    * @SINCE_2_1.13
64    */
65   struct Property
66   {
67     static constexpr Dali::Property::Index DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION;
68
69     /**
70      * @brief Enumeration for instances of properties belonging to the VisualRenderer class.
71      * @SINCE_2_1.13
72      */
73     enum
74     {
75       /**
76        * @brief Name "transformOffset", type Property::Vector2, animatable.
77        * @SINCE_2_1.13
78        * @note The default value is (0,0).
79        */
80       TRANSFORM_OFFSET = DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX,
81
82       /**
83        * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
84        * @details Name "transformSize", type Property::VECTOR2, animatable.
85        * @SINCE_2_1.13
86        * @see TRANSFORM_SIZE_POLICY
87        */
88       TRANSFORM_SIZE,
89
90       /**
91        * @brief The origin of the visual renderer within its control area.
92        * @details Name "transformOrigin", type Property::VECTOR2
93        * @note This is relative to the size of the actor, where the origin is the center of the actor,
94        * and the range is -0.5 to +0.5 vertically and horizontally
95        * @note Toolkit may impose additional layout directions
96        * @SINCE_2_1.13
97        * @note The default is top left
98        */
99       TRANSFORM_ORIGIN,
100
101       /**
102        * @brief The anchor-point of the visual renderer
103        * @details Name "transformAnchorPoint", type Property::VECTOR2
104        * @note This is relative to the size of the actor; where the origin is the center of the actor,
105        * and the range is -0.5 to +0.5 vertically and horizontally
106        * @note Toolkit may impose additional layout directions
107        * @SINCE_2_1.13
108        * @note The default is top left.
109        */
110       TRANSFORM_ANCHOR_POINT,
111
112       /**
113        * @brief Whether the x or y OFFSET/SIZE values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
114        * @details Name "transformOffsetSizeMode", type Property::VECTOR4
115        *
116        * @code
117        * visualRenderer.SetProperty( VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE,
118        *                             Vector4( Policy::ABSOLUTE, Policy::RELATIVE, Policy::ABSOLUTE, Policy::RELATIVE ));
119        * @endcode
120        * @see Policy::Type
121        * @SINCE_2_1.13
122        * @note By default, both the x and the y offset/size is RELATIVE.
123        */
124       TRANSFORM_OFFSET_SIZE_MODE,
125
126       /**
127        * @brief Any extra size the shader needs for drawing into.
128        * @details Name "extraSize", type Property::VECTOR2, animatable
129        * @SINCE_2_1.13
130        * @note the default is (0, 0)
131        */
132       EXTRA_SIZE,
133
134       /**
135        * @brief Mix color is a generic color for any visual.
136        * @details Name "visualMixColor", type Property::VECTOR3, animatable
137        * @SINCE_2_1.13
138        */
139       VISUAL_MIX_COLOR,
140
141       /**
142        * @brief PremultipliedAlpha is a float representing a bool, and is either 0.0f, or 1.0f
143        * @details Name "preMultipliedAlpha", type Property::FLOAT
144        * @SINCE_2_1.13
145        */
146       VISUAL_PRE_MULTIPLIED_ALPHA,
147     };
148   };
149
150   /**
151    * @brief Creates a new Renderer object.
152    *
153    * @SINCE_2_1.13
154    * @param[in] geometry Geometry to be used by this renderer
155    * @param[in] shader Shader to be used by this renderer
156    * @return A handle to the Renderer
157    */
158   static VisualRenderer New(Geometry& geometry, Shader& shader);
159
160   /**
161    * @brief Default constructor, creates an empty handle
162    *
163    * @SINCE_2_1.13
164    */
165   VisualRenderer();
166
167   /**
168    * @brief Destructor.
169    *
170    * @SINCE_2_1.13
171    */
172   ~VisualRenderer();
173
174   /**
175    * @brief Copy constructor, creates a new handle to the same object.
176    *
177    * @SINCE_2_1.13
178    * @param[in] handle Handle to an object
179    */
180   VisualRenderer(const VisualRenderer& handle);
181
182   /**
183    * @brief Downcasts to a visual renderer handle.
184    * If not, a renderer the returned visual renderer handle is left uninitialized.
185    *
186    * @SINCE_2_1.13
187    * @param[in] handle Handle to an object
188    * @return Renderer handle or an uninitialized handle
189    */
190   static VisualRenderer DownCast(BaseHandle handle);
191
192   /**
193    * @brief Assignment operator, changes this handle to point at the same object.
194    *
195    * @SINCE_2_1.13
196    * @param[in] handle Handle to an object
197    * @return Reference to the assigned object
198    */
199   VisualRenderer& operator=(const VisualRenderer& handle);
200
201   /**
202    * @brief Move constructor.
203    *
204    * @SINCE_2_1.13
205    * @param[in] rhs A reference to the moved handle
206    */
207   VisualRenderer(VisualRenderer&& rhs);
208
209   /**
210    * @brief Move assignment operator.
211    *
212    * @SINCE_2_1.13
213    * @param[in] rhs A reference to the moved handle
214    * @return A reference to this handle
215    */
216   VisualRenderer& operator=(VisualRenderer&& rhs);
217
218 public:
219   /// @cond internal
220   /**
221    * @brief The constructor.
222    * @note  Not intended for application developers.
223    * @SINCE_2_1.13
224    * @param[in] pointer A pointer to a newly allocated VisualRenderer
225    */
226   explicit DALI_INTERNAL VisualRenderer(Internal::VisualRenderer* pointer);
227   /// @endcond
228 };
229
230 /**
231  * @}
232  */
233 } //namespace Dali
234
235 #endif // DALI_VISUAL_RENDERER_H