diff --git a/Terminal.Gui/Drawing/Thickness.cs b/Terminal.Gui/Drawing/Thickness.cs index 956f8df13..bbe3b0c3a 100644 --- a/Terminal.Gui/Drawing/Thickness.cs +++ b/Terminal.Gui/Drawing/Thickness.cs @@ -110,6 +110,13 @@ public class Thickness : IEquatable return new Thickness (Left + other.Left, Top + other.Top, Right + other.Right, Bottom + other.Bottom); } + /// + /// Adds the thickness widths of another to another . + /// + /// + /// + /// + public static Thickness operator + (Thickness a, Thickness b) { return a.Add (b); } /// Draws the rectangle with an optional diagnostics label. /// diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs index 7b632b03c..4072ed5e2 100644 --- a/Terminal.Gui/View/Adornment/Adornment.cs +++ b/Terminal.Gui/View/Adornment/Adornment.cs @@ -30,15 +30,6 @@ public class Adornment : View /// public Adornment (View parent) { Parent = parent; } - ///// - ///// Helper to get the X and Y offset of the Bounds from the Adornment Frame. This is the Left and Top properties - ///// of . - ///// - //public override Point GetBoundsOffset () - //{ - // return new (Thickness.Left, Thickness.Top); - //} - /// /// Gets the rectangle that describes the area of the Adornment. The Location is always (0,0). /// The size is the size of the Frame @@ -47,6 +38,7 @@ public class Adornment : View { get => new (Point.Empty, Frame.Size); // QUESTION: So why even have a setter then? + // ANSWER: Because this is an override of a base class property, and the base class has a setter. set => throw new InvalidOperationException ("It makes no sense to set Bounds of a Thickness."); } @@ -103,7 +95,7 @@ public class Adornment : View } // Adornments are *Children* of a View, not SubViews. Thus View.FrameToScreen will not work. - // To get the screen-relative coordinates of a Adornment, we need get the parent's Frame + // To get the screen-relative coordinates of an Adornment, we need get the parent's Frame // in screen coords, and add our Frame location to it. Rectangle parent = Parent.FrameToScreen (); return new (new (parent.X + Frame.X, parent.Y + Frame.Y), Frame.Size); diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index c8cea4c3a..264febf98 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -86,8 +86,8 @@ public partial class View } /// - /// The adornment (specified as a ) inside of the view that offsets the - /// from the . The Border provides the space for a visual border (drawn using + /// The that offsets the from the . + /// The Border provides the space for a visual border (drawn using /// line-drawing glyphs) and the Title. The Border expands inward; in other words if `Border.Thickness.Top == 2` the /// border and title will take up the first row and the second row will be filled with spaces. /// @@ -181,7 +181,7 @@ public partial class View return Rectangle.Empty with { Size = Frame.Size }; } - Thickness totalThickness = Margin.Thickness.Add (Border.Thickness.Add (Padding.Thickness)); + Thickness totalThickness = GetAdornmentsThickness (); int width = Math.Max (0, Frame.Size.Width - totalThickness.Horizontal); int height = Math.Max (0, Frame.Size.Height - totalThickness.Vertical); @@ -199,20 +199,10 @@ public partial class View ); } #endif // DEBUG - Thickness totalThickness = Margin.Thickness.Add (Border.Thickness.Add (Padding.Thickness)); + Thickness totalThickness = GetAdornmentsThickness (); Frame = Frame with { - Size = - new ( - value.Size.Width + totalThickness.Horizontal, - //+ Margin.Thickness.Horizontal - //+ Border.Thickness.Horizontal - //+ Padding.Thickness.Horizontal, - value.Size.Height + totalThickness.Vertical - //+ Margin.Thickness.Vertical - //+ Border.Thickness.Vertical - //+ Padding.Thickness.Vertical - ) + Size = new (value.Size.Width + totalThickness.Horizontal, value.Size.Height + totalThickness.Vertical) }; } } @@ -343,7 +333,7 @@ public partial class View } /// - /// The frame (specified as a ) that separates a View from other SubViews of the same + /// The that that separates a View from other SubViews of the same /// SuperView. The margin offsets the from the . /// /// @@ -360,7 +350,7 @@ public partial class View public Margin Margin { get; private set; } /// - /// The frame (specified as a ) inside of the view that offsets the + /// The inside of the view that offsets the /// from the . /// /// @@ -589,12 +579,7 @@ public partial class View /// A thickness that describes the sum of the Adornments' thicknesses. public Thickness GetAdornmentsThickness () { - int left = Margin.Thickness.Left + Border.Thickness.Left + Padding.Thickness.Left; - int top = Margin.Thickness.Top + Border.Thickness.Top + Padding.Thickness.Top; - int right = Margin.Thickness.Right + Border.Thickness.Right + Padding.Thickness.Right; - int bottom = Margin.Thickness.Bottom + Border.Thickness.Bottom + Padding.Thickness.Bottom; - - return new (left, top, right, bottom); + return Margin.Thickness + Border.Thickness + Padding.Thickness; } ///