diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index cf56f42a..f3c72a36 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -25,6 +25,11 @@ #FF1F1F1F #FF6F6F6F #FFFFFFFF + #3C000000 + #3C00FF00 + #3CFF0000 + #5A00FF00 + #50FF0000 @@ -51,6 +56,11 @@ #FFDDDDDD #40F1F1F1 #FF252525 + #FF424242 + #FF38573C + #FF633F3E + #FF388442 + #FF9F4247 @@ -79,4 +89,9 @@ + + + + + diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml index b4758f06..f435b2e2 100644 --- a/src/Views/TextDiffView.axaml +++ b/src/Views/TextDiffView.axaml @@ -13,6 +13,11 @@ KnownLayer.Background; public LineBackgroundRenderer(CombinedTextDiffPresenter editor) @@ -139,7 +135,7 @@ namespace SourceGit.Views { if (line.FirstDocumentLine == null) continue; - + var index = line.FirstDocumentLine.LineNumber; if (index > _editor.DiffData.Lines.Count) break; @@ -159,11 +155,11 @@ namespace SourceGit.Views switch (type) { case Models.TextDiffLineType.None: - return BG_EMPTY; + return _editor.LineBGEmpty; case Models.TextDiffLineType.Added: - return BG_ADDED; + return _editor.LineBGAdd; case Models.TextDiffLineType.Deleted: - return BG_DELETED; + return _editor.LineBGDeleted; default: return null; } @@ -174,9 +170,6 @@ namespace SourceGit.Views public class LineStyleTransformer : DocumentColorizingTransformer { - private static readonly Brush HL_ADDED = new SolidColorBrush(Color.FromArgb(128, 0, 190, 0)); - private static readonly Brush HL_DELETED = new SolidColorBrush(Color.FromArgb(80, 255, 0, 0)); - public LineStyleTransformer(CombinedTextDiffPresenter editor) { _editor = editor; @@ -202,7 +195,7 @@ namespace SourceGit.Views if (info.Highlights.Count > 0) { - var bg = info.Type == Models.TextDiffLineType.Added ? HL_ADDED : HL_DELETED; + var bg = info.Type == Models.TextDiffLineType.Added ? _editor.SecondaryLineBGAdd : _editor.SecondaryLineBGDeleted; foreach (var highlight in info.Highlights) { ChangeLinePart(line.Offset + highlight.Start, line.Offset + highlight.Start + highlight.Count, v => @@ -225,6 +218,51 @@ namespace SourceGit.Views set => SetValue(DiffDataProperty, value); } + public static readonly StyledProperty LineBGEmptyProperty = + AvaloniaProperty.Register(nameof(LineBGEmpty), new SolidColorBrush(Color.FromArgb(60, 0, 0, 0))); + + public IBrush LineBGEmpty + { + get => GetValue(LineBGEmptyProperty); + set => SetValue(LineBGEmptyProperty, value); + } + + public static readonly StyledProperty LineBGAddProperty = + AvaloniaProperty.Register(nameof(LineBGAdd), new SolidColorBrush(Color.FromArgb(60, 0, 255, 0))); + + public IBrush LineBGAdd + { + get => GetValue(LineBGAddProperty); + set => SetValue(LineBGAddProperty, value); + } + + public static readonly StyledProperty LineBGDeletedProperty = + AvaloniaProperty.Register(nameof(LineBGDeleted), new SolidColorBrush(Color.FromArgb(60, 255, 0, 0))); + + public IBrush LineBGDeleted + { + get => GetValue(LineBGDeletedProperty); + set => SetValue(LineBGDeletedProperty, value); + } + + public static readonly StyledProperty SecondaryLineBGAddProperty = + AvaloniaProperty.Register(nameof(SecondaryLineBGAdd), new SolidColorBrush(Color.FromArgb(90, 0, 255, 0))); + + public IBrush SecondaryLineBGAdd + { + get => GetValue(SecondaryLineBGAddProperty); + set => SetValue(SecondaryLineBGAddProperty, value); + } + + public static readonly StyledProperty SecondaryLineBGDeletedProperty = + AvaloniaProperty.Register(nameof(SecondaryLineBGDeleted), new SolidColorBrush(Color.FromArgb(80, 255, 0, 0))); + + public IBrush SecondaryLineBGDeleted + { + get => GetValue(SecondaryLineBGDeletedProperty); + set => SetValue(SecondaryLineBGDeletedProperty, value); + } + public static readonly StyledProperty SecondaryFGProperty = AvaloniaProperty.Register(nameof(SecondaryFG), Brushes.Gray); @@ -499,10 +537,6 @@ namespace SourceGit.Views public class LineBackgroundRenderer : IBackgroundRenderer { - private static readonly Brush BG_EMPTY = new SolidColorBrush(Color.FromArgb(60, 0, 0, 0)); - private static readonly Brush BG_ADDED = new SolidColorBrush(Color.FromArgb(60, 0, 255, 0)); - private static readonly Brush BG_DELETED = new SolidColorBrush(Color.FromArgb(60, 255, 0, 0)); - public KnownLayer Layer => KnownLayer.Background; public LineBackgroundRenderer(SingleSideTextDiffPresenter editor) @@ -521,7 +555,7 @@ namespace SourceGit.Views { if (line.FirstDocumentLine == null) continue; - + var index = line.FirstDocumentLine.LineNumber; if (index > infos.Count) break; @@ -541,11 +575,11 @@ namespace SourceGit.Views switch (type) { case Models.TextDiffLineType.None: - return BG_EMPTY; + return _editor.LineBGEmpty; case Models.TextDiffLineType.Added: - return BG_ADDED; + return _editor.LineBGAdd; case Models.TextDiffLineType.Deleted: - return BG_DELETED; + return _editor.LineBGDeleted; default: return null; } @@ -556,9 +590,6 @@ namespace SourceGit.Views public class LineStyleTransformer : DocumentColorizingTransformer { - private static readonly Brush HL_ADDED = new SolidColorBrush(Color.FromArgb(90, 0, 255, 0)); - private static readonly Brush HL_DELETED = new SolidColorBrush(Color.FromArgb(80, 255, 0, 0)); - public LineStyleTransformer(SingleSideTextDiffPresenter editor) { _editor = editor; @@ -585,7 +616,7 @@ namespace SourceGit.Views if (info.Highlights.Count > 0) { - var bg = info.Type == Models.TextDiffLineType.Added ? HL_ADDED : HL_DELETED; + var bg = info.Type == Models.TextDiffLineType.Added ? _editor.LineBGAdd : _editor.LineBGDeleted; foreach (var highlight in info.Highlights) { ChangeLinePart(line.Offset + highlight.Start, line.Offset + highlight.Start + highlight.Count, v => @@ -617,6 +648,51 @@ namespace SourceGit.Views set => SetValue(DiffDataProperty, value); } + public static readonly StyledProperty LineBGEmptyProperty = + AvaloniaProperty.Register(nameof(LineBGEmpty), new SolidColorBrush(Color.FromArgb(60, 0, 0, 0))); + + public IBrush LineBGEmpty + { + get => GetValue(LineBGEmptyProperty); + set => SetValue(LineBGEmptyProperty, value); + } + + public static readonly StyledProperty LineBGAddProperty = + AvaloniaProperty.Register(nameof(LineBGAdd), new SolidColorBrush(Color.FromArgb(60, 0, 255, 0))); + + public IBrush LineBGAdd + { + get => GetValue(LineBGAddProperty); + set => SetValue(LineBGAddProperty, value); + } + + public static readonly StyledProperty LineBGDeletedProperty = + AvaloniaProperty.Register(nameof(LineBGDeleted), new SolidColorBrush(Color.FromArgb(60, 255, 0, 0))); + + public IBrush LineBGDeleted + { + get => GetValue(LineBGDeletedProperty); + set => SetValue(LineBGDeletedProperty, value); + } + + public static readonly StyledProperty SecondaryLineBGAddProperty = + AvaloniaProperty.Register(nameof(SecondaryLineBGAdd), new SolidColorBrush(Color.FromArgb(90, 0, 255, 0))); + + public IBrush SecondaryLineBGAdd + { + get => GetValue(SecondaryLineBGAddProperty); + set => SetValue(SecondaryLineBGAddProperty, value); + } + + public static readonly StyledProperty SecondaryLineBGDeletedProperty = + AvaloniaProperty.Register(nameof(SecondaryLineBGDeleted), new SolidColorBrush(Color.FromArgb(80, 255, 0, 0))); + + public IBrush SecondaryLineBGDeleted + { + get => GetValue(SecondaryLineBGDeletedProperty); + set => SetValue(SecondaryLineBGDeletedProperty, value); + } + public static readonly StyledProperty SecondaryFGProperty = AvaloniaProperty.Register(nameof(SecondaryFG), Brushes.Gray); @@ -736,7 +812,7 @@ namespace SourceGit.Views }; menu.Items.Add(copy); - + TextArea.TextView.OpenContextMenu(menu); e.Handled = true; }