diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index 67c1c7b60..9b5520f15 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -194,13 +194,34 @@ - - - + + + + + + + + + + + + + + + + diff --git a/src/Views/CommitBaseInfo.axaml.cs b/src/Views/CommitBaseInfo.axaml.cs index b617476d0..b8715ce28 100644 --- a/src/Views/CommitBaseInfo.axaml.cs +++ b/src/Views/CommitBaseInfo.axaml.cs @@ -87,6 +87,14 @@ protected override void OnUnloaded(RoutedEventArgs e) _iconResetTimer?.Dispose(); } + private async void OnCopyRefName(object sender, RoutedEventArgs e) + { + if (sender is Button { DataContext: Models.Decorator decorator }) + await this.CopyTextAsync(decorator.Name); + + e.Handled = true; + } + private async void OnCopyCommitSHA(object sender, RoutedEventArgs e) { if (sender is Button { DataContext: Models.Commit commit }) diff --git a/src/Views/CommitRefsPresenter.cs b/src/Views/CommitRefsPresenter.cs index ca8eabdd5..f403c9c0c 100644 --- a/src/Views/CommitRefsPresenter.cs +++ b/src/Views/CommitRefsPresenter.cs @@ -83,6 +83,15 @@ public bool ShowTags set => SetValue(ShowTagsProperty, value); } + public static readonly StyledProperty DecoratorProperty = + AvaloniaProperty.Register(nameof(Decorator)); + + public Models.Decorator Decorator + { + get => GetValue(DecoratorProperty); + set => SetValue(DecoratorProperty, value); + } + static CommitRefsPresenter() { AffectsMeasure( @@ -91,7 +100,8 @@ static CommitRefsPresenter() ForegroundProperty, UseGraphColorProperty, BackgroundProperty, - ShowTagsProperty); + ShowTagsProperty, + DecoratorProperty); } public Models.Decorator DecoratorAt(Point point) @@ -174,16 +184,21 @@ protected override Size MeasureOverride(Size availableSize) { _items.Clear(); - if (DataContext is not Models.Commit commit) + var commit = DataContext as Models.Commit; + IList refs; + if (Decorator != null) + refs = new[] { Decorator }; + else if (commit != null) + refs = commit.Decorators; + else return new Size(0, 0); - var refs = commit.Decorators; if (refs is { Count: > 0 }) { var typeface = new Typeface(FontFamily); var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold); var fg = Foreground; - var normalBG = UseGraphColor ? Models.CommitGraph.Pens[commit.Color].Brush : Brushes.Gray; + var normalBG = UseGraphColor && commit != null ? Models.CommitGraph.Pens[commit.Color].Brush : Brushes.Gray; var labelSize = FontSize; var requiredHeight = 16.0; var x = 0.0;