refactor bold underline painting, remove code duplication, use Registry for line height

This commit is contained in:
Konstantin Bulenkov
2015-05-07 17:47:43 +02:00
parent db5866e800
commit 09c1ee8495
@@ -2332,8 +2332,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
UIUtil.drawLine(g, end.x, y1, end.x + charWidth - 1, y1);
}
else if (attributes.getEffectType() == EffectType.BOLD_LINE_UNDERSCORE) {
UIUtil.drawLine(g, end.x, y - 1, end.x + charWidth - 1, y - 1);
UIUtil.drawLine(g, end.x, y, end.x + charWidth - 1, y);
drawBoldLineUnderScore(g, end.x, y - 1, charWidth - 1);
}
else if (attributes.getEffectType() != EffectType.BOXED) {
UIUtil.drawLine(g, end.x, y, end.x + charWidth - 1, y);
@@ -2342,6 +2341,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
}
private static void drawBoldLineUnderScore(Graphics g, int x, int y, int width) {
int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
g.fillRect(x, y, width, height);
}
@Override
public int getMaxWidthInRange(int startOffset, int endOffset) {
if (myUseNewRendering) return myView.getMaxWidthInRange(startOffset, endOffset);
@@ -3423,8 +3427,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawLine(g, xStart, y, xEnd, y);
UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
drawBoldLineUnderScore(g, xStart, y, xEnd-xStart);
g.setColor(savedColor);
}
else if (effectType == EffectType.STRIKEOUT) {