1 #ifndef DALI_INTERNAL_CUSTOM_ACTOR_H
2 #define DALI_INTERNAL_CUSTOM_ACTOR_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/internal/event/actors/actor-declarations.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/public-api/actors/custom-actor.h>
25 #include <dali/public-api/animation/animation.h>
31 class CustomActor : public Actor
35 * Create a new custom actor.
36 * @return A smart-pointer to the newly allocated Actor.
38 static CustomActorPtr New(CustomActorImpl& extension);
41 * Retrieve the custom actor implementation.
42 * @return The implementation, or an invalid pointer if no implementation was set.
44 CustomActorImpl& GetImplementation()
50 * Retrieve the custom actor implementation.
51 * @return The implementation, or an invalid pointer if no implementation was set.
53 const CustomActorImpl& GetImplementation() const
59 * Get the type info associated with this object.
61 * @return The type info
63 Dali::TypeInfo GetTypeInfo();
66 * @copydoc Internal::CustomActorImpl::SetTransparent()
68 void SetTransparent(bool transparent) override
70 Actor::SetTransparent(transparent);
74 * @copydoc Internal::CustomActorImpl::GetTransparent()
76 bool GetTransparent() const override
78 return Actor::GetTransparent();
83 * A reference counted object may only be deleted by calling Unreference()
85 ~CustomActor() override;
89 * @copydoc Internal::Actor::OnSceneConnectionExternal
91 void OnSceneConnectionExternal(int32_t depth) override
93 mImpl->OnSceneConnection(depth);
97 * @copydoc Internal::Actor::OnSceneDisconnectionExternal
99 void OnSceneDisconnectionExternal() override
101 mImpl->OnSceneDisconnection();
105 * @copydoc Internal::Actor::OnChildAdd
107 void OnChildAdd(Actor& child) override
109 Dali::Actor handle(&child);
110 mImpl->OnChildAdd(handle);
114 * @copydoc Internal::Actor::OnChildRemove
116 void OnChildRemove(Actor& child) override
118 Dali::Actor handle(&child);
119 mImpl->OnChildRemove(handle);
123 * @copydoc Internal::Actor::OnPropertySet
125 void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override
127 mImpl->OnPropertySet(index, propertyValue);
131 * @copydoc Internal::Actor::OnSizeSet
133 void OnSizeSet(const Vector3& targetSize) override
135 mImpl->OnSizeSet(targetSize);
139 * @copydoc Internal::Actor::OnSizeAnimation
141 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override
143 Dali::Animation animationHandle(&animation);
144 mImpl->OnSizeAnimation(animationHandle, targetSize);
148 * @copydoc Internal::Actor::OnRelayout
150 void OnRelayout(const Vector2& size, RelayoutContainer& container) override
152 mImpl->OnRelayout(size, container);
156 * @copydoc Internal::Actor::OnSetResizePolicy
158 void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override
160 mImpl->OnSetResizePolicy(policy, dimension);
164 * @copydoc Internal::Actor::GetNaturalSize
166 Vector3 GetNaturalSize() const override
168 return mImpl->GetNaturalSize();
172 * @copydoc Internal::Actor::CalculateChildSize
174 float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override
176 return mImpl->CalculateChildSize(child, dimension);
180 * @copydoc Internal::Actor::GetHeightForWidth
182 float GetHeightForWidth(float width) override
184 return mImpl->GetHeightForWidth(width);
188 * @copydoc Internal::Actor::GetWidthForHeight
190 float GetWidthForHeight(float height) override
192 return mImpl->GetWidthForHeight(height);
196 * @copydoc Internal::Actor::RelayoutDependentOnChildren
198 bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override
200 return mImpl->RelayoutDependentOnChildren(dimension);
204 * @copydoc Internal::Actor::OnCalculateRelayoutSize
206 void OnCalculateRelayoutSize(Dimension::Type dimension) override
208 return mImpl->OnCalculateRelayoutSize(dimension);
212 * @copydoc Internal::Actor::OnLayoutNegotiated
214 void OnLayoutNegotiated(float size, Dimension::Type dimension) override
216 return mImpl->OnLayoutNegotiated(size, dimension);
220 * Private constructor; see also CustomActor::New()
222 CustomActor(const SceneGraph::Node& node, CustomActorImpl& extension);
224 // no default or copy constructor or assignment
225 CustomActor() = delete;
226 CustomActor(const CustomActor&) = delete;
227 CustomActor& operator=(const CustomActor& rhs) = delete;
230 CustomActorImplPtr mImpl;
233 } // namespace Internal
235 // Helpers for public-api forwarding methods
237 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
239 DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
241 BaseObject& handle = actor.GetBaseObject();
243 return static_cast<Internal::CustomActor&>(handle);
246 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
248 DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
250 const BaseObject& handle = actor.GetBaseObject();
252 return static_cast<const Internal::CustomActor&>(handle);
257 #endif // DALI_INTERNAL_CUSTOM_ACTOR_H