mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[followup] IDEA-162563 Action menus do not have icons under HiDPI linux
- New interface: JBUI.JBIcon. EmptyIcon now implements it. - New method: JBUI.scale(JBIcon)
This commit is contained in:
@@ -42,7 +42,7 @@ import static com.intellij.patterns.StandardPatterns.or;
|
||||
* @author vnikolaenko
|
||||
*/
|
||||
public final class RegExpCompletionContributor extends CompletionContributor {
|
||||
private static final Icon emptyIcon = new EmptyIcon(PlatformIcons.PROPERTY_ICON.getIconWidth(), PlatformIcons.PROPERTY_ICON.getIconHeight());
|
||||
private static final Icon emptyIcon = EmptyIcon.create(PlatformIcons.PROPERTY_ICON);
|
||||
|
||||
public RegExpCompletionContributor() {
|
||||
{
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
import com.intellij.xdebugger.impl.frame.XValueMarkers;
|
||||
@@ -282,7 +283,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
|
||||
}
|
||||
catch (EvaluateException ignored) {
|
||||
}
|
||||
return EmptyIcon.create(6);//AllIcons.Debugger.StackFrame;
|
||||
return JBUI.scale(EmptyIcon.create(6));//AllIcons.Debugger.StackFrame;
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.tree.ValueDescriptor;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -47,7 +48,7 @@ class ColorObjectRenderer extends CompoundReferenceRenderer {
|
||||
if (rgbValue instanceof IntegerValue) {
|
||||
@SuppressWarnings("UseJBColor")
|
||||
final Color color = new Color(((IntegerValue)rgbValue).value(), true);
|
||||
return new ColorIcon(16, 12, color, true);
|
||||
return JBUI.scale(new ColorIcon(16, 12, color, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -52,7 +53,7 @@ import java.util.List;
|
||||
*/
|
||||
public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.create(1, 16);
|
||||
private static final Icon EMPTY_ICON = JBUI.scale(EmptyIcon.create(1, 16));
|
||||
|
||||
@Nullable
|
||||
private final Condition<Sdk> myFilter;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.navigation.Place;
|
||||
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -64,7 +65,7 @@ public class SidePanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public Icon getIconFor(final SidePanelItem value) {
|
||||
return EmptyIcon.create(16, 20);
|
||||
return JBUI.scale(EmptyIcon.create(16, 20));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class ImportStaticLookupActionProvider implements LookupActionProvider {
|
||||
}
|
||||
|
||||
final Icon checkIcon = PlatformIcons.CHECK_ICON;
|
||||
final Icon icon = item.willBeImported() ? checkIcon : new EmptyIcon(checkIcon.getIconWidth(), checkIcon.getIconHeight());
|
||||
final Icon icon = item.willBeImported() ? checkIcon : EmptyIcon.create(checkIcon);
|
||||
consumer.consume(new LookupElementAction(icon, "Import statically") {
|
||||
@Override
|
||||
public Result performLookupAction() {
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -153,7 +154,7 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
|
||||
myHelper.renderElement(presentation, qualify, true, getSubstitutor());
|
||||
}
|
||||
if (myColor != null) {
|
||||
presentation.setTypeText("", new ColorIcon(12, myColor));
|
||||
presentation.setTypeText("", JBUI.scale(new ColorIcon(12, myColor)));
|
||||
} else {
|
||||
presentation.setTypeText(getType().getPresentableText());
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ public class VisibilityIcons {
|
||||
setVisibilityIcon(PsiUtil.ACCESS_LEVEL_PACKAGE_LOCAL, baseIcon);
|
||||
}
|
||||
else {
|
||||
Icon emptyIcon = new EmptyIcon(PlatformIcons.PUBLIC_ICON.getIconWidth(), PlatformIcons.PUBLIC_ICON.getIconHeight());
|
||||
Icon emptyIcon = EmptyIcon.create(PlatformIcons.PUBLIC_ICON);
|
||||
baseIcon.setIcon(emptyIcon, 1);
|
||||
}
|
||||
}
|
||||
else if (PlatformIcons.PUBLIC_ICON != null) {
|
||||
Icon emptyIcon = new EmptyIcon(PlatformIcons.PUBLIC_ICON.getIconWidth(), PlatformIcons.PUBLIC_ICON.getIconHeight());
|
||||
Icon emptyIcon = EmptyIcon.create(PlatformIcons.PUBLIC_ICON);
|
||||
baseIcon.setIcon(emptyIcon, 1);
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class VisibilityIcons {
|
||||
break;
|
||||
default:
|
||||
if (PlatformIcons.PUBLIC_ICON != null) {
|
||||
icon = new EmptyIcon(PlatformIcons.PUBLIC_ICON.getIconWidth(), PlatformIcons.PUBLIC_ICON.getIconHeight());
|
||||
icon = EmptyIcon.create(PlatformIcons.PUBLIC_ICON);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import javax.swing.*;
|
||||
* @author peter
|
||||
*/
|
||||
public class PsiTypeCanonicalLookupElement extends LookupElement {
|
||||
private static final Icon EMPTY_ICON = new EmptyIcon(PlatformIcons.CLASS_ICON.getIconWidth() * 2, PlatformIcons.CLASS_ICON.getIconHeight());
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.create(PlatformIcons.CLASS_ICON.getIconWidth() * 2, PlatformIcons.CLASS_ICON.getIconHeight());
|
||||
|
||||
private final PsiType myType;
|
||||
private final String myPresentableText;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class IconUtil {
|
||||
if (baseIcon == null) {
|
||||
return EmptyIcon.ICON_16;
|
||||
}
|
||||
return new EmptyIcon(baseIcon.getIconWidth(), baseIcon.getIconHeight());
|
||||
return EmptyIcon.create(baseIcon);
|
||||
}
|
||||
|
||||
private static class FileIconProviderHolder {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -38,7 +39,7 @@ public enum DirDiffOperation {
|
||||
case DELETE: return AllIcons.Vcs.Remove;
|
||||
case NONE:
|
||||
}
|
||||
return EmptyIcon.create(16);
|
||||
return JBUI.scale(EmptyIcon.create(16));
|
||||
}
|
||||
|
||||
public Color getTextColor() {
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ import java.util.List;
|
||||
public class IntentionHintComponent implements Disposable, ScrollAwareHint {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.IntentionHintComponent.ListPopupRunnable");
|
||||
|
||||
private static final Icon ourInactiveArrowIcon = new EmptyIcon(AllIcons.General.ArrowDown.getIconWidth(), AllIcons.General.ArrowDown.getIconHeight());
|
||||
private static final Icon ourInactiveArrowIcon = EmptyIcon.create(AllIcons.General.ArrowDown);
|
||||
|
||||
private static final int NORMAL_BORDER_SIZE = 6;
|
||||
private static final int SMALL_BORDER_SIZE = 4;
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer<LookupItem>
|
||||
return EmptyIcon.ICON_0;
|
||||
}
|
||||
|
||||
return new EmptyIcon(SAMPLE_ICON.getIconWidth() * 2, SAMPLE_ICON.getIconHeight());
|
||||
return EmptyIcon.create(SAMPLE_ICON.getIconWidth() * 2, SAMPLE_ICON.getIconHeight());
|
||||
}
|
||||
|
||||
if (o instanceof Iconable && !(o instanceof PsiElement)) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class LookupActionsStep extends BaseListPopupStep<LookupElementAction> im
|
||||
h = Math.max(h, icon.getIconHeight());
|
||||
}
|
||||
}
|
||||
myEmptyIcon = new EmptyIcon(w, h);
|
||||
myEmptyIcon = EmptyIcon.create(w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ import java.util.Set;
|
||||
public class LookupCellRenderer implements ListCellRenderer {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.lookup.impl.LookupCellRenderer");
|
||||
//TODO[kb]: move all these awesome constants to Editor's Fonts & Colors settings
|
||||
private Icon myEmptyIcon = EmptyIcon.create(5);
|
||||
private Icon myEmptyIcon = JBUI.scale(EmptyIcon.create(5));
|
||||
private final Font myNormalFont;
|
||||
private final Font myBoldFont;
|
||||
private final FontMetrics myNormalMetrics;
|
||||
@@ -478,7 +478,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
int updateMaximumWidth(final LookupElementPresentation p, LookupElement item) {
|
||||
final Icon icon = p.getIcon();
|
||||
if (icon != null && (icon.getIconWidth() > myEmptyIcon.getIconWidth() || icon.getIconHeight() > myEmptyIcon.getIconHeight())) {
|
||||
myEmptyIcon = new EmptyIcon(Math.max(icon.getIconWidth(), myEmptyIcon.getIconWidth()), Math.max(icon.getIconHeight(), myEmptyIcon.getIconHeight()));
|
||||
myEmptyIcon = EmptyIcon.create(Math.max(icon.getIconWidth(), myEmptyIcon.getIconWidth()), Math.max(icon.getIconHeight(), myEmptyIcon.getIconHeight()));
|
||||
}
|
||||
|
||||
return RealLookupElementPresentation.calculateWidth(p, getRealFontMetrics(item, false), getRealFontMetrics(item, true)) +
|
||||
|
||||
+3
-2
@@ -38,6 +38,7 @@ import com.intellij.ui.SizedIcon;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -49,8 +50,8 @@ import java.util.Map;
|
||||
|
||||
public class RunConfigurationsComboBoxAction extends ComboBoxAction implements DumbAware {
|
||||
|
||||
public static final Icon CHECKED_ICON = new SizedIcon(AllIcons.Actions.Checked, 16, 16);
|
||||
public static final Icon CHECKED_SELECTED_ICON = new SizedIcon(AllIcons.Actions.Checked_selected, 16, 16);
|
||||
public static final Icon CHECKED_ICON = JBUI.scale(new SizedIcon(AllIcons.Actions.Checked, 16, 16));
|
||||
public static final Icon CHECKED_SELECTED_ICON = JBUI.scale(new SizedIcon(AllIcons.Actions.Checked_selected, 16, 16));
|
||||
public static final Icon EMPTY_ICON = EmptyIcon.ICON_16;
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.CommonActionsPanel;
|
||||
import com.intellij.ui.RowIcon;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -197,7 +198,7 @@ public class BookmarksFavoriteListProvider extends AbstractFavoritesListProvider
|
||||
if (renderer.getIcon() != null) {
|
||||
RowIcon icon = new RowIcon(3, RowIcon.Alignment.CENTER);
|
||||
icon.setIcon(bookmark.getIcon(), 0);
|
||||
icon.setIcon(EmptyIcon.create(1), 1);
|
||||
icon.setIcon(JBUI.scale(EmptyIcon.create(1)), 1);
|
||||
icon.setIcon(renderer.getIcon(), 2);
|
||||
renderer.setIcon(icon);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -51,7 +52,7 @@ public class NavBarItem extends SimpleColoredComponent implements Disposable {
|
||||
NavBarPresentation presentation = myPanel.getPresentation();
|
||||
myText = presentation.getPresentableText(object);
|
||||
Icon icon = presentation.getIcon(object);
|
||||
myIcon = icon != null ? icon : EmptyIcon.create(5);
|
||||
myIcon = icon != null ? icon : JBUI.scale(EmptyIcon.create(5));
|
||||
myAttributes = presentation.getTextAttributes(object, false);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -463,7 +463,7 @@ public abstract class ChooseByNameBase {
|
||||
toolbarComponent.setBorder(null);
|
||||
|
||||
if (myToolArea == null) {
|
||||
myToolArea = new JLabel(EmptyIcon.create(1, 24));
|
||||
myToolArea = new JLabel(JBUI.scale(EmptyIcon.create(1, 24)));
|
||||
}
|
||||
hBox.add(myToolArea);
|
||||
hBox.add(toolbarComponent);
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
@@ -156,8 +157,8 @@ public class ScopeEditorPanel {
|
||||
cancelCurrentProgress();
|
||||
}
|
||||
});
|
||||
myPartiallyIncluded.setIcon(new ColorIcon(10, MyTreeCellRenderer.PARTIAL_INCLUDED));
|
||||
myRecursivelyIncluded.setIcon(new ColorIcon(10, MyTreeCellRenderer.WHOLE_INCLUDED));
|
||||
myPartiallyIncluded.setIcon(JBUI.scale(new ColorIcon(10, MyTreeCellRenderer.PARTIAL_INCLUDED)));
|
||||
myRecursivelyIncluded.setIcon(JBUI.scale(new ColorIcon(10, MyTreeCellRenderer.WHOLE_INCLUDED)));
|
||||
}
|
||||
|
||||
private void updateCaretPositionText() {
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PackageDependenciesNode extends DefaultMutableTreeNode implements Navigatable{
|
||||
private static final EmptyIcon EMPTY_ICON = new EmptyIcon(0, IconUtil.getEmptyIcon(false).getIconHeight());
|
||||
private static final EmptyIcon EMPTY_ICON = EmptyIcon.create(0, IconUtil.getEmptyIcon(false).getIconHeight());
|
||||
|
||||
private Set<VirtualFile> myRegisteredFiles = null;
|
||||
private boolean myHasUnmarked = false;
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -190,7 +191,7 @@ public abstract class AdvancedSettingsAction extends DumbAwareAction {
|
||||
icon = UIManager.getIcon("CheckBox.icon");
|
||||
}
|
||||
if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
|
||||
icon = EmptyIcon.create(20, 18);
|
||||
icon = JBUI.scale(EmptyIcon.create(20, 18));
|
||||
}
|
||||
if (icon != null) {
|
||||
final Rectangle r1 = new Rectangle(checkBox.getWidth(), checkBox.getHeight());
|
||||
|
||||
+2
-1
@@ -40,6 +40,7 @@ import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,7 +62,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
|
||||
|
||||
public static final HighlightSeverity MIXED_FAKE_SEVERITY = new HighlightSeverity("Mixed", -1);
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public static final HighlightDisplayLevel MIXED_FAKE_LEVEL = new HighlightDisplayLevel(MIXED_FAKE_SEVERITY, EmptyIcon.create(12));
|
||||
public static final HighlightDisplayLevel MIXED_FAKE_LEVEL = new HighlightDisplayLevel(MIXED_FAKE_SEVERITY, JBUI.scale(EmptyIcon.create(12)));
|
||||
|
||||
private final static int SCOPE_ENABLED_COLUMN = 0;
|
||||
private final static int SCOPE_NAME_COLUMN = 1;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.FunctionUtil;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.TwoColorsIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -68,7 +69,7 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider {
|
||||
public MyInfo(@NotNull final PsiElement element, final Color color, final ElementColorProvider colorProvider) {
|
||||
super(element,
|
||||
element.getTextRange(),
|
||||
new ColorIcon(12, color),
|
||||
JBUI.scale(new ColorIcon(12, color)),
|
||||
Pass.LINE_MARKERS,
|
||||
FunctionUtil.<Object, String>nullConstant(),
|
||||
new GutterIconNavigationHandler<PsiElement>() {
|
||||
@@ -102,7 +103,7 @@ public final class ColorLineMarkerProvider implements LineMarkerProvider {
|
||||
@Override
|
||||
public Icon getCommonIcon(@NotNull List<MergeableLineMarkerInfo> infos) {
|
||||
if (infos.size() == 2 && infos.get(0) instanceof MyInfo && infos.get(1) instanceof MyInfo) {
|
||||
return new TwoColorsIcon(12, ((MyInfo)infos.get(0)).myColor, ((MyInfo)infos.get(1)).myColor);
|
||||
return JBUI.scale(new TwoColorsIcon(12, ((MyInfo)infos.get(0)).myColor, ((MyInfo)infos.get(1)).myColor));
|
||||
}
|
||||
return AllIcons.Gutter.Colors;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -54,7 +55,7 @@ public class DeferredIconImpl<T> implements DeferredIcon, RetrievableIcon, Scala
|
||||
private Function<T, Icon> myEvaluator;
|
||||
private volatile boolean myIsScheduled;
|
||||
private T myParam;
|
||||
private static final Icon EMPTY_ICON = JBUI.emptyIcon(16);
|
||||
private static final Icon EMPTY_ICON = JBUI.scale(EmptyIcon.create(16));
|
||||
private final boolean myNeedReadAction;
|
||||
private boolean myDone;
|
||||
private final boolean myAutoUpdatable;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -311,7 +312,7 @@ public abstract class FileColorSettingsTable extends JBTable {
|
||||
@Override
|
||||
Icon getIcon(FileColorConfiguration configuration) {
|
||||
Color color = myManager.getColor(configuration.getColorName());
|
||||
return color == null ? EmptyIcon.ICON_16 : new ColorIcon(16, 13, color, true);
|
||||
return color == null ? EmptyIcon.ICON_16 : JBUI.scale(new ColorIcon(16, 13, color, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.BidirectionalMap;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -113,7 +114,7 @@ public class CheckBoxList<T> extends JBList {
|
||||
}
|
||||
if (icon == null) {
|
||||
// com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI.getDefaultIcon()
|
||||
icon = JBUI.emptyIcon(20);
|
||||
icon = JBUI.scale(EmptyIcon.create(20));
|
||||
}
|
||||
Insets margin = checkBox.getMargin();
|
||||
return new Dimension(margin.left + icon.getIconWidth(), margin.top + icon.getIconHeight());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.WideSelectionTreeUI;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -30,7 +31,7 @@ import java.awt.*;
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent implements TreeCellRenderer{
|
||||
private static final Icon LOADING_NODE_ICON = new EmptyIcon(8, 16);
|
||||
private static final Icon LOADING_NODE_ICON = JBUI.scale(EmptyIcon.create(8, 16));
|
||||
|
||||
/**
|
||||
* Defines whether the tree is selected or not
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.ScalableIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -23,7 +24,7 @@ import java.awt.*;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class SizedIcon implements Icon, ScalableIcon {
|
||||
public class SizedIcon extends JBUI.JBAbstractIcon implements Icon, ScalableIcon {
|
||||
private final int myWidth;
|
||||
private final int myHeight;
|
||||
private final Icon myDelegate;
|
||||
@@ -36,37 +37,39 @@ public class SizedIcon implements Icon, ScalableIcon {
|
||||
myHeight = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
x = scale(x);
|
||||
y = scale(y);
|
||||
int dx = scale(myWidth) - scale(myDelegate.getIconWidth());
|
||||
int dy = scale(myHeight) - scale(myDelegate.getIconHeight());
|
||||
int dx = scaleVal(myWidth) - delegate().getIconWidth();
|
||||
int dy = scaleVal(myHeight) - delegate().getIconHeight();
|
||||
if (dx > 0 || dy > 0) {
|
||||
myDelegate.paintIcon(c, g, x + dx/2, y + dy/2);
|
||||
delegate().paintIcon(c, g, x + dx/2, y + dy/2);
|
||||
}
|
||||
else {
|
||||
myDelegate.paintIcon(c, g, x, y);
|
||||
delegate().paintIcon(c, g, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private int scale(int n) {
|
||||
return myScale == 1f ? n : (int) (n * myScale);
|
||||
public Icon delegate() {
|
||||
return myScaledDelegate != null ? myScaledDelegate : myDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scaleVal(int n) {
|
||||
return super.scaleVal(myScale == 1f ? n : (int) (n * myScale));
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
if (myDelegate instanceof ScalableIcon) {
|
||||
return myDelegate.getIconWidth();
|
||||
if (delegate() instanceof ScalableIcon) {
|
||||
return delegate().getIconWidth();
|
||||
}
|
||||
|
||||
return myWidth;
|
||||
return scaleVal(myWidth);
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
if (myDelegate instanceof ScalableIcon) {
|
||||
return myDelegate.getIconHeight();
|
||||
if (delegate() instanceof ScalableIcon) {
|
||||
return delegate().getIconHeight();
|
||||
}
|
||||
|
||||
return myHeight;
|
||||
return scaleVal(myHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +79,7 @@ public class SizedIcon implements Icon, ScalableIcon {
|
||||
} else if (myDelegate instanceof ScalableIcon) {
|
||||
myScaledDelegate = ((ScalableIcon)myDelegate).scale(scaleFactor);
|
||||
}
|
||||
myScale = scaleFactor;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,7 +34,7 @@ import java.awt.event.InputEvent;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ActionLink extends LinkLabel implements DataProvider {
|
||||
private static final EmptyIcon ICON = new EmptyIcon(0, 12);
|
||||
private static final EmptyIcon ICON = JBUI.scale(EmptyIcon.create(0, 12));
|
||||
private final AnAction myAction;
|
||||
private String myPlace = ActionPlaces.UNKNOWN;
|
||||
private InputEvent myEvent;
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -224,6 +225,6 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
|
||||
|
||||
@Override
|
||||
public Icon getDefaultIcon() {
|
||||
return JBUI.emptyIcon(20).asUIResource();
|
||||
return JBUI.scale(EmptyIcon.create(20)).asUIResource();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBGradientPaint;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -171,6 +172,6 @@ public class DarculaRadioButtonUI extends MetalRadioButtonUI {
|
||||
|
||||
@Override
|
||||
public Icon getDefaultIcon() {
|
||||
return JBUI.emptyIcon(20).asUIResource();
|
||||
return JBUI.scale(EmptyIcon.create(20)).asUIResource();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
@@ -25,7 +26,7 @@ import java.awt.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MacIntelliJCheckBoxUI extends IntelliJCheckBoxUI {
|
||||
public static final Icon DEFAULT_ICON = EmptyIcon.create(20);
|
||||
public static final Icon DEFAULT_ICON = JBUI.scale(EmptyIcon.create(20));
|
||||
|
||||
public MacIntelliJCheckBoxUI(JCheckBox c) {
|
||||
c.setOpaque(false);
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaRadioButtonUI;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
@@ -26,7 +27,7 @@ import java.awt.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class MacIntelliJRadioButtonUI extends DarculaRadioButtonUI {
|
||||
private static final Icon DEFAULT_ICON = EmptyIcon.create(26);
|
||||
private static final Icon DEFAULT_ICON = JBUI.scale(EmptyIcon.create(26));
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
@@ -52,6 +53,6 @@ public class WinIntelliJCheckBoxUI extends IntelliJCheckBoxUI {
|
||||
|
||||
@Override
|
||||
public Icon getDefaultIcon() {
|
||||
return JBUI.emptyIcon(18).asUIResource();
|
||||
return JBUI.scale(EmptyIcon.create(18)).asUIResource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ public class UiDropperAction extends ToggleAction implements DumbAware {
|
||||
append(", double-buffered", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
componentNode.setText(toString());
|
||||
setIcon(new TwoColorsIcon(11, component.getForeground(), component.getBackground()));
|
||||
setIcon(JBUI.scale(new TwoColorsIcon(11, component.getForeground(), component.getBackground())));
|
||||
}
|
||||
|
||||
setForeground(foreground);
|
||||
@@ -765,7 +765,7 @@ public class UiDropperAction extends ToggleAction implements DumbAware {
|
||||
|
||||
if (value instanceof UIResource) sb.append(" UIResource");
|
||||
setText(sb.toString());
|
||||
setIcon(new ColorIcon(13, 11, value, true));
|
||||
setIcon(JBUI.scale(new ColorIcon(13, 11, value, true)));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
append(", double-buffered", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
componentNode.setText(toString());
|
||||
setIcon(new TwoColorsIcon(11, component.getForeground(), component.getBackground()));
|
||||
setIcon(JBUI.scale(new TwoColorsIcon(11, component.getForeground(), component.getBackground())));
|
||||
}
|
||||
|
||||
setForeground(foreground);
|
||||
@@ -757,7 +757,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
|
||||
if (value instanceof UIResource) sb.append(" UIResource");
|
||||
setText(sb.toString());
|
||||
setIcon(new ColorIcon(13, 11, value, true));
|
||||
setIcon(JBUI.scale(new ColorIcon(13, 11, value, true)));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ import com.intellij.ui.plaf.beg.BegMenuItemUI;
|
||||
import com.intellij.ui.plaf.gtk.GtkMenuItemUI;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -53,7 +54,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
private static final Icon ourCheckedIcon = new SizedIcon(PlatformIcons.CHECK_ICON, 18, 18);
|
||||
private static final Icon ourCheckedIcon = JBUI.scale(new SizedIcon(PlatformIcons.CHECK_ICON, 18, 18));
|
||||
private static final Icon ourUncheckedIcon = EmptyIcon.ICON_18;
|
||||
|
||||
private final ActionRef<AnAction> myAction;
|
||||
|
||||
@@ -98,7 +98,7 @@ public class EditorWindow {
|
||||
return 9;
|
||||
}
|
||||
} : AllIcons.General.Modified;
|
||||
private static final Icon GAP_ICON = new EmptyIcon(MODIFIED_ICON.getIconWidth(), MODIFIED_ICON.getIconHeight());
|
||||
private static final Icon GAP_ICON = EmptyIcon.create(MODIFIED_ICON);
|
||||
|
||||
private boolean myIsDisposed = false;
|
||||
public static final Key<Integer> INITIAL_INDEX_KEY = Key.create("initial editor index");
|
||||
@@ -676,7 +676,7 @@ public class EditorWindow {
|
||||
|
||||
final VirtualFile file = editor.getFile();
|
||||
final Icon template = AllIcons.FileTypes.Text;
|
||||
myTabbedPane.insertTab(file, new EmptyIcon(template.getIconWidth(), template.getIconHeight()), new TComp(this, editor), null, indexToInsert);
|
||||
myTabbedPane.insertTab(file, EmptyIcon.create(template.getIconWidth(), template.getIconHeight()), new TComp(this, editor), null, indexToInsert);
|
||||
trimToSize(UISettings.getInstance().EDITOR_TAB_LIMIT, file, false);
|
||||
if (selectEditor) {
|
||||
setSelectedEditor(editor, focusEditor);
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ public class PresentationModeProgressPanel {
|
||||
Font font = JBUI.Fonts.label(11);
|
||||
myText.setFont(font);
|
||||
myText2.setFont(font);
|
||||
myText.setIcon(EmptyIcon.create(1, 16));
|
||||
myText2.setIcon(EmptyIcon.create(1, 16));
|
||||
myText.setIcon(JBUI.scale(EmptyIcon.create(1, 16)));
|
||||
myText2.setIcon(JBUI.scale(EmptyIcon.create(1, 16)));
|
||||
myUpdateQueue = new MergingUpdateQueue("Presentation Mode Progress", 100, true, null);
|
||||
myUpdate = new Update("Update UI") {
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -56,6 +56,7 @@ import com.intellij.ui.popup.list.GroupedItemsListRenderer;
|
||||
import com.intellij.util.ParameterizedRunnable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.MouseEventAdapter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -398,7 +399,7 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame, Disposable, Ac
|
||||
}
|
||||
Icon icon = presentation.getIcon();
|
||||
if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) {
|
||||
icon = JBUI.emptyIcon(16);
|
||||
icon = JBUI.scale(EmptyIcon.create(16));
|
||||
}
|
||||
action = wrapGroups(action);
|
||||
ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action));
|
||||
|
||||
@@ -984,7 +984,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
public void buildGroup(@NotNull ActionGroup actionGroup) {
|
||||
calcMaxIconSize(actionGroup);
|
||||
myEmptyIcon = myMaxIconHeight != -1 && myMaxIconWidth != -1 ? new EmptyIcon(myMaxIconWidth, myMaxIconHeight) : null;
|
||||
myEmptyIcon = myMaxIconHeight != -1 && myMaxIconWidth != -1 ? EmptyIcon.create(myMaxIconWidth, myMaxIconHeight) : null;
|
||||
|
||||
appendActionsFromGroup(actionGroup);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.awt.*;
|
||||
public class ColorIcon extends EmptyIcon {
|
||||
private final Color myColor;
|
||||
private boolean myBorder;
|
||||
private int myColorSize;
|
||||
protected int myColorSize;
|
||||
|
||||
public ColorIcon(int size, int colorSize, @NotNull Color color, final boolean border) {
|
||||
super(size, size);
|
||||
@@ -66,13 +66,13 @@ public class ColorIcon extends EmptyIcon {
|
||||
}
|
||||
|
||||
protected int getColorSize() {
|
||||
return scale(myColorSize);
|
||||
return scaleVal(myColorSize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected EmptyIcon createScaledInstance(float scale) {
|
||||
return new ColorIcon(getIconWidth(), myColorSize, myColor, myBorder);
|
||||
return new ColorIcon(width, myColorSize, myColor, myBorder).withJBUIScale(getJBUIScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.ScalableIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -28,42 +29,48 @@ import java.util.Map;
|
||||
/**
|
||||
* @author max
|
||||
* @author Konstantin Bulenkov
|
||||
* @author tav
|
||||
*
|
||||
* @see ColorIcon
|
||||
*/
|
||||
public class EmptyIcon implements Icon, ScalableIcon {
|
||||
private static final Map<Integer, EmptyIcon> cache = new HashMap<Integer, EmptyIcon>();
|
||||
public class EmptyIcon extends JBUI.JBAbstractIcon implements Icon, ScalableIcon {
|
||||
private static final Map<Pair<Integer, Float>, EmptyIcon> cache =
|
||||
new HashMap<Pair<Integer, Float>, EmptyIcon>(); // (size, jbuiScale) -> (icon)
|
||||
|
||||
public static final Icon ICON_16 = create(16);
|
||||
public static final Icon ICON_18 = create(18);
|
||||
public static final Icon ICON_8 = create(8);
|
||||
public static final Icon ICON_0 = create(0);
|
||||
public static final Icon ICON_16 = JBUI.scale(create(16));
|
||||
public static final Icon ICON_18 = JBUI.scale(create(18));
|
||||
public static final Icon ICON_8 = JBUI.scale(create(8));
|
||||
public static final Icon ICON_0 = JBUI.scale(create(0));
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
protected final int width;
|
||||
protected final int height;
|
||||
protected float scale = 1f;
|
||||
private EmptyIcon myScaledCache;
|
||||
protected boolean myUseCache;
|
||||
|
||||
public static Icon create(int size) {
|
||||
return create(size, size, true);
|
||||
/**
|
||||
* Creates an icon of the provided size.
|
||||
*
|
||||
* Use {@link JBUI#scale(EmptyIcon)} to meet HiDPI.
|
||||
*/
|
||||
public static EmptyIcon create(int size) {
|
||||
return create(size, size);
|
||||
}
|
||||
|
||||
private static Icon create(int width, int height, boolean autoScale) {
|
||||
int size = (width == height) ? width : -1;
|
||||
EmptyIcon icon = cache.get(size);
|
||||
if (icon == null) {
|
||||
icon = new EmptyIcon(width, height);
|
||||
if (size < JBUI.scale(129) && size > 0) cache.put(size, icon);
|
||||
}
|
||||
return autoScale ? icon.scale(JBUI.scale(1f)) : icon;
|
||||
/**
|
||||
* Creates an icon of the provided size.
|
||||
*
|
||||
* Use {@link JBUI#scale(EmptyIcon)} to meet HiDPI.
|
||||
*/
|
||||
public static EmptyIcon create(int width, int height) {
|
||||
return create(width, height, 1f, false);
|
||||
}
|
||||
|
||||
public static Icon create(int width, int height) {
|
||||
return create(width, height, true);
|
||||
}
|
||||
|
||||
public static Icon create(@NotNull Icon base) {
|
||||
return create(base.getIconWidth(), base.getIconHeight(), false);
|
||||
/**
|
||||
* Creates an icon of the size of the provided icon base.
|
||||
*/
|
||||
public static EmptyIcon create(@NotNull Icon base) {
|
||||
return create(base.getIconWidth(), base.getIconHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,9 +80,17 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
this(size, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@linkplain #create(int, int)} for caching.
|
||||
*/
|
||||
public EmptyIcon(int width, int height) {
|
||||
this(width, height, false);
|
||||
}
|
||||
|
||||
private EmptyIcon(int width, int height, boolean useCache) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.myUseCache = useCache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,14 +100,39 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
this(base.getIconWidth(), base.getIconHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmptyIcon withJBUIScale(float jbuiScale) {
|
||||
if (myUseCache && getJBUIScale() != jbuiScale) {
|
||||
Pair<Integer, Float> key = key(width, height, getJBUIScale());
|
||||
if (key != null) cache.remove(key); // rather useless to keep it in cache
|
||||
return create(width, height, jbuiScale, false);
|
||||
}
|
||||
return (EmptyIcon)super.withJBUIScale(jbuiScale);
|
||||
}
|
||||
|
||||
private static EmptyIcon create(int width, int height, float jbuiScale, boolean asUIResource) {
|
||||
Pair<Integer, Float> key = key(width, height, jbuiScale);
|
||||
EmptyIcon icon = (key != null) ? cache.get(key) : null;
|
||||
if (icon == null) {
|
||||
icon = asUIResource ? new EmptyIconUIResource(width, height, true) : new EmptyIcon(width, height, true);
|
||||
icon.setJBUIScale(jbuiScale);
|
||||
if (key != null) cache.put(key, icon);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
private static Pair<Integer, Float> key(int width, int height, float jbuiScale) {
|
||||
return (width == height && width < 129) ? Pair.create(width, jbuiScale) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return scale(width);
|
||||
return scaleVal(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return scale(height);
|
||||
return scaleVal(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,6 +148,7 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
if (height != icon.height) return false;
|
||||
if (width != icon.width) return false;
|
||||
if (scale != icon.scale) return false;
|
||||
if (getJBUIScale() != icon.getJBUIScale()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -117,6 +158,7 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
int result = width;
|
||||
result = 31 * result + height;
|
||||
result = 31 * result + (scale != +0.0f ? Float.floatToIntBits(scale) : 0);
|
||||
result = 31 * result + (getJBUIScale() != +0.0f ? Float.floatToIntBits(getJBUIScale()) : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -124,8 +166,9 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
return new EmptyIconUIResource(this);
|
||||
}
|
||||
|
||||
protected int scale(int n) {
|
||||
return scale == 1f ? n : (int) (n * scale);
|
||||
@Override
|
||||
public int scaleVal(int n) {
|
||||
return super.scaleVal(scale == 1f ? n : (int) (n * scale));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,22 +187,17 @@ public class EmptyIcon implements Icon, ScalableIcon {
|
||||
}
|
||||
|
||||
protected EmptyIcon createScaledInstance(float scale) {
|
||||
final EmptyIcon icon;
|
||||
if (scale != 1f) {
|
||||
icon = this;
|
||||
} else {
|
||||
icon = this instanceof UIResource ? new EmptyIconUIResource(width, height) : new EmptyIcon(width, height);
|
||||
}
|
||||
return icon;
|
||||
return (scale != 1f) ? this : create(width, height, getJBUIScale(), this instanceof UIResource);
|
||||
}
|
||||
|
||||
public static class EmptyIconUIResource extends EmptyIcon implements UIResource {
|
||||
public EmptyIconUIResource(EmptyIcon icon) {
|
||||
super(icon.width, icon.height);
|
||||
setJBUIScale(icon.getJBUIScale());
|
||||
}
|
||||
|
||||
private EmptyIconUIResource(int width, int height) {
|
||||
super(width, height);
|
||||
private EmptyIconUIResource(int width, int height, boolean useCache) {
|
||||
super(width, height, useCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,8 +157,15 @@ public class JBUI {
|
||||
return insets(0, 0, 0, r);
|
||||
}
|
||||
|
||||
public static EmptyIcon emptyIcon(int i) {
|
||||
return (EmptyIcon)EmptyIcon.create(scale(i));
|
||||
/**
|
||||
* @deprecated use JBUI.scale(EmptyIcon.create(size)) instead
|
||||
*/
|
||||
public static EmptyIcon emptyIcon(int size) {
|
||||
return scale(EmptyIcon.create(size));
|
||||
}
|
||||
|
||||
public static <T extends JBIcon> T scale(T icon) {
|
||||
return (T)icon.withJBUIScale(scale(1f));
|
||||
}
|
||||
|
||||
public static JBDimension emptySize() {
|
||||
@@ -276,4 +283,37 @@ public class JBUI {
|
||||
return new ComboBoxCompositeEditor(components);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplies an Icon with JBUI scale factor to meet HiDPI.
|
||||
*/
|
||||
public interface JBIcon extends Icon {
|
||||
float getJBUIScale();
|
||||
JBIcon withJBUIScale(float jbuiScale);
|
||||
int scaleVal(int value);
|
||||
}
|
||||
|
||||
public static abstract class JBAbstractIcon implements JBIcon {
|
||||
private float jbuiScale = 1f;
|
||||
|
||||
@Override
|
||||
public float getJBUIScale() {
|
||||
return jbuiScale;
|
||||
}
|
||||
|
||||
protected void setJBUIScale(float jbuiScale) {
|
||||
this.jbuiScale = jbuiScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIcon withJBUIScale(float jbuiScale) {
|
||||
setJBUIScale(jbuiScale);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scaleVal(int value) {
|
||||
return (int)(value * jbuiScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ThreeStateCheckBox extends JCheckBox {
|
||||
icon = UIManager.getIcon("CheckBox.icon");
|
||||
}
|
||||
if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
|
||||
icon = EmptyIcon.create(JBUI.scale(20), JBUI.scale(18));
|
||||
icon = JBUI.scale(EmptyIcon.create(20, 18));
|
||||
}
|
||||
if (icon != null) {
|
||||
final Insets i = getInsets();
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TwoColorsIcon extends ColorIcon {
|
||||
|
||||
@Override
|
||||
protected EmptyIcon createScaledInstance(float scale) {
|
||||
return new TwoColorsIcon(getColorSize(), getIconColor(), mySecondColor);
|
||||
return new TwoColorsIcon(myColorSize, getIconColor(), mySecondColor).withJBUIScale(getJBUIScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.textCompletion.DefaultTextCompletionValueDescriptor;
|
||||
import com.intellij.util.textCompletion.ValuesCompletionProvider;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.VcsLogRefs;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
@@ -230,7 +231,7 @@ public class GoToHashOrRefPopup {
|
||||
if (myColorManager.isMultipleRoots()) {
|
||||
lookupBuilder = lookupBuilder
|
||||
.withTypeText(getTypeText(item),
|
||||
new ColorIcon(15, VcsLogGraphTable.getRootBackgroundColor(item.getRoot(), myColorManager)),
|
||||
JBUI.scale(new ColorIcon(15, VcsLogGraphTable.getRootBackgroundColor(item.getRoot(), myColorManager))),
|
||||
true);
|
||||
}
|
||||
return lookupBuilder;
|
||||
|
||||
+11
-4
@@ -264,8 +264,8 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogFileFilte
|
||||
private SelectVisibleRootAction(@NotNull VirtualFile root) {
|
||||
super(root.getName(), root.getPresentableUrl(), null);
|
||||
myRoot = root;
|
||||
myIcon = new CheckboxColorIcon(JBUI.scale(CHECKBOX_ICON_SIZE), VcsLogGraphTable.getRootBackgroundColor(myRoot, myColorManager));
|
||||
getTemplatePresentation().setIcon(EmptyIcon.create(JBUI.scale(CHECKBOX_ICON_SIZE))); // see PopupFactoryImpl.calcMaxIconSize
|
||||
myIcon = JBUI.scale(new CheckboxColorIcon(CHECKBOX_ICON_SIZE, VcsLogGraphTable.getRootBackgroundColor(myRoot, myColorManager)));
|
||||
getTemplatePresentation().setIcon(JBUI.scale(EmptyIcon.create(CHECKBOX_ICON_SIZE))); // see PopupFactoryImpl.calcMaxIconSize
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,6 +329,13 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogFileFilte
|
||||
mySelected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckboxColorIcon withJBUIScale(float jbuiScale) {
|
||||
super.setJBUIScale(jbuiScale);
|
||||
mySizedIcon = JBUI.scale(mySizedIcon);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component component, Graphics g, int i, int j) {
|
||||
super.paintIcon(component, g, i, j);
|
||||
@@ -383,8 +390,8 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogFileFilte
|
||||
private SelectFromHistoryAction(@NotNull VcsLogStructureFilter filter) {
|
||||
super(getStructureActionText(filter), getTooltipTextForFilePaths(filter.getFiles()).replace("\n", " "), null);
|
||||
myFilter = filter;
|
||||
myIcon = new SizedIcon(PlatformIcons.CHECK_ICON_SMALL, CHECKBOX_ICON_SIZE, CHECKBOX_ICON_SIZE);
|
||||
myEmptyIcon = EmptyIcon.create(CHECKBOX_ICON_SIZE);
|
||||
myIcon = JBUI.scale(new SizedIcon(PlatformIcons.CHECK_ICON_SMALL, CHECKBOX_ICON_SIZE, CHECKBOX_ICON_SIZE));
|
||||
myEmptyIcon = JBUI.scale(EmptyIcon.create(CHECKBOX_ICON_SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.psi.xml.*;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.xml.util.ColorMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
|
||||
@@ -131,7 +132,7 @@ public class JavaFxAnnotator implements Annotator {
|
||||
}
|
||||
}
|
||||
if (color != null) {
|
||||
final ColorIcon icon = new ColorIcon(8, color);
|
||||
final ColorIcon icon = JBUI.scale(new ColorIcon(8, color));
|
||||
final Annotation annotation = holder.createInfoAnnotation(element, null);
|
||||
annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
|
||||
}
|
||||
|
||||
+1
-2
@@ -319,8 +319,7 @@ public abstract class AbstractQuickFixManager {
|
||||
BorderFactory
|
||||
.createCompoundBorder(BorderFactory.createLineBorder(Color.orange, 2), BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
|
||||
private static final Icon INACTIVE_ARROW_ICON = new EmptyIcon(
|
||||
AllIcons.General.ArrowDown.getIconWidth(), AllIcons.General.ArrowDown.getIconHeight());
|
||||
private static final Icon INACTIVE_ARROW_ICON = EmptyIcon.create(AllIcons.General.ArrowDown);
|
||||
|
||||
private class InspectionHint extends JLabel {
|
||||
private final RowIcon myInactiveIcon;
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -31,7 +32,7 @@ import java.awt.*;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class AbstractResourceRenderer<T> implements PropertyRenderer {
|
||||
protected final ColorIcon myColorIcon = new ColorIcon(10, 9);
|
||||
protected final ColorIcon myColorIcon = JBUI.scale(new ColorIcon(10, 9));
|
||||
protected final SimpleColoredComponent myColoredComponent = new SimpleColoredComponent() {
|
||||
@Override
|
||||
protected void doPaintIcon(@NotNull Graphics2D g, @NotNull Icon icon, int offset) {
|
||||
|
||||
+5
-5
@@ -58,22 +58,22 @@ public final class ColorIcon extends EmptyIcon {
|
||||
iconWidth + coloredComponent.getIpad().left + coloredComponent.getIconTextGap(), component.getHeight());
|
||||
}
|
||||
|
||||
int x = left + (iconWidth - myColorSize) / 2;
|
||||
int y = top + (iconHeight - myColorSize) / 2;
|
||||
int x = left + (iconWidth - scaleVal(myColorSize)) / 2;
|
||||
int y = top + (iconHeight - scaleVal(myColorSize)) / 2;
|
||||
|
||||
g.setColor(myColor);
|
||||
g.fillRect(x, y, myColorSize, myColorSize);
|
||||
g.fillRect(x, y, scaleVal(myColorSize), scaleVal(myColorSize));
|
||||
|
||||
if (myShowRedLine) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
Object hint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setColor(JBColor.red);
|
||||
g.drawLine(x, y + myColorSize, x + myColorSize, y);
|
||||
g.drawLine(x, y + scaleVal(myColorSize), x + scaleVal(myColorSize), y);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
|
||||
}
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(x, y, myColorSize, myColorSize);
|
||||
g.drawRect(x, y, scaleVal(myColorSize), scaleVal(myColorSize));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1010,7 +1010,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{
|
||||
myExpandIcon = UIUtil.isUnderDarcula() ? AllIcons.Mac.Tree_white_right_arrow : UIDesignerIcons.ExpandNode;
|
||||
myCollapseIcon = UIUtil.isUnderDarcula() ? AllIcons.Mac.Tree_white_down_arrow : UIDesignerIcons.CollapseNode;
|
||||
for (int i = 0; i < myIndentIcons.length; i++) {
|
||||
myIndentIcons[i] = new EmptyIcon(myExpandIcon.getIconWidth() + getPropertyIndentWidth() * i, myExpandIcon.getIconHeight());
|
||||
myIndentIcons[i] = EmptyIcon.create(myExpandIcon.getIconWidth() + getPropertyIndentWidth() * i, myExpandIcon.getIconHeight());
|
||||
}
|
||||
myIndentedExpandIcon = new IndentedIcon(myExpandIcon, getPropertyIndentWidth());
|
||||
myIndentedCollapseIcon = new IndentedIcon(myCollapseIcon, getPropertyIndentWidth());
|
||||
|
||||
Reference in New Issue
Block a user