mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-149457 Bookmark gutter icon does not scale
This commit is contained in:
@@ -21,10 +21,7 @@ import com.intellij.ide.presentation.VirtualFilePresentation;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VFileProperty;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.WritingAccessProvider;
|
||||
@@ -439,6 +436,22 @@ public class IconUtil {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a scaled icon instance.
|
||||
*
|
||||
* @param icon the icon to scale
|
||||
* @param scale the scale factor
|
||||
* @param smartScale whether to scale via {@link ScalableIcon#scale(float)} when applicable
|
||||
* @return the scaled icon
|
||||
*/
|
||||
@NotNull
|
||||
public static Icon scale(@NotNull Icon icon, float scale, boolean smartScale) {
|
||||
if (smartScale && icon instanceof ScalableIcon) {
|
||||
return ((ScalableIcon)icon).scale(scale);
|
||||
}
|
||||
return scale(icon, scale);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Icon colorize(@NotNull Icon source, @NotNull Color color) {
|
||||
return colorize(source, color, false);
|
||||
|
||||
@@ -53,8 +53,10 @@ import com.intellij.reference.SoftReference;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.RetrievableIcon;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -400,26 +402,32 @@ public class Bookmark implements Navigatable, Comparable<Bookmark> {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyCheckedIcon implements Icon, RetrievableIcon {
|
||||
private static class MyCheckedIcon extends JBUI.CachingScalableJBIcon implements RetrievableIcon {
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon retrieveIcon() {
|
||||
return PlatformIcons.CHECK_ICON;
|
||||
return IconUtil.scale(PlatformIcons.CHECK_ICON, getScale(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
(darkBackground() ? AllIcons.Actions.CheckedGrey : AllIcons.Actions.CheckedBlack).paintIcon(c, g, x, y);
|
||||
IconUtil.scale((darkBackground() ? AllIcons.Actions.CheckedGrey : AllIcons.Actions.CheckedBlack), getScale(), true).paintIcon(c, g, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return PlatformIcons.CHECK_ICON.getIconWidth();
|
||||
return scaleVal(PlatformIcons.CHECK_ICON.getIconWidth(), Scale.ARBITRARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return PlatformIcons.CHECK_ICON.getIconHeight();
|
||||
return scaleVal(PlatformIcons.CHECK_ICON.getIconHeight(), Scale.ARBITRARY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected MyCheckedIcon copy() {
|
||||
return new MyCheckedIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user