c0e0709025785db6fd0fdad7ffdc1c9ebc662007
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / canvas-view / canvas-view.h
1 #ifndef DALI_TOOLKIT_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_CANVAS_VIEW_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
26 #include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Internal DALI_INTERNAL
33 {
34 class CanvasView;
35 }
36 /**
37  * @addtogroup dali_toolkit_controls_canvas_view
38  * @{
39  */
40
41 /**
42  * @brief CanvasView is a class for displaying an vector primitives.
43  *
44  * @code
45  *    auto myCanvasView = CanvasView::New( viewBox ) ); //The viewBox is the size of viewbox of CanvasView.
46  *
47  *    //Create shape and set properties.
48  *    auto shape = Dali::CanvasRenderer::Shape::New();
49  *    shape.AddRect( 0, 0, 10, 10, 0, 0 );
50  *    shape.SetFillColor( Vector4( 1.0, 1.0, 1.0, 1.0 ) );
51  *    myCanvasView.AddDrawable( shape );
52  * @endcode
53  *
54  *
55  */
56 class DALI_TOOLKIT_API CanvasView : public Control
57 {
58 public:
59   /**
60    * @brief Creates an uninitialized CanvasView.
61    */
62   CanvasView();
63
64   /**
65    * @brief Creates an initialized CanvasView
66    *
67    * @return A handle to a newly allocated CanvasView
68    */
69   static CanvasView New();
70
71   /**
72    * @brief Creates an initialized CanvasView
73    *
74    * @param [in] viewBox The width and height.
75    * @return A handle to a newly allocated CanvasView
76    */
77   static CanvasView New(const Vector2& viewBox);
78
79   /**
80    * @brief Destructor.
81    *
82    * This is non-virtual since derived Handle types must not contain data or virtual methods.
83    */
84   ~CanvasView();
85
86   /**
87    * @brief Copy constructor.
88    *
89    * @param[in] canvasView CanvasView to copy. The copied CanvasView will point at the same implementation
90    */
91   CanvasView(const CanvasView& canvasView);
92
93   /**
94    * @brief Move constructor
95    *
96    * @param[in] rhs A reference to the moved handle
97    */
98   CanvasView(CanvasView&& rhs);
99
100   /**
101    * @brief Assignment operator.
102    *
103    * @param[in] canvasView The CanvasView to assign from
104    * @return The updated CanvasView
105    */
106   CanvasView& operator=(const CanvasView& canvasView);
107
108   /**
109    * @brief Move assignment
110    *
111    * @param[in] rhs A reference to the moved handle
112    * @return A reference to this
113    */
114   CanvasView& operator=(CanvasView&& rhs);
115
116   /**
117    * @brief Downcasts a handle to CanvasView handle.
118    *
119    * If handle points to a CanvasView, the downcast produces valid handle.
120    * If not, the returned handle is left uninitialized.
121    *
122    * @param[in] handle Handle to an object
123    * @return Handle to a CanvasView or an uninitialized handle
124    */
125   static CanvasView DownCast(BaseHandle handle);
126
127   /**
128    * @brief Add drawable object to the CanvasView.
129    * This method is similar to registration. The added shape is drawn on the inner canvas.
130    */
131   void AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
132
133 public: // Not intended for application developers
134   /// @cond internal
135   /**
136    * @brief Creates a handle using the Toolkit::Internal implementation.
137    *
138    * @param[in] implementation The CanvasView implementation
139    */
140   DALI_INTERNAL CanvasView(Internal::CanvasView& implementation);
141
142   /**
143    * @brief Allows the creation of this CanvasView from an Internal::CustomActor pointer.
144    *
145    * @param[in] internal A pointer to the internal CustomActor
146    */
147   DALI_INTERNAL CanvasView(Dali::Internal::CustomActor* internal);
148   /// @endcond
149 };
150
151 /**
152  * @}
153  */
154 } // namespace Toolkit
155
156 } // namespace Dali
157
158 #endif // DALI_TOOLKIT_CANVAS_VIEW_H