mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
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:
@@ -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++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user