X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Fdevel-api%2Flayouting%2Flayout-item-impl.cpp;h=987b799d09e6b83799807d141e1fceae577ed863;hb=refs%2Fchanges%2F06%2F188406%2F7;hp=409ff46b7874e5ec9662b5d0f53e6e6cb43fcee6;hpb=e4235b523a775fbbee334dea6cd929a6f3ccbc80;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp index 409ff46..987b799 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace @@ -78,13 +79,31 @@ void LayoutItem::Unparent() // Enable directly derived types to first remove children OnUnparent(); + // Remove myself from parent + LayoutParent* parent = GetParent(); + if( parent ) + { + parent->Remove( *this ); + } + + // Remove parent reference + SetParent(nullptr); + // Last, clear owner mImpl->mOwner = NULL; } void LayoutItem::SetAnimateLayout( bool animateLayout ) { + auto owner = GetOwner(); + auto actor = Actor::DownCast(owner); + + 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; + + OnAnimationStateChanged( animateLayout ); } bool LayoutItem::IsLayoutAnimated() const @@ -140,7 +159,7 @@ 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() did not set the measured dimension by calling setMeasuredDimension()" ); + "Layout's OnMeasure() Measured dimension flag not set" ); mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED ); } @@ -167,6 +186,8 @@ void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasur void LayoutItem::Layout( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) { + DALI_LOG_TRACE_METHOD( gLayoutFilter ); + if( mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ) ) { OnMeasure( mImpl->mOldWidthMeasureSpec, mImpl->mOldHeightMeasureSpec ); @@ -214,7 +235,7 @@ Extents LayoutItem::GetPadding() const { Extents padding = control.GetProperty( Toolkit::Control::Property::PADDING ); - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::Padding for %s : (%d,%d,%d,%d) \n", + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::Padding for %s : (%d,%d,%d,%d) \n", control.GetName().c_str(), padding.start, padding.end, padding.top, padding.bottom ); @@ -276,6 +297,8 @@ LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureS void LayoutItem::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec) { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::OnMeasure\n"); + SetMeasuredDimensions( GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ), GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ) ); } @@ -287,6 +310,10 @@ void LayoutItem::OnLayout( bool changed, LayoutLength left, LayoutLength top, La void LayoutItem::SetParent( LayoutParent* parent ) { mImpl->mLayoutParent = parent; + if ( parent == nullptr ) + { + mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); + } } LayoutParent* LayoutItem::GetParent() @@ -314,12 +341,12 @@ bool LayoutItem::IsLayoutRequested() const void LayoutItem::SetLayoutRequested() { - return mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); + 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", + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(%d) height(%d) \n", MeasureSpec::IntType( measuredWidth.GetSize() ), MeasureSpec::IntType( measuredHeight.GetSize() ) ); @@ -412,9 +439,9 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig { bool changed = false; - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); - 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; @@ -429,7 +456,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig mImpl->mRight = right; mImpl->mBottom = bottom; - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_HAS_BOUNDS ); + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); // Reflect up to parent control @@ -437,21 +464,27 @@ 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 ); if( mImpl->mAnimated ) { auto animation = Animation::New( 0.5f ); - animation.AnimateTo( Property( actor, Actor::Property::POSITION ), - Vector3( float(left.mValue), float(top.mValue), 0.0f ) ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE ), - Vector3( right-left, bottom-top, 0.0f ) ); + 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::SIZE_WIDTH ), float( newWidth ) ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), float( newHeight ) ); + animation.FinishedSignal().Connect( mSlotDelegate, &LayoutItem::OnLayoutAnimationFinished ); animation.Play(); } else { // @todo Collate into list of Property & Property::Value pairs. - actor.SetPosition( Vector3( float(left.mValue), float(top.mValue), 0.0f ) ); - actor.SetSize( Vector3( right-left, bottom-top, 0.0f ) ); + 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 ) ); } } @@ -460,6 +493,9 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig SizeChange( LayoutSize( newWidth, newHeight ), LayoutSize( oldWidth, oldHeight ) ); } } + + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); + return changed; }