/*
- * 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/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/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()
{
return Actor(internal.Get());
}
-Actor Actor::DownCast( BaseHandle handle )
-{
- return Actor( dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()) );
-}
-
-Actor::~Actor()
-{
-}
-
-Actor::Actor(const Actor& copy)
-: Constrainable(copy)
+Actor Actor::DownCast(BaseHandle handle)
{
+ return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
}
-Actor& Actor::operator=(const Actor& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
+Actor::~Actor() = default;
-Actor& Actor::operator=(BaseHandle::NullType* rhs)
-{
- DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
- Reset();
- return *this;
-}
+Actor::Actor(const Actor& copy) = default;
-const std::string& Actor::GetName() const
-{
- return GetImplementation(*this).GetName();
-}
+Actor& Actor::operator=(const Actor& rhs) = default;
-void Actor::SetName(const std::string& name)
-{
- GetImplementation(*this).SetName(name);
-}
+Actor::Actor(Actor&& rhs) noexcept = default;
-unsigned int Actor::GetId() const
-{
- return GetImplementation(*this).GetId();
-}
-
-bool Actor::IsRoot() const
-{
- return GetImplementation(*this).IsRoot();
-}
-
-bool Actor::OnStage() const
-{
- return GetImplementation(*this).OnStage();
-}
-
-bool Actor::IsLayer() const
-{
- return GetImplementation(*this).IsLayer();
-}
+Actor& Actor::operator=(Actor&& rhs) noexcept = default;
Layer Actor::GetLayer()
{
GetImplementation(*this).Add(GetImplementation(actor));
}
-void Actor::Insert(unsigned int index, Actor actor)
-{
- GetImplementation(*this).Insert(index, GetImplementation(actor));
-}
-
void Actor::Remove(Actor actor)
{
GetImplementation(*this).Remove(GetImplementation(actor));
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());
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)
-{
- GetImplementation(*this).SetAnchorPoint(anchorPoint);
-}
-
-Vector3 Actor::GetCurrentAnchorPoint() const
-{
- return GetImplementation(*this).GetCurrentAnchorPoint();
-}
-
-void Actor::SetSize(float width, float height)
-{
- 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::GetSize() const
-{
- return GetImplementation(*this).GetSize();
-}
-
-Vector3 Actor::GetCurrentSize() const
+Vector3 Actor::GetTargetSize() const
{
- return GetImplementation(*this).GetCurrentSize();
+ return GetImplementation(*this).GetTargetSize();
}
Vector3 Actor::GetNaturalSize() const
return GetImplementation(*this).GetNaturalSize();
}
-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 )
+void Actor::TranslateBy(const Vector3& distance)
{
- 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)
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 )
+bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
{
- GetImplementation(*this).SetColorMode(colorMode);
+ return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
}
-ColorMode Actor::GetColorMode() const
+void Actor::Raise()
{
- return GetImplementation(*this).GetColorMode();
+ GetImplementation(*this).Raise();
}
-Vector4 Actor::GetCurrentWorldColor() const
+void Actor::Lower()
{
- return GetImplementation(*this).GetCurrentWorldColor();
+ 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