#nullable enable namespace Terminal.Gui; /// /// Abstract base class for Popover Views. /// /// /// /// To show a Popover, use . To hide a popover, /// call with set to . /// /// /// If the user clicks anywhere not occluded by a SubView of the Popover, presses , /// or causes another popover to show, the Popover will be hidden. /// /// public abstract class PopoverBaseImpl : View, IPopover { /// /// Creates a new PopoverBaseImpl. /// protected PopoverBaseImpl () { Id = "popoverBaseImpl"; CanFocus = true; Width = Dim.Fill (); Height = Dim.Fill (); ViewportSettings = ViewportSettings.Transparent | ViewportSettings.TransparentMouse; // TODO: Add a diagnostic setting for this? //TextFormatter.VerticalAlignment = Alignment.End; //TextFormatter.Alignment = Alignment.End; //base.Text = "popover"; AddCommand (Command.Quit, Quit); KeyBindings.Add (Application.QuitKey, Command.Quit); return; bool? Quit (ICommandContext? ctx) { if (!Visible) { return null; } Visible = false; return true; } } /// protected override bool OnVisibleChanging () { bool ret = base.OnVisibleChanging (); if (!ret && !Visible) { // Whenever visible is changing to true, we need to resize; // it's our only chance because we don't get laid out until we're visible Layout (Application.Screen.Size); } return ret; } }