1 #ifndef __DALI_INTERNAL_CUSTOM_ACTOR_H__
2 #define __DALI_INTERNAL_CUSTOM_ACTOR_H__
5 * Copyright (c) 2014 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
64 * A reference counted object may only be deleted by calling Unreference()
66 virtual ~CustomActor();
71 * @copydoc Internal::Actor::OnStageConnectionExternal
73 virtual void OnStageConnectionExternal()
75 mImpl->OnStageConnection();
79 * @copydoc Internal::Actor::OnStageDisconnectionExternal
81 virtual void OnStageDisconnectionExternal()
83 mImpl->OnStageDisconnection();
87 * @copydoc Internal::Actor::OnChildAdd
89 virtual void OnChildAdd(Actor& child)
91 Dali::Actor handle(&child);
92 mImpl->OnChildAdd(handle);
96 * @copydoc Internal::Actor::OnChildRemove
98 virtual void OnChildRemove(Actor& child)
100 Dali::Actor handle(&child);
101 mImpl->OnChildRemove(handle);
105 * @copydoc Internal::Actor::OnPropertySet
107 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
109 mImpl->OnPropertySet(index, propertyValue);
113 * @copydoc Internal::Actor::OnSizeSet
115 virtual void OnSizeSet(const Vector3& targetSize)
117 mImpl->OnSizeSet(targetSize);
121 * @copydoc Internal::Actor::OnSizeAnimation
123 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
125 Dali::Animation animationHandle(&animation);
126 mImpl->OnSizeAnimation(animationHandle, targetSize);
130 * @copydoc Internal::Actor::OnTouchEvent
132 virtual bool OnTouchEvent(const TouchEvent& event)
134 return mImpl->OnTouchEvent(event);
138 * @copydoc Internal::Actor::OnHoverEvent
140 virtual bool OnHoverEvent(const HoverEvent& event)
142 return mImpl->OnHoverEvent(event);
146 * @copydoc Internal::Actor::OnKeyEvent
148 virtual bool OnKeyEvent(const KeyEvent& event)
150 return mImpl->OnKeyEvent(event);
154 * @copydoc Internal::Actor::OnMouseWheelEvent
156 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
158 return mImpl->OnMouseWheelEvent(event);
162 * @copydoc Internal::Actor::OnRelayout
164 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
166 mImpl->OnRelayout( size, container );
170 * @copydoc Internal::Actor::OnSetResizePolicy
172 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
174 mImpl->OnSetResizePolicy( policy, dimension );
178 * @copydoc Internal::Actor::GetNaturalSize
180 virtual Vector3 GetNaturalSize() const
182 return mImpl->GetNaturalSize();
186 * @copydoc Internal::Actor::CalculateChildSize
188 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
190 return mImpl->CalculateChildSize( child, dimension );
194 * @copydoc Internal::Actor::GetHeightForWidth
196 virtual float GetHeightForWidth( float width )
198 return mImpl->GetHeightForWidth( width );
202 * @copydoc Internal::Actor::GetWidthForHeight
204 virtual float GetWidthForHeight( float height )
206 return mImpl->GetWidthForHeight( height );
210 * @copydoc Internal::Actor::RelayoutDependentOnChildren
212 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
214 return mImpl->RelayoutDependentOnChildren( dimension );
218 * @copydoc Internal::Actor::OnCalculateRelayoutSize
220 virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
222 return mImpl->OnCalculateRelayoutSize( dimension );
226 * @copydoc Internal::Actor::OnLayoutNegotiated
228 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
230 return mImpl->OnLayoutNegotiated( size, dimension );
234 * Private constructor; see also CustomActor::New()
236 CustomActor(CustomActorImpl& extension);
239 CustomActor(const CustomActor&);
242 CustomActor& operator=(const CustomActor& rhs);
246 CustomActorImplPtr mImpl;
249 } // namespace Internal
251 // Helpers for public-api forwarding methods
253 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
255 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
257 BaseObject& handle = actor.GetBaseObject();
259 return static_cast<Internal::CustomActor&>(handle);
262 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
264 DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
266 const BaseObject& handle = actor.GetBaseObject();
268 return static_cast<const Internal::CustomActor&>(handle);
273 #endif // __DALI_INTERNAL_CUSTOM_ACTOR_H__