From 1ec712358408e86b3b3aa99db15d268c9bbb573d Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 15 Oct 2024 14:48:29 +0800 Subject: [PATCH] ux: add `Background` property to avoid unclear display for selected state --- src/Views/CommitRefsPresenter.cs | 16 ++++++++++++++++ src/Views/Histories.axaml | 1 + 2 files changed, 17 insertions(+) diff --git a/src/Views/CommitRefsPresenter.cs b/src/Views/CommitRefsPresenter.cs index 852f63e8..c9969c36 100644 --- a/src/Views/CommitRefsPresenter.cs +++ b/src/Views/CommitRefsPresenter.cs @@ -37,6 +37,15 @@ namespace SourceGit.Views set => SetValue(FontSizeProperty, value); } + public static readonly StyledProperty BackgroundProperty = + AvaloniaProperty.Register(nameof(Background), null); + + public IBrush Background + { + get => GetValue(BackgroundProperty); + set => SetValue(BackgroundProperty, value); + } + public static readonly StyledProperty ForegroundProperty = AvaloniaProperty.Register(nameof(Foreground), Brushes.White); @@ -71,6 +80,9 @@ namespace SourceGit.Views FontSizeProperty, ForegroundProperty, TagBackgroundProperty); + + AffectsRender( + BackgroundProperty); } public override void Render(DrawingContext context) @@ -80,6 +92,7 @@ namespace SourceGit.Views var useGraphColor = UseGraphColor; var fg = Foreground; + var bg = Background; var x = 1.0; foreach (var item in _items) { @@ -98,6 +111,9 @@ namespace SourceGit.Views } else { + if (bg != null) + context.DrawRectangle(bg, null, entireRect); + var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0)); using (context.PushOpacity(.2)) context.DrawRectangle(item.Brush, null, labelRect); diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index bc86706b..8670190c 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -138,6 +138,7 @@ VerticalAlignment="Center"/>