1 #ifndef DALI_INTERNAL_DRAWABLE_IMPL_H
2 #define DALI_INTERNAL_DRAWABLE_IMPL_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-object.h>
25 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
26 #include <dali/devel-api/adaptor-framework/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.
51 * @brief Enumeration indicating type used in the composition of two objects - the target and the source.
53 enum class CompositionType
55 NONE = 0, ///< Means that type is not defined.
56 CLIP_PATH, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered.
57 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.
58 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.
70 virtual ~Drawable() override;
73 * @brief Create factory item(implementation) object.
78 * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity()
80 virtual bool SetOpacity(float opacity);
83 * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity()
85 virtual float GetOpacity() const;
88 * @copydoc Dali::CanvasRenderer::Drawable::Rotate()
90 virtual bool Rotate(Degree degree);
93 * @copydoc Dali::CanvasRenderer::Drawable::Scale()
95 virtual bool Scale(float factor);
98 * @copydoc Dali::CanvasRenderer::Drawable::Translate()
100 virtual bool Translate(Vector2 translate);
103 * @copydoc Dali::CanvasRenderer::Drawable::Transform()
105 virtual bool Transform(const Dali::Matrix3& matrix);
108 * @copydoc Dali::CanvasRenderer::Drawable::GetBoundingBox
110 virtual Rect<float> GetBoundingBox() const;
113 * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
115 virtual bool SetClipPath(Dali::CanvasRenderer::Drawable& clip);
118 * @brief Returns a composition drawble object.
119 * @return Returns a composition drawble object.
121 virtual Dali::CanvasRenderer::Drawable GetCompositionDrawable() const;
124 * @brief Returns a composition type
125 * @return Returns a composition type
127 virtual CompositionType GetCompositionType() const;
130 * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
131 * @param[in] added Ture if added, false otherwise.
133 virtual void SetAdded(bool added);
136 * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
137 * @return Returns Ture if added, false otherwise.
139 virtual bool IsAdded() const;
142 * @brief Returns a drawable object pointer.
143 * @return Returns a drawable object pointer.
145 virtual void* GetObject() const;
148 * @brief Set a drawable object
149 * @param[in] object drawable object
151 virtual void SetObject(const void* object);
154 * @brief Set a changed state.
155 * @param[in] changed The state of changed.
157 virtual void SetChanged(bool changed);
160 * @brief Get a changed state.
161 * @return Returns state of changed.
163 virtual bool GetChanged() const;
166 * @brief Set drawable's type.
167 * @param[in] type Type of drawable.
169 virtual void SetType(Types type);
172 * @brief Get drawable's type.
173 * @return Returns type of drawable.
175 virtual Types GetType() const;
178 * @brief Returns a drawable's implements object pointer.
179 * @return Returns a drawable's implements object pointer.
181 Dali::Internal::Adaptor::Drawable* GetImplementation();
183 Drawable(const Drawable&) = delete;
184 Drawable& operator=(Drawable&) = delete;
185 Drawable(Drawable&&) = delete;
186 Drawable& operator=(Drawable&&) = delete;
189 Dali::Internal::Adaptor::Drawable* mImpl = nullptr;
192 } // namespace Adaptor
194 } // namespace Internal
196 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
198 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
200 BaseObject& handle = drawable.GetBaseObject();
202 return static_cast<Internal::Adaptor::Drawable&>(handle);
205 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
207 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
209 const BaseObject& handle = drawable.GetBaseObject();
211 return static_cast<const Internal::Adaptor::Drawable&>(handle);
216 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H