From: Adeel Kazmi Date: Thu, 28 Jun 2018 16:33:58 +0000 (+0000) Subject: Merge "Use Actor target size for default layout." into devel/master X-Git-Tag: dali_1.3.30~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=5a436526e75ad9bef35e98614a00527fe5586f78;hp=336f743269f056b02394659f50a60274a9f59660 Merge "Use Actor target size for default layout." into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp index 75b42b8..5ba721b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp @@ -1192,3 +1192,37 @@ int UtcDaliLayouting_RelayoutOnChildOrderChanged(void) END_TEST; } + +int UtcDaliLayouting_HboxLayout_TargetSize(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf"); + + Stage stage = Stage::GetCurrent(); + auto hbox = Control::New(); + auto hboxLayout = LinearLayout::New(); + DevelControl::SetLayout( hbox, hboxLayout ); + hbox.SetName( "HBox"); + + std::vector< Control > controls; + controls.push_back( CreateLeafControl( 40, 40 ) ); + for( auto&& iter : controls ) + { + iter.SetSize( 100, 100 ); + hbox.Add( iter ); + } + hbox.SetParentOrigin( ParentOrigin::CENTER ); + hbox.SetAnchorPoint( AnchorPoint::CENTER ); + stage.Add( hbox ); + + // Ensure layouting happens + application.SendNotification(); + application.Render(); + + // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right. + // hbox left justifies elements + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp index 7f8d9d0..d28ec90 100644 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp @@ -471,6 +471,18 @@ 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