Ensure width & height properties can be set individually 20/119920/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 20 Mar 2017 13:38:30 +0000 (13:38 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 20 Mar 2017 15:14:27 +0000 (15:14 +0000)
Change-Id: Ie8d7ee230a87f2152c8ad6320839c46bc70a2a5f

automated-tests/src/dali/utc-Dali-Actor.cpp
dali/internal/event/actors/actor-impl.cpp

index bcc2aca..0c84dd5 100644 (file)
@@ -979,6 +979,37 @@ int UtcDaliActorSetSizeIndividual(void)
   END_TEST;
 }
 
+int UtcDaliActorSetSizeIndividual02(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+  Stage::GetCurrent().Add( actor );
+
+  Vector3 vector( 100.0f, 200.0f, 400.0f );
+  DALI_TEST_CHECK( vector != actor.GetCurrentSize() );
+
+  actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width );
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_WIDTH ).Get< float >(), vector.width, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height );
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_HEIGHT ).Get< float >(), vector.height, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+  actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth );
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE_DEPTH ).Get< float >(), vector.depth, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+
+  // flush the queue and render once
+  application.SendNotification();
+  application.Render();
+
+  // Check the width in the new frame
+  DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION );
+  DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION );
+
+  END_TEST;
+}
+
 
 int UtcDaliActorGetCurrentSize(void)
 {
index a9eddf4..9a3d3d7 100644 (file)
@@ -1286,24 +1286,44 @@ void Actor::NotifyPositionAnimation( Animation& animation, float targetPosition,
 
 void Actor::SetWidth( float width )
 {
-  mTargetSize.width = width;
-
-  if( NULL != mNode )
+  if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout )
   {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
+    SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );
+    mRelayoutData->preferredSize.width = width;
+  }
+  else
+  {
+    mTargetSize.width = width;
+
+    if( NULL != mNode )
+    {
+      // mNode is being used in a separate thread; queue a message to set the value & base value
+      SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
+    }
   }
+
+  RelayoutRequest();
 }
 
 void Actor::SetHeight( float height )
 {
-  mTargetSize.height = height;
-
-  if( NULL != mNode )
+  if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout )
   {
-    // mNode is being used in a separate thread; queue a message to set the value & base value
-    SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
+    SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT );
+    mRelayoutData->preferredSize.height = height;
+  }
+  else
+  {
+    mTargetSize.height = height;
+
+    if( NULL != mNode )
+    {
+      // mNode is being used in a separate thread; queue a message to set the value & base value
+      SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), mNode, &mNode->mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
+    }
   }
+
+  RelayoutRequest();
 }
 
 void Actor::SetDepth( float depth )