X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Flayouting%2Flayout-group-impl.cpp;h=1f643ccc54f05ee334fc76109c8f90846bf696bc;hb=057a5b8dc25bf54f83799c4dda33bba6e8ed698b;hp=9df05c6cd009cc882de98037263235b9bdbe99a2;hpb=e8ea0328f92e38164592f09b9c978258622c0939;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp index 9df05c6..1f643cc 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"); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties\n"); if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ) @@ -191,6 +193,14 @@ void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, P { // If any child properties are set, must perform relayout RequestLayout(); + for( auto&& child : mImpl->mChildren ) + { + if( child.child->GetOwner() == handle ) + { + child.child->SetLayoutRequested(); + break; + } + } } } @@ -226,36 +236,14 @@ void LayoutGroup::MeasureChild( LayoutItemPtr child, #if defined( DEBUG_ENABLED ) if ( control ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins naturalSizewidth(%f)\n", control.GetNaturalSize().width ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild natural size(%f, %f)\n", control.GetNaturalSize().width, control.GetNaturalSize().height ); } #endif // Get last stored width and height specifications for the child auto desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); auto desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - // The size of the control could have changed due to padding being altered, the XXX_SPECIFICATIONs will not have been updated. - // So GetNaturalSize is called, if the control's natural size includes padding then th size will be updated. - if ( control ) - { - auto desiredSize = control.GetNaturalSize(); // Get's child control's size which could include new padding values. - - // Check if WIDTH_SPECIFICATION was a size value, if so then get update to child controls's width. - if ( desiredWidth > 0 ) - { - desiredWidth = desiredSize.width; - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredWidth ) ); - } - - // Check if HEIGHT_SPECIFICATION was a size value, if so then get update to child controls's height. - if ( desiredHeight > 0) - { - desiredHeight = desiredSize.height; - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredHeight ) ); - } - } - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d)\n", desiredWidth ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d) desiredHeight(%d)\n", desiredWidth, desiredHeight ); auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured. @@ -279,7 +267,6 @@ void LayoutGroup::MeasureChildWithMargins( LayoutItemPtr child, auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured. - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredWidth(%d)\n", desiredWidth ); MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec, @@ -421,6 +408,20 @@ void LayoutGroup::OnInitialize() DevelActor::ChildAddedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildAddedToOwner ); DevelActor::ChildRemovedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildRemovedFromOwner ); 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 ); + } + } + } } } @@ -431,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 ) @@ -451,15 +464,13 @@ void LayoutGroup::ChildAddedToOwner( Actor child ) // If the child doesn't already have a layout, then create a LayoutItem for it. childLayout = LayoutItem::New( control ); childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad? - +#if defined(DEBUG_ENABLED) auto desiredSize = control.GetNaturalSize(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner desiredSize(%f,%f) (naturalSize)\n", desiredSize.width, desiredSize.height ); - +#endif childControlDataImpl.SetLayout( *childLayout.Get() ); - // Default layout data for this object - child.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredSize.width ) ); - child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredSize.height ) ); + // Default layout data will be generated by Add(). } Add( *childLayout.Get() );