X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Flayouting%2Fgrid-impl.cpp;h=09224ee70a1a61d48adfea6d078415a273c110b4;hb=refs%2Fchanges%2F75%2F189675%2F5;hp=a83ed99971951fb1250525aa98a94dc8182ba104;hpb=2dd55c62173e94588e4bb45e263a32b3d77af65a;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/layouting/grid-impl.cpp b/dali-toolkit/internal/layouting/grid-impl.cpp index a83ed99..09224ee 100644 --- a/dali-toolkit/internal/layouting/grid-impl.cpp +++ b/dali-toolkit/internal/layouting/grid-impl.cpp @@ -50,8 +50,8 @@ Grid::Grid() : LayoutGroup(), mTotalHeight( 0 ), mTotalWidth( 0 ), - mNumColumns( AUTO_FIT ), - mNumRows( AUTO_FIT ), + mNumColumns( 1 ), + mNumRows( 1 ), mRequestedColumnWidth( 0 ), mRequestedNumColumns( AUTO_FIT ) { @@ -66,7 +66,7 @@ void Grid::SetNumberOfColumns( int columns ) // Store value and Relayout if changed. if( columns != mNumColumns ) { - mNumColumns = columns; + mNumColumns = std::max( 1, columns ); RequestLayout(); } } @@ -76,14 +76,14 @@ int Grid::GetNumberOfColumns() const return mNumColumns; } -void Grid::DetermineNumberOfColumns( int availableSpace ) +void Grid::DetermineNumberOfColumns( LayoutLength availableSpace ) { if( mRequestedNumColumns == AUTO_FIT ) { if( availableSpace > 0 ) { // Can only calculate number of columns if a column width has been set - mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace / mRequestedColumnWidth ) : 1; + mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace.AsInteger() / mRequestedColumnWidth ) : 1; } } } @@ -100,8 +100,8 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe LayoutLength widthSize = widthMeasureSpec.GetSize(); LayoutLength heightSize = heightMeasureSpec.GetSize(); - int availableContentWidth(0); - int availableContentHeight(0); + LayoutLength availableContentWidth( 0 ); + LayoutLength availableContentHeight( 0 ); LayoutLength desiredChildHeight( 0 ); LayoutLength desiredChildWidth( 0 ); @@ -132,7 +132,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe desiredChildWidth += childMargin.start + childMargin.end; mTotalWidth = desiredChildWidth * mNumColumns; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(%d) \n", mTotalWidth.mValue ); + DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(" << mTotalWidth << ") \n" ); } // Child is LayoutItem } // Child exists @@ -152,9 +152,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe availableContentWidth = mTotalWidth - gridLayoutPadding.start - gridLayoutPadding.end; widthSize = mTotalWidth; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth(%d) mTotalWidth(%d) \n", - availableContentWidth, - mTotalWidth.mValue ); + DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth" << availableContentWidth << " mTotalWidth(" << mTotalWidth << ") \n" ); // HEIGHT SPECIFICATIONS // heightMode EXACTLY so grid must be the given height @@ -168,8 +166,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe { mTotalHeight += desiredChildHeight; } - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(%d) \n", - mTotalHeight.mValue ); + DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(" << mTotalHeight << ") \n" ); // Ensure ourHeight does not exceed specified atmost height mTotalHeight = std::min( mTotalHeight, heightSize ); @@ -186,11 +183,11 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe // Grid expands to fit content // If number of columns AUTO_FIT then set to 1 column. - + mNumColumns = ( mNumColumns > 0 ) ? mNumColumns : 1; // Calculate numbers of rows, round down result as later check for remainder. - mNumRows = childCount / ( ( mNumColumns ) ? mNumColumns : 1 ); + mNumRows = childCount / mNumColumns; // If number of cells not cleanly dividable by colums, add another row to house remainder cells. - mNumRows += ( childCount % ( ( mNumColumns ) ? mNumColumns : 1 ) ) ? 1 : 0; + mNumRows += ( childCount % mNumColumns ) ? 1 : 0; availableContentHeight = desiredChildHeight * mNumRows; } @@ -199,7 +196,7 @@ void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpe DetermineNumberOfColumns( availableContentWidth ); // Locations define the start, end,top and bottom of each cell. - mLocations->CalculateLocations( mNumColumns, availableContentWidth, availableContentHeight, childCount, 0, 0 ); + mLocations->CalculateLocations( mNumColumns, availableContentWidth.AsInteger(), availableContentHeight.AsInteger(), childCount, 0, 0 ); SetMeasuredDimensions( ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK ),