X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Flayouting%2Flayout-item-impl.cpp;h=217ffa66ec06c99208ea52265a130713899256ba;hp=f6bd7f8ad1313bfcb2431a0885c3c40d936cade1;hb=8e98f1407744af67cc5b5f37e979c2496468c50c;hpb=20b42a9bcaba6b874f2271f03a56da6f884c4053 diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp index f6bd7f8..217ffa6 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp @@ -22,12 +22,13 @@ #include #include +namespace +{ + #if defined(DEBUG_ENABLED) - Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" ); +Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" ); #endif -namespace -{ const char* WIDTH_SPECIFICATION_NAME( "widthSpecification" ); const char* HEIGHT_SPECIFICATION_NAME( "heightSpecification" ); @@ -121,6 +122,8 @@ void LayoutItem::OnRegisterChildProperties( const std::string& containerType ) void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) { + DALI_LOG_TRACE_METHOD( gLayoutFilter ); + const bool forceLayout = mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); const bool specChanged = @@ -137,23 +140,13 @@ void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasur const bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize ); - if( forceLayout || needsLayout) + if( forceLayout || needsLayout ) { mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ); - //resolveRtlPropertiesIfNeeded(); - - int cacheIndex = -1; // = forceLayout ? -1 : mMeasureCache.indexOfKey(key); - if( cacheIndex < 0 ) //|| sIgnoreMeasureCache ) - { - // measure ourselves, this should set the measured dimension flag back - OnMeasure( widthMeasureSpec, heightMeasureSpec ); - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ); - } - else - { - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ); - } + // measure ourselves, this should set the measured dimension flag back + OnMeasure( widthMeasureSpec, heightMeasureSpec ); + mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ); // flag not set, setMeasuredDimension() was not invoked, we raise an exception to warn the developer DALI_ASSERT_ALWAYS( mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ) && @@ -163,8 +156,6 @@ void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasur mImpl->mOldWidthMeasureSpec = widthMeasureSpec; mImpl->mOldHeightMeasureSpec = heightMeasureSpec; - - //mMeasureCache.put(key, ((long) mMeasuredWidth) << 32 | (long) mMeasuredHeight & 0xffffffffL); // suppress sign extension } void LayoutItem::Layout( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) @@ -211,7 +202,34 @@ void LayoutItem::SetMinimumHeight( LayoutLength minimumHeight ) Extents LayoutItem::GetPadding() const { - return mImpl->mPadding; + Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner ); + if( control ) + { + Extents padding = control.GetProperty( Toolkit::Control::Property::PADDING ); + + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::Padding for %s : (%d,%d,%d,%d) \n", + control.GetName().c_str(), + padding.start, padding.end, padding.top, padding.bottom + ); + return padding; + } + else + { + return Extents(); + } +} + +Extents LayoutItem::GetMargin() const +{ + Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner ); + if ( control ) + { + return control.GetProperty( Toolkit::Control::Property::MARGIN ); + } + else + { + return Extents(); + } } LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureSpec ) @@ -228,6 +246,18 @@ LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureS break; } case MeasureSpec::Mode::AT_MOST: + { + LayoutLength tmp = specSize; + if( size < tmp ) + { + result = size; + } + else + { + result = specSize; + } + break; + } case MeasureSpec::Mode::EXACTLY: { result = specSize; @@ -254,6 +284,11 @@ LayoutParent* LayoutItem::GetParent() void LayoutItem::RequestLayout() { + Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner ); + if ( control ) + { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout %s\n", control.GetName().c_str()); + } // @todo Enforce failure if called in Measure/Layout passes. mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get(); @@ -265,8 +300,18 @@ bool LayoutItem::IsLayoutRequested() const return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); } +void LayoutItem::SetLayoutRequested() +{ + return mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); +} + void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight ) { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::SetMeasuredDimensions width(%d) height(%d) \n", + MeasureSpec::IntType( measuredWidth.GetSize() ), + MeasureSpec::IntType( measuredHeight.GetSize() ) + ); + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ); mImpl->mMeasuredWidth = measuredWidth; mImpl->mMeasuredHeight = measuredHeight;