X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Factors%2Factor.cpp;h=88a1cd96bc0ebc19d311000593bc8aaea4150baa;hb=e08e2992259823c5f9832ad959ffa510b0445a6c;hp=f3beeb8c294ad98a6adcce953934e2bcf85cc25f;hpb=15b3d3203453c509017ce4266b46c2cb211d0695;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index f3beeb8..88a1cd9 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -22,26 +22,14 @@ #include #include #include -#include #include #include #include #include -#include +#include #include - -#include -#include -#include - -#ifdef DYNAMICS_SUPPORT -#include -#include -#include -#include -#include -#endif +#include namespace Dali { @@ -67,7 +55,7 @@ Actor::~Actor() } Actor::Actor(const Actor& copy) -: Constrainable(copy) +: Handle(copy) { } @@ -87,7 +75,7 @@ void Actor::SetName(const std::string& name) GetImplementation(*this).SetName(name); } -unsigned int Actor::GetId() const +uint32_t Actor::GetId() const { return GetImplementation(*this).GetId(); } @@ -117,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)); @@ -132,32 +115,27 @@ 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); + 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) +Actor Actor::FindChildById( const uint32_t 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 @@ -199,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 @@ -252,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 @@ -267,34 +245,14 @@ 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) +void Actor::SetOrientation(const Radian& angle, const Vector3& axis) { - GetImplementation(*this).SetRotation(Radian(angle), axis); + GetImplementation(*this).SetOrientation(angle, axis); } -void Actor::SetRotation(const Radian& angle, const Vector3& axis) +void Actor::SetOrientation(const Quaternion& orientation) { - 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).SetOrientation(orientation); } void Actor::RotateBy(const Radian& angle, const Vector3& axis) @@ -307,24 +265,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) @@ -367,16 +325,6 @@ 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); @@ -407,11 +355,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(); @@ -422,11 +365,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(); @@ -492,135 +430,201 @@ bool Actor::IsKeyboardFocusable() const return GetImplementation(*this).IsKeyboardFocusable(); } -Actor::TouchSignalType& Actor::TouchedSignal() +void Actor::Raise() { - return GetImplementation(*this).TouchedSignal(); + GetImplementation( *this ).Raise(); } -Actor::HoverSignalType& Actor::HoveredSignal() +void Actor::Lower() { - return GetImplementation(*this).HoveredSignal(); + GetImplementation( *this ).Lower(); } -Actor::MouseWheelEventSignalType& Actor::MouseWheelEventSignal() +void Actor::RaiseToTop() { - return GetImplementation(*this).MouseWheelEventSignal(); + GetImplementation( *this ).RaiseToTop(); } -Actor::OnStageSignalType& Actor::OnStageSignal() +void Actor::LowerToBottom() { - return GetImplementation(*this).OnStageSignal(); + GetImplementation( *this ).LowerToBottom(); } -Actor::OffStageSignalType& Actor::OffStageSignal() +void Actor::RaiseAbove( Actor target ) { - return GetImplementation(*this).OffStageSignal(); + GetImplementation( *this ).RaiseAbove( GetImplementation( target ) ); } -DynamicsBody Actor::EnableDynamics(DynamicsBodyConfig bodyConfig) +void Actor::LowerBelow( Actor target ) { -#ifdef DYNAMICS_SUPPORT - Internal::DynamicsBodyConfig& internal = GetImplementation(bodyConfig); + GetImplementation( *this ).LowerBelow( GetImplementation( target ) ); +} - Internal::DynamicsBodyPtr body( GetImplementation(*this).EnableDynamics( &internal ) ); +void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) +{ + GetImplementation(*this).SetResizePolicy( policy, dimension ); +} - return DynamicsBody( body.Get() ); -#else - return DynamicsBody(); -#endif +ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const +{ + return GetImplementation(*this).GetResizePolicy( dimension ); } -DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offset ) +void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy ) { -#ifdef DYNAMICS_SUPPORT - Internal::ActorPtr internalActor( &GetImplementation(attachedActor) ); - Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offset) ); + GetImplementation(*this).SetSizeScalePolicy( policy ); +} - return DynamicsJoint( joint.Get() ); -#else - return DynamicsJoint(); -#endif +SizeScalePolicy::Type Actor::GetSizeScalePolicy() const +{ + return GetImplementation(*this).GetSizeScalePolicy(); } -DynamicsJoint Actor::AddDynamicsJoint( Actor attachedActor, const Vector3& offsetA, const Vector3& offsetB ) +float Actor::GetHeightForWidth( float width ) { -#ifdef DYNAMICS_SUPPORT - Internal::ActorPtr internalActor( &GetImplementation(attachedActor) ); - Internal::DynamicsJointPtr joint( GetImplementation(*this).AddDynamicsJoint( internalActor, offsetA, offsetB) ); + return GetImplementation(*this).GetHeightForWidth( width ); +} - return DynamicsJoint( joint.Get() ); -#else - return DynamicsJoint(); -#endif +float Actor::GetWidthForHeight( float height ) +{ + return GetImplementation(*this).GetWidthForHeight( height ); } -int Actor::GetNumberOfJoints() const +float Actor::GetRelayoutSize( Dimension::Type dimension ) const { -#ifdef DYNAMICS_SUPPORT - return GetImplementation(*this).GetNumberOfJoints(); -#else - return int(); -#endif + return GetImplementation(*this).GetRelayoutSize( dimension ); } -DynamicsJoint Actor::GetDynamicsJointByIndex( const int index ) +void Actor::SetPadding( const Padding& padding ) { -#ifdef DYNAMICS_SUPPORT - Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJointByIndex( index ) ); + Internal::Actor& impl = GetImplementation(*this); - return DynamicsJoint( joint.Get() ); -#else - return DynamicsJoint(); -#endif + Vector2 widthPadding( padding.left, padding.right ); + impl.SetPadding( widthPadding, Dimension::WIDTH ); + + Vector2 heightPadding( padding.bottom, padding.top ); + impl.SetPadding( heightPadding, Dimension::HEIGHT ); } -DynamicsJoint Actor::GetDynamicsJoint( Actor attachedActor ) +void Actor::GetPadding( Padding& paddingOut ) const { -#ifdef DYNAMICS_SUPPORT - Internal::DynamicsJointPtr joint( GetImplementation(*this).GetDynamicsJoint( &GetImplementation(attachedActor) ) ); + const Internal::Actor& impl = GetImplementation(*this); + + Vector2 widthPadding = impl.GetPadding( Dimension::WIDTH ); + Vector2 heightPadding = impl.GetPadding( Dimension::HEIGHT ); - return DynamicsJoint( joint.Get() ); -#else - return DynamicsJoint(); -#endif + paddingOut.left = widthPadding.x; + paddingOut.right = widthPadding.y; + paddingOut.bottom = heightPadding.x; + paddingOut.top = heightPadding.y; } -void Actor::RemoveDynamicsJoint( DynamicsJoint joint ) +void Actor::SetMinimumSize( const Vector2& size ) { -#ifdef DYNAMICS_SUPPORT - GetImplementation(*this).RemoveDynamicsJoint( &GetImplementation(joint) ); -#endif + Internal::Actor& impl = GetImplementation(*this); + + impl.SetMinimumSize( size.x, Dimension::WIDTH ); + impl.SetMinimumSize( size.y, Dimension::HEIGHT ); } -void Actor::DisableDynamics() +Vector2 Actor::GetMinimumSize() { -#ifdef DYNAMICS_SUPPORT - GetImplementation(*this).DisableDynamics(); -#endif + Internal::Actor& impl = GetImplementation(*this); + + return Vector2( impl.GetMinimumSize( Dimension::WIDTH ), impl.GetMinimumSize( Dimension::HEIGHT ) ); } -DynamicsBody Actor::GetDynamicsBody() +void Actor::SetMaximumSize( const Vector2& size ) { -#ifdef DYNAMICS_SUPPORT - Internal::DynamicsBodyPtr internal(GetImplementation(*this).GetDynamicsBody()); - return DynamicsBody( internal.Get() ); -#else - return DynamicsBody(); -#endif + Internal::Actor& impl = GetImplementation(*this); + + impl.SetMaximumSize( size.x, Dimension::WIDTH ); + impl.SetMaximumSize( size.y, Dimension::HEIGHT ); } -Actor::Actor(Internal::Actor* internal) -: Constrainable(internal) +Vector2 Actor::GetMaximumSize() { + Internal::Actor& impl = GetImplementation(*this); + + return Vector2( impl.GetMaximumSize( Dimension::WIDTH ), impl.GetMaximumSize( Dimension::HEIGHT ) ); +} + +int32_t Actor::GetHierarchyDepth() +{ + return GetImplementation(*this).GetHierarchyDepth(); +} + +Actor::TouchSignalType& Actor::TouchedSignal() +{ + DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" ); + + return GetImplementation(*this).TouchedSignal(); } -void UnparentAndReset( Actor& actor ) +Actor::TouchDataSignalType& Actor::TouchSignal() +{ + return GetImplementation( *this ).TouchSignal(); +} + +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(); +} + +uint32_t Actor::AddRenderer( Renderer& renderer ) +{ + return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) ); +} + +uint32_t Actor::GetRendererCount() const +{ + return GetImplementation(*this).GetRendererCount(); +} + +Renderer Actor::GetRendererAt( uint32_t 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( uint32_t index ) +{ + GetImplementation(*this).RemoveRenderer( index ); +} + +Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal() +{ + return GetImplementation(*this).OnRelayoutSignal(); +} + +Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal() +{ + return GetImplementation( *this ).LayoutDirectionChangedSignal(); +} + +Actor::Actor(Internal::Actor* internal) +: Handle(internal) { - if( actor ) - { - actor.Unparent(); - actor.Reset(); - } } } // namespace Dali