ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.71k stars 10.26k forks source link

Menu bar is off by one pixel from the top #6047

Open sherief opened 1 year ago

sherief commented 1 year ago

Version/Branch of Dear ImGui:

Version: v1.87 WIP Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: custom, Win32 + D3D12 Compiler: MSVC 2022 Operating System: Windows 10

My Issue/Question:

I have an app with a menu bar and I noticed that the menu bar starts at y-coordinate of 1, not zero, so it's one pixel away from the top of the window. Ideally, it'd extend all the way to the top so as to become an infinite-height target and easier to reach with the mouse via sliding the cursor all the way to the top of the window when in fullscreen mode.

Screenshots/Video

Screenshot 2023-01-04 212153 Screenshot 2023-01-04 212148

Standalone, minimal, complete and verifiable example: N/A

ocornut commented 1 year ago

Thank you for the issue report. I can confirm this.

It's not super trivial to change as that vertical alignment depends on: text-baseline, frame-padding, item-spacing, and our menu-bars are generic concepts where any items can be layed out. Both #597 and #3516 are hitting on the same family of problem.

sherief commented 1 year ago

Understandable. For now I have a WAR that adjusts Y==0 to Y = 1 when in fullscreen, and I don't have any issues with that.

sherief commented 1 year ago

BTW, it's also off by 3 pixels from the left. WAR-ed it the same way, but thought you should know. I didn't think that warrants filing a new bug but if that helps let me know and I'll file a separate one.

ocornut commented 1 year ago

It's the same issue for me, thank you! On one hand the padding issue in #597 and #3516 should be fixed, but either way the fix for them won't include e.g. border-size (often 1 pixel) so for this we need to separate the hit-testing from visual a little bit and main-menu-bar may be specific here.

A weird but functional workaround would be to extend style.TouchExtraPadding while submitting item in the main menu-bar, that will extend hit-testing range for those items. It will also leak to sub-menus but may be not noticeable.