Force the child with assigned size during relayout to do size negotiation 31/63031/4
authorRichard Huang <r.huang@samsung.com>
Mon, 21 Mar 2016 18:07:07 +0000 (18:07 +0000)
committerRichard Huang <r.huang@samsung.com>
Wed, 23 Mar 2016 14:49:15 +0000 (14:49 +0000)
Change-Id: Ibb89b20c22717070151dbf778422c75efd987cb7

dali/internal/event/actors/actor-impl.cpp
dali/internal/event/size-negotiation/relayout-controller-impl.cpp

index b7b8f74..95bf894 100644 (file)
@@ -4066,6 +4066,22 @@ void Actor::SetNegotiatedSize( RelayoutContainer& container )
 
 void Actor::NegotiateSize( const Vector2& allocatedSize, RelayoutContainer& container )
 {
+  // Force a size negotiation for actors that has assigned size during relayout
+  // This is required as otherwise the flags that force a relayout will not
+  // necessarilly be set. This will occur if the actor has already been laid out.
+  // The dirty flags are then cleared. Then if the actor is added back into the
+  // relayout container afterwards, the dirty flags would still be clear...
+  // causing a relayout to be skipped. Here we force any actors added to the
+  // container to be relayed out.
+  if(GetResizePolicy(Dimension::WIDTH) == ResizePolicy::USE_ASSIGNED_SIZE)
+  {
+    SetLayoutNegotiated(false, Dimension::WIDTH);
+  }
+  if(GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::USE_ASSIGNED_SIZE)
+  {
+    SetLayoutNegotiated(false, Dimension::HEIGHT);
+  }
+
   // Do the negotiation
   NegotiateDimensions( allocatedSize );
 
@@ -4079,6 +4095,19 @@ void Actor::NegotiateSize( const Vector2& allocatedSize, RelayoutContainer& cont
   {
     ActorPtr child = GetChildAt( i );
 
+    // Forces children that have already been laid out to be relayed out
+    // if they have assigned size during relayout.
+    if(child->GetResizePolicy(Dimension::WIDTH) == ResizePolicy::USE_ASSIGNED_SIZE)
+    {
+      child->SetLayoutNegotiated(false, Dimension::WIDTH);
+      child->SetLayoutDirty(true, Dimension::WIDTH);
+    }
+    if(child->GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::USE_ASSIGNED_SIZE)
+    {
+      child->SetLayoutNegotiated(false, Dimension::HEIGHT);
+      child->SetLayoutDirty(true, Dimension::HEIGHT);
+    }
+
     // Only relayout if required
     if( child->RelayoutRequired() )
     {
index 0d6b927..e380a7e 100644 (file)
@@ -480,16 +480,6 @@ void RelayoutController::Relayout()
           // 3. Negotiate the size with the current actor. Pass it an empty container which the actor
           //    has to fill with all the actors it has not done any size negotiation for.
 
-          // Force the actor in the relayout container to do a size negotiation
-          if(actorImpl.GetResizePolicy(Dimension::WIDTH) == ResizePolicy::USE_ASSIGNED_SIZE)
-          {
-            actorImpl.SetLayoutNegotiated(false, Dimension::WIDTH);
-          }
-          if(actorImpl.GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::USE_ASSIGNED_SIZE)
-          {
-            actorImpl.SetLayoutNegotiated(false, Dimension::HEIGHT);
-          }
-
           actorImpl.NegotiateSize( size, *mRelayoutStack );
         }
       }