using System;
using System.Reflection;
namespace Terminal.Gui;
///
/// A menu bar is a that snaps to the top of a displaying set of
/// s.
///
public class MenuBarv2 : Bar
{
///
public MenuBarv2 () : this ([]) { }
///
public MenuBarv2 (IEnumerable shortcuts) : base (shortcuts)
{
Y = 0;
Width = Dim.Fill ();
Height = Dim.Auto (DimAutoStyle.Content, 1);
BorderStyle = LineStyle.Dashed;
ColorScheme = Colors.ColorSchemes ["Menu"];
Orientation = Orientation.Horizontal;
SubviewLayout += MenuBarv2_LayoutStarted;
}
// MenuBarv2 arranges the items horizontally.
// The first item has no left border, the last item has no right border.
// The Shortcuts are configured with the command, help, and key views aligned in reverse order (EndToStart).
private void MenuBarv2_LayoutStarted (object sender, LayoutEventArgs e)
{
}
///
public override View Add (View view)
{
// Call base first, because otherwise it resets CanFocus to true
base.Add (view);
view.CanFocus = true;
if (view is Shortcut shortcut)
{
// TODO: not happy about using AlignmentModes for this. Too implied.
// TODO: instead, add a property (a style enum?) to Shortcut to control this
//shortcut.AlignmentModes = AlignmentModes.EndToStart;
shortcut.KeyView.Visible = false;
shortcut.HelpView.Visible = false;
}
return view;
}
}