diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index c740ebff2..5b154b4af 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -95,6 +95,8 @@ public class Adornment : View /// public override void BoundsToScreen (int col, int row, out int rcol, out int rrow, bool clipped = true) { + rcol = 0; + rrow = 0; // Adornments are *Children* of a View, not SubViews. Thus View.BoundsToScreen will not work. // To get the screen-relative coordinates of a Adornment, we need to know who // the Parent is @@ -102,7 +104,7 @@ public class Adornment : View rrow = row + parentFrame.Y; rcol = col + parentFrame.X; - // We now have rcol/rrow in coordinates relative to our View's SuperView. If our View's SuperView has + // We now have rcol/rrow in coordinates relative to our Parent View's SuperView. If our Parent View's SuperView has // a SuperView, keep going... Parent?.SuperView?.BoundsToScreen (rcol, rrow, out rcol, out rrow, clipped); } @@ -163,6 +165,11 @@ public class Adornment : View return; } + if (Parent is Label) + { + + } + Rectangle screenBounds = BoundsToScreen (Frame); Attribute normalAttr = GetNormalColor (); diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 6c9bf1a98..b22f2b030 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -538,10 +538,10 @@ public partial class View while (super is { }) { - if (super is Adornment ador) + if (super is Adornment) { // TODO: Move this into Adornment somehow to remove coupling. - ador.BoundsToScreen (rx, ry, out rx, out ry); + super.BoundsToScreen (rx, ry, out rx, out ry); } boundsOffset = super.GetBoundsOffset (); diff --git a/UICatalog/Scenarios/AdornmentExperiments.cs b/UICatalog/Scenarios/AdornmentExperiments.cs new file mode 100644 index 000000000..46b688bbd --- /dev/null +++ b/UICatalog/Scenarios/AdornmentExperiments.cs @@ -0,0 +1,56 @@ +using Terminal.Gui; + +namespace UICatalog.Scenarios; + +[ScenarioMetadata ("Adornment Experiments", "Playground for Adornment experiments")] +[ScenarioCategory ("Controls")] +public class AdornmentExperiments : Scenario +{ + private ConsoleDriver.DiagnosticFlags _diagnosticFlags; + + public override void Init () + { + Application.Init (); + ConfigurationManager.Themes.Theme = Theme; + ConfigurationManager.Apply (); + Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme]; + + _diagnosticFlags = ConsoleDriver.Diagnostics; + ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.FramePadding; + } + + private View _frameView; + public override void Setup () + { + _frameView = new View () + { + Title = "Frame View", + X = 0, + Y = 0, + Width = Dim.Percent(90), + Height = Dim.Percent (90), + CanFocus = true, + }; + Application.Top.Add (_frameView); + _frameView.Initialized += FrameView_Initialized; + + Application.Top.Closed += (s, e) => ConsoleDriver.Diagnostics = _diagnosticFlags; + } + + private void FrameView_Initialized (object sender, System.EventArgs e) + { + _frameView.Border.Thickness = new (1, 1, 1, 1); + _frameView.Padding.Thickness = new (0, 10, 0, 0); + _frameView.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; + + var label = new Label () + { + Text = "In Padding", + X = Pos.Center (), + Y = 0, + BorderStyle = LineStyle.Dashed + }; + _frameView.Padding.Add (label); + } + +} diff --git a/UICatalog/Scenarios/Adornments.cs b/UICatalog/Scenarios/Adornments.cs index a559ebb6d..b8da34349 100644 --- a/UICatalog/Scenarios/Adornments.cs +++ b/UICatalog/Scenarios/Adornments.cs @@ -97,8 +97,10 @@ public class Adornments : Scenario var btnButtonInPadding = new Button { X = Pos.Center (), Y = 1, Text = "_Button in Padding" }; btnButtonInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok"); - //btnButtonInPadding.BorderStyle = LineStyle.Dashed; + btnButtonInPadding.BorderStyle = LineStyle.Dashed; + btnButtonInPadding.Border.Thickness = new (3,3,3,3); view.Padding.Add (btnButtonInPadding); + btnButtonInPadding.Border.CloseButton.Visible = true; view.Border.CloseButton.Visible = true; view.Border.CloseButton.Accept += (s, e) =>