[dali_1.0.17] Merge branch 'tizen'
[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::OnMouseWheelEvent
155    */
156   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event)
157   {
158     return mImpl->OnMouseWheelEvent(event);
159   }
160
161   /**
162    * @copydoc Internal::Actor::GetChildByAlias
163    */
164   virtual Dali::Actor GetChildByAlias(const std::string& actorAlias)
165   {
166     return mImpl->GetChildByAlias(actorAlias);
167   }
168
169   /**
170    * @copydoc Internal::Actor::GetNaturalSize
171    */
172   virtual Vector3 GetNaturalSize() const
173   {
174     return mImpl->GetNaturalSize();
175   }
176
177   /**
178    * Private constructor; see also CustomActor::New()
179    */
180   CustomActor(CustomActorImpl& extension);
181
182   // Undefined
183   CustomActor(const CustomActor&);
184
185   // Undefined
186   CustomActor& operator=(const CustomActor& rhs);
187
188 protected:
189
190   CustomActorImplPtr mImpl;
191 };
192
193 } // namespace Internal
194
195 // Helpers for public-api forwarding methods
196
197 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
198 {
199   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
200
201   BaseObject& handle = actor.GetBaseObject();
202
203   return static_cast<Internal::CustomActor&>(handle);
204 }
205
206 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
207 {
208   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
209
210   const BaseObject& handle = actor.GetBaseObject();
211
212   return static_cast<const Internal::CustomActor&>(handle);
213 }
214
215 } // namespace Dali
216
217 #endif // __DALI_INTERNAL_CUSTOM_ACTOR_H__