namespace Terminal.Gui.App; /// /// Extension methods for making any into a popover. /// /// /// These extensions provide a fluent API for wrapping views in , /// enabling any View to be shown as a popover without implementing . /// public static class ViewPopoverExtensions { /// /// Converts any View into a popover. /// /// The type of view to make into a popover. /// The view to wrap. Cannot be null. /// A that wraps the view. /// Thrown if is null. /// /// /// This method wraps the view in a which automatically /// handles popover behavior including transparency, focus, and quit key handling. /// /// /// After creating the wrapper, register it with /// and show it with . /// /// /// /// /// // Make a custom view into a popover /// var myView = new View /// { /// X = Pos.Center (), /// Y = Pos.Center (), /// Width = 40, /// Height = 10, /// BorderStyle = LineStyle.Single /// }; /// myView.Add (new Label { Text = "Hello Popover!" }); /// /// var popover = myView.AsPopover(); /// app.Popover.Register (popover); /// app.Popover.Show (popover); /// /// // The wrapped view can still be accessed /// Console.WriteLine ($"View id: {popover.WrappedView.Id}"); /// /// public static PopoverWrapper AsPopover (this TView view) where TView : View { if (view is null) { throw new ArgumentNullException (nameof (view)); } return new PopoverWrapper { WrappedView = view }; } }