feature: allow to hide tags in graph (#1109)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-18 21:40:31 +08:00
parent ae1e46b586
commit 2512d3be7a
No known key found for this signature in database
10 changed files with 48 additions and 20 deletions

View file

@ -569,6 +569,8 @@
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">LAYOUT</x:String> <x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">LAYOUT</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">Horizontal</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">Horizontal</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">Vertical</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">Vertical</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">OPTIONS</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">Show Tags in Graph</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">COMMITS ORDER</x:String> <x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">COMMITS ORDER</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">Commit Date</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">Commit Date</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">Topologically</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">Topologically</x:String>

View file

@ -573,6 +573,8 @@
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">布局方式</x:String> <x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">布局方式</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">水平排布</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">水平排布</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">竖直排布</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">竖直排布</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">其它设置</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">在提交路线图中显示标签</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交列表排序规则</x:String> <x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交列表排序规则</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">按提交时间</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">按提交时间</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">按拓扑排序</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">按拓扑排序</x:String>

View file

@ -572,6 +572,8 @@
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">版面配置</x:String> <x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">版面配置</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">橫向顯示</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">橫向顯示</x:String>
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">縱向顯示</x:String> <x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">縱向顯示</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">其它設定</x:String>
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">在路線圖中顯示標籤</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交顯示順序</x:String> <x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交顯示順序</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">依時間排序</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">依時間排序</x:String>
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">依拓撲排序</x:String> <x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">依拓撲排序</x:String>

View file

@ -10,7 +10,6 @@
<Color x:Key="Color.Contents">#FFFAFAFA</Color> <Color x:Key="Color.Contents">#FFFAFAFA</Color>
<Color x:Key="Color.Badge">#FFB0CEE8</Color> <Color x:Key="Color.Badge">#FFB0CEE8</Color>
<Color x:Key="Color.BadgeFG">#FF1F1F1F</Color> <Color x:Key="Color.BadgeFG">#FF1F1F1F</Color>
<Color x:Key="Color.DecoratorTag">DarkGreen</Color>
<Color x:Key="Color.Conflict">#FF836C2E</Color> <Color x:Key="Color.Conflict">#FF836C2E</Color>
<Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color> <Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color>
<Color x:Key="Color.Border0">#FFCFCFCF</Color> <Color x:Key="Color.Border0">#FFCFCFCF</Color>
@ -37,7 +36,6 @@
<Color x:Key="Color.Contents">#FF1C1C1C</Color> <Color x:Key="Color.Contents">#FF1C1C1C</Color>
<Color x:Key="Color.Badge">#FF8F8F8F</Color> <Color x:Key="Color.Badge">#FF8F8F8F</Color>
<Color x:Key="Color.BadgeFG">#FFDDDDDD</Color> <Color x:Key="Color.BadgeFG">#FFDDDDDD</Color>
<Color x:Key="Color.DecoratorTag">#84c88a</Color>
<Color x:Key="Color.Conflict">#FFFAFAD2</Color> <Color x:Key="Color.Conflict">#FFFAFAD2</Color>
<Color x:Key="Color.ConflictForeground">#FF252525</Color> <Color x:Key="Color.ConflictForeground">#FF252525</Color>
<Color x:Key="Color.Border0">#FF181818</Color> <Color x:Key="Color.Border0">#FF181818</Color>
@ -64,7 +62,6 @@
<SolidColorBrush x:Key="Brush.Contents" Color="{DynamicResource Color.Contents}"/> <SolidColorBrush x:Key="Brush.Contents" Color="{DynamicResource Color.Contents}"/>
<SolidColorBrush x:Key="Brush.Badge" Color="{DynamicResource Color.Badge}"/> <SolidColorBrush x:Key="Brush.Badge" Color="{DynamicResource Color.Badge}"/>
<SolidColorBrush x:Key="Brush.BadgeFG" Color="{DynamicResource Color.BadgeFG}"/> <SolidColorBrush x:Key="Brush.BadgeFG" Color="{DynamicResource Color.BadgeFG}"/>
<SolidColorBrush x:Key="Brush.DecoratorTag" Color="{DynamicResource Color.DecoratorTag}"/>
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/> <SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
<SolidColorBrush x:Key="Brush.ConflictForeground" Color="{DynamicResource Color.ConflictForeground}"/> <SolidColorBrush x:Key="Brush.ConflictForeground" Color="{DynamicResource Color.ConflictForeground}"/>
<SolidColorBrush x:Key="Brush.Border0" Color="{DynamicResource Color.Border0}"/> <SolidColorBrush x:Key="Brush.Border0" Color="{DynamicResource Color.Border0}"/>

View file

@ -183,6 +183,12 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _showTagsAsTree, value); set => SetProperty(ref _showTagsAsTree, value);
} }
public bool ShowTagsInGraph
{
get => _showTagsInGraph;
set => SetProperty(ref _showTagsInGraph, value);
}
public bool UseTwoColumnsLayoutInHistories public bool UseTwoColumnsLayoutInHistories
{ {
get => _useTwoColumnsLayoutInHistories; get => _useTwoColumnsLayoutInHistories;
@ -643,6 +649,7 @@ namespace SourceGit.ViewModels
private string _ignoreUpdateTag = string.Empty; private string _ignoreUpdateTag = string.Empty;
private bool _showTagsAsTree = false; private bool _showTagsAsTree = false;
private bool _showTagsInGraph = true;
private bool _useTwoColumnsLayoutInHistories = false; private bool _useTwoColumnsLayoutInHistories = false;
private bool _displayTimeAsPeriodInHistories = false; private bool _displayTimeAsPeriodInHistories = false;
private bool _useSideBySideDiff = false; private bool _useSideBySideDiff = false;

View file

@ -173,8 +173,7 @@
<!-- REFS --> <!-- REFS -->
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/> <TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
<Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" MinHeight="24" IsVisible="{Binding HasDecorators}"> <Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" MinHeight="24" IsVisible="{Binding HasDecorators}">
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}" <v:CommitRefsPresenter Foreground="{DynamicResource Brush.FG1}"
Foreground="{DynamicResource Brush.FG1}"
FontFamily="{DynamicResource Fonts.Primary}" FontFamily="{DynamicResource Fonts.Primary}"
FontSize="11" FontSize="11"
AllowWrap="True" AllowWrap="True"

View file

@ -64,15 +64,6 @@ namespace SourceGit.Views
set => SetValue(UseGraphColorProperty, value); set => SetValue(UseGraphColorProperty, value);
} }
public static readonly StyledProperty<IBrush> TagBackgroundProperty =
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagBackground), Brushes.White);
public IBrush TagBackground
{
get => GetValue(TagBackgroundProperty);
set => SetValue(TagBackgroundProperty, value);
}
public static readonly StyledProperty<bool> AllowWrapProperty = public static readonly StyledProperty<bool> AllowWrapProperty =
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(AllowWrap)); AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(AllowWrap));
@ -82,6 +73,15 @@ namespace SourceGit.Views
set => SetValue(AllowWrapProperty, value); set => SetValue(AllowWrapProperty, value);
} }
public static readonly StyledProperty<bool> ShowTagsProperty =
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(ShowTags), true);
public bool ShowTags
{
get => GetValue(ShowTagsProperty);
set => SetValue(ShowTagsProperty, value);
}
static CommitRefsPresenter() static CommitRefsPresenter()
{ {
AffectsMeasure<CommitRefsPresenter>( AffectsMeasure<CommitRefsPresenter>(
@ -89,8 +89,8 @@ namespace SourceGit.Views
FontSizeProperty, FontSizeProperty,
ForegroundProperty, ForegroundProperty,
UseGraphColorProperty, UseGraphColorProperty,
TagBackgroundProperty, BackgroundProperty,
BackgroundProperty); ShowTagsProperty);
} }
public override void Render(DrawingContext context) public override void Render(DrawingContext context)
@ -171,15 +171,18 @@ namespace SourceGit.Views
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold); var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
var fg = Foreground; var fg = Foreground;
var normalBG = UseGraphColor ? commit.Brush : Brushes.Gray; var normalBG = UseGraphColor ? commit.Brush : Brushes.Gray;
var tagBG = UseGraphColor ? TagBackground : Brushes.Gray;
var labelSize = FontSize; var labelSize = FontSize;
var requiredWidth = 0.0; var requiredWidth = 0.0;
var requiredHeight = 16.0; var requiredHeight = 16.0;
var x = 0.0; var x = 0.0;
var allowWrap = AllowWrap; var allowWrap = AllowWrap;
var showTags = ShowTags;
foreach (var decorator in refs) foreach (var decorator in refs)
{ {
if (!showTags && decorator.Type == Models.DecoratorType.Tag)
continue;
var isHead = decorator.Type == Models.DecoratorType.CurrentBranchHead || var isHead = decorator.Type == Models.DecoratorType.CurrentBranchHead ||
decorator.Type == Models.DecoratorType.CurrentCommitHead; decorator.Type == Models.DecoratorType.CurrentCommitHead;
@ -209,7 +212,7 @@ namespace SourceGit.Views
geo = this.FindResource("Icons.Remote") as StreamGeometry; geo = this.FindResource("Icons.Remote") as StreamGeometry;
break; break;
case Models.DecoratorType.Tag: case Models.DecoratorType.Tag:
item.Brush = tagBG; item.Brush = Brushes.Gray;
geo = this.FindResource("Icons.Tag") as StreamGeometry; geo = this.FindResource("Icons.Tag") as StreamGeometry;
break; break;
default: default:

View file

@ -46,7 +46,6 @@
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Commit}"/> <Path Width="12" Height="12" Data="{StaticResource Icons.Commit}"/>
<v:CommitRefsPresenter Margin="8,0,0,0" <v:CommitRefsPresenter Margin="8,0,0,0"
TagBackground="{DynamicResource Brush.DecoratorTag}"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"
FontFamily="{DynamicResource Fonts.Primary}" FontFamily="{DynamicResource Fonts.Primary}"
FontSize="11" FontSize="11"

View file

@ -140,9 +140,9 @@
<v:CommitRefsPresenter Grid.Column="1" <v:CommitRefsPresenter Grid.Column="1"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
TagBackground="{DynamicResource Brush.DecoratorTag}"
Foreground="{DynamicResource Brush.FG1}" Foreground="{DynamicResource Brush.FG1}"
FontFamily="{DynamicResource Fonts.Primary}" FontFamily="{DynamicResource Fonts.Primary}"
ShowTags="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowTagsInGraph}"
FontSize="11" FontSize="11"
VerticalAlignment="Center"> VerticalAlignment="Center">
<v:CommitRefsPresenter.UseGraphColor> <v:CommitRefsPresenter.UseGraphColor>

View file

@ -447,6 +447,20 @@ namespace SourceGit.Views
ev.Handled = true; ev.Handled = true;
}; };
var others = new MenuItem();
others.Header = App.Text("Repository.HistoriesOptions");
others.IsEnabled = false;
var showTagsInGraph = new MenuItem();
showTagsInGraph.Header = App.Text("Repository.HistoriesOptions.ShowTagsInGraph");
if (ViewModels.Preferences.Instance.ShowTagsInGraph)
showTagsInGraph.Icon = App.CreateMenuIcon("Icons.Check");
showTagsInGraph.Click += (_, ev) =>
{
ViewModels.Preferences.Instance.ShowTagsInGraph = !ViewModels.Preferences.Instance.ShowTagsInGraph;
ev.Handled = true;
};
var menu = new ContextMenu(); var menu = new ContextMenu();
menu.Items.Add(layout); menu.Items.Add(layout);
menu.Items.Add(horizontal); menu.Items.Add(horizontal);
@ -455,6 +469,9 @@ namespace SourceGit.Views
menu.Items.Add(order); menu.Items.Add(order);
menu.Items.Add(dateOrder); menu.Items.Add(dateOrder);
menu.Items.Add(topoOrder); menu.Items.Add(topoOrder);
menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(others);
menu.Items.Add(showTagsInGraph);
menu.Open(button); menu.Open(button);
} }