ux: use different inline code background for different themes

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-25 21:26:21 +08:00
parent 91acf0a32a
commit d2e688908c
No known key found for this signature in database
3 changed files with 18 additions and 1 deletions

View file

@ -47,6 +47,15 @@ namespace SourceGit.Views
get => GetValue(FontWeightProperty);
set => SetValue(FontWeightProperty, value);
}
public static readonly StyledProperty<IBrush> InlineCodeBackgroundProperty =
AvaloniaProperty.Register<CommitSubjectPresenter, IBrush>(nameof(InlineCodeBackground), Brushes.Transparent);
public IBrush InlineCodeBackground
{
get => GetValue(InlineCodeBackgroundProperty);
set => SetValue(InlineCodeBackgroundProperty, value);
}
public static readonly StyledProperty<IBrush> ForegroundProperty =
AvaloniaProperty.Register<CommitSubjectPresenter, IBrush>(nameof(Foreground), Brushes.White);
@ -106,7 +115,7 @@ namespace SourceGit.Views
{
var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2);
var roundedRect = new RoundedRect(rect, new CornerRadius(4));
context.DrawRectangle(new SolidColorBrush(new Color(52, 101, 108, 118)), null, roundedRect);
context.DrawRectangle(InlineCodeBackground, null, roundedRect);
context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5));
}
else
@ -182,6 +191,10 @@ namespace SourceGit.Views
_needRebuildInlines = true;
InvalidateVisual();
}
else if (change.Property == InlineCodeBackgroundProperty)
{
InvalidateVisual();
}
}
protected override void OnPointerMoved(PointerEventArgs e)