1 #ifndef DALI_INTERNAL_CUSTOM_ACTOR_H
2 #define DALI_INTERNAL_CUSTOM_ACTOR_H
5 * Copyright (c) 2020 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-impl.h>
23 #include <dali/internal/event/actors/actor-declarations.h>
24 #include <dali/public-api/actors/custom-actor.h>
25 #include <dali/public-api/animation/animation.h>
33 class CustomActor : public Actor
38 * Create a new custom actor.
39 * @return A smart-pointer to the newly allocated Actor.
41 static CustomActorPtr New(CustomActorImpl& extension);
44 * Retrieve the custom actor implementation.
45 * @return The implementation, or an invalid pointer if no implementation was set.
47 CustomActorImpl& GetImplementation()
53 * Retrieve the custom actor implementation.
54 * @return The implementation, or an invalid pointer if no implementation was set.
56 const CustomActorImpl& GetImplementation() const
62 * Get the type info associated with this object.
64 * @return The type info
66 Dali::TypeInfo GetTypeInfo();
71 * A reference counted object may only be deleted by calling Unreference()
73 virtual ~CustomActor();
78 * @copydoc Internal::Actor::OnSceneConnectionExternal
80 virtual void OnSceneConnectionExternal( int32_t depth )
82 mImpl->OnSceneConnection( depth );
86 * @copydoc Internal::Actor::OnSceneDisconnectionExternal
88 virtual void OnSceneDisconnectionExternal()
90 mImpl->OnSceneDisconnection();
94 * @copydoc Internal::Actor::OnChildAdd
96 virtual void OnChildAdd(Actor& child)
98 Dali::Actor handle(&child);
99 mImpl->OnChildAdd(handle);
103 * @copydoc Internal::Actor::OnChildRemove
105 virtual void OnChildRemove(Actor& child)
107 Dali::Actor handle(&child);
108 mImpl->OnChildRemove(handle);
112 * @copydoc Internal::Actor::OnPropertySet
114 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
116 mImpl->OnPropertySet(index, propertyValue);
120 * @copydoc Internal::Actor::OnSizeSet
122 virtual void OnSizeSet(const Vector3& targetSize)
124 mImpl->OnSizeSet(targetSize);
128 * @copydoc Internal::Actor::OnSizeAnimation
130 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
132 Dali::Animation animationHandle(&animation);
133 mImpl->OnSizeAnimation(animationHandle, targetSize);
137 * @copydoc Internal::Actor::OnHoverEvent
139 virtual bool OnHoverEvent(const HoverEvent& event)
141 return mImpl->OnHoverEvent(event);
145 * @copydoc Internal::Actor::OnKeyEvent
147 virtual bool OnKeyEvent(const KeyEvent& event)
149 return mImpl->OnKeyEvent(event);
153 * @copydoc Internal::Actor::OnWheelEvent
155 virtual bool OnWheelEvent(const WheelEvent& event)
157 return mImpl->OnWheelEvent(event);
161 * @copydoc Internal::Actor::OnRelayout
163 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
165 mImpl->OnRelayout( size, container );
169 * @copydoc Internal::Actor::OnSetResizePolicy
171 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
173 mImpl->OnSetResizePolicy( policy, dimension );
177 * @copydoc Internal::Actor::GetNaturalSize
179 virtual Vector3 GetNaturalSize() const
181 return mImpl->GetNaturalSize();
185 * @copydoc Internal::Actor::CalculateChildSize
187 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
189 return mImpl->CalculateChildSize( child, dimension );
193 * @copydoc Internal::Actor::GetHeightForWidth
195 virtual float GetHeightForWidth( float width )
197 return mImpl->GetHeightForWidth( width );
201 * @copydoc Internal::Actor::GetWidthForHeight
203 virtual float GetWidthForHeight( float height )
205 return mImpl->GetWidthForHeight( height );
209 * @copydoc Internal::Actor::RelayoutDependentOnChildren
211 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
213 return mImpl->RelayoutDependentOnChildren( dimension );
217 * @copydoc Internal::Actor::OnCalculateRelayoutSize
219 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
221 return mImpl->OnCalculateRelayoutSize( dimension );
225 * @copydoc Internal::Actor::OnLayoutNegotiated
227 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
229 return mImpl->OnLayoutNegotiated( size, dimension );
233 * Private constructor; see also CustomActor::New()
235 CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension );
237 // no default or copy constructor or assignment
238 CustomActor() = delete;
239 CustomActor( const CustomActor& ) = delete;
240 CustomActor& operator=( const CustomActor& rhs ) = delete;
244 CustomActorImplPtr mImpl;
248 } // namespace Internal
250 // Helpers for public-api forwarding methods
252 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
254 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
256 BaseObject& handle = actor.GetBaseObject();
258 return static_cast<Internal::CustomActor&>(handle);
261 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
263 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
265 const BaseObject& handle = actor.GetBaseObject();
267 return static_cast<const Internal::CustomActor&>(handle);
272 #endif // DALI_INTERNAL_CUSTOM_ACTOR_H