From 19e574916f3ad3c11a7b9db6ccf3ed8d3fea3d4f Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Sat, 2 Mar 2024 14:51:28 -0700 Subject: [PATCH] Simplified FindDeepestView --- Terminal.Gui/View/Adornment/Adornment.cs | 3 +-- Terminal.Gui/View/Layout/ViewLayout.cs | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index f32e52583..e8ab1e781 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -2,7 +2,6 @@ // TODO: Missing 3D effect - 3D effects will be drawn by a mechanism separate from Adornments // TODO: If a Adornment has focus, navigation keys (e.g Command.NextView) should cycle through SubViews of the Adornments -// TODO: Why don't we let Frame.X/Y be the location of the Adornment> Why always 0? // QUESTION: How does a user navigate out of an Adornment to another Adornment, or back into the Parent's SubViews? /// @@ -144,7 +143,7 @@ public class Adornment : View // This just draws/clears the thickness, not the insides. Driver.SetAttribute (normalAttr); - Thickness.Draw (screenBounds, (string)(Data ?? string.Empty)); + Thickness.Draw (screenBounds, ToString ()); if (!string.IsNullOrEmpty (TextFormatter.Text)) { diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 00c483475..e8bf02de8 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -580,13 +580,10 @@ public partial class View return start.Margin; } - // TODO: Move this logic into Adornment? Why can't Adornment.Frame be used? if (start.Border.Thickness.Contains ( - new ( - start.Frame.X + start.Margin.Thickness.Left, - start.Frame.Y + start.Margin.Thickness.Top, - start.Frame.Width - start.Margin.Thickness.Horizontal, - start.Frame.Height - start.Margin.Thickness.Vertical), + start.Border.Frame with { + X = start.Frame.X + start.Border.Frame.X, + Y = start.Frame.Y + start.Border.Frame.Y }, x, y)) { @@ -594,14 +591,13 @@ public partial class View } if (start.Padding.Thickness.Contains ( - new ( - start.Frame.X + start.Margin.Thickness.Left + start.Border.Thickness.Left, - start.Frame.Y + start.Margin.Thickness.Top + start.Border.Thickness.Top, - start.Frame.Width - start.Margin.Thickness.Horizontal - start.Border.Thickness.Horizontal, - start.Frame.Height - start.Margin.Thickness.Vertical - start.Border.Thickness.Vertical), + start.Padding.Frame with + { + X = start.Frame.X + start.Padding.Frame.X, + Y = start.Frame.Y + start.Padding.Frame.Y + }, x, y)) - { return start.Padding; } @@ -716,7 +712,7 @@ public partial class View LayoutAdornments (); Rectangle oldBounds = Bounds; - OnLayoutStarted (new() { OldBounds = oldBounds }); + OnLayoutStarted (new () { OldBounds = oldBounds }); SetTextFormatterSize (); @@ -743,7 +739,7 @@ public partial class View LayoutNeeded = false; - OnLayoutComplete (new() { OldBounds = oldBounds }); + OnLayoutComplete (new () { OldBounds = oldBounds }); } /// Converts a screen-relative coordinate to a bounds-relative coordinate.