Size negotiation patch 2: Move SetPreferredSize into actor-impl.cpp 34/37934/2
authorKingsley Stephens <k.stephens@samsung.com>
Wed, 8 Apr 2015 13:10:46 +0000 (14:10 +0100)
committerKingsley Stephens <k.stephens@samsung.com>
Thu, 9 Apr 2015 10:44:20 +0000 (11:44 +0100)
Fix for putting an actor hierarchy onto stage.

Change-Id: Ib48ea5f2a5dde292292fe18a415fb0d6e749252a

dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/image-actor-impl.cpp
dali/public-api/actors/actor.cpp

index 21a9bdc..acfe0d7 100644 (file)
@@ -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();
 }
index fa84c86..41a03fa 100644 (file)
@@ -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.
    */
index b7ef27f..55212d5 100644 (file)
@@ -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;
   }
 }
index 1f9435d..99b2b4e 100644 (file)
@@ -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