move tasview context menu to the other side of the cursor if it's not fitting into the screen fully. of course if there's not enough space there EITHER, the user must do something about it, meanwhile best we can do is clamp location to 0. not using MouseEventArgs because we need absolute on-screen coords

other tastudio menus are small so probably fine?
This commit is contained in:
feos 2024-12-01 23:10:18 +03:00
parent 05f06aeb5b
commit adf74495dc
1 changed files with 18 additions and 1 deletions
src/BizHawk.Client.EmuHawk/tools/TAStudio

View File

@ -819,7 +819,24 @@ namespace BizHawk.Client.EmuHawk
}
else
{
RightClickMenu.Show(TasView, e.X, e.Y);
var offset = new Point(0);
var topLeft = Cursor.Position;
var bottomRight = new Point(
topLeft.X + RightClickMenu.Width,
topLeft.Y + RightClickMenu.Height);
var screen = Screen.AllScreens
.Where(s => s.WorkingArea.Contains(topLeft))
.FirstOrDefault();
// if we don't fully fit, move to the other side of the pointer
if (bottomRight.X > screen.WorkingArea.Right)
offset.X -= RightClickMenu.Width;
if (bottomRight.Y > screen.WorkingArea.Bottom)
offset.Y -= RightClickMenu.Height;
topLeft.Offset(offset);
// if the screen is insultingly tiny, best we can do is avoid negative pos
RightClickMenu.Show(
Math.Max(0, topLeft.X),
Math.Max(0, topLeft.Y));
}
}
else if (e.Button == MouseButtons.Left)