#nullable enable
namespace Terminal.Gui;
///
/// Provides a menu bar that spans the top of a View with drop-down and cascading menus.
///
/// By default, any sub-sub-menus (sub-menus of the s added to s)
/// are displayed in a cascading manner, where each sub-sub-menu pops out of the sub-menu frame (either to the
/// right or left, depending on where the sub-menu is relative to the edge of the screen). By setting
/// to , this behavior can be changed such that all
/// sub-sub-menus are drawn within a single frame below the MenuBar.
///
///
///
///
/// The appears on the first row of the SuperView and uses the full
/// width.
///
/// See also:
/// The provides global hot keys for the application. See .
///
/// When the menu is created key bindings for each menu item and its sub-menu items are added for each menu
/// item's hot key (both alone AND with AltMask) and shortcut, if defined.
///
///
/// If a key press matches any of the menu item's hot keys or shortcuts, the menu item's action is invoked or
/// sub-menu opened.
///
///
/// * If the menu bar is not open * Any shortcut defined within the menu will be invoked * Only hot keys defined
/// for the menu bar items will be invoked, and only if Alt is pressed too. * If the menu bar is open * Un-shifted
/// hot keys defined for the menu bar items will be invoked, only if the menu they belong to is open (the menu bar
/// item's text is visible). * Alt-shifted hot keys defined for the menu bar items will be invoked, only if the
/// menu they belong to is open (the menu bar item's text is visible). * If there is a visible hot key that
/// duplicates a shortcut (e.g. _File and Alt-F), the hot key wins.
///
///
public class MenuBar : View, IDesignable
{
// Spaces before the Title
private static readonly int _leftPadding = 1;
// Spaces after the submenu Title, before Help
private static readonly int _parensAroundHelp = 3;
// Spaces after the Title
private static readonly int _rightPadding = 1;
// The column where the MenuBar starts
private static readonly int _xOrigin = 0;
internal bool _isMenuClosing;
internal bool _isMenuOpening;
internal Menu? _openMenu;
internal List