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::OnTouchEvent
139 virtual bool OnTouchEvent(const TouchEvent& event)
141 return mImpl->OnTouchEvent(event);
145 * @copydoc Internal::Actor::OnHoverEvent
147 virtual bool OnHoverEvent(const HoverEvent& event)
149 return mImpl->OnHoverEvent(event);
153 * @copydoc Internal::Actor::OnKeyEvent
155 virtual bool OnKeyEvent(const KeyEvent& event)
157 return mImpl->OnKeyEvent(event);
161 * @copydoc Internal::Actor::OnWheelEvent
163 virtual bool OnWheelEvent(const WheelEvent& event)
165 return mImpl->OnWheelEvent(event);
169 * @copydoc Internal::Actor::OnRelayout
171 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
173 mImpl->OnRelayout( size, container );
177 * @copydoc Internal::Actor::OnSetResizePolicy
179 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
181 mImpl->OnSetResizePolicy( policy, dimension );
185 * @copydoc Internal::Actor::GetNaturalSize
187 virtual Vector3 GetNaturalSize() const
189 return mImpl->GetNaturalSize();
193 * @copydoc Internal::Actor::CalculateChildSize
195 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
197 return mImpl->CalculateChildSize( child, dimension );
201 * @copydoc Internal::Actor::GetHeightForWidth
203 virtual float GetHeightForWidth( float width )
205 return mImpl->GetHeightForWidth( width );
209 * @copydoc Internal::Actor::GetWidthForHeight
211 virtual float GetWidthForHeight( float height )
213 return mImpl->GetWidthForHeight( height );
217 * @copydoc Internal::Actor::RelayoutDependentOnChildren
219 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
221 return mImpl->RelayoutDependentOnChildren( dimension );
225 * @copydoc Internal::Actor::OnCalculateRelayoutSize
227 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
229 return mImpl->OnCalculateRelayoutSize( dimension );
233 * @copydoc Internal::Actor::OnLayoutNegotiated
235 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
237 return mImpl->OnLayoutNegotiated( size, dimension );
241 * Private constructor; see also CustomActor::New()
243 CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension );
245 // no default or copy constructor or assignment
246 CustomActor() = delete;
247 CustomActor( const CustomActor& ) = delete;
248 CustomActor& operator=( const CustomActor& rhs ) = delete;
252 CustomActorImplPtr mImpl;
256 } // namespace Internal
258 // Helpers for public-api forwarding methods
260 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
262 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
264 BaseObject& handle = actor.GetBaseObject();
266 return static_cast<Internal::CustomActor&>(handle);
269 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
271 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
273 const BaseObject& handle = actor.GetBaseObject();
275 return static_cast<const Internal::CustomActor&>(handle);
280 #endif // DALI_INTERNAL_CUSTOM_ACTOR_H