Size negotiation patch 1: Remove SetPreferred size
[platform/core/uifw/dali-demo.git] / shared / view.h
index fe73652..f456182 100644 (file)
@@ -84,10 +84,11 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar,
                            const Dali::TextStyle& textStyle )
 {
   Dali::Layer toolBarLayer = Dali::Layer::New();
+  toolBarLayer.SetName( "TOOLBAR_LAYER" );
   toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
   toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
-  toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight  ) ) );
   toolBarLayer.SetSize( 0.0f, style.mToolBarHeight );
+  toolBarLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::WIDTH );
 
   // Raise tool bar layer to the top.
   toolBarLayer.RaiseToTop();
@@ -95,12 +96,14 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar,
   // Tool bar
   Dali::Image image = Dali::ResourceImage::New( toolbarImagePath );
   Dali::ImageActor toolBarBackground = Dali::ImageActor::New( image );
+  toolBarBackground.SetName( "TOOLBAR_BACKGROUND" );
+  toolBarBackground.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS );
   toolBar = Dali::Toolkit::ToolBar::New();
+  toolBar.SetName( "TOOLBAR" );
   toolBar.SetBackground( toolBarBackground );
   toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
   toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
-  toolBar.SetSize( 0.0f, style.mToolBarHeight );
-  toolBar.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT );
+  toolBar.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS );
   toolBarBackground.SetSortModifier(1.0f);
 
   // Add the tool bar to the too bar layer.
@@ -112,7 +115,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar,
   if( !title.empty() )
   {
     Dali::Toolkit::TextView titleActor = Dali::Toolkit::TextView::New();
-    titleActor.SetName( "ToolbarTitle" );
+    titleActor.SetName( "TOOLBAR_TITLE" );
     titleActor.SetText( title );
     titleActor.SetSize( font.MeasureText( title ) );
     titleActor.SetStyleToCurrentText(textStyle);
@@ -138,14 +141,19 @@ Dali::Layer CreateView( Dali::Application& application,
 
   // Create default View.
   view = Dali::Toolkit::View::New();
+  view.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS );
 
   // Add the view to the stage before setting the background.
   stage.Add( view );
 
-  // Set background image.
-  if ( ! backgroundImagePath.empty() )
+  // Set background image, loading it at screen resolution:
+  if ( !backgroundImagePath.empty() )
   {
-    Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath );
+    Dali::ImageAttributes backgroundAttributes;
+    backgroundAttributes.SetSize( stage.GetSize() );
+    backgroundAttributes.SetFilterMode( Dali::ImageAttributes::BoxThenLinear );
+    backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ScaleToFill );
+    Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, backgroundAttributes );
     Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage );
     view.SetBackground( backgroundImageActor );
   }
@@ -160,13 +168,11 @@ Dali::Layer CreateView( Dali::Application& application,
   // Add tool bar layer to the view.
   view.AddContentLayer( toolBarLayer );
 
-
-
   // Create a content layer.
   Dali::Layer contentLayer = Dali::Layer::New();
   contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER );
   contentLayer.SetParentOrigin( Dali::ParentOrigin::CENTER );
-  contentLayer.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT );
+  contentLayer.SetResizePolicy( Dali::FILL_TO_PARENT, Dali::ALL_DIMENSIONS );
   view.AddContentLayer( contentLayer );
   contentLayer.LowerBelow( toolBarLayer );