(Canvas Renderer) Moved Devel Headers into sub-folder to improve SAM score
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / canvas-renderer / canvas-renderer-gradient.h
1 #ifndef DALI_CANVAS_RENDERER_GRADIENT_H
2 #define DALI_CANVAS_RENDERER_GRADIENT_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer.h>
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_adaptor_framework
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 namespace Adaptor
38 {
39 class CanvasRenderer;
40 class Gradient;
41 } // namespace Adaptor
42 } // namespace DALI_INTERNAL
43
44 /**
45  * @brief An abstract class representing the gradient fill of the Shape object.
46  *
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.
52  */
53 class DALI_ADAPTOR_API CanvasRenderer::Gradient : public BaseHandle
54 {
55 public:
56   /**
57    * @brief Constructor
58    */
59   Gradient();
60
61   /**
62    * @brief Destructor.
63    */
64   ~Gradient();
65
66   /**
67    * @brief This copy constructor is required for (smart) pointer semantics.
68    *
69    * @param[in] handle A reference to the copied handle
70    */
71   Gradient(const Gradient& handle) = default;
72
73 public:
74   /**
75    * @brief Enumeration specifying how to fill the area outside the gradient bounds.
76    */
77   enum class Spread
78   {
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.
82   };
83
84   /**
85    * @brief A data structure storing the information about the color and its relative position inside the gradient bounds.
86    */
87   struct ColorStop
88   {
89     float   offset; /**< The relative position of the color. */
90     Vector4 color;  /**< The color value. */
91   };
92
93   /// @brief List of Colorstop.
94   using ColorStops = Dali::Vector<ColorStop>;
95
96 public:
97   /**
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.
101    */
102   bool SetColorStops(ColorStops& colorStops);
103
104   /**
105    * @brief Gets the parameters of the colors of the gradient, their position and number.
106    * @return Returns the colorstops list.
107    */
108   ColorStops GetColorStops() const;
109
110   /**
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.
114    */
115   bool SetSpread(Spread spread);
116
117   /**
118    * @brief Get the spread type
119    * @return Returns the current spread type of the shape.
120    */
121   Spread GetSpread() const;
122
123   /**
124    * @brief Downcast a handle to Gradient handle.
125    *
126    * If handle points to an InputMethodContext the downcast produces valid
127    * handle. If not the returned handle is left uninitialized.
128    *
129    * @param[in] handle Handle to an object.
130    * @return Handle to an Gradient or an uninitialized handle.
131    */
132   static Gradient DownCast(BaseHandle handle);
133
134 public: // Not intended for application developers
135   /// @cond internal
136   /**
137    * @brief The constructor.
138    * @note  Not intended for application developers.
139    *
140    * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Gradient
141    */
142   explicit DALI_INTERNAL Gradient(Internal::Adaptor::Gradient* pImpl);
143   /// @endcond
144 };
145
146 /**
147  * @}
148  */
149 } // namespace Dali
150
151 #endif // DALI_CANVAS_RENDERER_GRADIENT_H