namespace Terminal.Gui.ViewBase; /// The Padding for a . Accessed via /// /// See the class. /// public class Padding : Adornment { /// public Padding () { /* Do nothing; A parameter-less constructor is required to support all views unit tests. */ } /// public Padding (View parent) : base (parent) { CanFocus = true; TabStop = TabBehavior.NoStop; } /// Called when a mouse event occurs within the Padding. /// /// /// The coordinates are relative to . /// /// /// A mouse click on the Padding will cause the Parent to focus. /// /// /// /// , if the event was handled, otherwise. protected override bool OnMouseEvent (MouseEventArgs mouseEvent) { if (Parent is null) { return false; } if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)) { if (Parent.CanFocus && !Parent.HasFocus) { Parent.SetFocus (); Parent.SetNeedsDraw (); return mouseEvent.Handled = true; } } return false; } /// /// Gets all SubViews of this Padding, optionally including SubViews of the Padding's Parent. /// /// /// Ignored. /// /// /// Ignored. /// /// /// If , includes SubViews from . If (default), /// returns only the direct SubViews /// of this Padding. /// /// /// A read-only collection containing all SubViews. If is /// , the collection includes SubViews from this Padding's direct SubViews as well /// as SubViews from the Padding's Parent. /// /// /// /// This method returns a snapshot of the SubViews at the time of the call. The collection is /// safe to iterate even if SubViews are added or removed during iteration. /// /// /// The order of SubViews in the returned collection is: /// /// Direct SubViews of this Padding /// SubViews of Parent (if is ) /// /// /// public override IReadOnlyCollection GetSubViews (bool includeMargin = false, bool includeBorder = false, bool includePadding = false) { List subViewsOfThisAdornment = new (base.GetSubViews (false, false, includePadding)); if (includePadding && Parent is { }) { // Include SubViews from Parent. Since we are a Padding of Parent do not // request Adornments again to avoid infinite recursion. subViewsOfThisAdornment.AddRange (Parent.GetSubViews (false, false, false)); } return subViewsOfThisAdornment; } }