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=67a673cfc8d98081066abcb763c459016d4c03ec;hp=10bfe2d74b21706694fa2c9c6b4313a3350e7db8;hb=703bc0c9e46c18a3290ba24f64f6237fffc9304f;hpb=8e98f1407744af67cc5b5f37e979c2496468c50c diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp index 10bfe2d..67a673c 100644 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp @@ -31,7 +31,7 @@ namespace { #if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" ); +Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); #endif } @@ -71,6 +71,8 @@ Toolkit::LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child ) childLayout.child = &child; mImpl->mChildren.emplace_back( childLayout ); + child.SetParent( this ); + auto owner = child.GetOwner(); // If the owner does not have any LayoutItem child properties, add them @@ -122,7 +124,7 @@ void LayoutGroup::Remove( LayoutItem& child ) void LayoutGroup::RemoveAll() { - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter ) + for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ) { OnChildRemove( *iter->child.Get() ); iter = mImpl->mChildren.erase(iter); @@ -182,7 +184,7 @@ void LayoutGroup::DoRegisterChildProperties( const std::string& containerType ) void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties\n"); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(%s)\n", handle.GetPropertyName(index).c_str()); if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ) @@ -190,12 +192,11 @@ void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, P ( index == Toolkit::Control::Property::MARGIN || index == Toolkit::Control::Property::PADDING ) ) { // If any child properties are set, must perform relayout - RequestLayout(); for( auto&& child : mImpl->mChildren ) { if( child.child->GetOwner() == handle ) { - child.child->SetLayoutRequested(); + child.child->RequestLayout(); break; } } @@ -405,7 +406,22 @@ void LayoutGroup::OnInitialize() 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() ) + { + auto parent = Toolkit::Control::DownCast( control.GetParent() ); + if( parent ) + { + auto parentLayout = Toolkit::LayoutGroup::DownCast( DevelControl::GetLayout( parent ) ); + if( parentLayout ) + { + Internal::LayoutGroup& parentLayoutImpl = GetImplementation( parentLayout ); + parentLayoutImpl.Add( *this ); + } + } + } } } @@ -416,7 +432,19 @@ void LayoutGroup::OnRegisterChildProperties( const std::string& containerType ) void LayoutGroup::OnUnparent() { + // Remove children RemoveAll(); + + // Remove myself from parent + LayoutParent* parent = GetParent(); + if( parent ) + { + LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( parent ) ); + if( parentGroup ) + { + parentGroup->Remove( *this ); + } + } } void LayoutGroup::ChildAddedToOwner( Actor child ) @@ -442,8 +470,29 @@ void LayoutGroup::ChildAddedToOwner( Actor child ) #endif childControlDataImpl.SetLayout( *childLayout.Get() ); + Vector3 size = child.GetTargetSize(); + // If the size of the control is set explicitly make sure that the control size + // stays the same after the layout except it is over written with match parent specs. + if ( size.x != 0 ) + { + childLayout->SetMinimumWidth( size.x ); + } + + if ( size.y != 0 ) + { + childLayout->SetMinimumHeight( size.y ); + } // Default layout data will be generated by Add(). } + else + { + LayoutGroupPtr layoutGroup( dynamic_cast< LayoutGroup* >( childLayout.Get() ) ); + if( !layoutGroup ) + { + // Set only in case of leaf children + childLayout->SetAnimateLayout( IsLayoutAnimated() ); + } + } Add( *childLayout.Get() ); } @@ -464,6 +513,16 @@ void LayoutGroup::ChildRemovedFromOwner( Actor child ) } } +void LayoutGroup::ChildOrderChanged() +{ + RequestLayout(); + // Force Children to be relaid out: + for( auto&& child : mImpl->mChildren ) + { + child.child->SetLayoutRequested(); + } +} + void LayoutGroup::OnOwnerPropertySet( Handle& handle, Property::Index index, Property::Value value ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutGroup::OnOwnerPropertySet\n"); @@ -480,6 +539,20 @@ void LayoutGroup::OnOwnerPropertySet( Handle& handle, Property::Index index, Pro } } +void LayoutGroup::OnAnimationStateChanged( bool animateLayout ) +{ + // Change children's animation state + for( auto&& child : mImpl->mChildren ) + { + LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( child.child.Get() ) ); + if( !parentGroup ) + { + // Change state only in case of leaf children + child.child->SetAnimateLayout( animateLayout ); + } + } +} + } // namespace Internal } // namespace Toolkit } // namespace Dali