Bläddra i källkod

enables hiding statusbar

Charlie Kindel 4 år sedan
förälder
incheckning
b1e28baa2a
3 ändrade filer med 20 tillägg och 10 borttagningar
  1. 6 6
      Terminal.Gui/Core/Toplevel.cs
  2. 2 2
      Terminal.Gui/Views/StatusBar.cs
  3. 12 2
      UICatalog/UICatalog.cs

+ 6 - 6
Terminal.Gui/Core/Toplevel.cs

@@ -333,9 +333,9 @@ namespace Terminal.Gui {
 			}
 			ny = Math.Max (y, l);
 			if (SuperView == null || SuperView.GetType () != typeof (Toplevel)) {
-				s = Application.Top.StatusBar != null;
+				s = Application.Top.StatusBar != null && Application.Top.StatusBar.Visible;
 			} else {
-				s = ((Toplevel)SuperView).StatusBar != null;
+				s = ((Toplevel)SuperView).StatusBar != null && ((Toplevel)SuperView).StatusBar.Visible;
 			}
 			if (SuperView == null || SuperView is Toplevel) {
 				l = s ? Driver.Rows - 1 : Driver.Rows;
@@ -368,12 +368,12 @@ namespace Terminal.Gui {
 				}
 			}
 			if (top.StatusBar != null) {
-				if (ny + top.Frame.Height > top.Frame.Height - 1) {
+				if (ny + top.Frame.Height > top.Frame.Height - (top.StatusBar.Visible ? 1 : 0)) {
 					if (top.Height is Dim.DimFill)
-						top.Height = Dim.Fill () - 1;
+						top.Height = Dim.Fill () - (top.StatusBar.Visible ? 1 : 0);
 				}
-				if (top.StatusBar.Frame.Y != top.Frame.Height - 1) {
-					top.StatusBar.Y = top.Frame.Height - 1;
+				if (top.StatusBar.Frame.Y != top.Frame.Height - (top.StatusBar.Visible ? 1 : 0)) {
+					top.StatusBar.Y = top.Frame.Height - (top.StatusBar.Visible ? 1 : 0);
 					top.LayoutSubviews ();
 				}
 				top.BringSubviewToFront (top.StatusBar);

+ 2 - 2
Terminal.Gui/Views/StatusBar.cs

@@ -105,8 +105,8 @@ namespace Terminal.Gui {
 			return delegate {
 				X = 0;
 				Height = 1;
-				if (SuperView == null || SuperView is Toplevel) {
-					Y = SuperView.Frame.Height - 1;
+				if (SuperView != null || SuperView is Toplevel) {
+					Y = SuperView.Frame.Height - (Visible ? 1 : 0);
 				} else {
 					//Y = Pos.Bottom (SuperView);
 				}

+ 12 - 2
UICatalog/UICatalog.cs

@@ -215,7 +215,10 @@ namespace UICatalog {
 			_numlock = new StatusItem (Key.CharMask, "Num", null);
 			_scrolllock = new StatusItem (Key.CharMask, "Scroll", null);
 
-			_statusBar = new StatusBar (new StatusItem [] {
+			_statusBar = new StatusBar () { 
+				Visible = true,
+			};
+			_statusBar.Items = new StatusItem [] {
 				_capslock,
 				_numlock,
 				_scrolllock,
@@ -228,7 +231,14 @@ namespace UICatalog {
 						_runningScenario.RequestStop();
 					}
 				}),
-			});
+				new StatusItem(Key.F10, "~F10~ Hide/Show Status Bar", () => {
+					_statusBar.Visible = !_statusBar.Visible;
+					_leftPane.Height = Dim.Fill(_statusBar.Visible ? 1 : 0);
+					_rightPane.Height = Dim.Fill(_statusBar.Visible ? 1 : 0);
+					_top.LayoutSubviews();
+					_top.ChildNeedsDisplay();
+				}),
+			};
 
 			SetColorScheme ();
 			_top = Application.Top;