Menus: slack triangle for submenu opening has better fit #6926
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When rolling over menus, sometimes their submenus wouldn't open correctly, particularly on the far right side of the menu item (or far left for menus opening to the left).
As reported in #6671:
Problem context
The code for handling that behavior implements a solution like this post, where it uses an imaginary triangle to define an area that the cursor can still roll into (outside of the menu item space even) before the current submenu closes and a different one opens.
However, it seems to be the current code is attempting to move the corners of this imaginary triangle unnecessarily, making it more likely it wouldn't detect the mouse had left a valid area when it did. This change was made in 86bad3c9e1 as fixes to #5614.
Fix
My changes remove those moves, making it follow the original triangle corners more correctly, while still keeping some of its limits in place. It seems to make it feel more responsive, without making it behave incorrectly.
Capture showing how rolling over the end of the menu works, while still respecting the "slack" area that goes over other menus (without opening them):
(I do the "slack" rollover very quickly on the above capture, but it works fine in normal speeds as well)
After my changes, I wasn't able to reproduce the problem shown in #5614 either, which makes me believe it's addressed by the rest of the code already.
This was tested on Windows, example_win32_directx9 example, VS Community 2022 (17.7.4), against current master (v1.90 WIP), using a high-dpi monitor. However, the code seems to make it self-contained enough, so I don't believe we'd have problems in other platforms, or in different DPI monitors. If anything, it removes a calculation that seemed to be missing DPI scaling. Therefore, I believe it's a low-risk change.
Fixes #6671.