[Tizen] Implements CanvasRenderer that can draw Vector Primitives using ThorVG
[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 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 Downcast a handle to Drawable handle.
112    *
113    * If handle points to an InputMethodContext the downcast produces valid
114    * handle. If not the returned handle is left uninitialized.
115    *
116    * @param[in] handle Handle to an object.
117    * @return Handle to an Drawable or an uninitialized handle.
118    */
119   static Drawable DownCast(BaseHandle handle);
120
121 public: // Not intended for application developers
122   /// @cond internal
123   /**
124    * @brief The constructor.
125    * @note  Not intended for application developers.
126    *
127    * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Drawable
128    */
129   explicit DALI_INTERNAL Drawable(Internal::Adaptor::Drawable* pImpl);
130   /// @endcond
131 };
132
133 /**
134  * @}
135  */
136 } // namespace Dali
137
138 #endif // DALI_CANVAS_RENDERER_DRAWABLE_H