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 * @copydoc Dali::CanvasRenderer::Drawable::SetMask()
120 virtual bool SetMask(Dali::CanvasRenderer::Drawable& mask, Dali::CanvasRenderer::Drawable::MaskType type);
123 * @brief Returns a composition drawble object.
124 * @return Returns a composition drawble object.
126 virtual Dali::CanvasRenderer::Drawable GetCompositionDrawable() const;
129 * @brief Returns a composition type
130 * @return Returns a composition type
132 virtual CompositionType GetCompositionType() const;
135 * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
136 * @param[in] added Ture if added, false otherwise.
138 virtual void SetAdded(bool added);
141 * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
142 * @return Returns Ture if added, false otherwise.
144 virtual bool IsAdded() const;
147 * @brief Returns a drawable object pointer.
148 * @return Returns a drawable object pointer.
150 virtual void* GetObject() const;
153 * @brief Set a drawable object
154 * @param[in] object drawable object
156 virtual void SetObject(const void* object);
159 * @brief Set a changed state.
160 * @param[in] changed The state of changed.
162 virtual void SetChanged(bool changed);
165 * @brief Get a changed state.
166 * @return Returns state of changed.
168 virtual bool GetChanged() const;
171 * @brief Set drawable's type.
172 * @param[in] type Type of drawable.
174 virtual void SetType(Types type);
177 * @brief Get drawable's type.
178 * @return Returns type of drawable.
180 virtual Types GetType() const;
183 * @brief Returns a drawable's implements object pointer.
184 * @return Returns a drawable's implements object pointer.
186 Dali::Internal::Adaptor::Drawable* GetImplementation();
188 Drawable(const Drawable&) = delete;
189 Drawable& operator=(Drawable&) = delete;
190 Drawable(Drawable&&) = delete;
191 Drawable& operator=(Drawable&&) = delete;
194 Dali::Internal::Adaptor::Drawable* mImpl = nullptr;
197 } // namespace Adaptor
199 } // namespace Internal
201 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
203 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
205 BaseObject& handle = drawable.GetBaseObject();
207 return static_cast<Internal::Adaptor::Drawable&>(handle);
210 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
212 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
214 const BaseObject& handle = drawable.GetBaseObject();
216 return static_cast<const Internal::Adaptor::Drawable&>(handle);
221 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H