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");
if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) &&
( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
// If any child properties are set, must perform relayout
RequestLayout();
- for( auto&& child : mImpl->mChildren )
- {
- if( child.child->GetOwner() == handle )
- {
- child.child->SetLayoutRequested();
- break;
- }
- }
}
}
#if defined( DEBUG_ENABLED )
if ( control )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild natural size(%f, %f)\n", control.GetNaturalSize().width, control.GetNaturalSize().height );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins naturalSizewidth(%f)\n", control.GetNaturalSize().width );
}
#endif
// Get last stored width and height specifications for the child
auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d) desiredHeight(%d)\n", desiredWidth, desiredHeight );
+
+ // 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 );
auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
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,
// 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 will be generated by Add().
+ // 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 ) );
}
Add( *childLayout.Get() );