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