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