Merge "[Tizen] Store LayoutItem target size when set explictly" into tizen_5.0
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / layout-group-impl.cpp
index 5ebb163..6147a80 100755 (executable)
@@ -350,7 +350,7 @@ void LayoutGroup::MeasureChild( LayoutItemPtr child,
   // 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 );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild child WIDTH_SPEC(%d) child HEIGHT SPEC(%d)\n", desiredWidth, desiredHeight );
 
   auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
 
@@ -374,13 +374,13 @@ 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 );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins child WIDTH_SPEC(%d)\n",  desiredWidth );
 
   MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
                                                            LayoutLength( padding.start + padding.end ) +
                                                            widthUsed, desiredWidth );
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredHeight(%d)\n",  desiredHeight );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins child HEIGHT_SPEC(%d)\n",  desiredHeight );
 
   MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec,
                                                             LayoutLength( padding.top + padding.bottom )+
@@ -398,12 +398,14 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
   auto specMode = measureSpec.GetMode();
   LayoutLength specSize = measureSpec.GetSize();
 
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension(%f)\n", childDimension.AsInteger() );
+
   LayoutLength size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding
 
   LayoutLength resultSize = 0;
   MeasureSpec::Mode resultMode = MeasureSpec::Mode::UNSPECIFIED;
 
-  switch( specMode )
+  switch( specMode ) // Parents specMode
   {
     // Parent has imposed an exact size on us
     case MeasureSpec::Mode::EXACTLY:
@@ -632,14 +634,21 @@ void LayoutGroup::ChildAddedToOwnerImpl( Actor child )
       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 )
+
+      auto childControl = Toolkit::Control::DownCast(childLayout->GetOwner());
+
+      bool setWidthExplictly = ( childControl.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ) > 0  );
+      if ( size.x != 0 || setWidthExplictly )
       {
-        childLayout->SetMinimumWidth( size.x );
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner SetTargetWidth(%f)\n", size.x );
+        childLayout->SetTargetWidth( size.x );
       }
 
-      if ( size.y != 0 )
+      bool setHeightExplcitly = ( childControl.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ) > 0 );
+      if ( size.y != 0 || setHeightExplcitly )
       {
-        childLayout->SetMinimumHeight( size.y );
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner SetTargetHeight(%f)\n", size.y);
+        childLayout->SetTargetHeight( size.y );
       }
       // Default layout data will be generated by Add().
     }