IDEA-169924 add registry properties to tune a breadcrumbs component

This commit is contained in:
Sergey Malenkov
2017-04-14 02:56:00 +03:00
parent e4494e08f4
commit 6bd85a452c
3 changed files with 34 additions and 8 deletions
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.paint.EffectPainter;
import com.intellij.ui.paint.RectanglePainter;
@@ -192,14 +193,22 @@ public class Breadcrumbs extends JComponent {
protected void paint(Graphics2D g, int x, int y, int width, int height, Crumb crumb, int thickness) {
if (thickness > 0) {
Color foreground = getForeground(crumb);
Color foreground = getMarkerForeground(crumb);
if (foreground != null) {
g.setColor(ColorUtil.toAlpha(foreground, (int)(.6 * foreground.getAlpha())));
g.setColor(foreground);
g.fillRect(x, y + height - thickness, width, thickness);
}
}
}
protected Color getMarkerForeground(Crumb crumb) {
if (!Registry.is("editor.breadcrumbs.marker")) return null;
Color foreground = getForeground(crumb);
if (foreground == null) return null;
double alpha = Registry.doubleValue("editor.breadcrumbs.marker.alpha");
return ColorUtil.toAlpha(foreground, (int)(alpha * foreground.getAlpha()));
}
protected Font getFont(Crumb crumb) {
Font font = getFont();
if (font == null) return null;
@@ -935,8 +935,17 @@ editor.breadcrumbs.highlight.on.hover.description=Highlight corresponding ranges
editor.breadcrumbs.above=false
editor.breadcrumbs.above.description=Show breadcrumbs above or below an editor
editor.breadcrumbs.small=false
editor.breadcrumbs.small.description=Use small font to show breadcrumbs
editor.breadcrumbs.small.font=false
editor.breadcrumbs.small.font.description=Use small font to show breadcrumbs
editor.breadcrumbs.system.font=false
editor.breadcrumbs.system.font.description=Use system font to show breadcrumbs
editor.breadcrumbs.marker=true
editor.breadcrumbs.marker.description=Use a special line to mark a hovered or current breadcrumbs
editor.breadcrumbs.marker.alpha=0.6
editor.breadcrumbs.marker.alpha.description=A relative transparency of a marker line for breadcrumbs
testDiscovery.enabled=false
testDiscovery.enabled.description=Enable instrumentation during tests to be able to start 'tests which pass this code' later
@@ -18,9 +18,9 @@ package com.intellij.xml.breadcrumbs;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.RelativeFont;
import com.intellij.ui.components.breadcrumbs.Breadcrumbs;
import com.intellij.ui.components.breadcrumbs.Crumb;
import com.intellij.util.ui.UIUtil;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
@@ -45,9 +45,17 @@ final class PsiBreadcrumbs extends Breadcrumbs {
@Override
public void setFont(Font font) {
super.setFont(Registry.is("editor.breadcrumbs.small")
? RelativeFont.SMALL.derive(font)
: font);
if (font != null) {
float size = font.getSize2D();
if (Registry.is("editor.breadcrumbs.system.font")) {
Font system = UIUtil.getLabelFont();
if (system != null) font = system;
}
if (Registry.is("editor.breadcrumbs.small.font")) {
font = font.deriveFont(size / 1.09f);
}
}
super.setFont(font);
}
@Override