From 7630b35d865477b4674ddd55e2799237a05f7de8 Mon Sep 17 00:00:00 2001 From: Tig Date: Tue, 8 Oct 2024 21:13:27 -0400 Subject: [PATCH] Fixed more menubar/statusbar --- Terminal.Gui/Application/Application.Mouse.cs | 2 +- UICatalog/Scenarios/ASCIICustomButton.cs | 2 +- UICatalog/Scenarios/ClassExplorer.cs | 11 +++---- UICatalog/Scenarios/ContextMenus.cs | 15 ++-------- UICatalog/Scenarios/LineViewExample.cs | 30 +++---------------- UICatalog/Scenarios/Localization.cs | 2 ++ UICatalog/Scenarios/WizardAsView.cs | 1 + 7 files changed, 18 insertions(+), 45 deletions(-) diff --git a/Terminal.Gui/Application/Application.Mouse.cs b/Terminal.Gui/Application/Application.Mouse.cs index d18cd48b5..ab1cf428d 100644 --- a/Terminal.Gui/Application/Application.Mouse.cs +++ b/Terminal.Gui/Application/Application.Mouse.cs @@ -224,7 +224,7 @@ public static partial class Application // Mouse handling { // The mouse was outside any View's Viewport. - Debug.Fail ("This should never happen. If it does please file an Issue!!"); + // Debug.Fail ("This should never happen. If it does please file an Issue!!"); return; } diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs index 04b4e0b3e..661efd80d 100644 --- a/UICatalog/Scenarios/ASCIICustomButton.cs +++ b/UICatalog/Scenarios/ASCIICustomButton.cs @@ -54,7 +54,7 @@ public class ASCIICustomButtonTest : Scenario ] }; - _scrollViewTestWindow = new ScrollViewTestWindow (); + _scrollViewTestWindow = new ScrollViewTestWindow { Y = Pos.Bottom (menu) }; top.Add (menu, _scrollViewTestWindow); Application.Run (top); diff --git a/UICatalog/Scenarios/ClassExplorer.cs b/UICatalog/Scenarios/ClassExplorer.cs index 204ef01b5..0bfd4e9fd 100644 --- a/UICatalog/Scenarios/ClassExplorer.cs +++ b/UICatalog/Scenarios/ClassExplorer.cs @@ -22,11 +22,6 @@ public class ClassExplorer : Scenario Application.Init (); var top = new Toplevel (); - var win = new Window - { - Title = GetName () - }; - var menu = new MenuBar { Menus = @@ -61,6 +56,12 @@ public class ClassExplorer : Scenario }; top.Add (menu); + var win = new Window + { + Title = GetName (), + Y = Pos.Bottom (menu) + }; + _treeView = new TreeView { X = 0, Y = 1, Width = Dim.Percent (50), Height = Dim.Fill () }; var lblSearch = new Label { Text = "Search" }; diff --git a/UICatalog/Scenarios/ContextMenus.cs b/UICatalog/Scenarios/ContextMenus.cs index 01c4e340e..816f80384 100644 --- a/UICatalog/Scenarios/ContextMenus.cs +++ b/UICatalog/Scenarios/ContextMenus.cs @@ -25,7 +25,8 @@ public class ContextMenus : Scenario // Setup - Create a top-level application window and configure it. Window appWindow = new () { - Title = GetQuitKeyAndName () + Title = GetQuitKeyAndName (), + Arrangement = ViewArrangement.Fixed }; var text = "Context Menu"; @@ -93,18 +94,8 @@ public class ContextMenus : Scenario Application.MouseEvent -= ApplicationMouseEvent; }; - var menu = new MenuBar - { - Menus = - [ - new ( - "_File", - new MenuItem [] { new ("_Quit", "", () => Application.RequestStop (), null, null, Application.QuitKey) }) - ] - }; - var top = new Toplevel (); - top.Add (appWindow, menu); + top.Add (appWindow); // Run - Start the application. Application.Run (top); diff --git a/UICatalog/Scenarios/LineViewExample.cs b/UICatalog/Scenarios/LineViewExample.cs index d3a75902f..ff3a6b82a 100644 --- a/UICatalog/Scenarios/LineViewExample.cs +++ b/UICatalog/Scenarios/LineViewExample.cs @@ -13,23 +13,12 @@ public class LineViewExample : Scenario public override void Main () { Application.Init (); - // Setup - Create a top-level application window and configure it. - Toplevel top = new (); - var menu = new MenuBar + var appWindow = new Window() { - Menus = - [ - new ("_File", new MenuItem [] { new ("_Quit", "", () => Quit ()) }) - ] + Title = GetQuitKeyAndName (), }; - top.Add (menu); - var appWindow = new Window () - { - Y = 1, - Height = Dim.Fill (1) // BUGBUG: what if StatusBar is taller than 1? - }; appWindow.Add (new Label { Y = 1, Text = "Regular Line" }); // creates a horizontal line @@ -78,22 +67,11 @@ public class LineViewExample : Scenario appWindow.Add (verticalArrow); - var statusBar = new StatusBar ( - new Shortcut [] - { - new (Application.QuitKey, "Quit", Quit) - } - ); - top.Add (appWindow); - top.Add (statusBar); - // Run - Start the application. - Application.Run (top); - top.Dispose (); + Application.Run (appWindow); + appWindow.Dispose (); // Shutdown - Calling Application.Shutdown is required. Application.Shutdown (); } - - private void Quit () { Application.RequestStop (); } } diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs index 3386dc3bd..f28750a0d 100644 --- a/UICatalog/Scenarios/Localization.cs +++ b/UICatalog/Scenarios/Localization.cs @@ -177,6 +177,8 @@ public class Localization : Scenario win.Add (wizardButton); win.Unloaded += (sender, e) => Quit (); + + win.Y = Pos.Bottom (menu); top.Add (win); Application.Run (top); diff --git a/UICatalog/Scenarios/WizardAsView.cs b/UICatalog/Scenarios/WizardAsView.cs index f68dc4b71..1a3e61baa 100644 --- a/UICatalog/Scenarios/WizardAsView.cs +++ b/UICatalog/Scenarios/WizardAsView.cs @@ -147,6 +147,7 @@ public class WizardAsView : Scenario lastStep.HelpText = "The wizard is complete!\n\nPress the Finish button to continue.\n\nPressing Esc will cancel."; + wizard.Y = Pos.Bottom (menu); topLevel.Add (wizard); Application.Run (topLevel); topLevel.Dispose ();