Add GetNaturalSize to Actor and deriving classes.
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / custom-actor-internal.h
1 #ifndef __DALI_INTERNAL_CUSTOM_ACTOR_H__
2 #define __DALI_INTERNAL_CUSTOM_ACTOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class CustomActor : public Actor
33 {
34 public:
35
36   /**
37    * Create a new custom actor.
38    * @return A smart-pointer to the newly allocated Actor.
39    */
40   static CustomActorPtr New(CustomActorImpl& extension);
41
42   /**
43    * Retrieve the custom actor implementation.
44    * @return The implementation, or an invalid pointer if no implementation was set.
45    */
46   CustomActorImpl& GetImplementation()
47   {
48     return *mImpl;
49   }
50
51   /**
52    * Retrieve the custom actor implementation.
53    * @return The implementation, or an invalid pointer if no implementation was set.
54    */
55   const CustomActorImpl& GetImplementation() const
56   {
57     return *mImpl;
58   }
59
60 protected:
61
62   /**
63    * A reference counted object may only be deleted by calling Unreference()
64    */
65   virtual ~CustomActor();
66
67 private:
68
69   /**
70    * @copydoc Internal::Actor::OnStageConnectionExternal
71    */
72   virtual void OnStageConnectionExternal()
73   {
74     mImpl->OnStageConnection();
75   }
76
77   /**
78    * @copydoc Internal::Actor::OnStageDisconnectionExternal
79    */
80   virtual void OnStageDisconnectionExternal()
81   {
82     mImpl->OnStageDisconnection();
83   }
84
85   /**
86    * @copydoc Internal::Actor::OnChildAdd
87    */
88   virtual void OnChildAdd(Actor& child)
89   {
90     Dali::Actor handle(&child);
91     mImpl->OnChildAdd(handle);
92   }
93
94   /**
95    * @copydoc Internal::Actor::OnChildRemove
96    */
97   virtual void OnChildRemove(Actor& child)
98   {
99     Dali::Actor handle(&child);
100     mImpl->OnChildRemove(handle);
101   }
102
103   /**
104    * @copydoc Internal::Actor::OnPropertySet
105    */
106   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
107   {
108     mImpl->OnPropertySet(index, propertyValue);
109   }
110
111   /**
112    * @copydoc Internal::Actor::OnSizeSet
113    */
114   virtual void OnSizeSet(const Vector3& targetSize)
115   {
116     mImpl->OnSizeSet(targetSize);
117   }
118
119   /**
120    * @copydoc Internal::Actor::OnSizeAnimation
121    */
122   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
123   {
124     Dali::Animation animationHandle(&animation);
125     mImpl->OnSizeAnimation(animationHandle, targetSize);
126   }
127
128   /**
129    * @copydoc Internal::Actor::OnTouchEvent
130    */
131   virtual bool OnTouchEvent(const TouchEvent& event)
132   {
133     return mImpl->OnTouchEvent(event);
134   }
135
136   /**
137    * @copydoc Internal::Actor::OnKeyEvent
138    */
139   virtual bool OnKeyEvent(const KeyEvent& event)
140   {
141     return mImpl->OnKeyEvent(event);
142   }
143
144   /**
145    * @copydoc Internal::Actor::OnMouseWheelEvent
146    */
147   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
148   {
149     return mImpl->OnMouseWheelEvent(event);
150   }
151
152   /**
153    * @copydoc Internal::Actor::GetChildByAlias
154    */
155   virtual Dali::Actor GetChildByAlias(const std::string& actorAlias)
156   {
157     return mImpl->GetChildByAlias(actorAlias);
158   }
159
160   /**
161    * @copydoc Internal::Actor::GetNaturalSize
162    */
163   virtual Vector3 GetNaturalSize() const
164   {
165     return mImpl->GetNaturalSize();
166   }
167
168   /**
169    * Private constructor; see also CustomActor::New()
170    */
171   CustomActor(CustomActorImpl& extension);
172
173   // Undefined
174   CustomActor(const CustomActor&);
175
176   // Undefined
177   CustomActor& operator=(const CustomActor& rhs);
178
179 protected:
180
181   CustomActorImplPtr mImpl;
182 };
183
184 } // namespace Internal
185
186 // Helpers for public-api forwarding methods
187
188 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
189 {
190   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
191
192   BaseObject& handle = actor.GetBaseObject();
193
194   return static_cast<Internal::CustomActor&>(handle);
195 }
196
197 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
198 {
199   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
200
201   const BaseObject& handle = actor.GetBaseObject();
202
203   return static_cast<const Internal::CustomActor&>(handle);
204 }
205
206 } // namespace Dali
207
208 #endif // __DALI_INTERNAL_CUSTOM_ACTOR_H__