mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-156617 Menu icons are blurry on Retina screen
GitOrigin-RevId: 296324e298c63fe6cadf638238c9888a465150f1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9bb54ae78c
commit
640b81d99c
@@ -14,10 +14,7 @@ import com.intellij.ui.scale.ScaleContextSupport;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FixedHashMap;
|
||||
import com.intellij.util.ui.ImageUtil;
|
||||
import com.intellij.util.ui.JBImageIcon;
|
||||
import com.intellij.util.ui.StartupUiUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -652,7 +649,12 @@ public final class IconLoader {
|
||||
|
||||
@Override
|
||||
public Icon getMenuBarIcon(boolean isDark) {
|
||||
Image img = loadFromUrl(ScaleContext.createIdentity(), isDark);
|
||||
boolean useMRI = MultiResolutionImageProvider.isMultiResolutionImageAvailable() && SystemInfo.isMac;
|
||||
ScaleContext ctx = useMRI ? ScaleContext.create() : ScaleContext.createIdentity();
|
||||
Image img = loadFromUrl(ctx, isDark);
|
||||
if (useMRI) {
|
||||
img = MultiResolutionImageProvider.convertFromJBImage(img);
|
||||
}
|
||||
if (img != null) {
|
||||
return new ImageIcon(img);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.util.JBHiDPIScaledImage;
|
||||
import com.intellij.util.MethodInvocator;
|
||||
import org.imgscalr.Scalr;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -154,7 +154,9 @@ public class MultiResolutionImageProvider {
|
||||
* default to the provided image's single resolution variant.
|
||||
*/
|
||||
@Nullable
|
||||
public static Image convertFromJBImage(Image jbImage) {
|
||||
public static Image convertFromJBImage(@Nullable Image jbImage) {
|
||||
if (jbImage == null) return null;
|
||||
|
||||
if (!checkSize(jbImage)) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
new IllegalArgumentException("the image has illegal size 0x0").printStackTrace();
|
||||
@@ -166,8 +168,10 @@ public class MultiResolutionImageProvider {
|
||||
* Returns an accessor to the provided {@code MultiResolutionImage}.
|
||||
* If the provided image is not {@code MultiResolutionImage} the resolution variants methods will default to the provided image.
|
||||
*/
|
||||
@NotNull
|
||||
public static Accessor getAccessor(@NotNull Image mrImage) {
|
||||
@Contract("null -> null; !null -> !null")
|
||||
public static Accessor getAccessor(@Nullable Image mrImage) {
|
||||
if (mrImage == null) return null;
|
||||
|
||||
if (!checkSize(mrImage)) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
new IllegalArgumentException("the image has illegal size 0x0").printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user