Merge "Remove extension from shader." into devel/new_mesh
[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 #include <dali/public-api/animation/animation.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class CustomActor : public Actor
34 {
35 public:
36
37   /**
38    * Create a new custom actor.
39    * @return A smart-pointer to the newly allocated Actor.
40    */
41   static CustomActorPtr New(CustomActorImpl& extension);
42
43   /**
44    * Retrieve the custom actor implementation.
45    * @return The implementation, or an invalid pointer if no implementation was set.
46    */
47   CustomActorImpl& GetImplementation()
48   {
49     return *mImpl;
50   }
51
52   /**
53    * Retrieve the custom actor implementation.
54    * @return The implementation, or an invalid pointer if no implementation was set.
55    */
56   const CustomActorImpl& GetImplementation() const
57   {
58     return *mImpl;
59   }
60
61 protected:
62
63   /**
64    * A reference counted object may only be deleted by calling Unreference()
65    */
66   virtual ~CustomActor();
67
68 private:
69
70   /**
71    * @copydoc Internal::Actor::OnStageConnectionExternal
72    */
73   virtual void OnStageConnectionExternal()
74   {
75     mImpl->OnStageConnection();
76   }
77
78   /**
79    * @copydoc Internal::Actor::OnStageDisconnectionExternal
80    */
81   virtual void OnStageDisconnectionExternal()
82   {
83     mImpl->OnStageDisconnection();
84   }
85
86   /**
87    * @copydoc Internal::Actor::OnChildAdd
88    */
89   virtual void OnChildAdd(Actor& child)
90   {
91     Dali::Actor handle(&child);
92     mImpl->OnChildAdd(handle);
93   }
94
95   /**
96    * @copydoc Internal::Actor::OnChildRemove
97    */
98   virtual void OnChildRemove(Actor& child)
99   {
100     Dali::Actor handle(&child);
101     mImpl->OnChildRemove(handle);
102   }
103
104   /**
105    * @copydoc Internal::Actor::OnPropertySet
106    */
107   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
108   {
109     mImpl->OnPropertySet(index, propertyValue);
110   }
111
112   /**
113    * @copydoc Internal::Actor::OnSizeSet
114    */
115   virtual void OnSizeSet(const Vector3& targetSize)
116   {
117     mImpl->OnSizeSet(targetSize);
118   }
119
120   /**
121    * @copydoc Internal::Actor::OnSizeAnimation
122    */
123   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
124   {
125     Dali::Animation animationHandle(&animation);
126     mImpl->OnSizeAnimation(animationHandle, targetSize);
127   }
128
129   /**
130    * @copydoc Internal::Actor::OnTouchEvent
131    */
132   virtual bool OnTouchEvent(const TouchEvent& event)
133   {
134     return mImpl->OnTouchEvent(event);
135   }
136
137   /**
138    * @copydoc Internal::Actor::OnHoverEvent
139    */
140   virtual bool OnHoverEvent(const HoverEvent& event)
141   {
142     return mImpl->OnHoverEvent(event);
143   }
144
145   /**
146    * @copydoc Internal::Actor::OnKeyEvent
147    */
148   virtual bool OnKeyEvent(const KeyEvent& event)
149   {
150     return mImpl->OnKeyEvent(event);
151   }
152
153   /**
154    * @copydoc Internal::Actor::OnWheelEvent
155    */
156   virtual bool OnWheelEvent(const WheelEvent& event)
157   {
158     return mImpl->OnWheelEvent(event);
159   }
160
161   /**
162    * @copydoc Internal::Actor::OnRelayout
163    */
164   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
165   {
166     mImpl->OnRelayout( size, container );
167   }
168
169   /**
170    * @copydoc Internal::Actor::OnSetResizePolicy
171    */
172   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
173   {
174     mImpl->OnSetResizePolicy( policy, dimension );
175   }
176
177   /**
178    * @copydoc Internal::Actor::GetNaturalSize
179    */
180   virtual Vector3 GetNaturalSize() const
181   {
182     return mImpl->GetNaturalSize();
183   }
184
185   /**
186    * @copydoc Internal::Actor::CalculateChildSize
187    */
188   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
189   {
190     return mImpl->CalculateChildSize( child, dimension );
191   }
192
193   /**
194    * @copydoc Internal::Actor::GetHeightForWidth
195    */
196   virtual float GetHeightForWidth( float width )
197   {
198     return mImpl->GetHeightForWidth( width );
199   }
200
201   /**
202    * @copydoc Internal::Actor::GetWidthForHeight
203    */
204   virtual float GetWidthForHeight( float height )
205   {
206     return mImpl->GetWidthForHeight( height );
207   }
208
209   /**
210    * @copydoc Internal::Actor::RelayoutDependentOnChildren
211    */
212   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
213   {
214     return mImpl->RelayoutDependentOnChildren( dimension );
215   }
216
217   /**
218    * @copydoc Internal::Actor::OnCalculateRelayoutSize
219    */
220   virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
221   {
222     return mImpl->OnCalculateRelayoutSize( dimension );
223   }
224
225   /**
226    * @copydoc Internal::Actor::OnLayoutNegotiated
227    */
228   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
229   {
230     return mImpl->OnLayoutNegotiated( size, dimension );
231   }
232
233   /**
234    * Private constructor; see also CustomActor::New()
235    */
236   CustomActor(CustomActorImpl& extension);
237
238   // Undefined
239   CustomActor(const CustomActor&);
240
241   // Undefined
242   CustomActor& operator=(const CustomActor& rhs);
243
244 protected:
245
246   CustomActorImplPtr mImpl;
247 };
248
249 } // namespace Internal
250
251 // Helpers for public-api forwarding methods
252
253 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
254 {
255   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
256
257   BaseObject& handle = actor.GetBaseObject();
258
259   return static_cast<Internal::CustomActor&>(handle);
260 }
261
262 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
263 {
264   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
265
266   const BaseObject& handle = actor.GetBaseObject();
267
268   return static_cast<const Internal::CustomActor&>(handle);
269 }
270
271 } // namespace Dali
272
273 #endif // __DALI_INTERNAL_CUSTOM_ACTOR_H__