1 #ifndef DALI_VISUAL_RENDERER_H
2 #define DALI_VISUAL_RENDERER_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/rendering/renderer.h>
27 * @addtogroup dali_core_rendering_effects
31 namespace Internal DALI_INTERNAL
37 * @brief VisualRenderer is a handle to a Renderer with extra properties for Toolkit::Visuals
41 class DALI_CORE_API VisualRenderer : public Renderer
45 * @brief Policies used by the transform for the offset or size.
48 struct TransformPolicy
51 * @brief Enumeration for the type of Transform Policy.
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
62 * @brief Enumeration for instances of properties belonging to the VisualRenderer class.
67 static constexpr Dali::Property::Index DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION;
70 * @brief Enumeration for instances of properties belonging to the VisualRenderer class.
76 * @brief Name "transformOffset", type Property::Vector2, animatable.
78 * @note The default value is (0,0).
80 TRANSFORM_OFFSET = DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX,
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.
86 * @see TRANSFORM_SIZE_POLICY
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
97 * @note The default is top left
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
108 * @note The default is top left.
110 TRANSFORM_ANCHOR_POINT,
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
117 * visualRenderer.SetProperty( VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE,
118 * Vector4( Policy::ABSOLUTE, Policy::RELATIVE, Policy::ABSOLUTE, Policy::RELATIVE ));
122 * @note By default, both the x and the y offset/size is RELATIVE.
124 TRANSFORM_OFFSET_SIZE_MODE,
127 * @brief Any extra size the shader needs for drawing into.
128 * @details Name "extraSize", type Property::VECTOR2, animatable
130 * @note the default is (0, 0)
135 * @brief Mix color is a generic color for any visual.
136 * @details Name "visualMixColor", type Property::VECTOR3, animatable
142 * @brief PremultipliedAlpha is a float representing a bool, and is either 0.0f, or 1.0f
143 * @details Name "preMultipliedAlpha", type Property::FLOAT
146 VISUAL_PRE_MULTIPLIED_ALPHA,
151 * @brief Creates a new Renderer object.
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
158 static VisualRenderer New(Geometry& geometry, Shader& shader);
161 * @brief Default constructor, creates an empty handle
175 * @brief Copy constructor, creates a new handle to the same object.
178 * @param[in] handle Handle to an object
180 VisualRenderer(const VisualRenderer& handle);
183 * @brief Downcasts to a visual renderer handle.
184 * If not, a renderer the returned visual renderer handle is left uninitialized.
187 * @param[in] handle Handle to an object
188 * @return Renderer handle or an uninitialized handle
190 static VisualRenderer DownCast(BaseHandle handle);
193 * @brief Assignment operator, changes this handle to point at the same object.
196 * @param[in] handle Handle to an object
197 * @return Reference to the assigned object
199 VisualRenderer& operator=(const VisualRenderer& handle);
202 * @brief Move constructor.
205 * @param[in] rhs A reference to the moved handle
207 VisualRenderer(VisualRenderer&& rhs);
210 * @brief Move assignment operator.
213 * @param[in] rhs A reference to the moved handle
214 * @return A reference to this handle
216 VisualRenderer& operator=(VisualRenderer&& rhs);
221 * @brief The constructor.
222 * @note Not intended for application developers.
224 * @param[in] pointer A pointer to a newly allocated VisualRenderer
226 explicit DALI_INTERNAL VisualRenderer(Internal::VisualRenderer* pointer);
235 #endif // DALI_VISUAL_RENDERER_H