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-group-impl.cpp;h=a27f060b40fa76e6cc7c73b9324fec5ef08230bb;hp=8907fc961153eb2a3f60202c1520ed2d3a349cd0;hb=b5b75a20279ee1671b8a78228583cf5114536fb0;hpb=66581ed768a430adc3e6a630948c28bfe6c32aa4 diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp index 8907fc9..a27f060 100644 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp @@ -59,6 +59,7 @@ LayoutGroup::~LayoutGroup() { // An object with a unique_ptr to an opaque structure must define it's destructor in the translation unit // where the opaque structure is defined. It cannot use the default method in the header file. + RemoveAll(); } Toolkit::LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child ) @@ -172,61 +173,6 @@ Toolkit::LayoutGroup::LayoutId LayoutGroup::Insert( LayoutItem& target, LayoutIt return childLayout.layoutId; } -Toolkit::LayoutGroup::LayoutId LayoutGroup::Move( LayoutItem& target, LayoutItem& child ) -{ - // Remove child from the previous position - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter ) - { - if( iter->child.Get() == &child ) - { - mImpl->mChildren.erase( iter ); - break; - } - } - - // Find target position - std::vector< Impl::ChildLayout >::iterator position; - for( auto iter = mImpl->mChildren.begin(); iter != mImpl->mChildren.end(); ++iter ) - { - if( iter->child.Get() == &target ) - { - position = iter; - break; - } - } - - Impl::ChildLayout childLayout; - childLayout.layoutId = mImpl->mNextLayoutId++; - childLayout.child = &child; - mImpl->mChildren.insert( position, childLayout ); - - RequestLayout(); - - return childLayout.layoutId; -} - -Toolkit::LayoutGroup::LayoutId LayoutGroup::MoveBack( LayoutItem& child ) -{ - // Remove child from the previous position - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter ) - { - if( iter->child.Get() == &child ) - { - mImpl->mChildren.erase( iter ); - break; - } - } - - Impl::ChildLayout childLayout; - childLayout.layoutId = mImpl->mNextLayoutId++; - childLayout.child = &child; - mImpl->mChildren.emplace_back( childLayout ); - - RequestLayout(); - - return childLayout.layoutId; -} - void LayoutGroup::RemoveAll() { for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ) @@ -507,12 +453,11 @@ void LayoutGroup::OnInitialize() // Take ownership of existing children for( unsigned int childIndex = 0 ; childIndex < control.GetChildCount(); ++childIndex ) { - ChildAddedToOwner( control.GetChildAt( childIndex ) ); + ChildAddedToOwnerImpl( control.GetChildAt( childIndex ) ); } DevelActor::ChildAddedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildAddedToOwner ); DevelActor::ChildRemovedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildRemovedFromOwner ); - DevelActor::ChildOrderChangedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildOrderChanged ); DevelHandle::PropertySetSignal( control ).Connect( mSlotDelegate, &LayoutGroup::OnOwnerPropertySet ); if( control.GetParent() ) @@ -551,6 +496,8 @@ void LayoutGroup::OnInitialize() } } } + + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_OWNER_SET ); } } @@ -563,6 +510,14 @@ void LayoutGroup::OnUnparent() { // Remove children RemoveAll(); + + auto control = Toolkit::Control::DownCast( GetOwner() ); + if( control ) + { + DevelActor::ChildAddedSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::ChildAddedToOwner ); + DevelActor::ChildRemovedSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::ChildRemovedFromOwner ); + DevelHandle::PropertySetSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::OnOwnerPropertySet ); + } } void LayoutGroup::RemoveChild( LayoutItem& item ) @@ -573,6 +528,12 @@ void LayoutGroup::RemoveChild( LayoutItem& item ) void LayoutGroup::ChildAddedToOwner( Actor child ) { + ChildAddedToOwnerImpl( child ); + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_ADD, child, Actor() ); +} + +void LayoutGroup::ChildAddedToOwnerImpl( Actor child ) +{ LayoutItemPtr childLayout; Toolkit::Control control = Toolkit::Control::DownCast( child ); @@ -653,42 +614,7 @@ void LayoutGroup::ChildRemovedFromOwner( Actor child ) if( childLayout ) { Remove( *childLayout.Get() ); - } - } -} - -void LayoutGroup::ChildOrderChanged( Actor child ) -{ - Toolkit::Control childControl = Toolkit::Control::DownCast( child ); - if( childControl ) - { - Internal::Control& childControlImpl = GetImplementation( childControl ); - Internal::Control::Impl& childControlDataImpl = Internal::Control::Impl::Get( childControlImpl ); - - auto childLayout = childControlDataImpl.GetLayout(); - if( childLayout ) - { - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - unsigned int count = control.GetChildCount(); - unsigned int index = static_cast< unsigned int >( childControl.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) ); - - // Find insertion position - while( ++index < count ) - { - auto sibling = Toolkit::Control::DownCast( control.GetChildAt( index ) ); - if( sibling ) - { - auto siblingLayout = DevelControl::GetLayout( sibling ); - if( siblingLayout ) - { - Internal::LayoutItem& siblingLayoutImpl = GetImplementation( siblingLayout ); - Move( siblingLayoutImpl, *childLayout ); - return; - } - } - } - - MoveBack( *childLayout ); + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_REMOVE, Actor(), child ); } } } @@ -741,10 +667,9 @@ void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMea bool exactWidth ( false ); bool exactHeight ( false ); - // Default Layouting behaviour if not overridden + // Layouting behaviour // EXACT, width and height as provided. - // MATCH_PARENT, width and hewidthSpecSizeight that of parent - + // MATCH_PARENT, width and height that of parent // WRAP_CONTENT, take width of widest child and height size of longest child (within given limit) // UNSPECIFIED, take width of widest child and height size of longest child. @@ -767,11 +692,13 @@ void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMea // Check below will be true for legacy containers and controls with layout required set. // Other layouts will have their own OnMeasure (a checked requirement) hence not execute LayoutGroup::OnMeasure. // Controls which have set layout required will not be legacy controls hence should not have a ResizePolicy set. - if( childControl.GetChildCount() > 0 ) + // Only need to map the resize policy the first time as the Layouting system will then set it to FIXED. + if( childControl.GetChildCount() > 0 && ! mImpl->mResizePolicyMapped ) { // First pass, Static mappings that are not dependant on parent SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::WIDTH ); SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::HEIGHT ); + mImpl->mResizePolicyMapped = true; } // Second pass, if any mappings were not possible due to parent size dependancies then calculate an exact desired size for child