Remove deprecated APIs in Tizen 3.0
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
1 /*
2  * Copyright (c) 2017 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 const std::string& Actor::GetName() const
69 {
70   return GetImplementation(*this).GetName();
71 }
72
73 void Actor::SetName(const std::string& name)
74 {
75   GetImplementation(*this).SetName(name);
76 }
77
78 uint32_t Actor::GetId() const
79 {
80   return GetImplementation(*this).GetId();
81 }
82
83 bool Actor::IsRoot() const
84 {
85   return GetImplementation(*this).IsRoot();
86 }
87
88 bool Actor::OnStage() const
89 {
90   return GetImplementation(*this).OnStage();
91 }
92
93 bool Actor::IsLayer() const
94 {
95   return GetImplementation(*this).IsLayer();
96 }
97
98 Layer Actor::GetLayer()
99 {
100   return GetImplementation(*this).GetLayer();
101 }
102
103 void Actor::Add(Actor actor)
104 {
105   GetImplementation(*this).Add(GetImplementation(actor));
106 }
107
108 void Actor::Remove(Actor actor)
109 {
110   GetImplementation(*this).Remove(GetImplementation(actor));
111 }
112
113 void Actor::Unparent()
114 {
115   GetImplementation(*this).Unparent();
116 }
117
118 uint32_t Actor::GetChildCount() const
119 {
120   return GetImplementation(*this).GetChildCount();
121 }
122
123 Actor Actor::GetChildAt( uint32_t index ) const
124 {
125   Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
126   return Actor( child.Get() );
127 }
128
129 Actor Actor::FindChildByName(const std::string& actorName)
130 {
131   Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
132   return Actor( child.Get() );
133 }
134
135 Actor Actor::FindChildById( const uint32_t id )
136 {
137   Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
138   return Actor( child.Get() );
139 }
140
141 Actor Actor::GetParent() const
142 {
143   Internal::Actor* parent = GetImplementation(*this).GetParent();
144
145   return Actor(parent);
146 }
147
148 void Actor::SetParentOrigin(const Vector3& origin)
149 {
150   GetImplementation(*this).SetParentOrigin(origin);
151 }
152
153 Vector3 Actor::GetCurrentParentOrigin() const
154 {
155   return GetImplementation(*this).GetCurrentParentOrigin();
156 }
157
158 void Actor::SetAnchorPoint(const Vector3& anchorPoint)
159 {
160   GetImplementation(*this).SetAnchorPoint(anchorPoint);
161 }
162
163 Vector3 Actor::GetCurrentAnchorPoint() const
164 {
165   return GetImplementation(*this).GetCurrentAnchorPoint();
166 }
167
168 void Actor::SetSize(float width, float height)
169 {
170   GetImplementation(*this).SetSize(width, height);
171 }
172
173 void Actor::SetSize(float width, float height, float depth)
174 {
175   GetImplementation(*this).SetSize(width, height, depth);
176 }
177
178 void Actor::SetSize(const Vector2& size)
179 {
180   GetImplementation(*this).SetSize( size );
181 }
182
183 void Actor::SetSize(const Vector3& size)
184 {
185   GetImplementation(*this).SetSize( size );
186 }
187
188 Vector3 Actor::GetTargetSize() const
189 {
190   return GetImplementation(*this).GetTargetSize();
191 }
192
193 Vector3 Actor::GetCurrentSize() const
194 {
195   return GetImplementation(*this).GetCurrentSize();
196 }
197
198 Vector3 Actor::GetNaturalSize() const
199 {
200   return GetImplementation(*this).GetNaturalSize();
201 }
202
203 void Actor::SetPosition(float x, float y)
204 {
205   GetImplementation(*this).SetPosition(x, y);
206 }
207
208 void Actor::SetPosition(float x, float y, float z)
209 {
210   GetImplementation(*this).SetPosition(x, y, z);
211 }
212
213 void Actor::SetPosition(const Vector3& position)
214 {
215   GetImplementation(*this).SetPosition(position);
216 }
217
218 void Actor::SetX(float x)
219 {
220   GetImplementation(*this).SetX(x);
221 }
222
223 void Actor::SetY(float y)
224 {
225   GetImplementation(*this).SetY(y);
226 }
227
228 void Actor::SetZ(float z)
229 {
230   GetImplementation(*this).SetZ(z);
231 }
232
233 void Actor::TranslateBy(const Vector3& distance)
234 {
235   GetImplementation(*this).TranslateBy(distance);
236 }
237
238 Vector3 Actor::GetCurrentPosition() const
239 {
240   return GetImplementation(*this).GetCurrentPosition();
241 }
242
243 Vector3 Actor::GetCurrentWorldPosition() const
244 {
245   return GetImplementation(*this).GetCurrentWorldPosition();
246 }
247
248 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
249 {
250   GetImplementation(*this).SetOrientation(angle, axis);
251 }
252
253 void Actor::SetOrientation(const Quaternion& orientation)
254 {
255   GetImplementation(*this).SetOrientation(orientation);
256 }
257
258 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
259 {
260   GetImplementation(*this).RotateBy(angle, axis);
261 }
262
263 void Actor::RotateBy(const Quaternion& relativeRotation)
264 {
265   GetImplementation(*this).RotateBy(relativeRotation);
266 }
267
268 Quaternion Actor::GetCurrentOrientation() const
269 {
270   return GetImplementation(*this).GetCurrentOrientation();
271 }
272
273 void Actor::SetInheritOrientation(bool inherit)
274 {
275   GetImplementation(*this).SetInheritOrientation(inherit);
276 }
277
278 bool Actor::IsOrientationInherited() const
279 {
280   return GetImplementation(*this).IsOrientationInherited();
281 }
282
283 Quaternion Actor::GetCurrentWorldOrientation() const
284 {
285   return GetImplementation(*this).GetCurrentWorldOrientation();
286 }
287
288 void Actor::SetScale(float scale)
289 {
290   GetImplementation(*this).SetScale(scale);
291 }
292
293 void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
294 {
295   GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
296 }
297
298 void Actor::SetScale(const Vector3& scale)
299 {
300   GetImplementation(*this).SetScale(scale);
301 }
302
303 void Actor::ScaleBy(const Vector3& relativeScale)
304 {
305   GetImplementation(*this).ScaleBy(relativeScale);
306 }
307
308 Vector3 Actor::GetCurrentScale() const
309 {
310   return GetImplementation(*this).GetCurrentScale();
311 }
312
313 Vector3 Actor::GetCurrentWorldScale() const
314 {
315   return GetImplementation(*this).GetCurrentWorldScale();
316 }
317
318 void Actor::SetInheritScale( bool inherit )
319 {
320   GetImplementation(*this).SetInheritScale( inherit );
321 }
322
323 bool Actor::IsScaleInherited() const
324 {
325   return GetImplementation(*this).IsScaleInherited();
326 }
327
328 void Actor::SetSizeModeFactor(const Vector3& factor)
329 {
330   GetImplementation(*this).SetSizeModeFactor(factor);
331 }
332
333 Vector3 Actor::GetSizeModeFactor() const
334 {
335   return GetImplementation(*this).GetSizeModeFactor();
336 }
337
338 Matrix Actor::GetCurrentWorldMatrix() const
339 {
340   return GetImplementation(*this).GetCurrentWorldMatrix();
341 }
342
343 void Actor::SetVisible(bool visible)
344 {
345   GetImplementation(*this).SetVisible(visible);
346 }
347
348 bool Actor::IsVisible() const
349 {
350   return GetImplementation(*this).IsVisible();
351 }
352
353 void Actor::SetOpacity(float opacity)
354 {
355   GetImplementation(*this).SetOpacity(opacity);
356 }
357
358 float Actor::GetCurrentOpacity() const
359 {
360   return GetImplementation(*this).GetCurrentOpacity();
361 }
362
363 void Actor::SetColor(const Vector4& color)
364 {
365   GetImplementation(*this).SetColor(color);
366 }
367
368 Vector4 Actor::GetCurrentColor() const
369 {
370   return GetImplementation(*this).GetCurrentColor();
371 }
372
373 void Actor::SetColorMode( ColorMode colorMode )
374 {
375   GetImplementation(*this).SetColorMode(colorMode);
376 }
377
378 ColorMode Actor::GetColorMode() const
379 {
380   return GetImplementation(*this).GetColorMode();
381 }
382
383 Vector4 Actor::GetCurrentWorldColor() const
384 {
385   return GetImplementation(*this).GetCurrentWorldColor();
386 }
387
388 void Actor::SetDrawMode( DrawMode::Type drawMode )
389 {
390   GetImplementation(*this).SetDrawMode( drawMode );
391 }
392
393 DrawMode::Type Actor::GetDrawMode() const
394 {
395   return GetImplementation(*this).GetDrawMode();
396 }
397
398 void Actor::SetSensitive(bool sensitive)
399 {
400   GetImplementation(*this).SetSensitive(sensitive);
401 }
402
403 bool Actor::IsSensitive() const
404 {
405   return GetImplementation(*this).IsSensitive();
406 }
407
408 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
409 {
410   return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
411 }
412
413 void Actor::SetLeaveRequired(bool required)
414 {
415   GetImplementation(*this).SetLeaveRequired(required);
416 }
417
418 bool Actor::GetLeaveRequired() const
419 {
420   return GetImplementation(*this).GetLeaveRequired();
421 }
422
423 void Actor::SetKeyboardFocusable( bool focusable )
424 {
425   GetImplementation(*this).SetKeyboardFocusable(focusable);
426 }
427
428 bool Actor::IsKeyboardFocusable() const
429 {
430   return GetImplementation(*this).IsKeyboardFocusable();
431 }
432
433 void Actor::Raise()
434 {
435   GetImplementation( *this ).Raise();
436 }
437
438 void Actor::Lower()
439 {
440   GetImplementation( *this ).Lower();
441 }
442
443 void Actor::RaiseToTop()
444 {
445   GetImplementation( *this ).RaiseToTop();
446 }
447
448 void Actor::LowerToBottom()
449 {
450   GetImplementation( *this ).LowerToBottom();
451 }
452
453 void Actor::RaiseAbove( Actor target )
454 {
455   GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
456 }
457
458 void Actor::LowerBelow( Actor target )
459 {
460   GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
461 }
462
463 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
464 {
465   GetImplementation(*this).SetResizePolicy( policy, dimension );
466 }
467
468 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
469 {
470   return GetImplementation(*this).GetResizePolicy( dimension );
471 }
472
473 void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
474 {
475   GetImplementation(*this).SetSizeScalePolicy( policy );
476 }
477
478 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
479 {
480   return GetImplementation(*this).GetSizeScalePolicy();
481 }
482
483 float Actor::GetHeightForWidth( float width )
484 {
485   return GetImplementation(*this).GetHeightForWidth( width );
486 }
487
488 float Actor::GetWidthForHeight( float height )
489 {
490   return GetImplementation(*this).GetWidthForHeight( height );
491 }
492
493 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
494 {
495   return GetImplementation(*this).GetRelayoutSize( dimension );
496 }
497
498 void Actor::SetPadding( const Padding& padding )
499 {
500   Internal::Actor& impl = GetImplementation(*this);
501
502   Vector2 widthPadding( padding.left, padding.right );
503   impl.SetPadding( widthPadding, Dimension::WIDTH );
504
505   Vector2 heightPadding( padding.bottom, padding.top );
506   impl.SetPadding( heightPadding, Dimension::HEIGHT );
507 }
508
509 void Actor::GetPadding( Padding& paddingOut ) const
510 {
511   const Internal::Actor& impl = GetImplementation(*this);
512
513   Vector2 widthPadding = impl.GetPadding( Dimension::WIDTH );
514   Vector2 heightPadding = impl.GetPadding( Dimension::HEIGHT );
515
516   paddingOut.left = widthPadding.x;
517   paddingOut.right = widthPadding.y;
518   paddingOut.bottom = heightPadding.x;
519   paddingOut.top = heightPadding.y;
520 }
521
522 void Actor::SetMinimumSize( const Vector2& size )
523 {
524   Internal::Actor& impl = GetImplementation(*this);
525
526   impl.SetMinimumSize( size.x, Dimension::WIDTH );
527   impl.SetMinimumSize( size.y, Dimension::HEIGHT );
528 }
529
530 Vector2 Actor::GetMinimumSize()
531 {
532   Internal::Actor& impl = GetImplementation(*this);
533
534   return Vector2( impl.GetMinimumSize( Dimension::WIDTH ), impl.GetMinimumSize( Dimension::HEIGHT ) );
535 }
536
537 void Actor::SetMaximumSize( const Vector2& size )
538 {
539   Internal::Actor& impl = GetImplementation(*this);
540
541   impl.SetMaximumSize( size.x, Dimension::WIDTH );
542   impl.SetMaximumSize( size.y, Dimension::HEIGHT );
543 }
544
545 Vector2 Actor::GetMaximumSize()
546 {
547   Internal::Actor& impl = GetImplementation(*this);
548
549   return Vector2( impl.GetMaximumSize( Dimension::WIDTH ), impl.GetMaximumSize( Dimension::HEIGHT ) );
550 }
551
552 int32_t Actor::GetHierarchyDepth()
553 {
554   return GetImplementation(*this).GetHierarchyDepth();
555 }
556
557 Actor::TouchSignalType& Actor::TouchedSignal()
558 {
559   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
560
561   return GetImplementation(*this).TouchedSignal();
562 }
563
564 Actor::TouchDataSignalType& Actor::TouchSignal()
565 {
566   return GetImplementation( *this ).TouchSignal();
567 }
568
569 Actor::HoverSignalType& Actor::HoveredSignal()
570 {
571   return GetImplementation(*this).HoveredSignal();
572 }
573
574 Actor::WheelEventSignalType& Actor::WheelEventSignal()
575 {
576   return GetImplementation(*this).WheelEventSignal();
577 }
578
579 Actor::OnStageSignalType& Actor::OnStageSignal()
580 {
581   return GetImplementation(*this).OnStageSignal();
582 }
583
584 Actor::OffStageSignalType& Actor::OffStageSignal()
585 {
586   return GetImplementation(*this).OffStageSignal();
587 }
588
589 uint32_t Actor::AddRenderer( Renderer& renderer )
590 {
591   return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
592 }
593
594 uint32_t Actor::GetRendererCount() const
595 {
596   return GetImplementation(*this).GetRendererCount();
597 }
598
599 Renderer Actor::GetRendererAt( uint32_t index )
600 {
601   Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
602   return Renderer( renderer.Get() );
603 }
604
605 void Actor::RemoveRenderer( Renderer& renderer )
606 {
607   GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
608 }
609
610 void Actor::RemoveRenderer( uint32_t index )
611 {
612   GetImplementation(*this).RemoveRenderer( index );
613 }
614
615 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
616 {
617   return GetImplementation(*this).OnRelayoutSignal();
618 }
619
620 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
621 {
622   return GetImplementation( *this ).LayoutDirectionChangedSignal();
623 }
624
625 Actor::Actor(Internal::Actor* internal)
626 : Handle(internal)
627 {
628 }
629
630 } // namespace Dali