diff --git a/Terminal.Gui/View/Adornment/Margin.cs b/Terminal.Gui/View/Adornment/Margin.cs index eff603e29..97dc0f093 100644 --- a/Terminal.Gui/View/Adornment/Margin.cs +++ b/Terminal.Gui/View/Adornment/Margin.cs @@ -43,27 +43,6 @@ public class Margin : Adornment } ShadowStyle = base.ShadowStyle; - - Add ( - _rightShadow = new () - { - X = Pos.AnchorEnd (1), - Y = 0, - Width = 1, - Height = Dim.Fill (), - ShadowStyle = ShadowStyle, - Orientation = Orientation.Vertical - }, - _bottomShadow = new () - { - X = 0, - Y = Pos.AnchorEnd (1), - Width = Dim.Fill (), - Height = 1, - ShadowStyle = ShadowStyle, - Orientation = Orientation.Horizontal - } - ); } /// @@ -135,9 +114,18 @@ public class Margin : Adornment /// public ShadowStyle SetShadow (ShadowStyle style) { - if (ShadowStyle == style) + if (_rightShadow is { }) { - // return style; + Remove (_rightShadow); + _rightShadow.Dispose (); + _rightShadow = null; + } + + if (_bottomShadow is { }) + { + Remove (_bottomShadow); + _bottomShadow.Dispose (); + _bottomShadow = null; } if (ShadowStyle != ShadowStyle.None) @@ -152,14 +140,28 @@ public class Margin : Adornment Thickness = new (Thickness.Left, Thickness.Top, Thickness.Right + 1, Thickness.Bottom + 1); } - if (_rightShadow is { }) + if (style != ShadowStyle.None) { - _rightShadow.ShadowStyle = style; - } + _rightShadow = new () + { + X = Pos.AnchorEnd (1), + Y = 0, + Width = 1, + Height = Dim.Fill (), + ShadowStyle = style, + Orientation = Orientation.Vertical + }; - if (_bottomShadow is { }) - { - _bottomShadow.ShadowStyle = style; + _bottomShadow = new () + { + X = 0, + Y = Pos.AnchorEnd (1), + Width = Dim.Fill (), + Height = 1, + ShadowStyle = style, + Orientation = Orientation.Horizontal + }; + Add (_rightShadow, _bottomShadow); } return style; @@ -169,7 +171,11 @@ public class Margin : Adornment public override ShadowStyle ShadowStyle { get => base.ShadowStyle; - set => base.ShadowStyle = SetShadow (value); + set + { + base.ShadowStyle = SetShadow (value); + + } } private const int PRESS_MOVE_HORIZONTAL = 1; diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs index 9099c406a..f55dcc867 100644 --- a/Terminal.Gui/View/View.Drawing.cs +++ b/Terminal.Gui/View/View.Drawing.cs @@ -700,6 +700,11 @@ public partial class View // Drawing APIs SuperView?.SetSubViewNeedsDisplay (); + if (this is Adornment adornment) + { + adornment.Parent?.SetSubViewNeedsDisplay (); + } + foreach (View subview in Subviews) { if (subview.Frame.IntersectsWith (region)) diff --git a/Terminal.Gui/View/View.Layout.cs b/Terminal.Gui/View/View.Layout.cs index af6dad65e..3625344ae 100644 --- a/Terminal.Gui/View/View.Layout.cs +++ b/Terminal.Gui/View/View.Layout.cs @@ -822,12 +822,12 @@ public partial class View // Layout APIs TextFormatter.NeedsFormat = true; + SuperView?.SetLayoutNeeded (); + if (this is Adornment adornment) { adornment.Parent?.SetLayoutNeeded (); } - - SuperView?.SetLayoutNeeded (); } /// diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs index b6986067e..67b3c8967 100644 --- a/UICatalog/Scenarios/ContentScrolling.cs +++ b/UICatalog/Scenarios/ContentScrolling.cs @@ -47,7 +47,7 @@ public class ContentScrolling : Scenario // Add a status label to the border that shows Viewport and ContentSize values. Bit of a hack. // TODO: Move to Padding with controls Border.Add (new Label { X = 20 }); - LayoutComplete += VirtualDemoView_LayoutComplete; + ViewportChanged += VirtualDemoView_LayoutComplete; MouseEvent += VirtualDemoView_MouseEvent; } @@ -81,18 +81,14 @@ public class ContentScrolling : Scenario } } - private void VirtualDemoView_LayoutComplete (object sender, LayoutEventArgs e) + private void VirtualDemoView_LayoutComplete (object sender, DrawEventArgs drawEventArgs) { - Label status = Border.Subviews.OfType