2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/actors/actor.h>
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>
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>
43 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: DALi is deprecated and will be removed from next version. Please use NUI(C# interface of DALi).\n For more information on NUI, see the NUI quick start page : https://docs.tizen.org/application/dotnet/get-started/nui/quickstart/ \n" );
44 Internal::ActorPtr internal = Internal::Actor::New();
46 return Actor(internal.Get());
49 Actor Actor::DownCast( BaseHandle handle )
51 return Actor( dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()) );
58 Actor::Actor(const Actor& copy)
63 Actor& Actor::operator=(const Actor& rhs)
65 BaseHandle::operator=(rhs);
69 const std::string& Actor::GetName() const
71 return GetImplementation(*this).GetName();
74 void Actor::SetName(const std::string& name)
76 GetImplementation(*this).SetName(name);
79 uint32_t Actor::GetId() const
81 return GetImplementation(*this).GetId();
84 bool Actor::IsRoot() const
86 return GetImplementation(*this).IsRoot();
89 bool Actor::OnStage() const
91 return GetImplementation(*this).OnStage();
94 bool Actor::IsLayer() const
96 return GetImplementation(*this).IsLayer();
99 Layer Actor::GetLayer()
101 return GetImplementation(*this).GetLayer();
104 void Actor::Add(Actor actor)
106 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: DALi is deprecated and will be removed from next version. Please use NUI(C# interface of DALi).\n For more information on NUI, see the NUI quick start page : https://docs.tizen.org/application/dotnet/get-started/nui/quickstart/ \n" );
107 GetImplementation(*this).Add(GetImplementation(actor));
110 void Actor::Remove(Actor actor)
112 GetImplementation(*this).Remove(GetImplementation(actor));
115 void Actor::Unparent()
117 GetImplementation(*this).Unparent();
120 uint32_t Actor::GetChildCount() const
122 return GetImplementation(*this).GetChildCount();
125 Actor Actor::GetChildAt( uint32_t index ) const
127 Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
128 return Actor( child.Get() );
131 Actor Actor::FindChildByName(const std::string& actorName)
133 Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
134 return Actor( child.Get() );
137 Actor Actor::FindChildById( const uint32_t id )
139 Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
140 return Actor( child.Get() );
143 Actor Actor::GetParent() const
145 Internal::Actor* parent = GetImplementation(*this).GetParent();
147 return Actor(parent);
150 void Actor::SetParentOrigin(const Vector3& origin)
152 GetImplementation(*this).SetParentOrigin(origin);
155 Vector3 Actor::GetCurrentParentOrigin() const
157 return GetImplementation(*this).GetCurrentParentOrigin();
160 void Actor::SetAnchorPoint(const Vector3& anchorPoint)
162 GetImplementation(*this).SetAnchorPoint(anchorPoint);
165 Vector3 Actor::GetCurrentAnchorPoint() const
167 return GetImplementation(*this).GetCurrentAnchorPoint();
170 void Actor::SetSize(float width, float height)
172 GetImplementation(*this).SetSize(width, height);
175 void Actor::SetSize(float width, float height, float depth)
177 GetImplementation(*this).SetSize(width, height, depth);
180 void Actor::SetSize(const Vector2& size)
182 GetImplementation(*this).SetSize( size );
185 void Actor::SetSize(const Vector3& size)
187 GetImplementation(*this).SetSize( size );
190 Vector3 Actor::GetTargetSize() const
192 return GetImplementation(*this).GetTargetSize();
195 Vector3 Actor::GetCurrentSize() const
197 return GetImplementation(*this).GetCurrentSize();
200 Vector3 Actor::GetNaturalSize() const
202 return GetImplementation(*this).GetNaturalSize();
205 void Actor::SetPosition(float x, float y)
207 GetImplementation(*this).SetPosition(x, y);
210 void Actor::SetPosition(float x, float y, float z)
212 GetImplementation(*this).SetPosition(x, y, z);
215 void Actor::SetPosition(const Vector3& position)
217 GetImplementation(*this).SetPosition(position);
220 void Actor::SetX(float x)
222 GetImplementation(*this).SetX(x);
225 void Actor::SetY(float y)
227 GetImplementation(*this).SetY(y);
230 void Actor::SetZ(float z)
232 GetImplementation(*this).SetZ(z);
235 void Actor::TranslateBy(const Vector3& distance)
237 GetImplementation(*this).TranslateBy(distance);
240 Vector3 Actor::GetCurrentPosition() const
242 return GetImplementation(*this).GetCurrentPosition();
245 Vector3 Actor::GetCurrentWorldPosition() const
247 return GetImplementation(*this).GetCurrentWorldPosition();
250 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
252 GetImplementation(*this).SetOrientation(angle, axis);
255 void Actor::SetOrientation(const Quaternion& orientation)
257 GetImplementation(*this).SetOrientation(orientation);
260 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
262 GetImplementation(*this).RotateBy(angle, axis);
265 void Actor::RotateBy(const Quaternion& relativeRotation)
267 GetImplementation(*this).RotateBy(relativeRotation);
270 Quaternion Actor::GetCurrentOrientation() const
272 return GetImplementation(*this).GetCurrentOrientation();
275 void Actor::SetInheritOrientation(bool inherit)
277 GetImplementation(*this).SetInheritOrientation(inherit);
280 bool Actor::IsOrientationInherited() const
282 return GetImplementation(*this).IsOrientationInherited();
285 Quaternion Actor::GetCurrentWorldOrientation() const
287 return GetImplementation(*this).GetCurrentWorldOrientation();
290 void Actor::SetScale(float scale)
292 GetImplementation(*this).SetScale(scale);
295 void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
297 GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
300 void Actor::SetScale(const Vector3& scale)
302 GetImplementation(*this).SetScale(scale);
305 void Actor::ScaleBy(const Vector3& relativeScale)
307 GetImplementation(*this).ScaleBy(relativeScale);
310 Vector3 Actor::GetCurrentScale() const
312 return GetImplementation(*this).GetCurrentScale();
315 Vector3 Actor::GetCurrentWorldScale() const
317 return GetImplementation(*this).GetCurrentWorldScale();
320 void Actor::SetInheritScale( bool inherit )
322 GetImplementation(*this).SetInheritScale( inherit );
325 bool Actor::IsScaleInherited() const
327 return GetImplementation(*this).IsScaleInherited();
330 void Actor::SetSizeModeFactor(const Vector3& factor)
332 GetImplementation(*this).SetSizeModeFactor(factor);
335 Vector3 Actor::GetSizeModeFactor() const
337 return GetImplementation(*this).GetSizeModeFactor();
340 Matrix Actor::GetCurrentWorldMatrix() const
342 return GetImplementation(*this).GetCurrentWorldMatrix();
345 void Actor::SetVisible(bool visible)
347 GetImplementation(*this).SetVisible(visible);
350 bool Actor::IsVisible() const
352 return GetImplementation(*this).IsVisible();
355 void Actor::SetOpacity(float opacity)
357 GetImplementation(*this).SetOpacity(opacity);
360 float Actor::GetCurrentOpacity() const
362 return GetImplementation(*this).GetCurrentOpacity();
365 void Actor::SetColor(const Vector4& color)
367 GetImplementation(*this).SetColor(color);
370 Vector4 Actor::GetCurrentColor() const
372 return GetImplementation(*this).GetCurrentColor();
375 void Actor::SetColorMode( ColorMode colorMode )
377 GetImplementation(*this).SetColorMode(colorMode);
380 ColorMode Actor::GetColorMode() const
382 return GetImplementation(*this).GetColorMode();
385 Vector4 Actor::GetCurrentWorldColor() const
387 return GetImplementation(*this).GetCurrentWorldColor();
390 void Actor::SetDrawMode( DrawMode::Type drawMode )
392 GetImplementation(*this).SetDrawMode( drawMode );
395 DrawMode::Type Actor::GetDrawMode() const
397 return GetImplementation(*this).GetDrawMode();
400 void Actor::SetSensitive(bool sensitive)
402 GetImplementation(*this).SetSensitive(sensitive);
405 bool Actor::IsSensitive() const
407 return GetImplementation(*this).IsSensitive();
410 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
412 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
415 void Actor::SetLeaveRequired(bool required)
417 GetImplementation(*this).SetLeaveRequired(required);
420 bool Actor::GetLeaveRequired() const
422 return GetImplementation(*this).GetLeaveRequired();
425 void Actor::SetKeyboardFocusable( bool focusable )
427 GetImplementation(*this).SetKeyboardFocusable(focusable);
430 bool Actor::IsKeyboardFocusable() const
432 return GetImplementation(*this).IsKeyboardFocusable();
437 GetImplementation( *this ).Raise();
442 GetImplementation( *this ).Lower();
445 void Actor::RaiseToTop()
447 GetImplementation( *this ).RaiseToTop();
450 void Actor::LowerToBottom()
452 GetImplementation( *this ).LowerToBottom();
455 void Actor::RaiseAbove( Actor target )
457 GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
460 void Actor::LowerBelow( Actor target )
462 GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
465 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
467 GetImplementation(*this).SetResizePolicy( policy, dimension );
470 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
472 return GetImplementation(*this).GetResizePolicy( dimension );
475 void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
477 GetImplementation(*this).SetSizeScalePolicy( policy );
480 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
482 return GetImplementation(*this).GetSizeScalePolicy();
485 float Actor::GetHeightForWidth( float width )
487 return GetImplementation(*this).GetHeightForWidth( width );
490 float Actor::GetWidthForHeight( float height )
492 return GetImplementation(*this).GetWidthForHeight( height );
495 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
497 return GetImplementation(*this).GetRelayoutSize( dimension );
500 void Actor::SetPadding( const Padding& padding )
502 Internal::Actor& impl = GetImplementation(*this);
504 Vector2 widthPadding( padding.left, padding.right );
505 impl.SetPadding( widthPadding, Dimension::WIDTH );
507 Vector2 heightPadding( padding.bottom, padding.top );
508 impl.SetPadding( heightPadding, Dimension::HEIGHT );
511 void Actor::GetPadding( Padding& paddingOut ) const
513 const Internal::Actor& impl = GetImplementation(*this);
515 Vector2 widthPadding = impl.GetPadding( Dimension::WIDTH );
516 Vector2 heightPadding = impl.GetPadding( Dimension::HEIGHT );
518 paddingOut.left = widthPadding.x;
519 paddingOut.right = widthPadding.y;
520 paddingOut.bottom = heightPadding.x;
521 paddingOut.top = heightPadding.y;
524 void Actor::SetMinimumSize( const Vector2& size )
526 Internal::Actor& impl = GetImplementation(*this);
528 impl.SetMinimumSize( size.x, Dimension::WIDTH );
529 impl.SetMinimumSize( size.y, Dimension::HEIGHT );
532 Vector2 Actor::GetMinimumSize()
534 Internal::Actor& impl = GetImplementation(*this);
536 return Vector2( impl.GetMinimumSize( Dimension::WIDTH ), impl.GetMinimumSize( Dimension::HEIGHT ) );
539 void Actor::SetMaximumSize( const Vector2& size )
541 Internal::Actor& impl = GetImplementation(*this);
543 impl.SetMaximumSize( size.x, Dimension::WIDTH );
544 impl.SetMaximumSize( size.y, Dimension::HEIGHT );
547 Vector2 Actor::GetMaximumSize()
549 Internal::Actor& impl = GetImplementation(*this);
551 return Vector2( impl.GetMaximumSize( Dimension::WIDTH ), impl.GetMaximumSize( Dimension::HEIGHT ) );
554 int32_t Actor::GetHierarchyDepth()
556 return GetImplementation(*this).GetHierarchyDepth();
559 Actor::TouchSignalType& Actor::TouchedSignal()
561 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
563 return GetImplementation(*this).TouchedSignal();
566 Actor::TouchDataSignalType& Actor::TouchSignal()
568 return GetImplementation( *this ).TouchSignal();
571 Actor::HoverSignalType& Actor::HoveredSignal()
573 return GetImplementation(*this).HoveredSignal();
576 Actor::WheelEventSignalType& Actor::WheelEventSignal()
578 return GetImplementation(*this).WheelEventSignal();
581 Actor::OnStageSignalType& Actor::OnStageSignal()
583 return GetImplementation(*this).OnStageSignal();
586 Actor::OffStageSignalType& Actor::OffStageSignal()
588 return GetImplementation(*this).OffStageSignal();
591 uint32_t Actor::AddRenderer( Renderer& renderer )
593 return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
596 uint32_t Actor::GetRendererCount() const
598 return GetImplementation(*this).GetRendererCount();
601 Renderer Actor::GetRendererAt( uint32_t index )
603 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
604 return Renderer( renderer.Get() );
607 void Actor::RemoveRenderer( Renderer& renderer )
609 GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
612 void Actor::RemoveRenderer( uint32_t index )
614 GetImplementation(*this).RemoveRenderer( index );
617 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
619 return GetImplementation(*this).OnRelayoutSignal();
622 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
624 return GetImplementation( *this ).LayoutDirectionChangedSignal();
627 Actor::Actor(Internal::Actor* internal)