From: Kingsley Stephens Date: Wed, 8 Apr 2015 13:12:14 +0000 (+0100) Subject: Size negotiation patch 2: Re-enable size negotiation on builder actors. X-Git-Tag: dali_1.0.38~12^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=f23c3425d67599e4c37f10fb9c685bdee57e6fb5 Size negotiation patch 2: Re-enable size negotiation on builder actors. Fix bug in resizing table view Change-Id: If423207d24823047303ccc054df2e2edd8f83afa --- diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 202e944..be1993c 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -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 ) ) { diff --git a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp index 4ca5be5..239d94e 100644 --- a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp @@ -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 diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index 384e291..624e973 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -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(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& 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; } diff --git a/dali-toolkit/internal/controls/view/view-impl.cpp b/dali-toolkit/internal/controls/view/view-impl.cpp index 3cb58ac..24229f3 100644 --- a/dali-toolkit/internal/controls/view/view-impl.cpp +++ b/dali-toolkit/internal/controls/view/view-impl.cpp @@ -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; diff --git a/dali-toolkit/internal/controls/view/view-impl.h b/dali-toolkit/internal/controls/view/view-impl.h index 9aacc9e..b956eae 100644 --- a/dali-toolkit/internal/controls/view/view-impl.h +++ b/dali-toolkit/internal/controls/view/view-impl.h @@ -137,11 +137,6 @@ private: // From Control */ virtual void OnInitialize(); - /** - * @copydoc Toolkit::Control::OnRelayout() - */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); - private: