1 #ifndef DALI_CANVAS_RENDERER_GRADIENT_H
2 #define DALI_CANVAS_RENDERER_GRADIENT_H
5 * Copyright (c) 2021 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/object/base-handle.h>
25 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 * @addtogroup dali_adaptor_framework
35 namespace Internal DALI_INTERNAL
41 } // namespace Adaptor
42 } // namespace DALI_INTERNAL
45 * @brief An abstract class representing the gradient fill of the Shape object.
47 * It contains the information about the gradient colors and their arrangement
48 * inside the gradient bounds. The gradients bounds are defined in the LinearGradient
49 * or RadialGradient class, depending on the type of the gradient to be used.
50 * It specifies the gradient behavior in case the area defined by the gradient bounds
51 * is smaller than the area to be filled.
53 class DALI_ADAPTOR_API CanvasRenderer::Gradient : public BaseHandle
67 * @brief This copy constructor is required for (smart) pointer semantics.
69 * @param[in] handle A reference to the copied handle
71 Gradient(const Gradient& handle) = default;
75 * @brief Enumeration specifying how to fill the area outside the gradient bounds.
79 PAD = 0, ///< The remaining area is filled with the closest stop color.
80 REFLECT, ///< The gradient pattern is reflected outside the gradient area until the expected region is filled.
81 REPEAT ///< The gradient pattern is repeated continuously beyond the gradient area until the expected region is filled.
85 * @brief A data structure storing the information about the color and its relative position inside the gradient bounds.
89 float offset; /**< The relative position of the color. */
90 Vector4 color; /**< The color value. */
93 /// @brief List of Colorstop.
94 using ColorStops = Dali::Vector<ColorStop>;
98 * @brief Sets the parameters of the colors of the gradient and their position.
99 * @param[in] colorStops An array of ColorStop data structure.
100 * @return Result::Success when succeed.
102 bool SetColorStops(ColorStops& colorStops);
105 * @brief Gets the parameters of the colors of the gradient, their position and number.
106 * @return Returns the colorstops list.
108 ColorStops GetColorStops() const;
111 * @brief Set the spread.
112 * @param[in] spread The current spraed type of the shape.
113 * @return Returns True when it's successful. False otherwise.
115 bool SetSpread(Spread spread);
118 * @brief Get the spread type
119 * @return Returns the current spread type of the shape.
121 Spread GetSpread() const;
124 * @brief Downcast a handle to Gradient handle.
126 * If handle points to an InputMethodContext the downcast produces valid
127 * handle. If not the returned handle is left uninitialized.
129 * @param[in] handle Handle to an object.
130 * @return Handle to an Gradient or an uninitialized handle.
132 static Gradient DownCast(BaseHandle handle);
134 public: // Not intended for application developers
137 * @brief The constructor.
138 * @note Not intended for application developers.
140 * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Gradient
142 explicit DALI_INTERNAL Gradient(Internal::Adaptor::Gradient* pImpl);
151 #endif // DALI_CANVAS_RENDERER_GRADIENT_H