ui/winui/container.cpp

branch
newapi
changeset 377
3a60db9ebb5d
parent 374
eae5d6623fd3
child 378
d41b1ffc5f77
--- a/ui/winui/container.cpp	Wed Oct 30 15:32:38 2024 +0100
+++ b/ui/winui/container.cpp	Sun Nov 10 10:16:47 2024 +0100
@@ -179,13 +179,24 @@
 void UiGridContainer::Add(FrameworkElement control, UiBool fill) {
 	GridLength gl;
 
-	int hexpand = FALSE;
-	int vexpand = FALSE;
+	bool hexpand = false;
+	bool vexpand = false;
+	bool hfill = false;
+	bool vfill = false;
+	if(layout.fill != UI_LAYOUT_UNDEFINED) {
+		fill = ui_lb2bool(layout.fill);
+	}
 	if (layout.hexpand != UI_LAYOUT_UNDEFINED) {
 		hexpand = layout.hexpand;
+		hfill = true;
 	}
 	if (layout.vexpand != UI_LAYOUT_UNDEFINED) {
 		vexpand = layout.vexpand;
+		vfill = true;
+	}
+	if (fill) {
+		hfill = true;
+		vfill = true;
 	}
 
 	// create new RowDefinition for the new line
@@ -203,6 +214,11 @@
 		}
 		rowdef.Height(gl);
 		grid.RowDefinitions().Append(rowdef);
+	} else if (vexpand) {
+		// adjust row
+		gl.GridUnitType = GridUnitType::Star;
+		gl.Value = 1;
+		grid.RowDefinitions().GetAt(y).Height(gl);
 	}
 
 	// create new columndefinition, if a new column is added
@@ -219,11 +235,20 @@
 		coldef.Width(gl);
 		grid.ColumnDefinitions().Append(coldef);
 		cols++;
+	} else if(hexpand) {
+		// adjust column
+		gl.GridUnitType = GridUnitType::Star;
+		gl.Value = 1;
+		grid.ColumnDefinitions().GetAt(x).Width(gl);
 	}
 
 	// add control
-	control.HorizontalAlignment(HorizontalAlignment::Stretch);
-	control.VerticalAlignment(VerticalAlignment::Stretch);
+	if (hfill) {
+		control.HorizontalAlignment(HorizontalAlignment::Stretch);
+	}
+	if (vfill) {
+		control.VerticalAlignment(VerticalAlignment::Stretch);
+	}
 
 	if (layout.colspan > 0) {
 		grid.SetColumnSpan(control, layout.colspan);

mercurial