New size negotiation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / view / view-impl.cpp
index 9a486ed..a1d0c09 100644 (file)
@@ -132,7 +132,7 @@ void View::SetBackground( ImageActor backgroundImage )
     mBackgroundLayer = Layer::New();
 
     mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-    mBackgroundLayer.SetSize( mViewSize );
+    mBackgroundLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
     // Add background layer to custom actor.
     Self().Add( mBackgroundLayer );
@@ -152,8 +152,10 @@ void View::SetBackground( ImageActor backgroundImage )
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  backgroundImage.SetScale( FillXYKeepAspectRatio( mViewSize, backgroundImage.GetSize() ) );
+  backgroundImage.SetRelayoutEnabled( false );    // We will scale its size manually
   mBackgroundLayer.Add( backgroundImage );
+
+  RelayoutRequest();
 }
 
 void View::SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse )
@@ -290,16 +292,14 @@ void View::OnInitialize()
   }
 }
 
-void View::OnControlSizeSet( const Vector3& targetSize )
+void View::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
-  mViewSize = targetSize;
   if( mBackgroundLayer )
   {
-    mBackgroundLayer.SetSize( mViewSize );
-    if( mBackgroundLayer.GetChildCount() > 0 )
+    if( mBackgroundLayer && mBackgroundLayer.GetChildCount() > 0 )
     {
       Actor background = mBackgroundLayer.GetChildAt(0);
-      background.SetScale( FillXYKeepAspectRatio( mViewSize, background.GetSize() ) );
+      background.SetScale( FillXYKeepAspectRatio( Vector3( size.width, size.height, 1.0f ), background.GetTargetSize() ) );
     }
   }
 }