use modern construct 'override' in the derive class.
[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) 2020 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   /**
62    * Get the type info associated with this object.
63    *
64    * @return The type info
65    */
66   Dali::TypeInfo GetTypeInfo();
67
68 protected:
69
70   /**
71    * A reference counted object may only be deleted by calling Unreference()
72    */
73   ~CustomActor() override;
74
75 private:
76
77   /**
78    * @copydoc Internal::Actor::OnSceneConnectionExternal
79    */
80   void OnSceneConnectionExternal( int32_t depth ) override
81   {
82     mImpl->OnSceneConnection( depth );
83   }
84
85   /**
86    * @copydoc Internal::Actor::OnSceneDisconnectionExternal
87    */
88   void OnSceneDisconnectionExternal() override
89   {
90     mImpl->OnSceneDisconnection();
91   }
92
93   /**
94    * @copydoc Internal::Actor::OnChildAdd
95    */
96   void OnChildAdd(Actor& child) override
97   {
98     Dali::Actor handle(&child);
99     mImpl->OnChildAdd(handle);
100   }
101
102   /**
103    * @copydoc Internal::Actor::OnChildRemove
104    */
105   void OnChildRemove(Actor& child) override
106   {
107     Dali::Actor handle(&child);
108     mImpl->OnChildRemove(handle);
109   }
110
111   /**
112    * @copydoc Internal::Actor::OnPropertySet
113    */
114   void OnPropertySet( Property::Index index, const Property::Value& propertyValue ) override
115   {
116     mImpl->OnPropertySet(index, propertyValue);
117   }
118
119   /**
120    * @copydoc Internal::Actor::OnSizeSet
121    */
122   void OnSizeSet(const Vector3& targetSize) override
123   {
124     mImpl->OnSizeSet(targetSize);
125   }
126
127   /**
128    * @copydoc Internal::Actor::OnSizeAnimation
129    */
130   void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override
131   {
132     Dali::Animation animationHandle(&animation);
133     mImpl->OnSizeAnimation(animationHandle, targetSize);
134   }
135
136   /**
137    * @copydoc Internal::Actor::OnRelayout
138    */
139   void OnRelayout( const Vector2& size, RelayoutContainer& container ) override
140   {
141     mImpl->OnRelayout( size, container );
142   }
143
144   /**
145    * @copydoc Internal::Actor::OnSetResizePolicy
146    */
147   void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) override
148   {
149     mImpl->OnSetResizePolicy( policy, dimension );
150   }
151
152   /**
153    * @copydoc Internal::Actor::GetNaturalSize
154    */
155   Vector3 GetNaturalSize() const override
156   {
157     return mImpl->GetNaturalSize();
158   }
159
160   /**
161    * @copydoc Internal::Actor::CalculateChildSize
162    */
163   float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) override
164   {
165     return mImpl->CalculateChildSize( child, dimension );
166   }
167
168   /**
169    * @copydoc Internal::Actor::GetHeightForWidth
170    */
171   float GetHeightForWidth( float width ) override
172   {
173     return mImpl->GetHeightForWidth( width );
174   }
175
176   /**
177    * @copydoc Internal::Actor::GetWidthForHeight
178    */
179   float GetWidthForHeight( float height ) override
180   {
181     return mImpl->GetWidthForHeight( height );
182   }
183
184   /**
185    * @copydoc Internal::Actor::RelayoutDependentOnChildren
186    */
187   bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) override
188   {
189     return mImpl->RelayoutDependentOnChildren( dimension );
190   }
191
192   /**
193    * @copydoc Internal::Actor::OnCalculateRelayoutSize
194    */
195   void OnCalculateRelayoutSize( Dimension::Type dimension ) override
196   {
197     return mImpl->OnCalculateRelayoutSize( dimension );
198   }
199
200   /**
201    * @copydoc Internal::Actor::OnLayoutNegotiated
202    */
203   void OnLayoutNegotiated( float size, Dimension::Type dimension ) override
204   {
205     return mImpl->OnLayoutNegotiated( size, dimension );
206   }
207
208   /**
209    * Private constructor; see also CustomActor::New()
210    */
211   CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension );
212
213   // no default or copy constructor or assignment
214   CustomActor() = delete;
215   CustomActor( const CustomActor& ) = delete;
216   CustomActor& operator=( const CustomActor& rhs ) = delete;
217
218 protected:
219
220   CustomActorImplPtr mImpl;
221
222 };
223
224 } // namespace Internal
225
226 // Helpers for public-api forwarding methods
227
228 inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
229 {
230   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
231
232   BaseObject& handle = actor.GetBaseObject();
233
234   return static_cast<Internal::CustomActor&>(handle);
235 }
236
237 inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
238 {
239   DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
240
241   const BaseObject& handle = actor.GetBaseObject();
242
243   return static_cast<const Internal::CustomActor&>(handle);
244 }
245
246 } // namespace Dali
247
248 #endif // DALI_INTERNAL_CUSTOM_ACTOR_H