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

Check box and radio button icon support #573

Closed
mgarin opened this issue Oct 23, 2019 · 4 comments
Closed

Check box and radio button icon support #573

mgarin opened this issue Oct 23, 2019 · 4 comments

Comments

@mgarin
Copy link
Owner

mgarin commented Oct 23, 2019

Right now checkbox and radio buttons (including menu items) can either display a check/radio icon or a custom icon, but not both at the same time. It would be nice to have them both.

To be more specific - changing component Icon should not remove or configure the check/radio icon anyhow, but instead add/remove a custom icon besides it.

For menu items this also means that other items in the same menu will have to be properly aligned to check/radio+custom icon width (or ignore it?).

@mgarin mgarin added this to the v1.2.11 milestone Oct 23, 2019
@mgarin mgarin self-assigned this Oct 23, 2019
@Sciss
Copy link
Contributor

Sciss commented Oct 23, 2019

For reference, here is a screenshot showing metal laf with user icon along checkbox (left) and web laf (right). tooltips are shown.
cbmi-with-icon-compare

@mgarin
Copy link
Owner Author

mgarin commented Oct 23, 2019

Yep. I re-checked other L&Fs today to see how they handle it in menus and it is mostly handled like in MetalLookAndFeel with a few exceptions.

I will most probably do it the same way it is done in MetalLookAndFeel - add check/radio icon in front and move icons of all other menu items forward to line up with check/radio menu item custom icons. The implementation is already in place, I'll just need to tune a few things in UI, content layout and painter.

@mgarin
Copy link
Owner Author

mgarin commented Oct 25, 2019

Ok, since I decided to fix this once and for all - I've made a different approach at rendering state icon for JCheckBoxMenuItem and JRadioButtonMenuItem to avoid JCheckBox and JRadioButton implementation affecting them anyhow.

First of all, here is the simple example state icons & custom icons:

image

Here is how it will align with other elements with state icons only:

image

And here are some normal menu items on top:

image

And here is a small niche case I've also added proper handling for:

image

This is basically the case when all state menu items do not have any custom icon while some other normal menu items are also present (with and without icons). This allows you not to have two ugly columns each of which is half-empty.

Menu will properly align even with differently-sized icons:

image

And even if you decide to go wild on the style:

image

And here is the dark example:

image

Alignments, paddings, layout and other settings can be adjusted for menu items in the style, although hopefully default layout and settings handle most cases. You can even disable aligning menu items:

image

I'll be pushing these changes shortly, just need to check everything last time.

mgarin added a commit that referenced this issue Oct 25, 2019
- AbstractStateMenuItemPainter.java - Modified for a different approach at handling state icon support
- AbstractStateButtonPainter.java, AbstractStateMenuItemPainter.java - Painter renamed from `checkStatePainter` to `stateIconPainter`
- MenuItemLayout.java, AbstractMenuItemLayout.java - Reworked to support new `state-icon` constraints
- MenuItemStateIcon.java, MenuItemStateIcon.xsd - Added for custom menu item state icon support
- AbstractMenuItemLayout.java, AbstractMenuItemLayout.xsd - Added `stateIconGap` option to allow configuring gap between state and custom icon
- StyleManager.java - Added `MenuItemStateIcon` annotation processing
- checkboxmenuitem.xml, radiobuttonmenuitem.xml - Added `MenuItemStateIcon` usage under `state-icon` constraints for painting separate state icon
- checkboxmenuitem.xml, radiobuttonmenuitem.xml - Adjusted light style to emphasize check/radio element better with smaller shadow
- checkbox.xml, radiobutton.xml, checkboxmenuitem.xml, radiobuttonmenuitem.xml - Adjusted according to painter changes
- tabbedpane.xml - Separated style from default menu items to avoid issues
@mgarin
Copy link
Owner Author

mgarin commented Oct 25, 2019

These changes are now available in master.
Snapshot build should also be available soon.

@mgarin mgarin closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants