From 181efc47ccdf2a0dcb481a2d5597df11cd089c43 Mon Sep 17 00:00:00 2001 From: Kingsley Stephens Date: Wed, 8 Apr 2015 14:10:46 +0100 Subject: [PATCH] Size negotiation patch 2: Move SetPreferredSize into actor-impl.cpp Fix for putting an actor hierarchy onto stage. Change-Id: Ib48ea5f2a5dde292292fe18a415fb0d6e749252a --- dali/internal/event/actors/actor-impl.cpp | 25 +++++++++++++---- dali/internal/event/actors/actor-impl.h | 14 ++++++++++ dali/internal/event/actors/image-actor-impl.cpp | 4 +-- dali/public-api/actors/actor.cpp | 36 +++---------------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 21a9bdc..acfe0d7 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -415,11 +415,6 @@ void Actor::Add( Actor& child ) { RelayoutRequest(); } - - if( child.RelayoutDependentOnParent() ) - { - child.RelayoutRequest(); - } } } } @@ -1171,6 +1166,11 @@ void Actor::SetSize( const Vector2& size ) SetSize( Vector3( size.width, size.height, CalculateSizeZ( size ) ) ); } +void Actor::SetSizeInternal( const Vector2& size ) +{ + SetSizeInternal( Vector3( size.width, size.height, CalculateSizeZ( size ) ) ); +} + float Actor::CalculateSizeZ( const Vector2& size ) const { return std::min( size.width, size.height ); @@ -1178,6 +1178,18 @@ float Actor::CalculateSizeZ( const Vector2& size ) const void Actor::SetSize( const Vector3& size ) { + if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout ) + { + SetPreferredSize( size.GetVectorXY() ); + } + else + { + SetSizeInternal( size ); + } +} + +void Actor::SetSizeInternal( const Vector3& size ) +{ if( NULL != mNode ) { mTargetSize = size; @@ -2375,6 +2387,9 @@ void Actor::ConnectToSceneGraph( int index ) } #endif + // Request relayout on all actors that are added to the scenegraph + RelayoutRequest(); + // Notification for Object::Observers OnSceneObjectAdd(); } diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index fa84c86..41a03fa 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -302,6 +302,13 @@ public: void SetSize( const Vector2& size ); /** + * Sets the update size for an actor. + * + * @param[in] size The size to set. + */ + void SetSizeInternal( const Vector2& size ); + + /** * Sets the size of an actor. * ActorAttachments attached to the actor, can be scaled to fit within this area. * This does not interfere with the actors scale factor. @@ -310,6 +317,13 @@ public: void SetSize( const Vector3& size ); /** + * Sets the update size for an actor. + * + * @param[in] size The size to set. + */ + void SetSizeInternal( const Vector3& size ); + + /** * Set the width component of the Actor's size. * @param [in] width The new width component. */ diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index b7ef27f..55212d5 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -170,7 +170,7 @@ void ImageActor::ClearPixelArea() if( image ) { mInternalSetSize = true; - SetSize( image->GetNaturalSize() ); + SetSizeInternal( image->GetNaturalSize() ); mInternalSetSize = false; } } @@ -225,7 +225,7 @@ void ImageActor::SetNaturalSize() if( mUsingNaturalSize ) { mInternalSetSize = true; - SetSize( CalculateNaturalSize() ); + SetSizeInternal( CalculateNaturalSize() ); mInternalSetSize = false; } } diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index 1f9435d..99b2b4e 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -172,50 +172,22 @@ Vector3 Actor::GetCurrentAnchorPoint() const void Actor::SetSize(float width, float height) { - if( IsRelayoutEnabled() ) - { - GetImplementation(*this).SetPreferredSize( Vector2( width, height ) ); - } - else - { - GetImplementation(*this).SetSize(width, height); - } + GetImplementation(*this).SetSize(width, height); } void Actor::SetSize(float width, float height, float depth) { - if( IsRelayoutEnabled() ) - { - GetImplementation(*this).SetPreferredSize( Vector2( width, height ) ); - } - else - { - GetImplementation(*this).SetSize(width, height, depth); - } + GetImplementation(*this).SetSize(width, height, depth); } void Actor::SetSize(const Vector2& size) { - if( IsRelayoutEnabled() ) - { - GetImplementation(*this).SetPreferredSize( size ); - } - else - { - GetImplementation(*this).SetSize( size ); - } + GetImplementation(*this).SetSize( size ); } void Actor::SetSize(const Vector3& size) { - if( IsRelayoutEnabled() ) - { - GetImplementation(*this).SetPreferredSize( size.GetVectorXY() ); - } - else - { - GetImplementation(*this).SetSize( size ); - } + GetImplementation(*this).SetSize( size ); } Vector3 Actor::GetTargetSize() const -- 2.7.4