END_TEST;
}
+int UtcDaliLayouting_HboxLayout06(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ rootControl.SetName( "AbsoluteLayout" );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox" );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 60, 40 ) );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ rootControl.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Change a layout
+ auto newHBoxLayout = LinearLayout::New();
+ newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+ DevelControl::SetLayout( hbox, newHBoxLayout );
+
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
// Padding tests
int UtcDaliLayouting_HboxLayout_Padding01(void)
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
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 );
+ }
+ }
+ }
}
}
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 )