CanvasRenderer: Add Drawable::SetClipPath() Api
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / canvas-renderer-drawable.h
1 #ifndef DALI_CANVAS_RENDERER_DRAWABLE_H
2 #define DALI_CANVAS_RENDERER_DRAWABLE_H
3
4 /*
5  * Copyright (c) 2021 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.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 Drawable;
41 class Shape;
42 } // namespace Adaptor
43 } // namespace DALI_INTERNAL
44
45 /**
46  * @brief Drawable is a object class for drawing a vector primitive.
47  */
48 class DALI_ADAPTOR_API CanvasRenderer::Drawable : public BaseHandle
49 {
50 public:
51   /**
52    * @brief Constructor
53    */
54   Drawable();
55
56   /**
57    * @brief Destructor.
58    */
59   ~Drawable();
60
61   /**
62    * @brief This copy constructor is required for (smart) pointer semantics.
63    *
64    * @param[in] handle A reference to the copied handle
65    */
66   Drawable(const Drawable& handle) = default;
67
68 public:
69   /**
70    * @brief Set the transparency value
71    * @param[in] opacity The transparency level [0 ~ 1.0], 0 means totally transparent, while 1 means opaque.
72    * @return Returns True when it's successful. False otherwise.
73    */
74   bool SetOpacity(float opacity);
75
76   /**
77    * @brief Get the transparency value
78    * @return Returns the transparency level
79    */
80   float GetOpacity() const;
81
82   /**
83    * @brief Set the angle of rotation transformation.
84    * @param[in] degree The degree value of angle.
85    * @return Returns True when it's successful. False otherwise.
86    */
87   bool Rotate(Degree degree);
88
89   /**
90    * @brief Set the scale value of scale transformation.
91    * @param[in] factor The scale factor value.
92    * @return Returns True when it's successful. False otherwise.
93    */
94   bool Scale(float factor);
95
96   /**
97    * @brief Set the x, y movement value of translate transformation.
98    * @param[in] translate The x and y-axis movement value.
99    * @return Returns True when it's successful. False otherwise.
100    */
101   bool Translate(Vector2 translate);
102
103   /**
104    * @brief Set the matrix value for affine transform.
105    * @param[in] matrix The 3x3 matrix value.
106    * @return Returns True when it's successful. False otherwise.
107    */
108   bool Transform(const Dali::Matrix3& matrix);
109
110   /**
111    * @brief Gets the bounding box of the drawable object before any transformation.
112    * @note The bounding box doesn't indicate the rendering region in the result but primitive region of the object.
113    * @return Returns the bounding box information.
114    */
115   Rect<float> GetBoundingBox() const;
116
117   /**
118    * @brief The intersection with clip drawable is determined and only the resulting pixels from own drawable are rendered.
119    * @param[in] clip The clip drawable object.
120    * @return Returns True when it's successful. False otherwise.
121    */
122   bool SetClipPath(Drawable& clip);
123
124   /**
125    * @brief Downcast a handle to Drawable handle.
126    *
127    * If handle points to an InputMethodContext the downcast produces valid
128    * handle. If not the returned handle is left uninitialized.
129    *
130    * @param[in] handle Handle to an object.
131    * @return Handle to an Drawable or an uninitialized handle.
132    */
133   static Drawable DownCast(BaseHandle handle);
134
135 public: // Not intended for application developers
136   /// @cond internal
137   /**
138    * @brief The constructor.
139    * @note  Not intended for application developers.
140    *
141    * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Drawable
142    */
143   explicit DALI_INTERNAL Drawable(Internal::Adaptor::Drawable* pImpl);
144   /// @endcond
145 };
146
147 /**
148  * @}
149  */
150 } // namespace Dali
151
152 #endif // DALI_CANVAS_RENDERER_DRAWABLE_H