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

MenuItem left padding #3

Closed
DevCharly opened this issue Oct 2, 2019 · 4 comments
Closed

MenuItem left padding #3

DevCharly opened this issue Oct 2, 2019 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@DevCharly
Copy link
Collaborator

Left padding of menu items is inconsistent:

image

@Blanco27
Copy link
Contributor

Blanco27 commented Apr 20, 2020

This only appears if you add a menu item with an icon and a checkBoxMenuItem in the same menu. The menu will always draw the checkIcon to the left of the default icons, so you have room for both checkIcon and a normal icon.
This can also be seen in the metal Look and Feel, because the same BasicMenuItemUI is used here.
K5yPdswgdl

There are two solutions for this. One of them is you use the logic of the Windows Look and Feel, it handles the case like this:
CheckBox with icon:
ao4Ub0UiwR

CheckBox without icon:
x3prRdhDGu

The other possibility is that the CheckBoxMenuItemUI behaves in the same way as the normal MenuItemUI, with the difference that when selected the CheckBoxMenuItemUI shows the CheckIcon as the normal icon and when deselected, it shows a null icon instead. With the second variant it is no longer possible to use the CheckBox and normal icon.

@DevCharly
Copy link
Collaborator Author

@MioBlanco thanks for pointing out the possibilities.

The idea is it to have a stable left padding that is always the same even if there are no icons and no check/radio items. The padding should be not too large (room for icon and checkbox) because this looks ugly.

The solution used in the Windows LaF would be optimal, but the second solution would be also good IMO.

DevCharly added a commit that referenced this issue Apr 26, 2020
- stable left margin (always space for one icon)
- right aligned accelerators
- larger gap between text and accelerator

current limitations:
- no HTML text support
- text not vertically aligned with other menu items if icons have different sizes
- vertical/horizontal alignment/textPosition properties are ignored

(issues #3 and #54)
DevCharly added a commit that referenced this issue Apr 27, 2020
@DevCharly
Copy link
Collaborator Author

I've implemented a new menu item renderer in branch menu-layout.

It uses currently the second variant described above by @MioBlanco
The first variant is under development...

DevCharly added a commit that referenced this issue Apr 28, 2020
…ustom icon, then use filled icon background to indicate selection (instead of using checkIcon) (issue #3)
@DevCharly DevCharly added this to the 0.34 milestone Apr 29, 2020
@DevCharly
Copy link
Collaborator Author

@MioBlanco first variant is now implemented in master branch

The accelerators are now right-aligned (as in Windows and macOS).
There is now a larger gap between the text and the accelerator.
The text and accelerator are no longer layouted in "columns", which makes menu width smaller.

image

Also a new menu selection style is now available:

image

Can be enabled with:

UIManager.put( "MenuItem.selectionType", "underline" );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants