1 #ifndef DALI_TOOLKIT_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_CANVAS_VIEW_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-toolkit/public-api/controls/control.h>
25 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
26 #include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
32 namespace Internal DALI_INTERNAL
37 * @addtogroup dali_toolkit_controls_canvas_view
42 * @brief CanvasView is a class for displaying an vector primitives.
45 * auto myCanvasView = CanvasView::New( viewBox ) ); //The viewBox is the size of viewbox of CanvasView.
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 );
54 * @section CanvasViewProperties Properties
55 * |%Property enum |String name |Type |Writable|Animatable|
56 * |----------------------------------|---------------------|----------------|--------|----------|
57 * | Property::VIEW_BOX | viewBox | Vector2 | O | X |
60 class DALI_TOOLKIT_API CanvasView : public Control
64 * @brief The start and end property ranges for this control.
68 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
72 * @brief An enumeration of properties belonging to the CanvasView class.
77 * @brief An enumeration of properties belonging to the CanvasView class.
82 * @brief the viewbox of the CanvasView.
83 * @details Name "viewBox", type Property::VECTOR2.
85 VIEW_BOX = PROPERTY_START_INDEX,
90 * @brief Creates an uninitialized CanvasView.
95 * @brief Creates an initialized CanvasView
97 * @return A handle to a newly allocated CanvasView
99 static CanvasView New();
102 * @brief Creates an initialized CanvasView
104 * @param [in] viewBox The width and height.
105 * @return A handle to a newly allocated CanvasView
107 static CanvasView New(const Vector2& viewBox);
112 * This is non-virtual since derived Handle types must not contain data or virtual methods.
117 * @brief Copy constructor.
119 * @param[in] canvasView CanvasView to copy. The copied CanvasView will point at the same implementation
121 CanvasView(const CanvasView& canvasView);
124 * @brief Move constructor
126 * @param[in] rhs A reference to the moved handle
128 CanvasView(CanvasView&& rhs);
131 * @brief Assignment operator.
133 * @param[in] canvasView The CanvasView to assign from
134 * @return The updated CanvasView
136 CanvasView& operator=(const CanvasView& canvasView);
139 * @brief Move assignment
141 * @param[in] rhs A reference to the moved handle
142 * @return A reference to this
144 CanvasView& operator=(CanvasView&& rhs);
147 * @brief Downcasts a handle to CanvasView handle.
149 * If handle points to a CanvasView, the downcast produces valid handle.
150 * If not, the returned handle is left uninitialized.
152 * @param[in] handle Handle to an object
153 * @return Handle to a CanvasView or an uninitialized handle
155 static CanvasView DownCast(BaseHandle handle);
158 * @brief Add drawable object to the CanvasView.
159 * This method is similar to registration. The added shape is drawn on the inner canvas.
160 * @param[in] drawable the drawable object.
162 void AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
165 * @brief Remove drawable object to the CanvasView.
166 * This method is similar to deregistration.
167 * @param[in] drawable the drawable object.
168 * @return Returns True when it's successful. False otherwise.
170 bool RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable);
172 public: // Not intended for application developers
175 * @brief Creates a handle using the Toolkit::Internal implementation.
177 * @param[in] implementation The CanvasView implementation
179 DALI_INTERNAL CanvasView(Internal::CanvasView& implementation);
182 * @brief Allows the creation of this CanvasView from an Internal::CustomActor pointer.
184 * @param[in] internal A pointer to the internal CustomActor
186 DALI_INTERNAL CanvasView(Dali::Internal::CustomActor* internal);
193 } // namespace Toolkit
197 #endif // DALI_TOOLKIT_CANVAS_VIEW_H