mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-131263 Visual issues with editor gutters
This commit is contained in:
+13
-26
@@ -76,7 +76,6 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
private static final int FREE_PAINTERS_AREA_WIDTH = 5;
|
||||
private static final int GAP_BETWEEN_ICONS = 3;
|
||||
private static final TooltipGroup GUTTER_TOOLTIP_GROUP = new TooltipGroup("GUTTER_TOOLTIP_GROUP", 0);
|
||||
private static final Color COLOR_F0F0 = new Color(0xF0F0F0);
|
||||
public static final TIntFunction ID = new TIntFunction() {
|
||||
@Override
|
||||
public int execute(int value) {
|
||||
@@ -96,7 +95,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
private TIntArrayList myTextAnnotationGutterSizes = new TIntArrayList();
|
||||
private ArrayList<TextAnnotationGutterProvider> myTextAnnotationGutters = new ArrayList<TextAnnotationGutterProvider>();
|
||||
private final Map<TextAnnotationGutterProvider, EditorGutterAction> myProviderToListener = new HashMap<TextAnnotationGutterProvider, EditorGutterAction>();
|
||||
private static final int GAP_BETWEEN_ANNOTATIONS = 6;
|
||||
private static final int GAP_BETWEEN_ANNOTATIONS = 5;
|
||||
private Color myBackgroundColor = null;
|
||||
private String myLastGutterToolTip = null;
|
||||
private int myLastPreferredHeight = -1;
|
||||
@@ -227,7 +226,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
|
||||
private void paintEditorBackgrounds(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) {
|
||||
Color defaultBackgroundColor = myEditor.getBackgroundColor();
|
||||
int startX = getWhitespaceSeparatorOffset() + 1;
|
||||
int startX = getWhitespaceSeparatorOffset() + (isFoldingOutlineShown() ? 1 : 0);
|
||||
IterationState state = new IterationState(myEditor, firstVisibleOffset, lastVisibleOffset, false, true);
|
||||
while (!state.atEnd()) {
|
||||
VisualPosition visualStart = myEditor.offsetToVisualPosition(state.getStartOffset());
|
||||
@@ -329,19 +328,12 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
|
||||
x += myTextAnnotationGutterSizes.get(i);
|
||||
}
|
||||
|
||||
if (!myEditor.isInDistractionFreeMode()) {
|
||||
UIUtil.drawVDottedLine((Graphics2D)g, getAnnotationsAreaOffset() + w - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
|
||||
}
|
||||
}
|
||||
|
||||
private void paintFoldingTree(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) {
|
||||
if (isFoldingOutlineShown()) {
|
||||
doPaintFoldingTree((Graphics2D)g, clip, firstVisibleOffset, lastVisibleOffset);
|
||||
}
|
||||
else {
|
||||
UIUtil.drawVDottedLine((Graphics2D)g, clip.x + clip.width - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
|
||||
}
|
||||
}
|
||||
|
||||
private void paintLineMarkers(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) {
|
||||
@@ -378,8 +370,6 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
|
||||
private void paintLineNumbers(Graphics g, Rectangle clip) {
|
||||
if (isLineNumbersShown()) {
|
||||
int x = getLineNumberAreaOffset() + getLineNumberAreaWidth() - 2;
|
||||
UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, null, getOutlineColor(false));
|
||||
doPaintLineNumbers(g, clip);
|
||||
}
|
||||
}
|
||||
@@ -396,7 +386,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
EditorColorsScheme colorsScheme = myEditor.getColorsScheme();
|
||||
boolean distractionMode = myEditor.isInDistractionFreeMode();
|
||||
Color color = distractionMode ? colorsScheme.getDefaultBackground() : colorsScheme.getColor(EditorColors.GUTTER_BACKGROUND);
|
||||
myBackgroundColor = color == null ? COLOR_F0F0 : color;
|
||||
myBackgroundColor = color == null ? EditorColors.GUTTER_BACKGROUND.getDefaultColor() : color;
|
||||
}
|
||||
return myBackgroundColor;
|
||||
}
|
||||
@@ -648,9 +638,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
}
|
||||
});
|
||||
|
||||
myLineMarkerAreaWidth = myIconsAreaWidth + FREE_PAINTERS_AREA_WIDTH +
|
||||
// if folding outline is shown, there will be enough place for change markers, otherwise add place for it.
|
||||
(isFoldingOutlineShown() ? 0 : getFoldingAnchorWidth() / 2);
|
||||
myLineMarkerAreaWidth = myIconsAreaWidth + FREE_PAINTERS_AREA_WIDTH;
|
||||
}
|
||||
|
||||
private void paintGutterRenderers(final Graphics g, int firstVisibleOffset, int lastVisibleOffset) {
|
||||
@@ -739,7 +727,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
|
||||
int height = endY - startY;
|
||||
int w = FREE_PAINTERS_AREA_WIDTH;
|
||||
int x = getLineMarkerAreaOffset() + myIconsAreaWidth;
|
||||
int x = getLineMarkerAreaOffset() + myIconsAreaWidth - 1;
|
||||
return new Rectangle(x, startY, w, height);
|
||||
}
|
||||
|
||||
@@ -770,7 +758,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
|
||||
final int leftSize = x - getLineMarkerAreaOffset();
|
||||
|
||||
x = getLineMarkerAreaOffset() + myIconsAreaWidth;
|
||||
x = getLineMarkerAreaOffset() + myIconsAreaWidth - 2; // because of 2px LineMarkerRenderers
|
||||
for (GutterMark r : row) {
|
||||
if (((GutterIconRenderer)r).getAlignment() == GutterIconRenderer.Alignment.RIGHT) {
|
||||
Icon icon = r.getIcon();
|
||||
@@ -780,7 +768,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
}
|
||||
}
|
||||
|
||||
int rightSize = myIconsAreaWidth + getLineMarkerAreaOffset() - x;
|
||||
int rightSize = myIconsAreaWidth + getLineMarkerAreaOffset() - x + 1;
|
||||
|
||||
if (middleCount > 0) {
|
||||
middleSize -= GAP_BETWEEN_ICONS;
|
||||
@@ -845,7 +833,9 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
private void paintFoldingLines(final Graphics2D g, final Rectangle clip) {
|
||||
if (!isFoldingOutlineShown()) return;
|
||||
|
||||
UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, null, getOutlineColor(false));
|
||||
g.setColor(getOutlineColor(false));
|
||||
int x = getWhitespaceSeparatorOffset();
|
||||
UIUtil.drawLine(g, x, clip.y, x, clip.y + clip.height);
|
||||
|
||||
final int anchorX = getFoldingAreaOffset();
|
||||
final int width = getFoldingAnchorWidth();
|
||||
@@ -981,14 +971,11 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
}
|
||||
|
||||
public int getFoldingAreaOffset() {
|
||||
return getLineMarkerAreaOffset() +
|
||||
getLineMarkerAreaWidth();
|
||||
return getLineMarkerAreaOffset() + getLineMarkerAreaWidth();
|
||||
}
|
||||
|
||||
public int getFoldingAreaWidth() {
|
||||
return isFoldingOutlineShown()
|
||||
? getFoldingAnchorWidth() + 2
|
||||
: 0;
|
||||
return getFoldingAnchorWidth() + (isFoldingOutlineShown() ? 2 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1347,7 +1334,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
closeAllAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
private final TIntFunction myLineNumberAreaWidthFunction = new TIntFunction() {
|
||||
@Override
|
||||
public int execute(int lineNumber) {
|
||||
return getFontMetrics(Font.PLAIN).stringWidth(Integer.toString(lineNumber + 1)) + 6;
|
||||
return getFontMetrics(Font.PLAIN).stringWidth(Integer.toString(lineNumber + 1)) + 5;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6771,10 +6771,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
int shortner = 0;
|
||||
if (myGutterComponent.isFoldingOutlineShown()) {
|
||||
shortner = myGutterComponent.getFoldingAreaWidth() / 2;
|
||||
}
|
||||
int shortner = myGutterComponent.getFoldingAreaWidth() / 2;
|
||||
|
||||
g.setColor(myGutterComponent.getBackground());
|
||||
g.fillRect(0, 0, width - shortner, height);
|
||||
|
||||
+2
-12
@@ -36,7 +36,6 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.FocusWatcher;
|
||||
import com.intellij.ui.PrevNextActionsDescriptor;
|
||||
import com.intellij.ui.SideBorder;
|
||||
import com.intellij.ui.TabbedPaneWrapper;
|
||||
import com.intellij.ui.tabs.UiDecorator;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -351,7 +350,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
if (remove) {
|
||||
container.remove(component.getParent());
|
||||
} else {
|
||||
container.add(new TopBottomComponentWrapper(component, top));
|
||||
container.add(new TopBottomComponentWrapper(component));
|
||||
}
|
||||
container.revalidate();
|
||||
}
|
||||
@@ -474,19 +473,10 @@ public abstract class EditorComposite implements Disposable {
|
||||
private static class TopBottomComponentWrapper extends JPanel {
|
||||
private final JComponent myWrappee;
|
||||
|
||||
public TopBottomComponentWrapper(JComponent component, boolean top) {
|
||||
public TopBottomComponentWrapper(JComponent component) {
|
||||
super(new BorderLayout());
|
||||
myWrappee = component;
|
||||
setOpaque(false);
|
||||
|
||||
setBorder(new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP, true) {
|
||||
@Override
|
||||
public Color getLineColor() {
|
||||
Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR);
|
||||
return result == null ? Color.black : result;
|
||||
}
|
||||
});
|
||||
|
||||
add(component);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
<option name="ANNOTATIONS_COLOR" value="000080" />
|
||||
<option name="ANNOTATIONS_MERGED_COLOR" value="008080" />
|
||||
<option name="CARET_COLOR" value="0"/>
|
||||
<option name="RIGHT_MARGIN_COLOR" value="c0c0c0"/>
|
||||
<option name="RIGHT_MARGIN_COLOR" value="E0E0E0"/>
|
||||
<option name="SOFT_WRAP_SIGN_COLOR" value="c0c0c0"/>
|
||||
<option name="TEARLINE_COLOR" value="808080"/>
|
||||
<option name="SELECTED_TEARLINE_COLOR" value="000000"/>
|
||||
<option name="TEARLINE_COLOR" value="D0D0D0"/>
|
||||
<option name="SELECTED_TEARLINE_COLOR" value="9C9C9C"/>
|
||||
<option name="READONLY_FRAGMENT_BACKGROUND" value="cfe7ff"/>
|
||||
|
||||
<option name="ADDED_LINES_COLOR" value="CBE3CA"/>
|
||||
|
||||
@@ -72,19 +72,18 @@ public class LineStatusTrackerDrawing {
|
||||
final EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
|
||||
Color stripeColor = getDiffGutterColor(range);
|
||||
|
||||
boolean foldingOutlineShown = ((EditorEx)editor).getGutterComponentEx().isFoldingOutlineShown();
|
||||
int triangle = 4;
|
||||
if (range.getInnerRanges() == null) { // actual painter
|
||||
g.setColor(stripeColor);
|
||||
|
||||
final int endX = gutter.getWhitespaceSeparatorOffset();
|
||||
final int x = r.x + r.width - 4;
|
||||
final int x = r.x + r.width - 3;
|
||||
final int width = endX - x;
|
||||
if (r.height > 0) {
|
||||
g.fillRect(x, r.y, width, r.height); // todo: intersection with dotted gutter outline
|
||||
g.fillRect(x, r.y, width, r.height);
|
||||
}
|
||||
else {
|
||||
final int[] xPoints = new int[]{x, x, endX - (foldingOutlineShown ? -1 : triangle + 1)};
|
||||
final int[] xPoints = new int[]{x, x, endX};
|
||||
final int[] yPoints = new int[]{r.y - triangle, r.y + triangle, r.y};
|
||||
g.fillPolygon(xPoints, yPoints, 3);
|
||||
}
|
||||
@@ -97,7 +96,7 @@ public class LineStatusTrackerDrawing {
|
||||
if (range.getType() == Range.DELETED) {
|
||||
final int y = lineToY(editor, range.getLine1());
|
||||
|
||||
final int[] xPoints = new int[]{x, x, endX - (foldingOutlineShown ? 0 : triangle + 1)};
|
||||
final int[] xPoints = new int[]{x, x, endX + 1};
|
||||
final int[] yPoints = new int[]{y - triangle, y + triangle, y};
|
||||
|
||||
g.setColor(stripeColor);
|
||||
@@ -215,7 +214,7 @@ public class LineStatusTrackerDrawing {
|
||||
toolbar.setBackground(background);
|
||||
|
||||
toolbar
|
||||
.setBorder(new ColoredSideBorder(foreground, foreground, (range.getType() != Range.INSERTED) ? null : foreground, foreground, 1));
|
||||
.setBorder(new ColoredSideBorder(foreground, foreground, range.getType() != Range.INSERTED ? null : foreground, foreground, 1));
|
||||
|
||||
final JPanel component = new JPanel(new BorderLayout());
|
||||
component.setOpaque(false);
|
||||
|
||||
Reference in New Issue
Block a user