[dali_1.2.60] Merge branch 'devel/master'
[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 unsigned int 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 unsigned int Actor::GetChildCount() const
119 {
120   return GetImplementation(*this).GetChildCount();
121 }
122
123 Actor Actor::GetChildAt(unsigned int 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 unsigned int 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::SetPositionInheritanceMode( PositionInheritanceMode mode )
249 {
250   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetPositionInheritanceMode() is deprecated and will be removed from next release. Use SetInheritPosition() instead.\n" );
251
252   GetImplementation(*this).SetPositionInheritanceMode( mode );
253 }
254
255 PositionInheritanceMode Actor::GetPositionInheritanceMode() const
256 {
257   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPositionInheritanceMode() is deprecated and will be removed from next release. Use IsPositionInherited() instead.\n" );
258
259   return GetImplementation(*this).GetPositionInheritanceMode();
260 }
261
262 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
263 {
264   GetImplementation(*this).SetOrientation(angle, axis);
265 }
266
267 void Actor::SetOrientation(const Quaternion& orientation)
268 {
269   GetImplementation(*this).SetOrientation(orientation);
270 }
271
272 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
273 {
274   GetImplementation(*this).RotateBy(angle, axis);
275 }
276
277 void Actor::RotateBy(const Quaternion& relativeRotation)
278 {
279   GetImplementation(*this).RotateBy(relativeRotation);
280 }
281
282 Quaternion Actor::GetCurrentOrientation() const
283 {
284   return GetImplementation(*this).GetCurrentOrientation();
285 }
286
287 void Actor::SetInheritOrientation(bool inherit)
288 {
289   GetImplementation(*this).SetInheritOrientation(inherit);
290 }
291
292 bool Actor::IsOrientationInherited() const
293 {
294   return GetImplementation(*this).IsOrientationInherited();
295 }
296
297 Quaternion Actor::GetCurrentWorldOrientation() const
298 {
299   return GetImplementation(*this).GetCurrentWorldOrientation();
300 }
301
302 void Actor::SetScale(float scale)
303 {
304   GetImplementation(*this).SetScale(scale);
305 }
306
307 void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
308 {
309   GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
310 }
311
312 void Actor::SetScale(const Vector3& scale)
313 {
314   GetImplementation(*this).SetScale(scale);
315 }
316
317 void Actor::ScaleBy(const Vector3& relativeScale)
318 {
319   GetImplementation(*this).ScaleBy(relativeScale);
320 }
321
322 Vector3 Actor::GetCurrentScale() const
323 {
324   return GetImplementation(*this).GetCurrentScale();
325 }
326
327 Vector3 Actor::GetCurrentWorldScale() const
328 {
329   return GetImplementation(*this).GetCurrentWorldScale();
330 }
331
332 void Actor::SetInheritScale( bool inherit )
333 {
334   GetImplementation(*this).SetInheritScale( inherit );
335 }
336
337 bool Actor::IsScaleInherited() const
338 {
339   return GetImplementation(*this).IsScaleInherited();
340 }
341
342 void Actor::SetSizeModeFactor(const Vector3& factor)
343 {
344   GetImplementation(*this).SetSizeModeFactor(factor);
345 }
346
347 Vector3 Actor::GetSizeModeFactor() const
348 {
349   return GetImplementation(*this).GetSizeModeFactor();
350 }
351
352 Matrix Actor::GetCurrentWorldMatrix() const
353 {
354   return GetImplementation(*this).GetCurrentWorldMatrix();
355 }
356
357 void Actor::SetVisible(bool visible)
358 {
359   GetImplementation(*this).SetVisible(visible);
360 }
361
362 bool Actor::IsVisible() const
363 {
364   return GetImplementation(*this).IsVisible();
365 }
366
367 void Actor::SetOpacity(float opacity)
368 {
369   GetImplementation(*this).SetOpacity(opacity);
370 }
371
372 float Actor::GetCurrentOpacity() const
373 {
374   return GetImplementation(*this).GetCurrentOpacity();
375 }
376
377 void Actor::SetColor(const Vector4& color)
378 {
379   GetImplementation(*this).SetColor(color);
380 }
381
382 Vector4 Actor::GetCurrentColor() const
383 {
384   return GetImplementation(*this).GetCurrentColor();
385 }
386
387 void Actor::SetColorMode( ColorMode colorMode )
388 {
389   GetImplementation(*this).SetColorMode(colorMode);
390 }
391
392 ColorMode Actor::GetColorMode() const
393 {
394   return GetImplementation(*this).GetColorMode();
395 }
396
397 Vector4 Actor::GetCurrentWorldColor() const
398 {
399   return GetImplementation(*this).GetCurrentWorldColor();
400 }
401
402 void Actor::SetDrawMode( DrawMode::Type drawMode )
403 {
404   GetImplementation(*this).SetDrawMode( drawMode );
405 }
406
407 DrawMode::Type Actor::GetDrawMode() const
408 {
409   return GetImplementation(*this).GetDrawMode();
410 }
411
412 void Actor::SetSensitive(bool sensitive)
413 {
414   GetImplementation(*this).SetSensitive(sensitive);
415 }
416
417 bool Actor::IsSensitive() const
418 {
419   return GetImplementation(*this).IsSensitive();
420 }
421
422 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
423 {
424   return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
425 }
426
427 void Actor::SetLeaveRequired(bool required)
428 {
429   GetImplementation(*this).SetLeaveRequired(required);
430 }
431
432 bool Actor::GetLeaveRequired() const
433 {
434   return GetImplementation(*this).GetLeaveRequired();
435 }
436
437 void Actor::SetKeyboardFocusable( bool focusable )
438 {
439   GetImplementation(*this).SetKeyboardFocusable(focusable);
440 }
441
442 bool Actor::IsKeyboardFocusable() const
443 {
444   return GetImplementation(*this).IsKeyboardFocusable();
445 }
446
447 void Actor::Raise()
448 {
449   GetImplementation( *this ).Raise();
450 }
451
452 void Actor::Lower()
453 {
454   GetImplementation( *this ).Lower();
455 }
456
457 void Actor::RaiseToTop()
458 {
459   GetImplementation( *this ).RaiseToTop();
460 }
461
462 void Actor::LowerToBottom()
463 {
464   GetImplementation( *this ).LowerToBottom();
465 }
466
467 void Actor::RaiseAbove( Actor target )
468 {
469   GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
470 }
471
472 void Actor::LowerBelow( Actor target )
473 {
474   GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
475 }
476
477 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
478 {
479   GetImplementation(*this).SetResizePolicy( policy, dimension );
480 }
481
482 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
483 {
484   return GetImplementation(*this).GetResizePolicy( dimension );
485 }
486
487 void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
488 {
489   GetImplementation(*this).SetSizeScalePolicy( policy );
490 }
491
492 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
493 {
494   return GetImplementation(*this).GetSizeScalePolicy();
495 }
496
497 float Actor::GetHeightForWidth( float width )
498 {
499   return GetImplementation(*this).GetHeightForWidth( width );
500 }
501
502 float Actor::GetWidthForHeight( float height )
503 {
504   return GetImplementation(*this).GetWidthForHeight( height );
505 }
506
507 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
508 {
509   return GetImplementation(*this).GetRelayoutSize( dimension );
510 }
511
512 void Actor::SetPadding( const Padding& padding )
513 {
514   Internal::Actor& impl = GetImplementation(*this);
515
516   Vector2 widthPadding( padding.left, padding.right );
517   impl.SetPadding( widthPadding, Dimension::WIDTH );
518
519   Vector2 heightPadding( padding.bottom, padding.top );
520   impl.SetPadding( heightPadding, Dimension::HEIGHT );
521 }
522
523 void Actor::GetPadding( Padding& paddingOut ) const
524 {
525   const Internal::Actor& impl = GetImplementation(*this);
526
527   Vector2 widthPadding = impl.GetPadding( Dimension::WIDTH );
528   Vector2 heightPadding = impl.GetPadding( Dimension::HEIGHT );
529
530   paddingOut.left = widthPadding.x;
531   paddingOut.right = widthPadding.y;
532   paddingOut.bottom = heightPadding.x;
533   paddingOut.top = heightPadding.y;
534 }
535
536 void Actor::SetMinimumSize( const Vector2& size )
537 {
538   Internal::Actor& impl = GetImplementation(*this);
539
540   impl.SetMinimumSize( size.x, Dimension::WIDTH );
541   impl.SetMinimumSize( size.y, Dimension::HEIGHT );
542 }
543
544 Vector2 Actor::GetMinimumSize()
545 {
546   Internal::Actor& impl = GetImplementation(*this);
547
548   return Vector2( impl.GetMinimumSize( Dimension::WIDTH ), impl.GetMinimumSize( Dimension::HEIGHT ) );
549 }
550
551 void Actor::SetMaximumSize( const Vector2& size )
552 {
553   Internal::Actor& impl = GetImplementation(*this);
554
555   impl.SetMaximumSize( size.x, Dimension::WIDTH );
556   impl.SetMaximumSize( size.y, Dimension::HEIGHT );
557 }
558
559 Vector2 Actor::GetMaximumSize()
560 {
561   Internal::Actor& impl = GetImplementation(*this);
562
563   return Vector2( impl.GetMaximumSize( Dimension::WIDTH ), impl.GetMaximumSize( Dimension::HEIGHT ) );
564 }
565
566 int Actor::GetHierarchyDepth()
567 {
568   return GetImplementation(*this).GetHierarchyDepth();
569 }
570
571 Actor::TouchSignalType& Actor::TouchedSignal()
572 {
573   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
574
575   return GetImplementation(*this).TouchedSignal();
576 }
577
578 Actor::TouchDataSignalType& Actor::TouchSignal()
579 {
580   return GetImplementation( *this ).TouchSignal();
581 }
582
583 Actor::HoverSignalType& Actor::HoveredSignal()
584 {
585   return GetImplementation(*this).HoveredSignal();
586 }
587
588 Actor::WheelEventSignalType& Actor::WheelEventSignal()
589 {
590   return GetImplementation(*this).WheelEventSignal();
591 }
592
593 Actor::OnStageSignalType& Actor::OnStageSignal()
594 {
595   return GetImplementation(*this).OnStageSignal();
596 }
597
598 Actor::OffStageSignalType& Actor::OffStageSignal()
599 {
600   return GetImplementation(*this).OffStageSignal();
601 }
602
603 unsigned int Actor::AddRenderer( Renderer& renderer )
604 {
605   return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
606 }
607
608 unsigned int Actor::GetRendererCount() const
609 {
610   return GetImplementation(*this).GetRendererCount();
611 }
612
613 Renderer Actor::GetRendererAt( unsigned int index )
614 {
615   Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
616   return Renderer( renderer.Get() );
617 }
618
619 void Actor::RemoveRenderer( Renderer& renderer )
620 {
621   GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
622 }
623
624 void Actor::RemoveRenderer( unsigned int index )
625 {
626   GetImplementation(*this).RemoveRenderer( index );
627 }
628
629 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
630 {
631   return GetImplementation(*this).OnRelayoutSignal();
632 }
633
634 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
635 {
636   return GetImplementation( *this ).LayoutDirectionChangedSignal();
637 }
638
639 Actor::Actor(Internal::Actor* internal)
640 : Handle(internal)
641 {
642 }
643
644 } // namespace Dali