From 7c911ca830021b9a6d17b57d1934c1db28a43a5a Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Thu, 28 May 2020 16:29:35 -0600 Subject: [PATCH] Fix #522 - Last view of FrameView not drawn (#575) * PoC * PoC progress * progress * Fixed #522 - updated sample * reverted untested PR * reverted untested PR * backed out more PRs that weren't ready --- Terminal.Gui/Core/PosDim.cs | 3 +- Terminal.Gui/Views/FrameView.cs | 4 +- UICatalog/Scenarios/ComputedLayout.cs | 26 +++++--- UICatalog/Scenarios/Editor.cs | 1 + UICatalog/Scenarios/HexEditor.cs | 5 +- ...wExperiment.cs => WindowsAndFrameViews.cs} | 61 +++++++++++-------- 6 files changed, 63 insertions(+), 37 deletions(-) rename UICatalog/Scenarios/{WindowExperiment.cs => WindowsAndFrameViews.cs} (69%) diff --git a/Terminal.Gui/Core/PosDim.cs b/Terminal.Gui/Core/PosDim.cs index e9c7efd8f..51ea52072 100644 --- a/Terminal.Gui/Core/PosDim.cs +++ b/Terminal.Gui/Core/PosDim.cs @@ -110,8 +110,9 @@ namespace Terminal.Gui { /// /// This sample shows how align a to the bottom-right of a . /// + /// // See Issue #502 /// anchorButton.X = Pos.AnchorEnd () - (Pos.Right (anchorButton) - Pos.Left (anchorButton)); - /// anchorButton.Y = Pos.AnchorEnd () - 1; + /// anchorButton.Y = Pos.AnchorEnd (1); /// /// public static Pos AnchorEnd (int margin = 0) diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs index 6768a01ae..93fecf4b5 100644 --- a/Terminal.Gui/Views/FrameView.cs +++ b/Terminal.Gui/Views/FrameView.cs @@ -75,8 +75,8 @@ namespace Terminal.Gui { contentView = new ContentView () { X = 1, Y = 1, - Width = Dim.Fill (2), - Height = Dim.Fill (2) + Width = Dim.Fill (1), + Height = Dim.Fill (1) }; Initialize (); } diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index 0797aab80..6bbb4dbe8 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -28,10 +28,6 @@ namespace UICatalog { ColorScheme = Colors.Error }; - Application.Resized += (sender, a) => { - horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)]; - }; - Win.Add (horizontalRuler); // Demonstrate using Dim to create a vertical ruler that always measures the parent window's height @@ -47,6 +43,7 @@ namespace UICatalog { }; Application.Resized += (sender, a) => { + horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)]; verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height*2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height*2)]; }; @@ -77,11 +74,27 @@ namespace UICatalog { labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog }); labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog }); labelList.Add (new Label ($"{i++}-{txt}") { TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill (), X = 0, Y = Pos.Bottom (labelList.LastOrDefault ()), ColorScheme = Colors.Dialog }); - subWin.Add (labelList.ToArray ()); + // #522 repro? + var frameView = new FrameView ($"Centered FrameView with {margin} character margin") { + X = Pos.Center (), + Y = Pos.Bottom(subWin), + Width = Dim.Fill (margin), + Height = 7 + }; + Win.Add (frameView); + i = 1; + labelList = new List