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

Issue with the icon rendering in selected mode #465

Closed
nroduit opened this issue Jan 16, 2022 · 3 comments
Closed

Issue with the icon rendering in selected mode #465

nroduit opened this issue Jan 16, 2022 · 3 comments
Milestone

Comments

@nroduit
Copy link
Contributor

nroduit commented Jan 16, 2022

Following the Intellij principles for colors, there are sometimes situations for some themes where the rendering of an icon selection (JToggleButton) is not good (very low contrast).
In the example below with Monokai Pro (Material), we see the rendering of the selection of the Draw action:
image

To try to improve this, I use the method setSelectedIcon() and FlatSVGIcon.setColorFilter() to make the gray of the icons darker. However the setColorFilter() method applies to an icon but I haven't found a way to derive an existing FlatSVGIcon (like for getDisabledIcon() or scale) without having to completely reload the icon. Is this the right way to do it or am I missing something obvious?

@DevCharly
Copy link
Collaborator

There is no method to clone a FlatSVGIcon. Maybe should add one...

Anyway FlatSVGIcon has a cache that avoids loading SVG file if already loaded.
So creating two FlatSVGIcon with same name/URL loads the SVG file only once.

BTW the constructor of FlatSVGIcon is very lightweight because it does not load anything.
The SVG file is only loaded when needed (when invoking getIconWidth(), getIconHeight() or paintIcon()).

@nroduit
Copy link
Contributor Author

nroduit commented Jan 16, 2022

Thank you for the quick and clear answer.

In fact when icons are created in actions or others, it is difficult when retrieving icons of type FlatSVGIcon to be able to create on the fly a derived icon (for selection or rollover) because there is no method to get the URI.

Having a method FlatSVGIcon.derive(ColorFilter colorFilter ) would allow to benefit easily from all the possibilities related to the filters.

@DevCharly
Copy link
Collaborator

I've added a copy constructor to FlatSVGIcon.

See latest 2.0.1-SNAPSHOT https://github.com/JFormDesigner/FlatLaf#snapshots

Use:

FlatSVGIcon selIcon = new FlatSVGIcon( icon );
selIcon.setColorFilter( selColorFilter );

@DevCharly DevCharly added this to the 2.0.1 milestone Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants