Stop setting crazy Z value when SetSize(width,height) is used 05/44605/3
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 23 Jul 2015 12:42:26 +0000 (13:42 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 27 Jul 2015 16:38:25 +0000 (17:38 +0100)
Change-Id: Ic428a491ec271748eac7930a3126c4f9fb5132e3

automated-tests/src/dali-internal/utc-Dali-Internal-Image-Culling.cpp
automated-tests/src/dali/utc-Dali-Actor.cpp
automated-tests/src/dali/utc-Dali-ImageActor.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/image-actor-impl.cpp

index 7297524..178f981 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ void TestImageInside( TestApplication& application, int width, int height )
   imageActor.SetPosition(0.0f, 0.0f, 0.0f);
 
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   drawTrace.Reset();
   imageActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
@@ -228,7 +228,7 @@ void SphereTestImageAtBoundary( TestApplication& application, int width, int hei
   ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
 
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   imageSize.z = 0.0f;
   float radius = imageSize.Length() * 0.5f; // Radius of bounding box
@@ -279,7 +279,7 @@ void OBBTestImageAtBoundary( TestApplication& application, int width, int height
   ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
 
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   imageSize.z = 0.0f;
   tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f) \n",
@@ -336,7 +336,7 @@ void SphereTestImageOutsideBoundary( TestApplication& application, int width, in
 
   ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   imageSize.z = 0.0f;
   float radius = imageSize.Length() * 0.5f; // Radius of bounding box
@@ -380,7 +380,7 @@ void OBBTestImageOutsideBoundary( TestApplication& application, int width, int h
 
   ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   imageSize.z = 0.0f;
   tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f)\n",
@@ -817,7 +817,7 @@ int UtcDaliImageCulling_Disable(void)
 
   ImageActor imageActor = CreateOnStageActor(application, image, width, height, true);
   Vector3 imageSize = imageActor.GetCurrentSize();
-  DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION);
+  DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION);
 
   imageSize.z = 0.0f;
 
index 3ba9bd9..d8cc27d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -663,7 +663,7 @@ int UtcDaliActorSetSize01(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Vector3 vector(100.0f, 100.0f, 100.0f);
+  Vector3 vector(100.0f, 100.0f, 0.0f);
 
   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
 
@@ -703,7 +703,7 @@ int UtcDaliActorSetSize03(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  Vector3 vector(100.0f, 100.0f, 100.0f);
+  Vector3 vector(100.0f, 100.0f, 0.0f);
 
   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
 
index 6c44479..56525af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -198,7 +198,7 @@ int UtcDaliImageActorSetSize01(void)
   actor.SetShaderEffect( effect );
 
   const float INVALID_SIZE = float(1u<<31);
-  Vector3 vector( INVALID_SIZE, INVALID_SIZE, INVALID_SIZE );
+  Vector3 vector( INVALID_SIZE, INVALID_SIZE, 0.0f );
 
   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
 
index 2bd9b83..ea6f1d0 100644 (file)
@@ -1077,23 +1077,19 @@ void Actor::SetSize( float width, float height, float depth )
 
 void Actor::SetSize( const Vector2& size )
 {
-  SetSize( Vector3( size.width, size.height, CalculateSizeZ( size ) ) );
+  SetSize( Vector3( size.width, size.height, 0.f ) );
 }
 
 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 );
+  SetSizeInternal( Vector3( size.width, size.height, 0.f ) );
 }
 
 void Actor::SetSize( const Vector3& size )
 {
   if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout )
   {
+    // TODO we cannot just ignore the given Z but that means rewrite the size negotiation!!
     SetPreferredSize( size.GetVectorXY() );
   }
   else
@@ -4041,7 +4037,7 @@ Vector2 Actor::GetPreferredSize() const
 {
   if ( mRelayoutData )
   {
-    return mRelayoutData->preferredSize;
+    return Vector2( mRelayoutData->preferredSize );
   }
 
   return GetDefaultPreferredSize();
index 6887d8b..6be3f77 100644 (file)
@@ -1542,16 +1542,8 @@ protected:
    */
   bool IsNodeConnected() const;
 
-  /**
-   * Calculate the size of the z dimension for a 2D size
-   *
-   * @param[in] size The 2D size (X, Y) to calculate Z from
-   *
-   * @return Return the Z dimension for this size
-   */
-  float CalculateSizeZ( const Vector2& size ) const;
-
 public:
+
   // Default property extensions from Object
 
   /**
index 5c6b028..601a699 100644 (file)
@@ -104,6 +104,7 @@ ImageActorPtr ImageActor::New()
 
 void ImageActor::OnInitialize()
 {
+  // TODO: Remove this, at the moment its needed for size negotiation to work
   SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
 }
 
@@ -208,7 +209,7 @@ ImageActor::~ImageActor()
 Vector3 ImageActor::GetNaturalSize() const
 {
   Vector2 naturalSize( CalculateNaturalSize() );
-  return Vector3( naturalSize.width, naturalSize.height, CalculateSizeZ( naturalSize ) );
+  return Vector3( naturalSize.width, naturalSize.height, 0.f );
 }
 
 Vector2 ImageActor::CalculateNaturalSize() const