Apply deprecate macro and LOG
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
index 88fc0d6..b96283f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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/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/rendering/renderer-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/size-negotiation/relayout-controller-impl.h>
 
 namespace Dali
 {
 
-const char* const Actor::SIGNAL_TOUCHED = "touched";
-const char* const Actor::SIGNAL_HOVERED = "hovered";
-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()
 {
 }
@@ -79,7 +55,7 @@ Actor::~Actor()
 }
 
 Actor::Actor(const Actor& copy)
-: Constrainable(copy)
+: Handle(copy)
 {
 }
 
@@ -89,13 +65,6 @@ Actor& Actor::operator=(const Actor& rhs)
   return *this;
 }
 
-Actor& Actor::operator=(BaseHandle::NullType* rhs)
-{
-  DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
-  Reset();
-  return *this;
-}
-
 const std::string& Actor::GetName() const
 {
   return GetImplementation(*this).GetName();
@@ -136,11 +105,6 @@ void Actor::Add(Actor actor)
   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));
@@ -158,25 +122,20 @@ unsigned int Actor::GetChildCount() const
 
 Actor Actor::GetChildAt(unsigned int index) const
 {
-  return GetImplementation(*this).GetChildAt(index);
+  Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
+  return Actor( child.Get() );
 }
 
 Actor Actor::FindChildByName(const std::string& actorName)
 {
-  Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
-  return Actor(child.Get());
-}
-
-Actor Actor::FindChildByAlias(const std::string& actorAlias)
-{
-  Actor child = GetImplementation(*this).FindChildByAlias(actorAlias);
-  return child;
+  Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
+  return Actor( child.Get() );
 }
 
 Actor Actor::FindChildById(const unsigned int id)
 {
-  Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
-  return Actor(child.Get());
+  Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
+  return Actor( child.Get() );
 }
 
 Actor Actor::GetParent() const
@@ -218,17 +177,17 @@ void Actor::SetSize(float width, float height, float depth)
 
 void Actor::SetSize(const Vector2& size)
 {
-  GetImplementation(*this).SetSize(size);
+  GetImplementation(*this).SetSize( size );
 }
 
 void Actor::SetSize(const Vector3& size)
 {
-  GetImplementation(*this).SetSize(size);
+  GetImplementation(*this).SetSize( size );
 }
 
-Vector3 Actor::GetSize() const
+Vector3 Actor::GetTargetSize() const
 {
-  return GetImplementation(*this).GetSize();
+  return GetImplementation(*this).GetTargetSize();
 }
 
 Vector3 Actor::GetCurrentSize() const
@@ -271,9 +230,9 @@ void Actor::SetZ(float z)
   GetImplementation(*this).SetZ(z);
 }
 
-void Actor::MoveBy(const Vector3& distance)
+void Actor::TranslateBy(const Vector3& distance)
 {
-  GetImplementation(*this).MoveBy(distance);
+  GetImplementation(*this).TranslateBy(distance);
 }
 
 Vector3 Actor::GetCurrentPosition() const
@@ -288,32 +247,26 @@ Vector3 Actor::GetCurrentWorldPosition() const
 
 void Actor::SetPositionInheritanceMode( PositionInheritanceMode mode )
 {
+  DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetPositionInheritanceMode() is deprecated and will be removed from next release. Use SetInheritPosition() instead.\n" );
+
   GetImplementation(*this).SetPositionInheritanceMode( mode );
 }
 
 PositionInheritanceMode Actor::GetPositionInheritanceMode() const
 {
-  return GetImplementation(*this).GetPositionInheritanceMode();
-}
+  DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPositionInheritanceMode() is deprecated and will be removed from next release. Use IsPositionInherited() instead.\n" );
 
-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);
+  return GetImplementation(*this).GetPositionInheritanceMode();
 }
 
-void Actor::SetRotation(const Quaternion& rotation)
+void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
 {
-  GetImplementation(*this).SetRotation(rotation);
+  GetImplementation(*this).SetOrientation(angle, axis);
 }
 
-void Actor::RotateBy(const Degree& angle, const Vector3& axis)
+void Actor::SetOrientation(const Quaternion& orientation)
 {
-  GetImplementation(*this).RotateBy(Radian(angle), axis);
+  GetImplementation(*this).SetOrientation(orientation);
 }
 
 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
@@ -326,24 +279,24 @@ void Actor::RotateBy(const Quaternion& relativeRotation)
   GetImplementation(*this).RotateBy(relativeRotation);
 }
 
-Quaternion Actor::GetCurrentRotation() const
+Quaternion Actor::GetCurrentOrientation() const
 {
-  return GetImplementation(*this).GetCurrentRotation();
+  return GetImplementation(*this).GetCurrentOrientation();
 }
 
-void Actor::SetInheritRotation(bool inherit)
+void Actor::SetInheritOrientation(bool inherit)
 {
-  GetImplementation(*this).SetInheritRotation(inherit);
+  GetImplementation(*this).SetInheritOrientation(inherit);
 }
 
-bool Actor::IsRotationInherited() const
+bool Actor::IsOrientationInherited() const
 {
-  return GetImplementation(*this).IsRotationInherited();
+  return GetImplementation(*this).IsOrientationInherited();
 }
 
-Quaternion Actor::GetCurrentWorldRotation() const
+Quaternion Actor::GetCurrentWorldOrientation() const
 {
-  return GetImplementation(*this).GetCurrentWorldRotation();
+  return GetImplementation(*this).GetCurrentWorldOrientation();
 }
 
 void Actor::SetScale(float scale)
@@ -386,6 +339,16 @@ bool Actor::IsScaleInherited() const
   return GetImplementation(*this).IsScaleInherited();
 }
 
+void Actor::SetSizeModeFactor(const Vector3& factor)
+{
+  GetImplementation(*this).SetSizeModeFactor(factor);
+}
+
+Vector3 Actor::GetSizeModeFactor() const
+{
+  return GetImplementation(*this).GetSizeModeFactor();
+}
+
 Matrix Actor::GetCurrentWorldMatrix() const
 {
   return GetImplementation(*this).GetCurrentWorldMatrix();
@@ -406,11 +369,6 @@ 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();
@@ -421,11 +379,6 @@ 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();
@@ -491,140 +444,166 @@ bool Actor::IsKeyboardFocusable() const
   return GetImplementation(*this).IsKeyboardFocusable();
 }
 
-Actor::TouchSignalV2& Actor::TouchedSignal()
+void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
 {
-  return GetImplementation(*this).TouchedSignal();
+  GetImplementation(*this).SetResizePolicy( policy, dimension );
 }
 
-Actor::HoverSignalV2& Actor::HoveredSignal()
+ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
 {
-  return GetImplementation(*this).HoveredSignal();
+  return GetImplementation(*this).GetResizePolicy( dimension );
 }
 
-Actor::MouseWheelEventSignalV2& Actor::MouseWheelEventSignal()
+void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
 {
-  return GetImplementation(*this).MouseWheelEventSignal();
+  GetImplementation(*this).SetSizeScalePolicy( policy );
 }
 
-Actor::SetSizeSignalV2& Actor::SetSizeSignal()
+SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
 {
-  return GetImplementation(*this).SetSizeSignal();
+  return GetImplementation(*this).GetSizeScalePolicy();
 }
 
-Actor::OnStageSignalV2& Actor::OnStageSignal()
+float Actor::GetHeightForWidth( float width )
 {
-  return GetImplementation(*this).OnStageSignal();
+  return GetImplementation(*this).GetHeightForWidth( width );
 }
 
-Actor::OffStageSignalV2& Actor::OffStageSignal()
+float Actor::GetWidthForHeight( float height )
 {
-  return GetImplementation(*this).OffStageSignal();
+  return GetImplementation(*this).GetWidthForHeight( height );
 }
 
-DynamicsBody Actor::EnableDynamics(DynamicsBodyConfig bodyConfig)
+float Actor::GetRelayoutSize( Dimension::Type dimension ) const
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyConfig& internal = GetImplementation(bodyConfig);
+  return GetImplementation(*this).GetRelayoutSize( dimension );
+}
+
+void Actor::SetPadding( const Padding& padding )
+{
+  Internal::Actor& impl = GetImplementation(*this);
 
-  Internal::DynamicsBodyPtr body( GetImplementation(*this).EnableDynamics( &internal ) );
+  Vector2 widthPadding( padding.left, padding.right );
+  impl.SetPadding( widthPadding, Dimension::WIDTH );
 
-  return DynamicsBody( body.Get() );
-#else
-  return DynamicsBody();
-#endif
+  Vector2 heightPadding( padding.bottom, padding.top );
+  impl.SetPadding( heightPadding, Dimension::HEIGHT );
 }
 
-DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offset )
+void Actor::GetPadding( Padding& paddingOut ) const
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::ActorPtr internalActor( &GetImplementation(attachedActor) );
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offset) );
+  const Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  Vector2 widthPadding = impl.GetPadding( Dimension::WIDTH );
+  Vector2 heightPadding = impl.GetPadding( Dimension::HEIGHT );
+
+  paddingOut.left = widthPadding.x;
+  paddingOut.right = widthPadding.y;
+  paddingOut.bottom = heightPadding.x;
+  paddingOut.top = heightPadding.y;
 }
 
-DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offsetA, const Vector3& offsetB )
+void Actor::SetMinimumSize( const Vector2& size )
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::ActorPtr internalActor( &GetImplementation(attachedActor) );
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offsetA, offsetB) );
+  Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  impl.SetMinimumSize( size.x, Dimension::WIDTH );
+  impl.SetMinimumSize( size.y, Dimension::HEIGHT );
 }
 
-const int Actor::GetNumberOfJoints() const
+Vector2 Actor::GetMinimumSize()
 {
-#ifdef DYNAMICS_SUPPORT
-  return GetImplementation(*this).GetNumberOfJoints();
-#else
-  return int();
-#endif
+  Internal::Actor& impl = GetImplementation(*this);
+
+  return Vector2( impl.GetMinimumSize( Dimension::WIDTH ), impl.GetMinimumSize( Dimension::HEIGHT ) );
 }
 
-DynamicsJoint Actor::GetDynamicsJointByIndex( const int index )
+void Actor::SetMaximumSize( const Vector2& size )
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJointByIndex( index ) );
+  Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  impl.SetMaximumSize( size.x, Dimension::WIDTH );
+  impl.SetMaximumSize( size.y, Dimension::HEIGHT );
 }
 
-DynamicsJoint Actor::GetDynamicsJoint( Actor attachedActor )
+Vector2 Actor::GetMaximumSize()
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJoint( &GetImplementation(attachedActor) ) );
+  Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  return Vector2( impl.GetMaximumSize( Dimension::WIDTH ), impl.GetMaximumSize( Dimension::HEIGHT ) );
 }
 
-void Actor::RemoveDynamicsJoint( DynamicsJoint joint )
+int Actor::GetHierarchyDepth()
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).RemoveDynamicsJoint( &GetImplementation(joint) );
-#endif
+  return GetImplementation(*this).GetHierarchyDepth();
 }
 
-void Actor::DisableDynamics()
+Actor::TouchSignalType& Actor::TouchedSignal()
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).DisableDynamics();
-#endif
+  DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
+
+  return GetImplementation(*this).TouchedSignal();
 }
 
-DynamicsBody Actor::GetDynamicsBody()
+Actor::TouchDataSignalType& Actor::TouchSignal()
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyPtr internal(GetImplementation(*this).GetDynamicsBody());
-  return DynamicsBody( internal.Get() );
-#else
-  return DynamicsBody();
-#endif
+  return GetImplementation( *this ).TouchSignal();
 }
 
-Actor::Actor(Internal::Actor* internal)
-: Constrainable(internal)
+Actor::HoverSignalType& Actor::HoveredSignal()
+{
+  return GetImplementation(*this).HoveredSignal();
+}
+
+Actor::WheelEventSignalType& Actor::WheelEventSignal()
+{
+  return GetImplementation(*this).WheelEventSignal();
+}
+
+Actor::OnStageSignalType& Actor::OnStageSignal()
 {
+  return GetImplementation(*this).OnStageSignal();
+}
+
+Actor::OffStageSignalType& Actor::OffStageSignal()
+{
+  return GetImplementation(*this).OffStageSignal();
 }
 
-void UnparentAndReset( Actor& actor )
+unsigned int Actor::AddRenderer( Renderer& renderer )
+{
+  return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
+}
+
+unsigned int Actor::GetRendererCount() const
+{
+  return GetImplementation(*this).GetRendererCount();
+}
+
+Renderer Actor::GetRendererAt( unsigned int index )
+{
+  Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
+  return Renderer( renderer.Get() );
+}
+
+void Actor::RemoveRenderer( Renderer& renderer )
+{
+  GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
+}
+
+void Actor::RemoveRenderer( unsigned int index )
+{
+  GetImplementation(*this).RemoveRenderer( index );
+}
+
+Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
+{
+  return GetImplementation(*this).OnRelayoutSignal();
+}
+
+Actor::Actor(Internal::Actor* internal)
+: Handle(internal)
 {
-  if( actor )
-  {
-    actor.Unparent();
-    actor.Reset();
-  }
 }
 
 } // namespace Dali