Merge "Add BuildPickingRay to devel api" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / decorated-visual-renderer.h
1 #ifndef DALI_DECOREATED_VISUAL_RENDERER_H
2 #define DALI_DECOREATED_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/visual-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 DecoratedVisualRenderer;
34 }
35
36 /**
37  * @brief DecoratedVisualRenderer is a handle to a Renderer with extra properties for Toolkit::Visuals with some decoration
38  *
39  * @SINCE_2_1.21
40  */
41 class DALI_CORE_API DecoratedVisualRenderer : public VisualRenderer
42 {
43 public:
44   /**
45    * @brief Enumeration for instances of properties belonging to the DecoratedVisualRenderer class.
46    * @SINCE_2_1.21
47    */
48   struct Property
49   {
50     static constexpr Dali::Property::Index DEFAULT_DECORATED_VISUAL_RENDERER_PROPERTY_START_INDEX = VisualRenderer::Property::DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION;
51
52     /**
53      * @brief Enumeration for instances of properties belonging to the DecoratedVisualRenderer class.
54      * @SINCE_2_1.21
55      */
56     enum
57     {
58       /**
59        * @brief The radius for the rounded corners of the visual.
60        * @details Name "cornerRadius", type Property::Vector4, animatable.
61        *
62        * @see Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS
63        * @SINCE_2_1.21
64        * @note The default value is (0, 0, 0, 0).
65        */
66       CORNER_RADIUS = DEFAULT_DECORATED_VISUAL_RENDERER_PROPERTY_START_INDEX,
67
68       /**
69        * @brief Whether the CORNER_RADIUS values are relative (percentage [0.0f to 0.5f] of the control) or absolute (in world units).
70        * @details Name "cornerRadiusPolicy", type Property::FLOAT
71        *
72        * @code
73        * decoratedVisualRenderer.SetProperty( DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, Policy::ABSOLUTE );
74        * @endcode
75        *
76        * @see Policy::Type
77        * @see Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY
78        * @SINCE_2_1.21
79        * @note The default value is Policy::RELATIVE.
80        */
81       CORNER_RADIUS_POLICY,
82
83       /**
84        * @brief The width for the borderline of the visual.
85        * @details Name "borderlineWidth", type Property::FLOAT, animatable.
86        *
87        * @see Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH
88        * @SINCE_2_1.21
89        * @note The default value is 0.0.
90        */
91       BORDERLINE_WIDTH,
92
93       /**
94        * @brief The color for the borderline of the visual.
95        * @details Name "borderlineColor", type Property::Vector4, animatable.
96        *
97        * @see Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR
98        * @SINCE_2_1.21
99        * @note The default value is Color::BLACK.
100        */
101       BORDERLINE_COLOR,
102
103       /**
104        * @brief The offset from the visual borderline (recommend [-1.0f to 1.0f]).
105        * @details Name "borderlineOffset", type Property::FLOAT, animatable.
106        *
107        * @see Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET
108        * @SINCE_2_1.21
109        * @note The default value is 0.0f.
110        */
111       BORDERLINE_OFFSET,
112
113       /**
114        * @brief The blur radius of the visual.
115        * @details Name "blurRadius", type Property::FLOAT, animatable.
116        *          If the value is 0, the edge is sharp. Otherwise, the larger the value, the more the edge is blurred.
117        *
118        * @see Dali::Toolkit::DevelColorVisual::Property::BLUR_RADIUS
119        * @SINCE_2_1.21
120        * @note The default value is 0.0f.
121        */
122       BLUR_RADIUS,
123     };
124   };
125
126   /**
127    * @brief Creates a new DecoratedVisualRenderer object.
128    *
129    * @SINCE_2_1.21
130    * @param[in] geometry Geometry to be used by this renderer
131    * @param[in] shader Shader to be used by this renderer
132    * @return A handle to the Renderer
133    */
134   static DecoratedVisualRenderer New(Geometry& geometry, Shader& shader);
135
136   /**
137    * @brief Default constructor, creates an empty handle
138    *
139    * @SINCE_2_1.21
140    */
141   DecoratedVisualRenderer();
142
143   /**
144    * @brief Destructor.
145    *
146    * @SINCE_2_1.21
147    */
148   ~DecoratedVisualRenderer();
149
150   /**
151    * @brief Copy constructor, creates a new handle to the same object.
152    *
153    * @SINCE_2_1.21
154    * @param[in] handle Handle to an object
155    */
156   DecoratedVisualRenderer(const DecoratedVisualRenderer& handle);
157
158   /**
159    * @brief Downcasts to a decorated visual renderer handle.
160    * If not, a renderer the returned decorated visual renderer handle is left uninitialized.
161    *
162    * @SINCE_2_1.21
163    * @param[in] handle Handle to an object
164    * @return Renderer handle or an uninitialized handle
165    */
166   static DecoratedVisualRenderer DownCast(BaseHandle handle);
167
168   /**
169    * @brief Assignment operator, changes this handle to point at the same object.
170    *
171    * @SINCE_2_1.21
172    * @param[in] handle Handle to an object
173    * @return Reference to the assigned object
174    */
175   DecoratedVisualRenderer& operator=(const DecoratedVisualRenderer& handle);
176
177   /**
178    * @brief Register relate with corner radius uniforms so we can use it as uniform properties.
179    *
180    * @SINCE_2_1.21
181    */
182   void RegisterCornerRadiusUniform();
183
184   /**
185    * @brief Register relate with borderline uniforms so we can use it as uniform properties.
186    *
187    * @SINCE_2_1.21
188    */
189   void RegisterBorderlineUniform();
190
191   /**
192    * @brief Register relate with blur radius uniforms so we can use it as uniform properties.
193    *
194    * @SINCE_2_1.21
195    */
196   void RegisterBlurRadiusUniform();
197
198   /**
199    * @brief Move constructor.
200    *
201    * @SINCE_2_1.21
202    * @param[in] rhs A reference to the moved handle
203    */
204   DecoratedVisualRenderer(DecoratedVisualRenderer&& rhs) noexcept;
205
206   /**
207    * @brief Move assignment operator.
208    *
209    * @SINCE_2_1.21
210    * @param[in] rhs A reference to the moved handle
211    * @return A reference to this handle
212    */
213   DecoratedVisualRenderer& operator=(DecoratedVisualRenderer&& rhs) noexcept;
214
215 public:
216   /// @cond internal
217   /**
218    * @brief The constructor.
219    * @note  Not intended for application developers.
220    * @SINCE_2_1.21
221    * @param[in] pointer A pointer to a newly allocated DecoratedVisualRenderer
222    */
223   explicit DALI_INTERNAL DecoratedVisualRenderer(Internal::DecoratedVisualRenderer* pointer);
224   /// @endcond
225 };
226
227 /**
228  * @}
229  */
230 } //namespace Dali
231
232 #endif // DALI_DECOREATED_VISUAL_RENDERER_H