Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2558. MenuBar positions wrong in some situations. #2567

Merged
merged 21 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9ff50d3
Fixes #2558. MenuBar positions wrong in some situations.
BDisp Apr 20, 2023
82beaa1
Replacing Application.Top with Application.Current.
BDisp Apr 24, 2023
80410ba
Fix typo.
BDisp Apr 24, 2023
f759b27
Fix shortcut tag overlapping help on smaller width and add more unit …
BDisp Apr 24, 2023
fac62cc
Resizing the console will close all opened menus.
BDisp Apr 24, 2023
b362bb3
Resize first the console before show ContextMenu.
BDisp Apr 24, 2023
d984bcb
Merge branch 'v2_develop' into v2_menu-on-smaller-top-fix_2558
tig Apr 28, 2023
c6c9fc3
Merge branch 'v2_develop' into v2_menu-on-smaller-top-fix_2558
BDisp Apr 29, 2023
d975a57
Remove DriverFrame and DriverFrameOffset as not relevant.
BDisp Apr 29, 2023
bc0bf2f
Replace _frame with Frame as requested.
BDisp Apr 29, 2023
2d9b874
Fix xml document comment.
BDisp Apr 29, 2023
77f0b43
Compare equality between Dialog and Application.Top.
BDisp Apr 29, 2023
2816f67
Move GetDriverLocationOffset and GetDriverLocationOffsetFromCurrent t…
BDisp Apr 29, 2023
ee4a3ee
Merge branch 'v2_develop' into v2_menu-on-smaller-top-fix_2558
BDisp Apr 29, 2023
100d49e
Merge branch 'v2_develop' into v2_menu-on-smaller-top-fix_2558
BDisp May 4, 2023
4c74092
Resolving merge conflicts.
BDisp May 4, 2023
14338b7
Fix merge errors.
BDisp May 4, 2023
dd3a763
Ensure menu is closed on click.
BDisp May 4, 2023
3c267c3
Force Height always be 1 to avoid mouse events respond even outside b…
BDisp May 5, 2023
0f54fdd
Recovering UseSubMenusSingleFrame hope doesn't break again.
BDisp May 5, 2023
b97f318
Fix bugs and made requested changes.
BDisp May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Terminal.Gui/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,9 @@ static void OnUnGrabbedMouse (View view)

static void ProcessMouseEvent (MouseEvent me)
{
bool OutsideFrame (Point p, Rect r)
bool OutsideBounds (Point p, Rect r)
{
return p.X < 0 || p.X > r.Width - 1 || p.Y < 0 || p.Y > r.Height - 1;
return p.X < 0 || p.X > r.Right || p.Y < 0 || p.Y > r.Bottom;
}

if (IsMouseDisabled) {
Expand Down Expand Up @@ -1243,7 +1243,7 @@ bool OutsideFrame (Point p, Rect r)
OfY = me.Y - newxy.Y,
View = view
};
if (OutsideFrame (new Point (nme.X, nme.Y), _mouseGrabView.Frame)) {
if (OutsideBounds (new Point (nme.X, nme.Y), _mouseGrabView.Bounds)) {
_lastMouseOwnerView?.OnMouseLeave (me);
}
//System.Diagnostics.Debug.WriteLine ($"{nme.Flags};{nme.X};{nme.Y};{mouseGrabView}");
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/View/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public override bool Enabled {
}
}
}

/// <summary>
/// Event fired when the <see cref="Visible"/> value is being changed.
/// </summary>
Expand Down Expand Up @@ -481,7 +481,7 @@ bool CanBeVisible (View view)

return true;
}

/// <summary>
/// Pretty prints the View
/// </summary>
Expand Down
19 changes: 5 additions & 14 deletions Terminal.Gui/Views/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public sealed class ContextMenu : IDisposable {
public ContextMenu () : this (0, 0, new MenuBarItem ()) { }

/// <summary>
/// Initializes a context menu, with a <see cref="View"/> specifiying the parent/hose of the menu.
/// Initializes a context menu, with a <see cref="View"/> specifying the parent/host of the menu.
/// </summary>
/// <param name="host">The host view.</param>
/// <param name="menuItems">The menu items for the context menu.</param>
Expand Down Expand Up @@ -79,7 +79,6 @@ public void Dispose ()
}
if (container != null) {
container.Closing -= Container_Closing;
container.TerminalResized -= Container_Resized;
}
}

Expand All @@ -91,13 +90,12 @@ public void Show ()
if (menuBar != null) {
Hide ();
}
container = Application.Top;
container = Application.Current;
container.Closing += Container_Closing;
container.TerminalResized += Container_Resized;
var frame = container.Frame;
var frame = new Rect (0, 0, View.Driver.Cols, View.Driver.Rows);
var position = Position;
if (Host != null) {
Host.ViewToScreen (container.Frame.X, container.Frame.Y, out int x, out int y);
Host.ViewToScreen (frame.X, frame.Y, out int x, out int y);
var pos = new Point (x, y);
pos.Y += Host.Frame.Height - 1;
if (position != pos) {
Expand All @@ -119,7 +117,7 @@ public void Show ()
if (Host == null) {
position.Y = frame.Bottom - rect.Height - 1;
} else {
Host.ViewToScreen (container.Frame.X, container.Frame.Y, out int x, out int y);
Host.ViewToScreen (frame.X, frame.Y, out int x, out int y);
var pos = new Point (x, y);
position.Y = pos.Y - rect.Height - 1;
}
Expand All @@ -145,13 +143,6 @@ public void Show ()
menuBar.OpenMenu ();
}

private void Container_Resized (object sender, SizeChangedEventArgs e)
{
if (IsShow) {
Show ();
}
}

private void Container_Closing (object sender, ToplevelClosingEventArgs obj)
{
Hide ();
Expand Down
Loading