From 92dac0ecfbd192e40a81e49614614db6efd5a796 Mon Sep 17 00:00:00 2001 From: Tig Date: Sat, 26 Oct 2024 16:46:24 -0700 Subject: [PATCH] View Draw API docs and code cleanup --- Terminal.Gui/View/Adornment/Adornment.cs | 2 +- Terminal.Gui/View/View.Drawing.cs | 2 +- Terminal.Gui/Views/FileDialog.cs | 2 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/TabView.cs | 6 +++--- Terminal.Gui/Views/TileView.cs | 6 ++---- UnitTests/Views/ToplevelTests.cs | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index df62f7d60..83ff32729 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -199,7 +199,7 @@ public class Adornment : View, IDesignable } /// - protected override bool OnDrawComplete (Rectangle viewport) { return Thickness == Thickness.Empty; } + protected override void OnDrawComplete () { } /// /// Indicates whether the specified Parent's SuperView-relative coordinates are within the Adornment's Thickness. diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs index fbd75542e..0574a8cc7 100644 --- a/Terminal.Gui/View/View.Drawing.cs +++ b/Terminal.Gui/View/View.Drawing.cs @@ -51,7 +51,7 @@ public partial class View // Drawing APIs ClearNeedsDisplay (); // We're done - DoDrawComplete (Viewport); + DoDrawComplete (); } #region DrawAdornments diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 7b12b992d..23d7b8764 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -461,7 +461,7 @@ public class FileDialog : Dialog AllowedTypeMenuClicked (0); // TODO: Using v1's menu bar here is a hack. Need to upgrade this. - _allowedTypeMenuBar.DrawComplete += (s, e) => + _allowedTypeMenuBar.DrawingContent += (s, e) => { _allowedTypeMenuBar.Move (e.NewViewport.Width - 1, 0); Driver.AddRune (Glyphs.DownArrow); diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 2a1dc08d5..558fa99e9 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -394,7 +394,7 @@ internal sealed class Menu : View } // By doing this we draw last, over everything else. - private void Top_DrawComplete (object? sender, DrawEventArgs e) + private void Top_DrawComplete (object? sender, EventArgs e) { if (!Visible) { diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 6e59f28ec..4f6461e93 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -660,11 +660,11 @@ public class TabView : View return true; } - protected override bool OnDrawComplete (Rectangle viewport) + protected override void OnDrawComplete () { if (_host._tabLocations is null) { - return true; + return; } TabToRender [] tabLocations = _host._tabLocations; @@ -1193,7 +1193,7 @@ public class TabView : View tab.DrawAdornments (); } - return true; + return; } private int GetUnderlineYPosition () diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 9a14c0c04..0056ef425 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -180,12 +180,10 @@ public class TileView : View protected override bool OnRenderingLineCanvas () { return false; } /// - protected override bool OnDrawComplete (Rectangle viewport) + protected override void OnDrawComplete () { Driver?.SetAttribute (ColorScheme.Normal); - //Clear (); - var lc = new LineCanvas (); List allLines = GetAllLineViewsRecursively (this); @@ -275,7 +273,7 @@ public class TileView : View } } - return false; + return; } //// BUGBUG: Why is this not handled by a key binding??? diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 04bcb7b6c..6ef8237d2 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -964,7 +964,7 @@ public partial class ToplevelTests (ITestOutputHelper output) Application.Top!.DrawComplete += OnDrawContentComplete; top.Add (viewAddedToTop); - void OnDrawContentComplete (object sender, DrawEventArgs e) + void OnDrawContentComplete (object sender, EventArgs _) { Assert.Equal (new (1, 3, 18, 16), viewAddedToTop.Frame);