How to make VerticalBox slots fill the ChildSlot space?

I’m making a simple dialog window implementation by creating a SCompoundWidget-based widget.
It’s declared like this:

ChildSlot
.VAlign(VAlign_Fill)
.HAlign(HAlign_Fill)
 [
	 SNew(SVerticalBox)
	 + SVerticalBox::Slot()
	.MaxHeight(32.f)
	[
		TitleContainer.ToSharedRef()
	]
	 + SVerticalBox::Slot()
	.VAlign(VAlign_Fill)
	[
		SNew(SBorder)
		.BorderImage(&WindowStyle->ContentBoxBrush)
		.Content()
		[
			SNew(SVerticalBox)
			+ SVerticalBox::Slot()
			.VAlign(VAlign_Center)
			.HAlign(HAlign_Center)
			[
				ConfirmTextBlock.ToSharedRef()
			]
			+ SVerticalBox::Slot()
			.VAlign(VAlign_Center)
			.HAlign(HAlign_Center)
			[
				SNew(SHorizontalBox)
				+ SHorizontalBox::Slot()
				.HAlign(HAlign_Right)
				.Padding(10)
				[
					SNew(SButton)
					.ButtonStyle(&WindowStyle->OKButtonStyle)
				]
				+ SHorizontalBox::Slot()
				.HAlign(HAlign_Left)
				.Padding(10)
				[
					SNew(SButton)
					.ButtonStyle(&WindowStyle->CancelButtonStyle)
				]
			]
		]
	]
 ];

But the 2nd slot of top-level Vertical Box (window contents) doesn’t fill the remaining space of widget’s Childslot

As you can see a bit less than a half of widget space for contents is empty. What should be the proper declaration to make this work?

1 Like

OK, after some research of Engine source I found out what’s going on.
When you create FSlot for SBoxPanel (vertical or horizontal), it sets SizeRule_Stretch for its SizeRule and 1.0f for its SizeParam.Value by default. That means that it allots equal space for each FSlot even if you set MaxHeight or MaxWidth for any of them. So you need to additionally use AutoHeight() or AutoWidth() for slots with MaxSize to let other slots fill the space.

Resolved. =)