Size negotiation patch 2: Re-enable size negotiation on builder actors. 35/37935/2
authorKingsley Stephens <k.stephens@samsung.com>
Wed, 8 Apr 2015 13:12:14 +0000 (14:12 +0100)
committerKingsley Stephens <k.stephens@samsung.com>
Thu, 9 Apr 2015 10:44:51 +0000 (11:44 +0100)
Fix bug in resizing table view

Change-Id: If423207d24823047303ccc054df2e2edd8f83afa

dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.h
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/view/view-impl.cpp
dali-toolkit/internal/controls/view/view-impl.h

index 202e944..be1993c 100644 (file)
@@ -534,9 +534,6 @@ BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node,
 
       if( actor )
       {
-        // TEMP: Assume all script created actors are not using size negotiation for now
-        actor.SetRelayoutEnabled( false );
-
         // add children of all the styles
         if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
         {
index 4ca5be5..239d94e 100644 (file)
@@ -138,7 +138,7 @@ GaussianBlurView::GaussianBlurView()
 GaussianBlurView::GaussianBlurView( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
                                     const float downsampleWidthScale, const float downsampleHeightScale,
                                     bool blurUserImage)
-  : Control( CONTROL_BEHAVIOUR_NONE )
+  : Control( NO_SIZE_NEGOTIATION )
   , mNumSamples(numSamples)
   , mBlurBellCurveWidth( 0.001f )
   , mPixelFormat(renderTargetPixelFormat)
@@ -266,12 +266,14 @@ void GaussianBlurView::OnInitialize()
 
   // Create an ImageActor for performing a horizontal blur on the texture
   mImageActorHorizBlur = ImageActor::New();
+  mImageActorHorizBlur.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
   mImageActorHorizBlur.SetParentOrigin(ParentOrigin::CENTER);
   mImageActorHorizBlur.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
   mImageActorHorizBlur.SetShaderEffect( mHorizBlurShader );
 
   // Create an ImageActor for performing a vertical blur on the texture
   mImageActorVertBlur = ImageActor::New();
+  mImageActorVertBlur.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
   mImageActorVertBlur.SetParentOrigin(ParentOrigin::CENTER);
   mImageActorVertBlur.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
   mImageActorVertBlur.SetShaderEffect( mVertBlurShader );
@@ -283,6 +285,7 @@ void GaussianBlurView::OnInitialize()
   if(!mBlurUserImage)
   {
     mImageActorComposite = ImageActor::New();
+    mImageActorComposite.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
     mImageActorComposite.SetParentOrigin(ParentOrigin::CENTER);
     mImageActorComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
     mImageActorComposite.SetOpacity(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH); // ensure alpha is enabled for this object and set default value
@@ -293,6 +296,7 @@ void GaussianBlurView::OnInitialize()
 
     // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
     mTargetActor = ImageActor::New();
+    mTargetActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
     mTargetActor.SetParentOrigin(ParentOrigin::CENTER);
     mTargetActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
 
index 384e291..624e973 100644 (file)
@@ -143,6 +143,7 @@ void SuperBlurView::OnInitialize()
   for(unsigned int i=0; i<=mBlurLevels;i++)
   {
     mImageActors[i] = ImageActor::New(  );
+    mImageActors[i].SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
     mImageActors[i].SetParentOrigin( ParentOrigin::CENTER );
     mImageActors[i].SetZ(-static_cast<float>(i)*0.01f);
     mImageActors[i].SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA );
@@ -251,16 +252,6 @@ void SuperBlurView::ClearBlurResource()
   }
 }
 
-void SuperBlurView::OnRelayout( const Vector2& size, RelayoutContainer& container )
-{
-  unsigned int numChildren = Self().GetChildCount();
-
-  for( unsigned int i=0; i<numChildren; ++i )
-  {
-    Self().GetChildAt(i).SetSize(size);
-  }
-}
-
 void SuperBlurView::OnControlSizeSet( const Vector3& targetSize )
 {
   if( mTargetSize != Vector2(targetSize) )
index 041e717..cecc4c3 100644 (file)
@@ -119,11 +119,6 @@ private: // from Control
    */
   virtual void OnControlSizeSet(const Vector3& targetSize);
 
-  /**
-   * @copydoc Control::OnRelayout()
-   */
-  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
-
 private:
 
   /**
index 4f17023..db2910a 100644 (file)
@@ -60,11 +60,13 @@ void PrintArray( Array2d<Dali::Toolkit::Internal::TableView::CellData>& array )
     {
       Dali::Toolkit::Internal::TableView::CellData data = array[i][j];
       char actor = ' ';
+      std::string actorName;
       if( data.actor )
       {
         actor = 'A';
+        actorName = data.actor.GetName();
       }
-      TV_LOG("Array[%d,%d]=%c %d,%d,%d,%d  ", i, j, actor,
+      TV_LOG("Array[%d,%d]=%c %s %d,%d,%d,%d  ", i, j, actor, actorName.c_str(),
           data.position.rowIndex, data.position.columnIndex,
           data.position.rowSpan, data.position.columnSpan );
     }
@@ -192,50 +194,33 @@ bool TableView::AddChild( Actor& child, const Toolkit::TableView::CellPosition&
   // adopt the child
   Self().Add( child );
 
-  // put the actor to the main cell
-  CellData& data = mCellData[ position.rowIndex ][ position.columnIndex ];
-  data.actor = child;
-  data.position = position;
-
   // if child spans multiple rows of columns
-  bool spanned = false;
-  if( position.rowSpan > 1 )
+  if( ( position.rowSpan > 1 ) && ( position.rowIndex + position.rowSpan > mCellData.GetRows() ) )
   {
-    // span might go outside table
-    if( position.rowIndex + position.rowSpan > mCellData.GetRows() )
-    {
-      // increase table size for the full span, only increasing rows
-      ResizeContainers( position.rowIndex + position.rowSpan, mCellData.GetColumns() );
-    }
-
-    spanned = true;
+    // increase table size for the full span, only increasing rows
+    ResizeContainers( position.rowIndex + position.rowSpan, mCellData.GetColumns() );
   }
 
-  if( position.columnSpan > 1 )
+  if( ( position.columnSpan > 1 ) && ( position.columnIndex + position.columnSpan > mCellData.GetColumns() ) )
   {
-    // span might go outside table
-    if( position.columnIndex + position.columnSpan > mCellData.GetColumns() )
-    {
-      // increase table size for the full span, only increasing columns
-      ResizeContainers( mCellData.GetRows(), position.columnIndex + position.columnSpan );
-    }
-
-    spanned = true;
+    // increase table size for the full span, only increasing columns
+    ResizeContainers( mCellData.GetRows(), position.columnIndex + position.columnSpan );
   }
 
-  // if it spanned multiple rows, put the cellinfo in all of those
-  if( spanned )
+  // Fill in all cells that need the data
+  CellData data;
+  data.actor = child;
+  data.position = position;
+
+  for( unsigned int row = position.rowIndex; row < ( position.rowIndex + position.rowSpan ); ++row )
   {
-    for( unsigned int row = position.rowIndex; row < ( position.rowIndex + position.rowSpan ); ++row )
+    // store same information to all cells, this way we can identify
+    // if a cell is the prime location of an actor or a spanned one
+    for( unsigned int column = position.columnIndex; column < ( position.columnIndex + position.columnSpan ); ++column )
     {
       // store same information to all cells, this way we can identify
       // if a cell is the prime location of an actor or a spanned one
-      for( unsigned int column = position.columnIndex; column < ( position.columnIndex + position.columnSpan ); ++column )
-      {
-        // store same information to all cells, this way we can identify
-        // if a cell is the prime location of an actor or a spanned one
-        mCellData[ row ][ column ] = data;
-      }
+      mCellData[ row ][ column ] = data;
     }
   }
 
@@ -1280,6 +1265,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension )
               // Accumulate the width
               for( unsigned int i = 0; i < position.columnSpan; ++i )
               {
+                DALI_ASSERT_DEBUG( column + i < mColumnData.Size() );
                 cellSize += mColumnData[ column + i ].size;
               }
 
@@ -1300,6 +1286,7 @@ float TableView::CalculateChildSize( const Actor& child, Dimension dimension )
               // Accumulate the height
               for( unsigned int i = 0; i < position.rowSpan; ++i )
               {
+                DALI_ASSERT_DEBUG( row + i < mRowData.Size() );
                 cellSize += mRowData[ row + i ].size;
               }
 
index 3cb58ac..24229f3 100644 (file)
@@ -152,7 +152,8 @@ void View::SetBackground( ImageActor backgroundImage )
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  backgroundImage.SetRelayoutEnabled( false );    // We will scale its size manually
+  backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+  backgroundImage.SetSizeScalePolicy( FILL_WITH_ASPECT_RATIO );
   mBackgroundLayer.Add( backgroundImage );
 
   RelayoutRequest();
@@ -294,18 +295,6 @@ void View::OnInitialize()
   }
 }
 
-void View::OnRelayout( const Vector2& size, RelayoutContainer& container )
-{
-  if( mBackgroundLayer )
-  {
-    if( mBackgroundLayer && mBackgroundLayer.GetChildCount() > 0 )
-    {
-      Actor background = mBackgroundLayer.GetChildAt(0);
-      background.SetScale( FillXYKeepAspectRatio( Vector3( size.width, size.height, 1.0f ), background.GetTargetSize() ) );
-    }
-  }
-}
-
 View::Orientation View::DegreeToViewOrientation( Degree degree )
 {
   View::Orientation orientation = PORTRAIT;
index 9aacc9e..b956eae 100644 (file)
@@ -137,11 +137,6 @@ private: // From Control
    */
   virtual void OnInitialize();
 
-  /**
-   * @copydoc Toolkit::Control::OnRelayout()
-   */
-  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
-
 private: