mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 09:47:58 +01:00
Fixes #2226. StatusBar misplaced when window maximized (and occasionally on resize).
This commit is contained in:
@@ -87,39 +87,9 @@ namespace Terminal.Gui {
|
||||
CanFocus = false;
|
||||
ColorScheme = Colors.Menu;
|
||||
X = 0;
|
||||
Y = Pos.AnchorEnd (1);
|
||||
Width = Dim.Fill ();
|
||||
Height = 1;
|
||||
|
||||
Initialized += StatusBar_Initialized;
|
||||
Application.Resized += Application_Resized ();
|
||||
}
|
||||
|
||||
private void StatusBar_Initialized (object sender, EventArgs e)
|
||||
{
|
||||
if (SuperView.Frame == Rect.Empty) {
|
||||
((Toplevel)SuperView).Loaded += StatusBar_Loaded;
|
||||
} else {
|
||||
Y = Math.Max (SuperView.Frame.Height - (Visible ? 1 : 0), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void StatusBar_Loaded ()
|
||||
{
|
||||
Y = Math.Max (SuperView.Frame.Height - (Visible ? 1 : 0), 0);
|
||||
((Toplevel)SuperView).Loaded -= StatusBar_Loaded;
|
||||
}
|
||||
|
||||
private Action<Application.ResizedEventArgs> Application_Resized ()
|
||||
{
|
||||
return delegate {
|
||||
X = 0;
|
||||
Height = 1;
|
||||
if (SuperView != null || SuperView is Toplevel) {
|
||||
if (Frame.Y != SuperView.Frame.Height - (Visible ? 1 : 0)) {
|
||||
Y = SuperView.Frame.Height - (Visible ? 1 : 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ustring shortcutDelimiter = "-";
|
||||
@@ -145,12 +115,6 @@ namespace Terminal.Gui {
|
||||
///<inheritdoc/>
|
||||
public override void Redraw (Rect bounds)
|
||||
{
|
||||
//if (Frame.Y != Driver.Rows - 1) {
|
||||
// Frame = new Rect (Frame.X, Driver.Rows - 1, Frame.Width, Frame.Height);
|
||||
// Y = Driver.Rows - 1;
|
||||
// SetNeedsDisplay ();
|
||||
//}
|
||||
|
||||
Move (0, 0);
|
||||
Driver.SetAttribute (GetNormalColor ());
|
||||
for (int i = 0; i < Frame.Width; i++)
|
||||
@@ -228,17 +192,6 @@ namespace Terminal.Gui {
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposedValue) {
|
||||
if (disposing) {
|
||||
Application.Resized -= Application_Resized ();
|
||||
}
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
public override bool OnEnter (View view)
|
||||
{
|
||||
|
||||
@@ -31,11 +31,10 @@ namespace Terminal.Gui.Views {
|
||||
Assert.False (sb.CanFocus);
|
||||
Assert.Equal (Colors.Menu, sb.ColorScheme);
|
||||
Assert.Equal (0, sb.X);
|
||||
Assert.Equal ("Pos.AnchorEnd(margin=1)", sb.Y.ToString ());
|
||||
Assert.Equal (Dim.Fill (), sb.Width);
|
||||
Assert.Equal (1, sb.Height);
|
||||
|
||||
Assert.Null (sb.Y);
|
||||
|
||||
var driver = new FakeDriver ();
|
||||
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
@@ -47,11 +46,11 @@ namespace Terminal.Gui.Views {
|
||||
Assert.True (FakeConsole.CursorVisible);
|
||||
|
||||
Application.Iteration += () => {
|
||||
Assert.Equal (24, sb.Y);
|
||||
Assert.Equal (24, sb.Frame.Y);
|
||||
|
||||
driver.SetWindowSize (driver.Cols, 15);
|
||||
|
||||
Assert.Equal (14, sb.Y);
|
||||
Assert.Equal (14, sb.Frame.Y);
|
||||
|
||||
sb.OnEnter (null);
|
||||
driver.GetCursorVisibility (out cv);
|
||||
|
||||
@@ -153,5 +153,88 @@ namespace Terminal.Gui.Core {
|
||||
Assert.Equal (expected, r.Title.ToString ());
|
||||
r.Dispose ();
|
||||
}
|
||||
|
||||
[Fact,AutoInitShutdown]
|
||||
public void MenuBar_And_StatusBar_Inside_Window ()
|
||||
{
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
new MenuBarItem ("File", new MenuItem [] {
|
||||
new MenuItem ("Open", "", null),
|
||||
new MenuItem ("Quit", "", null),
|
||||
}),
|
||||
new MenuBarItem ("Edit", new MenuItem [] {
|
||||
new MenuItem ("Copy", "", null),
|
||||
})
|
||||
});
|
||||
|
||||
var sb = new StatusBar (new StatusItem [] {
|
||||
new StatusItem (Key.CtrlMask | Key.Q, "~^Q~ Quit", null),
|
||||
new StatusItem (Key.CtrlMask | Key.O, "~^O~ Open", null),
|
||||
new StatusItem (Key.CtrlMask | Key.C, "~^C~ Copy", null),
|
||||
});
|
||||
|
||||
var fv = new FrameView ("Frame View") {
|
||||
Y = 1,
|
||||
Width = Dim.Fill(),
|
||||
Height = Dim.Fill (1)
|
||||
};
|
||||
var win = new Window ();
|
||||
win.Add (menu, sb, fv);
|
||||
var top = Application.Top;
|
||||
top.Add (win);
|
||||
Application.Begin (top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌──────────────────┐
|
||||
│ File Edit │
|
||||
│┌ Frame View ────┐│
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
│└────────────────┘│
|
||||
│ ^Q Quit │ ^O Open│
|
||||
└──────────────────┘", output);
|
||||
|
||||
((FakeDriver)Application.Driver).SetBufferSize (40, 20);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌──────────────────────────────────────┐
|
||||
│ File Edit │
|
||||
│┌ Frame View ────────────────────────┐│
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
│└────────────────────────────────────┘│
|
||||
│ ^Q Quit │ ^O Open │ ^C Copy │
|
||||
└──────────────────────────────────────┘", output);
|
||||
|
||||
((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
┌──────────────────┐
|
||||
│ File Edit │
|
||||
│┌ Frame View ────┐│
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
││ ││
|
||||
│└────────────────┘│
|
||||
│ ^Q Quit │ ^O Open│
|
||||
└──────────────────┘", output);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user