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.
59 virtual ~Drawable() override;
62 * @brief Create factory item(implementation) object.
67 * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity()
69 virtual bool SetOpacity(float opacity);
72 * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity()
74 virtual float GetOpacity() const;
77 * @copydoc Dali::CanvasRenderer::Drawable::Rotate()
79 virtual bool Rotate(Degree degree);
82 * @copydoc Dali::CanvasRenderer::Drawable::Scale()
84 virtual bool Scale(float factor);
87 * @copydoc Dali::CanvasRenderer::Drawable::Translate()
89 virtual bool Translate(Vector2 translate);
92 * @copydoc Dali::CanvasRenderer::Drawable::Transform()
94 virtual bool Transform(const Dali::Matrix3& matrix);
97 * @copydoc Dali::CanvasRenderer::Drawable::GetBoundingBox
99 virtual Rect<float> GetBoundingBox() const;
102 * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
103 * @param[in] added Ture if added, false otherwise.
105 virtual void SetAdded(bool added);
108 * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
109 * @return Returns Ture if added, false otherwise.
111 virtual bool IsAdded() const;
114 * @brief Returns a drawable object pointer.
115 * @return Returns a drawable object pointer.
117 virtual void* GetObject() const;
120 * @brief Set a drawable object
121 * @param[in] object drawable object
123 virtual void SetObject(const void* object);
126 * @brief Set a changed state.
127 * @param[in] changed The state of changed.
129 virtual void SetChanged(bool changed);
132 * @brief Get a changed state.
133 * @return Returns state of changed.
135 virtual bool GetChanged() const;
138 * @brief Set drawable's type.
139 * @param[in] type Type of drawable.
141 virtual void SetType(Types type);
144 * @brief Get drawable's type.
145 * @return Returns type of drawable.
147 virtual Types GetType() const;
150 * @brief Returns a drawable's implements object pointer.
151 * @return Returns a drawable's implements object pointer.
153 Dali::Internal::Adaptor::Drawable* GetImplementation();
155 Drawable(const Drawable&) = delete;
156 Drawable& operator=(Drawable&) = delete;
157 Drawable(Drawable&&) = delete;
158 Drawable& operator=(Drawable&&) = delete;
161 Dali::Internal::Adaptor::Drawable* mImpl = nullptr;
164 } // namespace Adaptor
166 } // namespace Internal
168 inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
170 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
172 BaseObject& handle = drawable.GetBaseObject();
174 return static_cast<Internal::Adaptor::Drawable&>(handle);
177 inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
179 DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
181 const BaseObject& handle = drawable.GetBaseObject();
183 return static_cast<const Internal::Adaptor::Drawable&>(handle);
188 #endif // DALI_INTERNAL_DRAWABLE_IMPL_H