From 79e37596812f7e3dba9a233d7b0b8d231c4f3687 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 10 Oct 2023 14:43:41 +0800 Subject: [PATCH] style: apply corner radius for avatar pictures --- src/Views/Controls/Avatar.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Views/Controls/Avatar.cs b/src/Views/Controls/Avatar.cs index c979cb3c..9b5cfe6b 100644 --- a/src/Views/Controls/Avatar.cs +++ b/src/Views/Controls/Avatar.cs @@ -103,10 +103,9 @@ namespace SourceGit.Views.Controls { /// /// protected override void OnRender(DrawingContext dc) { - base.OnRender(dc); + var corner = Math.Max(2, Width / 16); if (Source == null && label != null) { - var corner = Math.Max(2, Width / 16); var offsetX = (double)0; if (HorizontalAlignment == HorizontalAlignment.Right) { offsetX = -Width * 0.5; @@ -114,9 +113,12 @@ namespace SourceGit.Views.Controls { offsetX = Width * 0.5; } - Brush brush = BACKGROUND_BRUSHES[colorIdx]; + Brush brush = BACKGROUND_BRUSHES[colorIdx]; dc.DrawRoundedRectangle(brush, null, new Rect(-Width * 0.5 + offsetX, -Height * 0.5, Width, Height), corner, corner); dc.DrawText(label, new Point(label.Width * -0.5 + offsetX, label.Height * -0.5)); + } else { + dc.PushClip(new RectangleGeometry(new Rect(0, 0, Width, Height), corner, corner)); + base.OnRender(dc); } }