From a717dc18762c61088dc3a8ed931da408627ae01b Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 23 Aug 2024 19:22:04 +0800 Subject: [PATCH] ux: add `Color.DecoratorHead` for current branch head (#395) --- src/Resources/Themes.axaml | 7 +++++-- src/Views/CommitBaseInfo.axaml | 1 + src/Views/CommitRefsPresenter.cs | 34 +++++++++++++++++++++----------- src/Views/Histories.axaml | 1 + 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index daad5eb6..f517b53e 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -16,7 +16,8 @@ #FF6F6F6F #FFF8F8F8 #FFFFB835 - #FF02C302 + #fb5607 + #669900 Black #FF836C2E #FFFFFFFF @@ -50,7 +51,8 @@ #FF505050 #FFF8F8F8 #FFFFB835 - #FF02C302 + #f4f1de + #669900 Black #FFFAFAD2 #FF252525 @@ -84,6 +86,7 @@ + diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index d6ec6eae..8c2bf3cf 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -98,6 +98,7 @@ > RefsProperty = @@ -80,6 +80,15 @@ namespace SourceGit.Views set => SetValue(BranchNameBackgroundProperty, value); } + public static readonly StyledProperty HeadBranchNameBackgroundProperty = + AvaloniaProperty.Register(nameof(HeadBranchNameBackground), Brushes.White); + + public IBrush HeadBranchNameBackground + { + get => GetValue(HeadBranchNameBackgroundProperty); + set => SetValue(HeadBranchNameBackgroundProperty, value); + } + public static readonly StyledProperty TagNameBackgroundProperty = AvaloniaProperty.Register(nameof(TagNameBackground), Brushes.White); @@ -111,8 +120,6 @@ namespace SourceGit.Views var iconFG = IconForeground; var iconBG = IconBackground; - var branchBG = BranchNameBackground; - var tagBG = TagNameBackground; var x = 0.0; foreach (var item in _items) @@ -121,7 +128,7 @@ namespace SourceGit.Views var labelRect = new RoundedRect(new Rect(x + 16, 0, item.Label.Width + 8, 16), new CornerRadius(0, 2, 2, 0)); context.DrawRectangle(iconBG, null, iconRect); - context.DrawRectangle(item.IsTag ? tagBG : branchBG, null, labelRect); + context.DrawRectangle(item.LabelBG, null, labelRect); context.DrawText(item.Label, new Point(x + 20, 8.0 - item.Label.Height * 0.5)); using (context.PushTransform(Matrix.CreateTranslation(x + 4, 4))) @@ -141,6 +148,9 @@ namespace SourceGit.Views var typeface = new Typeface(FontFamily); var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold); var labelFG = LabelForeground; + var branchBG = BranchNameBackground; + var headBG = HeadBranchNameBackground; + var tagBG = TagNameBackground; var labelSize = FontSize; var requiredWidth = 0.0; @@ -154,29 +164,31 @@ namespace SourceGit.Views CultureInfo.CurrentCulture, FlowDirection.LeftToRight, isHead ? typefaceBold : typeface, - isHead ? labelSize + 0.5 : labelSize, + labelSize, labelFG); - var item = new RenderItem() - { - Label = label, - IsTag = decorator.Type == Models.DecoratorType.Tag, - }; - + var item = new RenderItem() { Label = label }; StreamGeometry geo; switch (decorator.Type) { case Models.DecoratorType.CurrentBranchHead: + item.LabelBG = headBG; + geo = this.FindResource("Icons.Check") as StreamGeometry; + break; case Models.DecoratorType.CurrentCommitHead: + item.LabelBG = branchBG; geo = this.FindResource("Icons.Check") as StreamGeometry; break; case Models.DecoratorType.RemoteBranchHead: + item.LabelBG = branchBG; geo = this.FindResource("Icons.Remote") as StreamGeometry; break; case Models.DecoratorType.Tag: + item.LabelBG = tagBG; geo = this.FindResource("Icons.Tag") as StreamGeometry; break; default: + item.LabelBG = branchBG; geo = this.FindResource("Icons.Branch") as StreamGeometry; break; } diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index b89ab8c4..931e4951 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -70,6 +70,7 @@