mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[macosx] Improve system menu icons quality
Swing can't paint correctly our HiDPI icons at the system menu. It scales them down (from 2x to 1x) downgrading the quality. An ideal fix would be to add appropriate functionality to Swing. So far the fix is to pass Swing 1x icons.
This commit is contained in:
@@ -247,6 +247,17 @@ public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon(Icon icon) {
|
||||
if (SystemInfo.isMacSystemMenu && ActionPlaces.MAIN_MENU.equals(myPlace)) {
|
||||
if (icon instanceof IconLoader.LazyIcon) {
|
||||
// [tav] JDK can't paint correctly our HiDPI icons at the system menu bar
|
||||
icon = ((IconLoader.LazyIcon)icon).inNormalScale(false);
|
||||
}
|
||||
}
|
||||
super.setIcon(icon);
|
||||
}
|
||||
|
||||
public boolean isToggleable() {
|
||||
return myToggleable;
|
||||
}
|
||||
|
||||
@@ -573,6 +573,19 @@ public final class IconLoader {
|
||||
}
|
||||
|
||||
protected abstract Icon compute();
|
||||
|
||||
public Icon inNormalScale(boolean isRetina) {
|
||||
Icon icon = getOrComputeIcon();
|
||||
if (icon != null) {
|
||||
if (icon instanceof CachedImageIcon) {
|
||||
Image img = ((CachedImageIcon)icon).myScaledIconsCache.getOrigImage(isRetina);
|
||||
if (img != null) {
|
||||
icon = new ImageIcon(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
private static class LabelHolder {
|
||||
|
||||
Reference in New Issue
Block a user