1 #ifndef DALI_INTERNAL_DRAWABLE_IMPL_H
2 #define DALI_INTERNAL_DRAWABLE_IMPL_H
5 * Copyright (c) 2022 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-object.h>
25 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer-drawable.h>
26 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer.h>
35 * Dali internal Drawable.
37 class Drawable : public Dali::BaseObject
41 * @brief Enumeration for type of drawable.
45 NONE = 0, ///< Means that type is not defined.
46 SHAPE, ///< Meaning of Shape class that inherits Drawable.
47 DRAWABLE_GROUP, ///< Meaning of DrawableGorup class that inherits Drawable.
48 PICTURE ///< Meaning of Picture class that inherits Drawable.
52 * @brief Enumeration indicating type used in the composition of two objects - the target and the source.
54 enum class CompositionType
56 NONE = 0, ///< Means that type is not defined.
57 CLIP_PATH, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered.
58 ALPHA_MASK, ///< The pixels of the source and the target are alpha blended. As a result, only the part of the source, which intersects with the target is visible.
59 ALPHA_MASK_INVERSE ///< The pixels of the source and the complement to the target's pixels are alpha blended. As a result, only the part of the source which is not covered by the target is visible.
71 virtual ~Drawable() override;
74 * @brief Create factory item(implementation) object.
79 * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity()
81 virtual bool SetOpacity(float opacity);
84 * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity()
86 virtual float GetOpacity() const;
89 * @copydoc Dali::CanvasRenderer::Drawable::Rotate()
91 virtual bool Rotate(Degree degree);
94 * @copydoc Dali::CanvasRenderer::Drawable::Scale()
96 virtual bool Scale(float factor);
99 * @copydoc Dali::CanvasRenderer::Drawable::Translate()
101 virtual bool Translate(Vector2 translate);
104 * @copydoc Dali::CanvasRenderer::Drawable::Transform()
106 virtual bool Transform(const Dali::Matrix3& matrix);
109 * @copydoc Dali::CanvasRenderer::Drawable::GetBoundingBox
111 virtual Rect<float> GetBoundingBox() const;
114 * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
116 virtual bool SetClipPath(Dali::CanvasRenderer::Drawable& clip);
119 * @copydoc Dali::CanvasRenderer::Drawable::SetMask()
121 virtual bool SetMask(Dali::CanvasRenderer::Drawable& mask, Dali::CanvasRenderer::Drawable::MaskType type);
124 * @brief Returns a composition drawble object.
125 * @return Returns a composition drawble object.
127 virtual Dali::CanvasRenderer::Drawable GetCompositionDrawable() const;
130 * @brief Returns a composition type
131 * @return Returns a composition type
133 virtual CompositionType GetCompositionType() const;
136 * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
137 * @param[in] added Ture if added, false otherwise.
139 virtual void SetAdded(bool added);
142 * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
143 * @return Returns Ture if added, false otherwise.
145 virtual bool IsAdded() const;
148 * @brief Returns a drawable object pointer.
149 * @return Returns a drawable object pointer.
151 virtual void* GetObject() const;
154 * @brief Set a drawable object
155 * @param[in] object drawable object
157 virtual void SetObject(const void* object);
160 * @brief Set a changed state.
161 * @param[in] changed The state of changed.
163 virtual void SetChanged(bool changed);
166 * @brief Get a changed state.
167 * @return Returns state of changed.
169 virtual bool GetChanged() const;
172 * @brief Set drawable's type.
173 * @param[in] type Type of drawable.
175 virtual void SetType(Types type);
178 * @brief Get drawable's type.
179 * @return Returns type of drawable.
181 virtual Types GetType() const;
184 * @brief Returns a drawable's implements object pointer.
185 * @return Returns a drawable's implements object pointer.
187 Dali::Internal::Adaptor::Drawable* GetImplementation();
189 Drawable(const Drawable&) = delete;
190 Drawable& operator=(Drawable&) = delete;
191 Drawable(Drawable&&) = delete;
192 Drawable& operator=(Drawable&&) = delete;
195 Dali::Internal::Adaptor::Drawable* mImpl = nullptr;
198 } // namespace Adaptor
200 } // namespace Internal
202 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
204 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
206 BaseObject& handle = drawable.GetBaseObject();
208 return static_cast<Internal::Adaptor::Drawable&>(handle);
211 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
213 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
215 const BaseObject& handle = drawable.GetBaseObject();
217 return static_cast<const Internal::Adaptor::Drawable&>(handle);
222 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H