Change default resize policy to USE_NATURAL_SIZE and fix UTC tests 29/40429/3
authorTom Robinson <tom.robinson@samsung.com>
Wed, 3 Jun 2015 13:26:56 +0000 (14:26 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Wed, 3 Jun 2015 14:14:00 +0000 (07:14 -0700)
Change-Id: I4d223222b6928f8a1801a036b24d9eade18f5e7a

automated-tests/src/dali/utc-Dali-Actor.cpp
automated-tests/src/dali/utc-Dali-CustomActor.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/common/stage-impl.cpp
dali/internal/event/images/image-impl.h
dali/public-api/actors/actor-enumerations.h

index cb36c4a..412936f 100644 (file)
@@ -2686,8 +2686,8 @@ int UtcDaliRelayoutProperties_ResizePolicies(void)
   Actor actor = Actor::New();
 
   // Defaults
-  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
-  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "FIXED", TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::WIDTH_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::HEIGHT_RESIZE_POLICY ).Get< std::string >(), "USE_NATURAL_SIZE", TEST_LOCATION );
 
   // Set resize policy for all dimensions
   actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
index 7f60458..00da4c1 100644 (file)
@@ -607,6 +607,7 @@ public:
   {
     Impl::TestCustomActor* impl = new Impl::TestCustomActor( true );
     TestCustomActor custom( *impl ); // takes ownership
+    custom.SetName( "SizeNegotiationActor" );
 
     impl->Initialize();
 
index a12f052..8793e1a 100644 (file)
@@ -71,7 +71,8 @@ namespace ResizePolicy
 
 namespace
 {
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )DALI_ENUM_TO_STRING( FIXED )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )
+DALI_ENUM_TO_STRING( FIXED )
 DALI_ENUM_TO_STRING( USE_NATURAL_SIZE )
 DALI_ENUM_TO_STRING( FILL_TO_PARENT )
 DALI_ENUM_TO_STRING( SIZE_RELATIVE_TO_PARENT )
@@ -89,7 +90,8 @@ namespace SizeScalePolicy
 namespace
 {
 // Enumeration to / from string conversion tables
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )DALI_ENUM_TO_STRING( USE_SIZE_SET )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( Type )
+DALI_ENUM_TO_STRING( USE_SIZE_SET )
 DALI_ENUM_TO_STRING( FIT_WITH_ASPECT_RATIO )
 DALI_ENUM_TO_STRING( FILL_WITH_ASPECT_RATIO )
 DALI_ENUM_TO_STRING_TABLE_END( Type )
@@ -112,7 +114,7 @@ struct Actor::RelayoutData
     // Set size negotiation defaults
     for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
     {
-      resizePolicies[ i ] = ResizePolicy::FIXED;
+      resizePolicies[ i ] = ResizePolicy::DEFAULT;
       negotiatedDimensions[ i ] = 0.0f;
       dimensionNegotiated[ i ] = false;
       dimensionDirty[ i ] = false;
@@ -1337,7 +1339,7 @@ ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
     }
   }
 
-  return ResizePolicy::FIXED;   // Default
+  return ResizePolicy::DEFAULT;
 }
 
 void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
index 1e1dc48..5678841 100644 (file)
@@ -93,6 +93,10 @@ void Stage::Initialize()
   // The stage owns the default layer
   mRootLayer = Layer::NewRoot( *mLayerList, mUpdateManager, false/*not system-level*/ );
   mRootLayer->SetName("RootLayer");
+  // The root layer needs to have a fixed resize policy (as opposed to the default USE_NATURAL_SIZE).
+  // This stops actors parented to the stage having their relayout requests propagating
+  // up to the root layer, and down through other children unnecessarily.
+  mRootLayer->SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
 
   // Create the default camera actor first; this is needed by the RenderTaskList
   CreateDefaultCameraActor();
index 0d5a9da..d0ec736 100644 (file)
@@ -83,7 +83,6 @@ public:
    * Only to be used after the image has finished loading.
    * (Ticket's LoadingSucceeded callback was called)
    * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
-   * Connect to SignalLoadingFinished or use GetLoadingState to make sure this value is actual.
    * @pre image should be loaded
    */
   virtual unsigned int GetWidth() const;
@@ -93,7 +92,6 @@ public:
    * Only to be used after the image has finished loading.
    * (Ticket's LoadingSucceeded callback was called)
    * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
-   * Connect to SignalLoadingFinished or use GetLoadingState to make sure this value is actual.
    * @pre image should be loaded
    */
   virtual unsigned int GetHeight() const;
index 16be145..dc86d14 100644 (file)
@@ -81,6 +81,7 @@ enum Type
   DIMENSION_DEPENDENCY,  ///< One dimension is dependent on the other
   USE_ASSIGNED_SIZE      ///< The size will be assigned to the actor
 };
+const Type DEFAULT = USE_NATURAL_SIZE; ///< Default resize policy
 }
 
 /**