1 #ifndef DALI_CANVAS_RENDERER_DRAWABLE_H
2 #define DALI_CANVAS_RENDERER_DRAWABLE_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/public-api/object/base-handle.h>
25 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 * @addtogroup dali_adaptor_framework
35 namespace Internal DALI_INTERNAL
42 } // namespace Adaptor
43 } // namespace DALI_INTERNAL
46 * @brief Drawable is a object class for drawing a vector primitive.
48 class DALI_ADAPTOR_API CanvasRenderer::Drawable : public BaseHandle
62 * @brief This copy constructor is required for (smart) pointer semantics.
64 * @param[in] handle A reference to the copied handle
66 Drawable(const Drawable& handle) = default;
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.
74 bool SetOpacity(float opacity);
77 * @brief Get the transparency value
78 * @return Returns the transparency level
80 float GetOpacity() const;
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.
87 bool Rotate(Degree degree);
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.
94 bool Scale(float factor);
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.
101 bool Translate(Vector2 translate);
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.
108 bool Transform(const Dali::Matrix3& matrix);
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.
115 Rect<float> GetBoundingBox() const;
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.
122 bool SetClipPath(Drawable& clip);
125 * @brief Downcast a handle to Drawable handle.
127 * If handle points to an InputMethodContext the downcast produces valid
128 * handle. If not the returned handle is left uninitialized.
130 * @param[in] handle Handle to an object.
131 * @return Handle to an Drawable or an uninitialized handle.
133 static Drawable DownCast(BaseHandle handle);
135 public: // Not intended for application developers
138 * @brief The constructor.
139 * @note Not intended for application developers.
141 * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Drawable
143 explicit DALI_INTERNAL Drawable(Internal::Adaptor::Drawable* pImpl);
152 #endif // DALI_CANVAS_RENDERER_DRAWABLE_H