mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-195082 Provide an option to invert icons in Project View on selection
This commit is contained in:
@@ -9,10 +9,13 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -22,6 +25,13 @@ import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class NodeRenderer extends ColoredTreeCellRenderer {
|
||||
protected Icon fixIconIfNeeded(Icon icon, boolean selected, boolean hasFocus) {
|
||||
if (!UIUtil.isUnderDarcula() && Registry.is("ide.project.view.change.icon.on.selection") && selected && hasFocus) {
|
||||
return IconLoader.getDarkIcon(icon, true);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
Object node = TreeUtil.getUserObject(value);
|
||||
@@ -30,7 +40,7 @@ public class NodeRenderer extends ColoredTreeCellRenderer {
|
||||
NodeDescriptor descriptor = (NodeDescriptor)node;
|
||||
// TODO: use this color somewhere
|
||||
Color color = descriptor.getColor();
|
||||
setIcon(descriptor.getIcon());
|
||||
setIcon(fixIconIfNeeded(descriptor.getIcon(), selected, hasFocus));
|
||||
}
|
||||
|
||||
ItemPresentation p0 = getPresentation(node);
|
||||
@@ -38,7 +48,7 @@ public class NodeRenderer extends ColoredTreeCellRenderer {
|
||||
if (p0 instanceof PresentationData) {
|
||||
PresentationData presentation = (PresentationData)p0;
|
||||
Color color = node instanceof NodeDescriptor ? ((NodeDescriptor)node).getColor() : null;
|
||||
setIcon(presentation.getIcon(false));
|
||||
setIcon(fixIconIfNeeded(presentation.getIcon(false), selected, hasFocus));
|
||||
|
||||
final List<PresentableNodeDescriptor.ColoredFragment> coloredText = presentation.getColoredText();
|
||||
Color forcedForeground = presentation.getForcedTextForeground();
|
||||
|
||||
@@ -1639,4 +1639,6 @@ show.new.plugin.page=true
|
||||
show.new.plugin.page.description=Show new plugin page configurable
|
||||
|
||||
ide.action.menu.item.pack.on.text.update=true
|
||||
ide.project.view.change.icon.on.selection=false
|
||||
ide.project.view.change.icon.on.selection.description=Use Darcula icons when tree element is focused and selected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user