Commit d00e5939 authored by Julia Beliaeva's avatar Julia Beliaeva Committed by intellij-monorepo-bot
Browse files

[git-index] make line markers wider on hover in the new ui

GitOrigin-RevId: d4b7abe3fdcc3f422a480d339b97b684d842f592
parent 2d7e8b47
Showing with 42 additions and 12 deletions
+42 -12
......@@ -124,7 +124,7 @@ public final class LineStatusMarkerDrawUtil {
int end = change.y2;
Color gutterColor = getGutterColor(change.type, editor);
int line = gutter.getHoveredFreeMarkersLine();
if (line != -1 && editor.xyToLogicalPosition(new Point(x, start)).line <= line && line < editor.xyToLogicalPosition(new Point(x, end)).line) {
if (isRangeHovered(editor, line, x, start, end)) {
paintRect(g, gutterColor, null, x - 1, start, endX + 2, end);
} else {
paintRect(g, gutterColor, null, x, start, endX, end);
......@@ -162,6 +162,12 @@ public final class LineStatusMarkerDrawUtil {
}
}
public static boolean isRangeHovered(@NotNull Editor editor, int line, int x, int start, int end) {
return line != -1 &&
editor.xyToLogicalPosition(new Point(x, start)).line <= line &&
line < editor.xyToLogicalPosition(new Point(x, end)).line;
}
public static void paintRange(@NotNull Graphics g,
@NotNull Editor editor,
@NotNull Range range,
......
......@@ -23,6 +23,7 @@ import com.intellij.openapi.diff.DiffBundle
import com.intellij.openapi.diff.LineStatusMarkerDrawUtil
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.editor.impl.EditorImpl
import com.intellij.openapi.editor.markup.MarkupEditorFilter
import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory
......@@ -361,16 +362,20 @@ class GitStageLineStatusTracker(
}
private fun paintStageLines(g: Graphics2D, editor: Editor, block: List<ChangedLines<StageLineFlags>>) {
val isNewUi = ExperimentalUI.isNewUI()
val borderColor = LineStatusMarkerDrawUtil.getGutterBorderColor(editor)
val area = LineStatusMarkerDrawUtil.getGutterArea(editor)
val x = area.first
val endX = area.second
val midX = if (ExperimentalUI.isNewUI()) (endX + x) / 2 else (endX + x + 3) / 2
val midX = if (isNewUi) (endX + x) / 2 else (endX + x + 3) / 2
val y = block.first().y1
val endY = block.last().y2
val hoveredLine = (editor as EditorEx).gutterComponentEx.hoveredFreeMarkersLine
for (change in block) {
if (change.y1 != change.y2 &&
change.flags.isUnstaged) {
......@@ -378,16 +383,11 @@ class GitStageLineStatusTracker(
val end = change.y2
val gutterColor = LineStatusMarkerDrawUtil.getGutterColor(change.type, editor)
if (change.flags.isStaged) {
if (ExperimentalUI.isNewUI()) {
g.paintHalfRoundedRect(gutterColor, x, start + 1, midX, end - 1, endX - x)
}
else {
LineStatusMarkerDrawUtil.paintRect(g, gutterColor, null, x, start, midX, end)
}
if (isNewUi && LineStatusMarkerDrawUtil.isRangeHovered(editor, hoveredLine, x, start, end)) {
g.paintUnStagedChange(change, gutterColor, x - 1, endX + 1, midX, start, end)
}
else {
LineStatusMarkerDrawUtil.paintRect(g, gutterColor, null, x, start, endX, end)
g.paintUnStagedChange(change, gutterColor, x, endX, midX, start, end)
}
}
}
......@@ -400,12 +400,20 @@ class GitStageLineStatusTracker(
val end = change.y2
val stagedBorderColor = LineStatusMarkerDrawUtil.getIgnoredGutterBorderColor(change.type, editor)
LineStatusMarkerDrawUtil.paintRect(g, null, stagedBorderColor, x, start, endX, end)
if (isNewUi && LineStatusMarkerDrawUtil.isRangeHovered(editor, hoveredLine, x, start, end)) {
LineStatusMarkerDrawUtil.paintRect(g, null, stagedBorderColor, x - 1, start, endX + 1, end)
} else {
LineStatusMarkerDrawUtil.paintRect(g, null, stagedBorderColor, x, start, endX, end)
}
}
}
}
else if (y != endY) {
LineStatusMarkerDrawUtil.paintRect(g, null, borderColor, x, y, endX, endY)
if (isNewUi && LineStatusMarkerDrawUtil.isRangeHovered(editor, hoveredLine, x, y, endY)) {
LineStatusMarkerDrawUtil.paintRect(g, null, borderColor, x - 1, y, endX + 1, endY)
} else {
LineStatusMarkerDrawUtil.paintRect(g, null, borderColor, x, y, endX, endY)
}
}
for (change in block) {
......@@ -427,6 +435,22 @@ class GitStageLineStatusTracker(
}
}
private fun Graphics2D.paintUnStagedChange(change: ChangedLines<StageLineFlags>, color: Color?,
x: Int, endX: Int, midX: Int,
start: Int, end: Int) {
if (change.flags.isStaged) {
if (ExperimentalUI.isNewUI()) {
paintHalfRoundedRect(color, x, start + 1, midX, end - 1, endX - x)
}
else {
LineStatusMarkerDrawUtil.paintRect(this, color, null, x, start, midX, end)
}
}
else {
LineStatusMarkerDrawUtil.paintRect(this, color, null, x, start, endX, end)
}
}
private fun Graphics2D.paintHalfRoundedRect(color: Color?, x1: Int, y1: Int, x2: Int, y2: Int, arc: Int) {
if (color == null) return
paintHalfRoundedRect(color, x1.toDouble(), y1.toDouble(), x2.toDouble(), y2.toDouble(), arc.toDouble())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment