Ensure BaseHandle class move noexcept (core public-api)
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
index 94ee146..0c1b911 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-#include <dali/public-api/math/degree.h>
 #include <dali/public-api/math/radian.h>
 #include <dali/public-api/math/vector2.h>
 
+#include <dali/internal/common/const-string.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/layer-impl.h>
-#include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
 #include <dali/internal/event/animation/constraint-impl.h>
-#include <dali/internal/event/effects/shader-effect-impl.h>
-
-#include <dali/public-api/dynamics/dynamics-body.h>
-#include <dali/public-api/dynamics/dynamics-joint.h>
-#include <dali/public-api/dynamics/dynamics-body-config.h>
-
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-body-config-impl.h>
-#include <dali/internal/event/dynamics/dynamics-body-impl.h>
-#include <dali/internal/event/dynamics/dynamics-joint-impl.h>
-#include <dali/internal/event/dynamics/dynamics-world-impl.h>
-#endif
-
-using namespace std;
+#include <dali/internal/event/rendering/renderer-impl.h>
+#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
 
 namespace Dali
 {
-
-const char* const Actor::SIGNAL_TOUCHED = "touched";
-const char* const Actor::SIGNAL_MOUSE_WHEEL_EVENT = "mouse-wheel-event";
-const char* const Actor::SIGNAL_SET_SIZE = "set-size";
-const char* const Actor::SIGNAL_ON_STAGE = "on-stage";
-const char* const Actor::SIGNAL_OFF_STAGE = "off-stage";
-
-const char* const Actor::ACTION_SHOW = "show";
-const char* const Actor::ACTION_HIDE = "hide";
-
-Actor::Actor()
-{
-}
+Actor::Actor() = default;
 
 Actor Actor::New()
 {
@@ -70,44 +43,20 @@ Actor Actor::New()
   return Actor(internal.Get());
 }
 
-Actor Actor::DownCast( BaseHandle handle )
-{
-  return Actor( dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()) );
-}
-
-Actor::~Actor()
-{
-}
-
-const std::string& Actor::GetName() const
+Actor Actor::DownCast(BaseHandle handle)
 {
-  return GetImplementation(*this).GetName();
+  return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
 }
 
-void Actor::SetName(const std::string& name)
-{
-  GetImplementation(*this).SetName(name);
-}
+Actor::~Actor() = default;
 
-unsigned int Actor::GetId() const
-{
-  return GetImplementation(*this).GetId();
-}
+Actor::Actor(const Actor& copy) = default;
 
-bool Actor::IsRoot() const
-{
-  return GetImplementation(*this).IsRoot();
-}
+Actor& Actor::operator=(const Actor& rhs) = default;
 
-bool Actor::OnStage() const
-{
-  return GetImplementation(*this).OnStage();
-}
+Actor::Actor(Actor&& rhs) noexcept = default;
 
-bool Actor::IsLayer() const
-{
-  return GetImplementation(*this).IsLayer();
-}
+Actor& Actor::operator=(Actor&& rhs) noexcept = default;
 
 Layer Actor::GetLayer()
 {
@@ -129,29 +78,24 @@ void Actor::Unparent()
   GetImplementation(*this).Unparent();
 }
 
-unsigned int Actor::GetChildCount() const
+uint32_t Actor::GetChildCount() const
 {
   return GetImplementation(*this).GetChildCount();
 }
 
-Actor Actor::GetChildAt(unsigned int index) const
+Actor Actor::GetChildAt(uint32_t index) const
 {
-  return GetImplementation(*this).GetChildAt(index);
-}
-
-Actor Actor::FindChildByName(const std::string& actorName)
-{
-  Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
+  Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
   return Actor(child.Get());
 }
 
-Actor Actor::FindChildByAlias(const std::string& actorAlias)
+Actor Actor::FindChildByName(std::string_view actorName)
 {
-  Actor child = GetImplementation(*this).FindChildByAlias(actorAlias);
-  return child;
+  Internal::ActorPtr child = GetImplementation(*this).FindChildByName(Internal::ConstString(actorName));
+  return Actor(child.Get());
 }
 
-Actor Actor::FindChildById(const unsigned int id)
+Actor Actor::FindChildById(const uint32_t id)
 {
   Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
   return Actor(child.Get());
@@ -164,124 +108,19 @@ Actor Actor::GetParent() const
   return Actor(parent);
 }
 
-void Actor::SetParentOrigin(const Vector3& origin)
-{
-  GetImplementation(*this).SetParentOrigin(origin);
-}
-
-Vector3 Actor::GetCurrentParentOrigin() const
-{
-  return GetImplementation(*this).GetCurrentParentOrigin();
-}
-
-void Actor::SetAnchorPoint(const Vector3& anchorPoint)
+Vector3 Actor::GetTargetSize() const
 {
-  GetImplementation(*this).SetAnchorPoint(anchorPoint);
+  return GetImplementation(*this).GetTargetSize();
 }
 
-Vector3 Actor::GetCurrentAnchorPoint() const
+Vector3 Actor::GetNaturalSize() const
 {
-  return GetImplementation(*this).GetCurrentAnchorPoint();
+  return GetImplementation(*this).GetNaturalSize();
 }
 
-void Actor::SetSize(float width, float height)
+void Actor::TranslateBy(const Vector3& distance)
 {
-  GetImplementation(*this).SetSize(width, height);
-}
-
-void Actor::SetSize(float width, float height, float depth)
-{
-  GetImplementation(*this).SetSize(width, height, depth);
-}
-
-void Actor::SetSize(const Vector2& size)
-{
-  GetImplementation(*this).SetSize(size);
-}
-
-void Actor::SetSize(const Vector3& size)
-{
-  GetImplementation(*this).SetSize(size);
-}
-
-Vector3 Actor::GetCurrentSize() const
-{
-  return GetImplementation(*this).GetCurrentSize();
-}
-
-void Actor::SetPosition(float x, float y)
-{
-  GetImplementation(*this).SetPosition(x, y);
-}
-
-void Actor::SetPosition(float x, float y, float z)
-{
-  GetImplementation(*this).SetPosition(x, y, z);
-}
-
-void Actor::SetPosition(const Vector3& position)
-{
-  GetImplementation(*this).SetPosition(position);
-}
-
-void Actor::SetX(float x)
-{
-  GetImplementation(*this).SetX(x);
-}
-
-void Actor::SetY(float y)
-{
-  GetImplementation(*this).SetY(y);
-}
-
-void Actor::SetZ(float z)
-{
-  GetImplementation(*this).SetZ(z);
-}
-
-void Actor::MoveBy(const Vector3& distance)
-{
-  GetImplementation(*this).MoveBy(distance);
-}
-
-Vector3 Actor::GetCurrentPosition() const
-{
-  return GetImplementation(*this).GetCurrentPosition();
-}
-
-Vector3 Actor::GetCurrentWorldPosition() const
-{
-  return GetImplementation(*this).GetCurrentWorldPosition();
-}
-
-void Actor::SetPositionInheritanceMode( PositionInheritanceMode mode )
-{
-  GetImplementation(*this).SetPositionInheritanceMode( mode );
-}
-
-PositionInheritanceMode Actor::GetPositionInheritanceMode() const
-{
-  return GetImplementation(*this).GetPositionInheritanceMode();
-}
-
-void Actor::SetRotation(const Degree& angle, const Vector3& axis)
-{
-  GetImplementation(*this).SetRotation(Radian(angle), axis);
-}
-
-void Actor::SetRotation(const Radian& angle, const Vector3& axis)
-{
-  GetImplementation(*this).SetRotation(angle, axis);
-}
-
-void Actor::SetRotation(const Quaternion& rotation)
-{
-  GetImplementation(*this).SetRotation(rotation);
-}
-
-void Actor::RotateBy(const Degree& angle, const Vector3& axis)
-{
-  GetImplementation(*this).RotateBy(Radian(angle), axis);
+  GetImplementation(*this).TranslateBy(distance);
 }
 
 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
@@ -294,327 +133,135 @@ void Actor::RotateBy(const Quaternion& relativeRotation)
   GetImplementation(*this).RotateBy(relativeRotation);
 }
 
-Quaternion Actor::GetCurrentRotation() const
-{
-  return GetImplementation(*this).GetCurrentRotation();
-}
-
-void Actor::SetInheritRotation(bool inherit)
-{
-  GetImplementation(*this).SetInheritRotation(inherit);
-}
-
-bool Actor::IsRotationInherited() const
-{
-  return GetImplementation(*this).IsRotationInherited();
-}
-
-Quaternion Actor::GetCurrentWorldRotation() const
-{
-  return GetImplementation(*this).GetCurrentWorldRotation();
-}
-
-void Actor::SetScale(float scale)
-{
-  GetImplementation(*this).SetScale(scale);
-}
-
-void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
-{
-  GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
-}
-
-void Actor::SetScale(const Vector3& scale)
-{
-  GetImplementation(*this).SetScale(scale);
-}
-
 void Actor::ScaleBy(const Vector3& relativeScale)
 {
   GetImplementation(*this).ScaleBy(relativeScale);
 }
 
-Vector3 Actor::GetCurrentScale() const
-{
-  return GetImplementation(*this).GetCurrentScale();
-}
-
-Vector3 Actor::GetCurrentWorldScale() const
-{
-  return GetImplementation(*this).GetCurrentWorldScale();
-}
-
-void Actor::SetInheritScale( bool inherit )
-{
-  GetImplementation(*this).SetInheritScale( inherit );
-}
-
-bool Actor::IsScaleInherited() const
-{
-  return GetImplementation(*this).IsScaleInherited();
-}
-
-Matrix Actor::GetCurrentWorldMatrix() const
-{
-  return GetImplementation(*this).GetCurrentWorldMatrix();
-}
-
-void Actor::SetVisible(bool visible)
-{
-  GetImplementation(*this).SetVisible(visible);
-}
-
-bool Actor::IsVisible() const
-{
-  return GetImplementation(*this).IsVisible();
-}
-
-void Actor::SetOpacity(float opacity)
-{
-  GetImplementation(*this).SetOpacity(opacity);
-}
-
-void Actor::OpacityBy(float relativeOpacity)
-{
-  GetImplementation(*this).OpacityBy(relativeOpacity);
-}
-
-float Actor::GetCurrentOpacity() const
-{
-  return GetImplementation(*this).GetCurrentOpacity();
-}
-
-void Actor::SetColor(const Vector4& color)
-{
-  GetImplementation(*this).SetColor(color);
-}
-
-void Actor::ColorBy(const Vector4& relativeColor)
-{
-  GetImplementation(*this).ColorBy(relativeColor);
-}
-
-Vector4 Actor::GetCurrentColor() const
-{
-  return GetImplementation(*this).GetCurrentColor();
-}
-
-void Actor::SetColorMode( ColorMode colorMode )
-{
-  GetImplementation(*this).SetColorMode(colorMode);
-}
-
-ColorMode Actor::GetColorMode() const
-{
-  return GetImplementation(*this).GetColorMode();
-}
-
-Vector4 Actor::GetCurrentWorldColor() const
-{
-  return GetImplementation(*this).GetCurrentWorldColor();
-}
-
-void Actor::SetInheritShaderEffect(bool inherit)
-{
-  GetImplementation(*this).SetInheritShaderEffect(inherit);
-}
-
-bool Actor::GetInheritShaderEffect() const
-{
-  return GetImplementation(*this).GetInheritShaderEffect();
-}
-
-void Actor::SetShaderEffect(ShaderEffect effect)
+bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
 {
-  GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
+  return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
 }
 
-ShaderEffect Actor::GetShaderEffect() const
+void Actor::Raise()
 {
-  Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect();
-
-  return ShaderEffect(internal.Get());
+  GetImplementation(*this).Raise();
 }
 
-void Actor::RemoveShaderEffect()
+void Actor::Lower()
 {
-  GetImplementation(*this).RemoveShaderEffect();
+  GetImplementation(*this).Lower();
 }
 
-void Actor::SetDrawMode( DrawMode::Type drawMode )
+void Actor::RaiseToTop()
 {
-  GetImplementation(*this).SetDrawMode( drawMode );
+  GetImplementation(*this).RaiseToTop();
 }
 
-DrawMode::Type Actor::GetDrawMode() const
+void Actor::LowerToBottom()
 {
-  return GetImplementation(*this).GetDrawMode();
+  GetImplementation(*this).LowerToBottom();
 }
 
-void Actor::SetSensitive(bool sensitive)
+void Actor::RaiseAbove(Actor target)
 {
-  GetImplementation(*this).SetSensitive(sensitive);
+  GetImplementation(*this).RaiseAbove(GetImplementation(target));
 }
 
-bool Actor::IsSensitive() const
+void Actor::LowerBelow(Actor target)
 {
-  return GetImplementation(*this).IsSensitive();
+  GetImplementation(*this).LowerBelow(GetImplementation(target));
 }
 
-bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
+void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
 {
-  return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
+  GetImplementation(*this).SetResizePolicy(policy, dimension);
 }
 
-void Actor::SetLeaveRequired(bool required)
+ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
 {
-  GetImplementation(*this).SetLeaveRequired(required);
+  return GetImplementation(*this).GetResizePolicy(dimension);
 }
 
-bool Actor::GetLeaveRequired() const
+float Actor::GetHeightForWidth(float width)
 {
-  return GetImplementation(*this).GetLeaveRequired();
+  return GetImplementation(*this).GetHeightForWidth(width);
 }
 
-void Actor::SetKeyboardFocusable( bool focusable )
+float Actor::GetWidthForHeight(float height)
 {
-  GetImplementation(*this).SetKeyboardFocusable(focusable);
+  return GetImplementation(*this).GetWidthForHeight(height);
 }
 
-bool Actor::IsKeyboardFocusable() const
+float Actor::GetRelayoutSize(Dimension::Type dimension) const
 {
-  return GetImplementation(*this).IsKeyboardFocusable();
+  return GetImplementation(*this).GetRelayoutSize(dimension);
 }
 
-Actor::TouchSignalV2& Actor::TouchedSignal()
+Actor::TouchEventSignalType& Actor::TouchedSignal()
 {
   return GetImplementation(*this).TouchedSignal();
 }
 
-Actor::MouseWheelEventSignalV2& Actor::MouseWheelEventSignal()
+Actor::HoverSignalType& Actor::HoveredSignal()
 {
-  return GetImplementation(*this).MouseWheelEventSignal();
+  return GetImplementation(*this).HoveredSignal();
 }
 
-Actor::SetSizeSignalV2& Actor::SetSizeSignal()
+Actor::WheelEventSignalType& Actor::WheelEventSignal()
 {
-  return GetImplementation(*this).SetSizeSignal();
+  return GetImplementation(*this).WheelEventSignal();
 }
 
-Actor::OnStageSignalV2& Actor::OnStageSignal()
+Actor::OnSceneSignalType& Actor::OnSceneSignal()
 {
-  return GetImplementation(*this).OnStageSignal();
+  return GetImplementation(*this).OnSceneSignal();
 }
 
-Actor::OffStageSignalV2& Actor::OffStageSignal()
+Actor::OffSceneSignalType& Actor::OffSceneSignal()
 {
-  return GetImplementation(*this).OffStageSignal();
+  return GetImplementation(*this).OffSceneSignal();
 }
 
-DynamicsBody Actor::EnableDynamics(DynamicsBodyConfig bodyConfig)
+uint32_t Actor::AddRenderer(Renderer& renderer)
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyConfig& internal = GetImplementation(bodyConfig);
-
-  Internal::DynamicsBodyPtr body( GetImplementation(*this).EnableDynamics( &internal ) );
-
-  return DynamicsBody( body.Get() );
-#else
-  return DynamicsBody();
-#endif
+  return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
 }
 
-DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offset )
+uint32_t Actor::GetRendererCount() const
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::ActorPtr internalActor( &GetImplementation(attachedActor) );
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offset) );
-
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  return GetImplementation(*this).GetRendererCount();
 }
 
-DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offsetA, const Vector3& offsetB )
+Renderer Actor::GetRendererAt(uint32_t index)
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::ActorPtr internalActor( &GetImplementation(attachedActor) );
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offsetA, offsetB) );
-
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
+  return Renderer(renderer.Get());
 }
 
-const int Actor::GetNumberOfJoints() const
+void Actor::RemoveRenderer(Renderer& renderer)
 {
-#ifdef DYNAMICS_SUPPORT
-  return GetImplementation(*this).GetNumberOfJoints();
-#else
-  return int();
-#endif
+  GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
 }
 
-DynamicsJoint Actor::GetDynamicsJointByIndex( const int index )
+void Actor::RemoveRenderer(uint32_t index)
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJointByIndex( index ) );
-
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
-}
-
-DynamicsJoint Actor::GetDynamicsJoint( Actor attachedActor )
-{
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJoint( &GetImplementation(attachedActor) ) );
-
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  GetImplementation(*this).RemoveRenderer(index);
 }
 
-void Actor::RemoveDynamicsJoint( DynamicsJoint joint )
+Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).RemoveDynamicsJoint( &GetImplementation(joint) );
-#endif
+  return GetImplementation(*this).OnRelayoutSignal();
 }
 
-void Actor::DisableDynamics()
+Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).DisableDynamics();
-#endif
-}
-
-DynamicsBody Actor::GetDynamicsBody()
-{
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyPtr internal(GetImplementation(*this).GetDynamicsBody());
-  return DynamicsBody( internal.Get() );
-#else
-  return DynamicsBody();
-#endif
+  return GetImplementation(*this).LayoutDirectionChangedSignal();
 }
 
 Actor::Actor(Internal::Actor* internal)
-: Constrainable(internal)
-{
-}
-
-void UnparentAndReset( Actor& actor )
+: Handle(internal)
 {
-  if( actor )
-  {
-    actor.Unparent();
-    actor.Reset();
-  }
 }
 
 } // namespace Dali