Update subview handling and use C# 12 collection exprs

Refactor subview checks to use GetSubViews with padding, ensuring accurate layout calculations. Update button list initialization in MessageBoxes.cs to use the C# 12 collection expression for conciseness. Minor formatting cleanup in Dialog.cs. No functional changes to dialog padding logic.
This commit is contained in:
Tig
2025-12-23 12:27:22 -07:00
parent f41b009f7c
commit a916169b5e
3 changed files with 5 additions and 5 deletions

View File

@@ -240,7 +240,7 @@ public class MessageBoxes : Scenario
int numButtons = int.Parse (numButtonsEdit.Text); int numButtons = int.Parse (numButtonsEdit.Text);
int defaultButton = int.Parse (defaultButtonEdit.Text); int defaultButton = int.Parse (defaultButtonEdit.Text);
List<string> btns = new (); List<string> btns = [];
for (var i = 0; i < numButtons; i++) for (var i = 0; i < numButtons; i++)
{ {

View File

@@ -88,7 +88,7 @@ public partial class View
int max = GetContentSize ().Width; int max = GetContentSize ().Width;
// If ContentSizeTracksViewport is false and there are no subviews, use the explicitly set ContentSize // If ContentSizeTracksViewport is false and there are no subviews, use the explicitly set ContentSize
if (!ContentSizeTracksViewport && InternalSubViews.Count == 0) if (!ContentSizeTracksViewport && GetSubViews (includePadding: true).Count == 0)
{ {
return max; return max;
} }
@@ -117,7 +117,7 @@ public partial class View
int max = GetContentSize ().Height; int max = GetContentSize ().Height;
// If ContentSizeTracksViewport is false and there are no subviews, use the explicitly set ContentSize // If ContentSizeTracksViewport is false and there are no subviews, use the explicitly set ContentSize
if (!ContentSizeTracksViewport && InternalSubViews.Count == 0) if (!ContentSizeTracksViewport && GetSubViews (includePadding: true).Count == 0)
{ {
return max; return max;
} }
@@ -128,7 +128,7 @@ public partial class View
} }
// Iterate through all subviews to calculate the maximum height // Iterate through all subviews to calculate the maximum height
foreach (View subView in InternalSubViews) foreach (View subView in GetSubViews (includePadding: true))
{ {
max = Math.Max (max, subView.Y.GetAnchor (0) + subView.Height.Calculate (0, max, subView, Dimension.Height)); max = Math.Max (max, subView.Y.GetAnchor (0) + subView.Height.Calculate (0, max, subView, Dimension.Height));
} }

View File

@@ -232,7 +232,7 @@ public class Dialog : Window, IDesignable
// Update padding if buttons have been laid out (maxHeight > 1) // Update padding if buttons have been laid out (maxHeight > 1)
if (maxHeight > 1 || Padding.Thickness.Bottom == 0) if (maxHeight > 1 || Padding.Thickness.Bottom == 0)
{ {
Padding.Thickness = Padding.Thickness with { Bottom = maxHeight }; Padding.Thickness = Padding.Thickness with { Bottom = maxHeight };
} }
} }