Add to request Relayout when connected to Stage 47/191347/2
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 16 Oct 2018 07:03:43 +0000 (16:03 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 18 Oct 2018 07:07:55 +0000 (16:07 +0900)
Change-Id: I82fd90a662ea52a8b1bf4025fa2c08a30f65de9a
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index 49da596..46ba80b 100644 (file)
@@ -3412,3 +3412,53 @@ int UtcDaliLayouting_SetLayout(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliLayouting_StageAdd(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_StageAdd");
+
+  Stage stage = Stage::GetCurrent();
+
+  AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
+  Control container = Control::New();
+  container.SetName( "Container" );
+  DevelControl::SetLayout( container, absoluteLayout );
+  container.SetAnchorPoint( Dali::AnchorPoint::CENTER );
+  container.SetParentOrigin( Dali::ParentOrigin::CENTER );
+
+  Control child = Control::New();
+  child.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT );
+  child.SetPosition( 0.0f, 0.0f );
+  child.SetSize( 480.0f, 180.0f );
+  child.SetName( "Child Control" );
+  container.Add( child );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Not re-laid out
+  DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  // Add container to stage here
+  // Should call RequestLayout() to measure and layout
+  stage.Add( container );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( container.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Stage Size
+  DALI_TEST_EQUALS( child.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
index 8f862f5..1804809 100755 (executable)
@@ -573,6 +573,9 @@ void Control::OnStageConnection( int depth )
 
   // The clipping renderer is only created if required.
   CreateClippingRenderer( *this );
 
   // The clipping renderer is only created if required.
   CreateClippingRenderer( *this );
+
+  // Request to be laid out when the control is connected to the Stage.
+  Toolkit::DevelControl::RequestLayout( *this );
 }
 
 void Control::OnStageDisconnection()
 }
 
 void Control::OnStageDisconnection()