Add move semantics to commonly used classes in dali-core
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/actors/actor.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/layer.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/common/dali-common.h>
25 #include <dali/public-api/math/radian.h>
26 #include <dali/public-api/math/vector2.h>
27
28 #include <dali/internal/event/actors/actor-impl.h>
29 #include <dali/internal/event/actors/layer-impl.h>
30 #include <dali/internal/event/rendering/renderer-impl.h>
31 #include <dali/internal/event/animation/constraint-impl.h>
32 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
33
34 namespace Dali
35 {
36
37 Actor::Actor()
38 {
39 }
40
41 Actor Actor::New()
42 {
43   Internal::ActorPtr internal = Internal::Actor::New();
44
45   return Actor(internal.Get());
46 }
47
48 Actor Actor::DownCast( BaseHandle handle )
49 {
50   return Actor( dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()) );
51 }
52
53 Actor::~Actor()
54 {
55 }
56
57 Actor::Actor(const Actor& copy)
58 : Handle(copy)
59 {
60 }
61
62 Actor& Actor::operator=(const Actor& rhs)
63 {
64   BaseHandle::operator=(rhs);
65   return *this;
66 }
67
68 Actor::Actor( Actor&& rhs ) = default;
69
70 Actor& Actor::operator=( Actor&& rhs ) = default;
71
72 Layer Actor::GetLayer()
73 {
74   return GetImplementation(*this).GetLayer();
75 }
76
77 void Actor::Add(Actor actor)
78 {
79   GetImplementation(*this).Add(GetImplementation(actor));
80 }
81
82 void Actor::Remove(Actor actor)
83 {
84   GetImplementation(*this).Remove(GetImplementation(actor));
85 }
86
87 void Actor::Unparent()
88 {
89   GetImplementation(*this).Unparent();
90 }
91
92 uint32_t Actor::GetChildCount() const
93 {
94   return GetImplementation(*this).GetChildCount();
95 }
96
97 Actor Actor::GetChildAt( uint32_t index ) const
98 {
99   Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
100   return Actor( child.Get() );
101 }
102
103 Actor Actor::FindChildByName(const std::string& actorName)
104 {
105   Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
106   return Actor( child.Get() );
107 }
108
109 Actor Actor::FindChildById( const uint32_t id )
110 {
111   Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
112   return Actor( child.Get() );
113 }
114
115 Actor Actor::GetParent() const
116 {
117   Internal::Actor* parent = GetImplementation(*this).GetParent();
118
119   return Actor(parent);
120 }
121
122 Vector3 Actor::GetTargetSize() const
123 {
124   return GetImplementation(*this).GetTargetSize();
125 }
126
127 Vector3 Actor::GetNaturalSize() const
128 {
129   return GetImplementation(*this).GetNaturalSize();
130 }
131
132 void Actor::TranslateBy(const Vector3& distance)
133 {
134   GetImplementation(*this).TranslateBy(distance);
135 }
136
137 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
138 {
139   GetImplementation(*this).RotateBy(angle, axis);
140 }
141
142 void Actor::RotateBy(const Quaternion& relativeRotation)
143 {
144   GetImplementation(*this).RotateBy(relativeRotation);
145 }
146
147 void Actor::ScaleBy(const Vector3& relativeScale)
148 {
149   GetImplementation(*this).ScaleBy(relativeScale);
150 }
151
152 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
153 {
154   return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
155 }
156
157 void Actor::Raise()
158 {
159   GetImplementation( *this ).Raise();
160 }
161
162 void Actor::Lower()
163 {
164   GetImplementation( *this ).Lower();
165 }
166
167 void Actor::RaiseToTop()
168 {
169   GetImplementation( *this ).RaiseToTop();
170 }
171
172 void Actor::LowerToBottom()
173 {
174   GetImplementation( *this ).LowerToBottom();
175 }
176
177 void Actor::RaiseAbove( Actor target )
178 {
179   GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
180 }
181
182 void Actor::LowerBelow( Actor target )
183 {
184   GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
185 }
186
187 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
188 {
189   GetImplementation(*this).SetResizePolicy( policy, dimension );
190 }
191
192 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
193 {
194   return GetImplementation(*this).GetResizePolicy( dimension );
195 }
196
197 float Actor::GetHeightForWidth( float width )
198 {
199   return GetImplementation(*this).GetHeightForWidth( width );
200 }
201
202 float Actor::GetWidthForHeight( float height )
203 {
204   return GetImplementation(*this).GetWidthForHeight( height );
205 }
206
207 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
208 {
209   return GetImplementation(*this).GetRelayoutSize( dimension );
210 }
211
212 Actor::TouchSignalType& Actor::TouchedSignal()
213 {
214   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
215
216   return GetImplementation(*this).TouchedSignal();
217 }
218
219 Actor::TouchDataSignalType& Actor::TouchSignal()
220 {
221   return GetImplementation( *this ).TouchSignal();
222 }
223
224 Actor::HoverSignalType& Actor::HoveredSignal()
225 {
226   return GetImplementation(*this).HoveredSignal();
227 }
228
229 Actor::WheelEventSignalType& Actor::WheelEventSignal()
230 {
231   return GetImplementation(*this).WheelEventSignal();
232 }
233
234 Actor::OnStageSignalType& Actor::OnStageSignal()
235 {
236   return GetImplementation(*this).OnStageSignal();
237 }
238
239 Actor::OffStageSignalType& Actor::OffStageSignal()
240 {
241   return GetImplementation(*this).OffStageSignal();
242 }
243
244 uint32_t Actor::AddRenderer( Renderer& renderer )
245 {
246   return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
247 }
248
249 uint32_t Actor::GetRendererCount() const
250 {
251   return GetImplementation(*this).GetRendererCount();
252 }
253
254 Renderer Actor::GetRendererAt( uint32_t index )
255 {
256   Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
257   return Renderer( renderer.Get() );
258 }
259
260 void Actor::RemoveRenderer( Renderer& renderer )
261 {
262   GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
263 }
264
265 void Actor::RemoveRenderer( uint32_t index )
266 {
267   GetImplementation(*this).RemoveRenderer( index );
268 }
269
270 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
271 {
272   return GetImplementation(*this).OnRelayoutSignal();
273 }
274
275 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
276 {
277   return GetImplementation( *this ).LayoutDirectionChangedSignal();
278 }
279
280 Actor::Actor(Internal::Actor* internal)
281 : Handle(internal)
282 {
283 }
284
285 } // namespace Dali