Merge branch 'tizen' of platform/core/uifw/dali-core into devel/new_mesh
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
index 58214dd..a950133 100644 (file)
 #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/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/layer-impl.h>
+#include <dali/internal/event/actors/renderer-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;
 
 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()
 {
 }
@@ -80,7 +56,7 @@ Actor::~Actor()
 }
 
 Actor::Actor(const Actor& copy)
-: Constrainable(copy)
+: Handle(copy)
 {
 }
 
@@ -90,13 +66,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();
@@ -137,6 +106,11 @@ 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));
@@ -163,12 +137,6 @@ Actor Actor::FindChildByName(const std::string& actorName)
   return Actor(child.Get());
 }
 
-Actor Actor::FindChildByAlias(const std::string& actorAlias)
-{
-  Actor child = GetImplementation(*this).FindChildByAlias(actorAlias);
-  return child;
-}
-
 Actor Actor::FindChildById(const unsigned int id)
 {
   Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
@@ -222,11 +190,21 @@ void Actor::SetSize(const Vector3& size)
   GetImplementation(*this).SetSize(size);
 }
 
+Vector3 Actor::GetTargetSize() const
+{
+  return GetImplementation(*this).GetTargetSize();
+}
+
 Vector3 Actor::GetCurrentSize() const
 {
   return GetImplementation(*this).GetCurrentSize();
 }
 
+Vector3 Actor::GetNaturalSize() const
+{
+  return GetImplementation(*this).GetNaturalSize();
+}
+
 void Actor::SetPosition(float x, float y)
 {
   GetImplementation(*this).SetPosition(x, y);
@@ -257,9 +235,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
@@ -282,19 +260,19 @@ PositionInheritanceMode Actor::GetPositionInheritanceMode() const
   return GetImplementation(*this).GetPositionInheritanceMode();
 }
 
-void Actor::SetRotation(const Degree& angle, const Vector3& axis)
+void Actor::SetOrientation(const Degree& angle, const Vector3& axis)
 {
-  GetImplementation(*this).SetRotation(Radian(angle), axis);
+  GetImplementation(*this).SetOrientation(Radian(angle), axis);
 }
 
-void Actor::SetRotation(const Radian& angle, const Vector3& axis)
+void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
 {
-  GetImplementation(*this).SetRotation(angle, axis);
+  GetImplementation(*this).SetOrientation(angle, axis);
 }
 
-void Actor::SetRotation(const Quaternion& rotation)
+void Actor::SetOrientation(const Quaternion& orientation)
 {
-  GetImplementation(*this).SetRotation(rotation);
+  GetImplementation(*this).SetOrientation(orientation);
 }
 
 void Actor::RotateBy(const Degree& angle, const Vector3& axis)
@@ -312,24 +290,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)
@@ -372,6 +350,26 @@ bool Actor::IsScaleInherited() const
   return GetImplementation(*this).IsScaleInherited();
 }
 
+void Actor::SetSizeMode(SizeMode mode)
+{
+  GetImplementation(*this).SetSizeMode(mode);
+}
+
+SizeMode Actor::GetSizeMode() const
+{
+  return GetImplementation(*this).GetSizeMode();
+}
+
+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();
@@ -392,11 +390,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();
@@ -407,11 +400,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();
@@ -432,37 +420,6 @@ Vector4 Actor::GetCurrentWorldColor() const
   return GetImplementation(*this).GetCurrentWorldColor();
 }
 
-void Actor::SetInheritShaderEffect(bool inherit)
-{
-  // TODO remove this API
-  // @deprecated
-}
-
-bool Actor::GetInheritShaderEffect() const
-{
-  // TODO remove this API
-  // @deprecated
-  return false;
-}
-
-void Actor::SetShaderEffect(ShaderEffect effect)
-{
-  // TODO remove this API
-  GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
-}
-
-ShaderEffect Actor::GetShaderEffect() const
-{
-  // TODO remove this API
-  return ShaderEffect();
-}
-
-void Actor::RemoveShaderEffect()
-{
-  // TODO remove this API
-  GetImplementation(*this).RemoveShaderEffect();
-}
-
 void Actor::SetDrawMode( DrawMode::Type drawMode )
 {
   GetImplementation(*this).SetDrawMode( drawMode );
@@ -508,125 +465,192 @@ bool Actor::IsKeyboardFocusable() const
   return GetImplementation(*this).IsKeyboardFocusable();
 }
 
-Actor::TouchSignalV2& Actor::TouchedSignal()
+void Actor::SetRelayoutEnabled( bool enabled )
 {
-  return GetImplementation(*this).TouchedSignal();
+  GetImplementation(*this).SetRelayoutEnabled( enabled );
 }
 
-Actor::MouseWheelEventSignalV2& Actor::MouseWheelEventSignal()
+bool Actor::IsRelayoutEnabled() const
 {
-  return GetImplementation(*this).MouseWheelEventSignal();
+  return GetImplementation(*this).IsRelayoutEnabled();
 }
 
-Actor::SetSizeSignalV2& Actor::SetSizeSignal()
+void Actor::SetResizePolicy( ResizePolicy policy, Dimension dimension )
 {
-  return GetImplementation(*this).SetSizeSignal();
+  GetImplementation(*this).SetResizePolicy( policy, dimension );
 }
 
-Actor::OnStageSignalV2& Actor::OnStageSignal()
+ResizePolicy Actor::GetResizePolicy( Dimension dimension ) const
 {
-  return GetImplementation(*this).OnStageSignal();
+  return GetImplementation(*this).GetResizePolicy( dimension );
 }
 
