Skip to content

Commit

Permalink
fix #2369
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
vadosnaprimer committed Dec 1, 2024
1 parent 05f06ae commit adf7449
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,24 @@ private void TasView_MouseUp(object sender, MouseEventArgs e)
}
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

Check failure on line 827 in src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs

View workflow job for this annotation

GitHub Actions / Build solution with analyzers

.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)
Expand Down

0 comments on commit adf7449

Please sign in to comment.