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=f70a5f1c5fc134153b28d1086ebfd9da9a51c8c2;hp=20e23f3b95ef53b28a12b97721a302f0b208a126;hb=66581ed768a430adc3e6a630948c28bfe6c32aa4;hpb=7e015b34bd79604bb7fa3eab78d2417df6d241ee diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp index 20e23f3..f70a5f1 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp @@ -95,15 +95,11 @@ void LayoutItem::Unparent() void LayoutItem::SetAnimateLayout( bool animateLayout ) { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s)\n", (animateLayout)?"true":"false" ); - auto owner = GetOwner(); auto actor = Actor::DownCast(owner); - if( actor ) - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s) owner(%s)\n", (animateLayout)?"true":"false", actor.GetName().c_str() ); - } + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s) owner(%s)\n", (animateLayout)?"true":"false", + ( ( Actor::DownCast( owner) ) ? Actor::DownCast(owner).GetName().c_str() : "Invalid Actor" ) ); mImpl->mAnimated = animateLayout; @@ -163,7 +159,11 @@ void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasur const bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize ); - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::Measure("<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 ) && - "Layout's OnMeasure() mension()" ); + "Layout's OnMeasure() Measured dimension flag not set" ); mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED ); } @@ -270,6 +270,8 @@ LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureS auto specMode = measureSpec.GetMode(); auto specSize = measureSpec.GetSize(); + DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::GetDefaultSize MeasureSpec("< LayoutLength( 0 ) ) { result = size; } @@ -296,6 +302,7 @@ LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureS break; } } + DALI_LOG_STREAM( gLayoutFilter, Debug::General, "LayoutItem::GetDefaultSize setting default size:" << result << "\n" ); return result; } @@ -303,6 +310,7 @@ void LayoutItem::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas { DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::OnMeasure\n"); + // GetDefaultSize will limit the MeasureSpec to the suggested minimumWidth and minimumHeight SetMeasuredDimensions( GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ), GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ) ); } @@ -314,6 +322,7 @@ void LayoutItem::OnLayout( bool changed, LayoutLength left, LayoutLength top, La void LayoutItem::SetParent( LayoutParent* parent ) { mImpl->mLayoutParent = parent; + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); } LayoutParent* LayoutItem::GetParent() @@ -344,12 +353,28 @@ void LayoutItem::SetLayoutRequested() mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); } +bool LayoutItem::IsResizePolicyRequired() const +{ + return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); +} + +void LayoutItem::SetResizePolicyRequired( bool resizePolicyRequired ) +{ + if( resizePolicyRequired ) + { + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); + } + else + { + mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); + } +} + void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight ) { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(%d) height(%d) \n", - MeasureSpec::IntType( measuredWidth.GetSize() ), - MeasureSpec::IntType( measuredHeight.GetSize() ) - ); + + DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(" << measuredWidth.GetSize() << ") height(" << measuredHeight.GetSize() << ") Control:" << + ( ( Actor::DownCast( GetOwner()) ) ? Actor::DownCast(GetOwner()).GetName().c_str() : "Invalid Actor" ) << "\n" ); mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ); mImpl->mMeasuredWidth = measuredWidth; @@ -383,7 +408,7 @@ LayoutLength LayoutItem::GetSuggestedMinimumWidth() const auto actor = Actor::DownCast(owner); auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO; - return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength::IntType( naturalSize.width ) ); + return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) ); } LayoutLength LayoutItem::GetSuggestedMinimumHeight() const @@ -392,7 +417,7 @@ LayoutLength LayoutItem::GetSuggestedMinimumHeight() const auto actor = Actor::DownCast(owner); auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO; - return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength::IntType(naturalSize.height) ); + return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) ); } MeasuredSize LayoutItem::ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, MeasuredSize::State childMeasuredState ) @@ -439,16 +464,16 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig { bool changed = false; - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); + DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" ); - if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom ) + if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) ) { changed = true; - auto oldWidth = mImpl->mRight - mImpl->mLeft; - auto oldHeight = mImpl->mBottom - mImpl->mTop; - auto newWidth = right - left; - auto newHeight = bottom - top; + LayoutLength oldWidth = mImpl->mRight - mImpl->mLeft; + LayoutLength oldHeight = mImpl->mBottom - mImpl->mTop; + LayoutLength newWidth = right - left; + LayoutLength newHeight = bottom - top; bool sizeChanged = (newWidth != oldWidth) || (newHeight != oldHeight); mImpl->mLeft = left; @@ -456,7 +481,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig mImpl->mRight = right; mImpl->mBottom = bottom; - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_HAS_BOUNDS ); + mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); // Reflect up to parent control @@ -464,16 +489,16 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig auto actor = Actor::DownCast(owner); if( actor ) { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(%s) (%d, %d, %d, %d)\n", actor.GetName().c_str(), - left.mValue, top.mValue, right.mValue, bottom.mValue ); + DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" ); + if( mImpl->mAnimated ) { auto animation = Animation::New( 0.5f ); - animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), float( left.mValue ) ); - animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), float( top.mValue ) ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), left.AsInteger() ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), top.AsInteger() ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), float( newWidth ) ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), float( newHeight ) ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), newWidth.AsInteger() ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), newHeight.AsInteger() ); animation.FinishedSignal().Connect( mSlotDelegate, &LayoutItem::OnLayoutAnimationFinished ); animation.Play(); @@ -481,10 +506,10 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig else { // @todo Collate into list of Property & Property::Value pairs. - actor.SetX( float( left.mValue ) ); - actor.SetY( float( top.mValue ) ); - actor.SetProperty( Actor::Property::SIZE_WIDTH, float( newWidth ) ); - actor.SetProperty( Actor::Property::SIZE_HEIGHT, float( newHeight ) ); + actor.SetX( left.AsInteger() ); + actor.SetY( top.AsInteger() ); + actor.SetProperty( Actor::Property::SIZE_WIDTH, newWidth.AsInteger() ); + actor.SetProperty( Actor::Property::SIZE_HEIGHT, newHeight.AsInteger() ); } } @@ -494,7 +519,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig } } - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); + DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" ); return changed; } @@ -505,7 +530,7 @@ void LayoutItem::OnLayoutAnimationFinished( Animation& animation ) auto actor = Actor::DownCast(owner); if( actor ) { - actor.SetSize( Vector3( mImpl->mRight-mImpl->mLeft, mImpl->mBottom-mImpl->mTop, 0.0f ) ); + actor.SetSize( Vector3( mImpl->mRight.AsInteger() - mImpl->mLeft.AsInteger(), mImpl->mBottom.AsInteger() - mImpl->mTop.AsInteger(), 0.0f ) ); } }