-Actor::OffStageSignalV2& Actor::OffStageSignal()
+void Actor::SetSizeScalePolicy( SizeScalePolicy policy )
 {
-  return GetImplementation(*this).OffStageSignal();
+  GetImplementation(*this).SetSizeScalePolicy( policy );
+}
+
+SizeScalePolicy Actor::GetSizeScalePolicy() const
+{
+  return GetImplementation(*this).GetSizeScalePolicy();
+}
+
+void Actor::SetDimensionDependency( Dimension dimension, Dimension dependency )
+{
+  GetImplementation(*this).SetDimensionDependency( dimension, dependency );
+}
+
+Dimension Actor::GetDimensionDependency( Dimension dimension )
+{
+  return GetImplementation(*this).GetDimensionDependency( dimension );
+}
+
+float Actor::GetHeightForWidth( float width )
+{
+  return GetImplementation(*this).GetHeightForWidth( width );
+}
+
+float Actor::GetWidthForHeight( float height )
+{
+  return GetImplementation(*this).GetWidthForHeight( height );
+}
+
+float Actor::GetRelayoutSize( Dimension dimension ) const
+{
+  return GetImplementation(*this).GetRelayoutSize( dimension );
+}
+
+void Actor::RelayoutRequestTree()
+{
+  GetImplementation(*this).RelayoutRequestTree();
+}
+
+void Actor::PropagateRelayoutFlags()
+{
+  GetImplementation(*this).PropagateRelayoutFlags();
 }
 
-DynamicsBody Actor::EnableDynamics(DynamicsBodyConfig bodyConfig)
+void Actor::SetPadding( const Padding& padding )
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyConfig& internal = GetImplementation(bodyConfig);
+  Internal::Actor& impl = GetImplementation(*this);
 
-  Internal::DynamicsBodyPtr body( GetImplementation(*this).EnableDynamics( &internal ) );
+  Vector2 widthPadding( padding.left, padding.right );
+  impl.SetPadding( widthPadding, WIDTH );
 
-  return DynamicsBody( body.Get() );
-#else
-  return DynamicsBody();
-#endif
+  Vector2 heightPadding( padding.bottom, padding.top );
+  impl.SetPadding( heightPadding, 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( WIDTH );
+  Vector2 heightPadding = impl.GetPadding( 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::SetPreferredSize( const Vector2& size )
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::ActorPtr internalActor( &GetImplementation(attachedActor) );
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offsetA, offsetB) );
+  GetImplementation(*this).SetPreferredSize( size );
+}
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+Vector2 Actor::GetPreferredSize() const
+{
+  return GetImplementation(*this).GetPreferredSize();
 }
 
-const int Actor::GetNumberOfJoints() const
+void Actor::SetMinimumSize( const Vector2& size )
 {
-#ifdef DYNAMICS_SUPPORT
-  return GetImplementation(*this).GetNumberOfJoints();
-#else
-  return int();
-#endif
+  Internal::Actor& impl = GetImplementation(*this);
+
+  impl.SetMinimumSize( size.x, WIDTH );
+  impl.SetMinimumSize( size.y, HEIGHT );
 }
 
-DynamicsJoint Actor::GetDynamicsJointByIndex( const int index )
+Vector2 Actor::GetMinimumSize()
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJointByIndex( index ) );
+  Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  return Vector2( impl.GetMinimumSize( WIDTH ), impl.GetMinimumSize( HEIGHT ) );
 }
 
-DynamicsJoint Actor::GetDynamicsJoint( Actor attachedActor )
+void Actor::SetMaximumSize( const Vector2& size )
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJoint( &GetImplementation(attachedActor) ) );
+  Internal::Actor& impl = GetImplementation(*this);
 
-  return DynamicsJoint( joint.Get() );
-#else
-  return DynamicsJoint();
-#endif
+  impl.SetMaximumSize( size.x, WIDTH );
+  impl.SetMaximumSize( size.y, HEIGHT );
+}
+
+Vector2 Actor::GetMaximumSize()
+{
+  Internal::Actor& impl = GetImplementation(*this);
+
+  return Vector2( impl.GetMaximumSize( WIDTH ), impl.GetMaximumSize( HEIGHT ) );
+}
+
+Actor::TouchSignalType& Actor::TouchedSignal()
+{
+  return GetImplementation(*this).TouchedSignal();
+}
+
+Actor::HoverSignalType& Actor::HoveredSignal()
+{
+  return GetImplementation(*this).HoveredSignal();
+}
+
+Actor::MouseWheelEventSignalType& Actor::MouseWheelEventSignal()
+{
+  return GetImplementation(*this).MouseWheelEventSignal();
+}
+
+Actor::OnStageSignalType& Actor::OnStageSignal()
+{
+  return GetImplementation(*this).OnStageSignal();
+}
+
+Actor::OffStageSignalType& Actor::OffStageSignal()
+{
+  return GetImplementation(*this).OffStageSignal();
+}
+
+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 )
+{
+  return Renderer( &GetImplementation(*this).GetRendererAt( index ) );
 }
 
-void Actor::RemoveDynamicsJoint( DynamicsJoint joint )
+void Actor::RemoveRenderer( Renderer& renderer )
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).RemoveDynamicsJoint( &GetImplementation(joint) );
-#endif
+  GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
 }
 
-void Actor::DisableDynamics()
+void Actor::RemoveRenderer( unsigned int index )
 {
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).DisableDynamics();
-#endif
+  GetImplementation(*this).RemoveRenderer( index );
 }
 
-DynamicsBody Actor::GetDynamicsBody()
+Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
 {
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsBodyPtr internal(GetImplementation(*this).GetDynamicsBody());
-  return DynamicsBody( internal.Get() );
-#else
-  return DynamicsBody();
-#endif
+  return GetImplementation(*this).OnRelayoutSignal();
 }
 
 Actor::Actor(Internal::Actor* internal)
-: Constrainable(internal)
+: Handle(internal)
 {
 }