StatusBar.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// A status bar is a <see cref="View"/> that snaps to the bottom of a <see cref="Toplevel"/> displaying set of
  4. /// <see cref="Shortcut"/>s. The <see cref="StatusBar"/> should be context sensitive. This means, if the main menu
  5. /// and an open text editor are visible, the items probably shown will be ~F1~ Help ~F2~ Save ~F3~ Load. While a dialog
  6. /// to ask a file to load is executed, the remaining commands will probably be ~F1~ Help. So for each context must be a
  7. /// new instance of a status bar.
  8. /// </summary>
  9. public class StatusBar : Bar
  10. {
  11. /// <inheritdoc />
  12. public StatusBar () : this ([]) { }
  13. /// <inheritdoc />
  14. public StatusBar (IEnumerable<Shortcut> shortcuts) : base (shortcuts)
  15. {
  16. Orientation = Orientation.Horizontal;
  17. Y = Pos.AnchorEnd ();
  18. Width = Dim.Fill ();
  19. StatusBarStyle = true;
  20. }
  21. /// <inheritdoc />
  22. public override View Add (View view)
  23. {
  24. view.CanFocus = false;
  25. if (view is Shortcut shortcut)
  26. {
  27. shortcut.KeyBindingScope = KeyBindingScope.Application;
  28. shortcut.AlignmentModes = AlignmentModes.EndToStart | AlignmentModes.IgnoreFirstOrLast;
  29. }
  30. return base.Add (view);
  31. }
  32. }