Explorar el Código

Improved caret visibility

Krzysztof Krysiński hace 4 meses
padre
commit
b7e764474d

+ 5 - 2
src/PixiEditor/Views/Overlays/TextOverlay/Caret.cs

@@ -26,7 +26,7 @@ internal class Caret : IDisposable
     public VecF[] GlyphPositions { get; set; }
     public VecF[] GlyphPositions { get; set; }
     public VecD Offset { get; set; }
     public VecD Offset { get; set; }
     public float[] GlyphWidths { get; set; }
     public float[] GlyphWidths { get; set; }
-    public float CaretWidth { get; set; } = 1;
+    public float CaretWidth { get; set; } = 0.5f;
 
 
     private Paint paint = new Paint() { Color = Colors.White, Style = PaintStyle.StrokeAndFill, StrokeWidth = 3 };
     private Paint paint = new Paint() { Color = Colors.White, Style = PaintStyle.StrokeAndFill, StrokeWidth = 3 };
 
 
@@ -63,7 +63,10 @@ internal class Caret : IDisposable
 
 
         paint.Color = new Color(Colors.White.R, Colors.White.G, Colors.White.B, (byte)(visible ? 255 : 0));
         paint.Color = new Color(Colors.White.R, Colors.White.G, Colors.White.B, (byte)(visible ? 255 : 0));
 
 
-        canvas.DrawLine(from, to, paint);
+        VecD strokeOffset = new VecD(CaretWidth / 2, 0);
+        canvas.DrawLine(from - strokeOffset, to - strokeOffset, paint);
+        paint.Color = new Color(Colors.Black.R, Colors.Black.G, Colors.Black.B, (byte)(visible ? 255 : 0));
+        canvas.DrawLine(from + strokeOffset, to + strokeOffset, paint);
     }
     }
 
 
     public void Dispose()
     public void Dispose()

+ 1 - 1
src/PixiEditor/Views/Overlays/TextOverlay/TextOverlay.cs

@@ -237,7 +237,7 @@ internal class TextOverlay : Overlay
         caret.GlyphWidths = glyphWidths;
         caret.GlyphWidths = glyphWidths;
         caret.Offset = Position;
         caret.Offset = Position;
 
 
-        caret.CaretWidth = 3f / (float)ZoomScale;
+        caret.CaretWidth = 2f / (float)ZoomScale;
         caret.Render(context);
         caret.Render(context);
     }
     }