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();
67 * A reference counted object may only be deleted by calling Unreference()
69 ~CustomActor() override;
73 * @copydoc Internal::Actor::OnSceneConnectionExternal
75 void OnSceneConnectionExternal(int32_t depth) override
77 mImpl->OnSceneConnection(depth);
81 * @copydoc Internal::Actor::OnSceneDisconnectionExternal
83 void OnSceneDisconnectionExternal() override
85 mImpl->OnSceneDisconnection();
89 * @copydoc Internal::Actor::OnChildAdd
91 void OnChildAdd(Actor& child) override
93 Dali::Actor handle(&child);
94 mImpl->OnChildAdd(handle);
98 * @copydoc Internal::Actor::OnChildRemove
100 void OnChildRemove(Actor& child) override
102 Dali::Actor handle(&child);
103 mImpl->OnChildRemove(handle);
107 * @copydoc Internal::Actor::OnPropertySet
109 void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override
111 mImpl->OnPropertySet(index, propertyValue);
115 * @copydoc Internal::Actor::OnSizeSet
117 void OnSizeSet(const Vector3& targetSize) override
119 mImpl->OnSizeSet(targetSize);
123 * @copydoc Internal::Actor::OnSizeAnimation
125 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override
127 Dali::Animation animationHandle(&animation);
128 mImpl->OnSizeAnimation(animationHandle, targetSize);
132 * @copydoc Internal::Actor::OnRelayout
134 void OnRelayout(const Vector2& size, RelayoutContainer& container) override
136 mImpl->OnRelayout(size, container);
140 * @copydoc Internal::Actor::OnSetResizePolicy
142 void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override
144 mImpl->OnSetResizePolicy(policy, dimension);
148 * @copydoc Internal::Actor::GetNaturalSize
150 Vector3 GetNaturalSize() const override
152 return mImpl->GetNaturalSize();
156 * @copydoc Internal::Actor::CalculateChildSize
158 float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override
160 return mImpl->CalculateChildSize(child, dimension);
164 * @copydoc Internal::Actor::GetHeightForWidth
166 float GetHeightForWidth(float width) override
168 return mImpl->GetHeightForWidth(width);
172 * @copydoc Internal::Actor::GetWidthForHeight
174 float GetWidthForHeight(float height) override
176 return mImpl->GetWidthForHeight(height);
180 * @copydoc Internal::Actor::RelayoutDependentOnChildren
182 bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override
184 return mImpl->RelayoutDependentOnChildren(dimension);
188 * @copydoc Internal::Actor::OnCalculateRelayoutSize
190 void OnCalculateRelayoutSize(Dimension::Type dimension) override
192 return mImpl->OnCalculateRelayoutSize(dimension);
196 * @copydoc Internal::Actor::OnLayoutNegotiated
198 void OnLayoutNegotiated(float size, Dimension::Type dimension) override
200 return mImpl->OnLayoutNegotiated(size, dimension);
204 * Private constructor; see also CustomActor::New()
206 CustomActor(const SceneGraph::Node& node, CustomActorImpl& extension);
208 // no default or copy constructor or assignment
209 CustomActor() = delete;
210 CustomActor(const CustomActor&) = delete;
211 CustomActor& operator=(const CustomActor& rhs) = delete;
214 CustomActorImplPtr mImpl;
217 } // namespace Internal
219 // Helpers for public-api forwarding methods
221 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
223 DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
225 BaseObject& handle = actor.GetBaseObject();
227 return static_cast<Internal::CustomActor&>(handle);
230 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
232 DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
234 const BaseObject& handle = actor.GetBaseObject();
236 return static_cast<const Internal::CustomActor&>(handle);
241 #endif // DALI_INTERNAL_CUSTOM_ACTOR_H