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.
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 * @copydoc Dali::CanvasRenderer::Drawable::GetBoundingBox
102 virtual Rect<float> GetBoundingBox() const;
105 * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
106 * @param[in] added Ture if added, false otherwise.
108 virtual void SetAdded(bool added);
111 * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
112 * @return Returns Ture if added, false otherwise.
114 virtual bool IsAdded() const;
117 * @brief Returns a drawable object pointer.
118 * @return Returns a drawable object pointer.
120 virtual void* GetObject() const;
123 * @brief Set a drawable object
124 * @param[in] object drawable object
126 virtual void SetObject(const void* object);
129 * @brief Set a changed state.
130 * @param[in] changed The state of changed.
132 virtual void SetChanged(bool changed);
135 * @brief Get a changed state.
136 * @return Returns state of changed.
138 virtual bool GetChanged() const;
141 * @brief Set drawable's type.
142 * @param[in] type Type of drawable.
144 virtual void SetType(Types type);
147 * @brief Get drawable's type.
148 * @return Returns type of drawable.
150 virtual Types GetType() const;
153 * @brief Returns a drawable's implements object pointer.
154 * @return Returns a drawable's implements object pointer.
156 Dali::Internal::Adaptor::Drawable* GetImplementation();
158 Drawable(const Drawable&) = delete;
159 Drawable& operator=(Drawable&) = delete;
160 Drawable(Drawable&&) = delete;
161 Drawable& operator=(Drawable&&) = delete;
164 Dali::Internal::Adaptor::Drawable* mImpl = nullptr;
167 } // namespace Adaptor
169 } // namespace Internal
171 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
173 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
175 BaseObject& handle = drawable.GetBaseObject();
177 return static_cast<Internal::Adaptor::Drawable&>(handle);
180 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
182 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
184 const BaseObject& handle = drawable.GetBaseObject();
186 return static_cast<const Internal::Adaptor::Drawable&>(handle);
191 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H