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

JMenu submenu offset above parent #42

Closed
smileatom opened this issue Jan 13, 2020 · 10 comments
Closed

JMenu submenu offset above parent #42

smileatom opened this issue Jan 13, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@smileatom
Copy link

smileatom commented Jan 13, 2020

Screen Shot 2020-01-13 at 7 15 46 PM
Is this offset of a submenu normal? This is in a JPopupMenu on macos.
Screen Shot 2020-01-13 at 8 11 06 AM

I was expecting the submenu to be top aligned with its parent but its a few pixels higher. If there were cascading submenus this would keep going higher and higher I would think. Can this offset be removed?

I see theres not much custom code in the L&F menu UI so I guess maybe theres nothing to be done here.

@smileatom
Copy link
Author

OK I think I see what the problem is,
Screen Shot 2020-01-14 at 12 18 50 AM

The top (and bottom) margins of the parent JMenu appear to be perhaps a little cut off and the submenu Y coordinate is likely displaying at the Y coordinate of the parent but the parents not drawing those pixels for some reason. I was going to report that on MacOS the bottom and top of Menus appears to be cutoff (not same height as the rest of items, so this seems to be a side effect of that.

@smileatom
Copy link
Author

Setting Insets for Menu fixes this offset in a popupmenu

def["PopupMenu.borderInsets"] = Insets(4,0,4,0)
Screen Shot 2020-01-14 at 8 37 31 PM

@smileatom
Copy link
Author

If thats acceptable and not an indicator of another border/inset issue with the default this can be closed.

@smileatom
Copy link
Author

smileatom commented Jan 15, 2020

Screen Shot 2020-01-14 at 8 40 00 PM
Actually if you look at the separator and border there appear to be artifacts exposed in the menu or unfinished border drawing.

def["PopupMenu.borderInsets"] = Insets(4,4,4,4)

If I set left and right insets equal to top and bottom the artifacts go away so I guess the border drawing expects there to be some left and right insets.

@DevCharly
Copy link
Collaborator

If I set left and right insets equal to top and bottom the artifacts go away so I guess the border drawing expects there to be some left and right insets

Yes, there should be at least 1px at each side.

Unfortunately changing PopupMenu.borderInsets affects all popup menus including JCompoBox.

Better use following as workaround until it is fixed in FlatLaf:

UIManager.put( "Menu.submenuPopupOffsetY", -1 ); 

BTW I see this issue only on macOS. On Windows it is fine.

Also is there a UI default to change the menu expansion icon?

You can either change the "arrow type" to "triangle" (see https://www.formdev.com/flatlaf/customizing/#arrow_type) or use the "Flat Darcula" or "Flat IntelliJ" themes.

@DevCharly DevCharly added the bug Something isn't working label Jan 15, 2020
@smileatom
Copy link
Author

In .25 I see with default borders the alignment is fixed. If I use a custom inset though its off from the submenu to parent. I dont know why but these menus do feel cramped at the top and bottom as if they are cut off on Mac OS by default. Anyway as a default with no custom insets the bug is fixed.

Screen Shot 2020-01-17 at 8 56 37 PM

Just wanted to pass along that if you do use custom insets from UI defaults it does push off the submenu alignment even though they have the same insets.

@DevCharly
Copy link
Collaborator

Yes, I also don't like the current look, but had not the time to improve it for 0.25 because NetBeans 11.3 merge window closes tomorrow and I wanted 0.25 to be in NetBeans.

I'll improve this for 0.26 with 4-6px gap at top/bottom and 0-2px gap at left/right.

I also consider to give the popup menus a slightly different color so that it is easier to distinguish from the underlying window (currently the popup background color is the same as the window/dialog background color).

@DevCharly
Copy link
Collaborator

The improvement for the menus are now implemented in master branch.

image
image

See change log for list of changes:
https://github.com/JFormDesigner/FlatLaf/blob/master/CHANGELOG.md

Hope you like it 😄

@smileatom
Copy link
Author

Hey that looks good!

@DevCharly
Copy link
Collaborator

fixed in 0.26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants