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.
25 #include <dali/public-api/object/base-object.h>
28 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
29 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
38 * Dali internal Drawable.
40 class Drawable : public Dali::BaseObject
44 * @brief Enumeration for type of drawable.
46 enum class DrawableTypes
48 NONE = 0, ///< Means that type is not defined.
49 SHAPE, ///< Meaning of Shape class that inherits Drawable.
50 DRAWABLE_GROUP ///< Meaning of DrawableGorup class that inherits Drawable.
62 virtual ~Drawable() override;
65 * @brief Create factory item(implementation) object.
70 * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
72 virtual bool SetOpacity(float opacity);
75 * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
77 virtual float GetOpacity() const;
80 * @copydoc Dali::CanvasRenderer::Drawable::Rotate
82 virtual bool Rotate(Degree degree);
85 * @copydoc Dali::CanvasRenderer::Drawable::Scale
87 virtual bool Scale(float factor);
90 * @copydoc Dali::CanvasRenderer::Drawable::Translate
92 virtual bool Translate(Vector2 translate);
95 * @copydoc Dali::CanvasRenderer::Drawable::Transform
97 virtual bool Transform(const Dali::Matrix3& matrix);
100 * @brief Set whether drawable added to the other object(canvas or drawable) or not.
101 * @param[in] added Ture if added, false otherwise.
103 virtual void SetDrawableAdded(bool added);
106 * @brief Returns whether this object was added to another object(canvas or drawable).
107 * @return Returns Ture if added, false otherwise.
109 virtual bool IsDrawableAdded();
112 * @brief Returns a drawable object pointer.
113 * @return Returns a drawable object pointer.
115 virtual void* GetObject() const;
118 * @brief Set a drawable object
119 * @param[in] object drawable object
121 virtual void SetObject(const void* object);
124 * @brief Set a changed state.
125 * @param[in] changed The state of changed.
127 virtual void SetChanged(bool changed);
130 * @brief Get a changed state.
131 * @return Returns state of changed.
133 virtual bool GetChanged() const;
136 * @brief Set drawable's type.
137 * @param[in] type Type of drawable.
139 virtual void SetDrawableType(DrawableTypes type);
142 * @brief Get drawable's type.
143 * @return Returns type of drawable.
145 virtual DrawableTypes GetDrawableType() const;
148 * @brief Returns a drawable's implements object pointer.
149 * @return Returns a drawable's implements object pointer.
151 Dali::Internal::Adaptor::Drawable* GetImplementation();
153 Drawable(const Drawable&) = delete;
154 Drawable& operator=(Drawable&) = delete;
155 Drawable(Drawable&&) = delete;
156 Drawable& operator=(Drawable&&) = delete;
159 Dali::Internal::Adaptor::Drawable* pImpl = nullptr;
162 } // namespace Adaptor
164 } // namespace Internal
166 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
168 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
170 BaseObject& handle = drawable.GetBaseObject();
172 return static_cast<Internal::Adaptor::Drawable&>(handle);
175 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
177 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
179 const BaseObject& handle = drawable.GetBaseObject();
181 return static_cast<const Internal::Adaptor::Drawable&>(handle);
186 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H