Skip to content

Commit 2512d3b

Browse files
committed
feature: allow to hide tags in graph (#1109)
Signed-off-by: leo <[email protected]>
1 parent ae1e46b commit 2512d3b

File tree

10 files changed

+48
-20
lines changed

10 files changed

+48
-20
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@
569569
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">LAYOUT</x:String>
570570
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">Horizontal</x:String>
571571
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">Vertical</x:String>
572+
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">OPTIONS</x:String>
573+
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">Show Tags in Graph</x:String>
572574
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">COMMITS ORDER</x:String>
573575
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">Commit Date</x:String>
574576
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">Topologically</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@
573573
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">布局方式</x:String>
574574
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">水平排布</x:String>
575575
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">竖直排布</x:String>
576+
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">其它设置</x:String>
577+
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">在提交路线图中显示标签</x:String>
576578
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交列表排序规则</x:String>
577579
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">按提交时间</x:String>
578580
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">按拓扑排序</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@
572572
<x:String x:Key="Text.Repository.HistoriesLayout" xml:space="preserve">版面配置</x:String>
573573
<x:String x:Key="Text.Repository.HistoriesLayout.Horizontal" xml:space="preserve">橫向顯示</x:String>
574574
<x:String x:Key="Text.Repository.HistoriesLayout.Vertical" xml:space="preserve">縱向顯示</x:String>
575+
<x:String x:Key="Text.Repository.HistoriesOptions" xml:space="preserve">其它設定</x:String>
576+
<x:String x:Key="Text.Repository.HistoriesOptions.ShowTagsInGraph" xml:space="preserve">在路線圖中顯示標籤</x:String>
575577
<x:String x:Key="Text.Repository.HistoriesOrder" xml:space="preserve">提交顯示順序</x:String>
576578
<x:String x:Key="Text.Repository.HistoriesOrder.ByDate" xml:space="preserve">依時間排序</x:String>
577579
<x:String x:Key="Text.Repository.HistoriesOrder.Topo" xml:space="preserve">依拓撲排序</x:String>

src/Resources/Themes.axaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<Color x:Key="Color.Contents">#FFFAFAFA</Color>
1111
<Color x:Key="Color.Badge">#FFB0CEE8</Color>
1212
<Color x:Key="Color.BadgeFG">#FF1F1F1F</Color>
13-
<Color x:Key="Color.DecoratorTag">DarkGreen</Color>
1413
<Color x:Key="Color.Conflict">#FF836C2E</Color>
1514
<Color x:Key="Color.ConflictForeground">#FFFFFFFF</Color>
1615
<Color x:Key="Color.Border0">#FFCFCFCF</Color>
@@ -37,7 +36,6 @@
3736
<Color x:Key="Color.Contents">#FF1C1C1C</Color>
3837
<Color x:Key="Color.Badge">#FF8F8F8F</Color>
3938
<Color x:Key="Color.BadgeFG">#FFDDDDDD</Color>
40-
<Color x:Key="Color.DecoratorTag">#84c88a</Color>
4139
<Color x:Key="Color.Conflict">#FFFAFAD2</Color>
4240
<Color x:Key="Color.ConflictForeground">#FF252525</Color>
4341
<Color x:Key="Color.Border0">#FF181818</Color>
@@ -64,7 +62,6 @@
6462
<SolidColorBrush x:Key="Brush.Contents" Color="{DynamicResource Color.Contents}"/>
6563
<SolidColorBrush x:Key="Brush.Badge" Color="{DynamicResource Color.Badge}"/>
6664
<SolidColorBrush x:Key="Brush.BadgeFG" Color="{DynamicResource Color.BadgeFG}"/>
67-
<SolidColorBrush x:Key="Brush.DecoratorTag" Color="{DynamicResource Color.DecoratorTag}"/>
6865
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
6966
<SolidColorBrush x:Key="Brush.ConflictForeground" Color="{DynamicResource Color.ConflictForeground}"/>
7067
<SolidColorBrush x:Key="Brush.Border0" Color="{DynamicResource Color.Border0}"/>

src/ViewModels/Preferences.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ public bool ShowTagsAsTree
183183
set => SetProperty(ref _showTagsAsTree, value);
184184
}
185185

186+
public bool ShowTagsInGraph
187+
{
188+
get => _showTagsInGraph;
189+
set => SetProperty(ref _showTagsInGraph, value);
190+
}
191+
186192
public bool UseTwoColumnsLayoutInHistories
187193
{
188194
get => _useTwoColumnsLayoutInHistories;
@@ -643,6 +649,7 @@ private bool RemoveInvalidRepositoriesRecursive(List<RepositoryNode> collection)
643649
private string _ignoreUpdateTag = string.Empty;
644650

645651
private bool _showTagsAsTree = false;
652+
private bool _showTagsInGraph = true;
646653
private bool _useTwoColumnsLayoutInHistories = false;
647654
private bool _displayTimeAsPeriodInHistories = false;
648655
private bool _useSideBySideDiff = false;

src/Views/CommitBaseInfo.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@
173173
<!-- REFS -->
174174
<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}"/>
175175
<Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" MinHeight="24" IsVisible="{Binding HasDecorators}">
176-
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
177-
Foreground="{DynamicResource Brush.FG1}"
176+
<v:CommitRefsPresenter Foreground="{DynamicResource Brush.FG1}"
178177
FontFamily="{DynamicResource Fonts.Primary}"
179178
FontSize="11"
180179
AllowWrap="True"

src/Views/CommitRefsPresenter.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ public bool UseGraphColor
6464
set => SetValue(UseGraphColorProperty, value);
6565
}
6666

67-
public static readonly StyledProperty<IBrush> TagBackgroundProperty =
68-
AvaloniaProperty.Register<CommitRefsPresenter, IBrush>(nameof(TagBackground), Brushes.White);
69-
70-
public IBrush TagBackground
71-
{
72-
get => GetValue(TagBackgroundProperty);
73-
set => SetValue(TagBackgroundProperty, value);
74-
}
75-
7667
public static readonly StyledProperty<bool> AllowWrapProperty =
7768
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(AllowWrap));
7869

@@ -82,15 +73,24 @@ public bool AllowWrap
8273
set => SetValue(AllowWrapProperty, value);
8374
}
8475

76+
public static readonly StyledProperty<bool> ShowTagsProperty =
77+
AvaloniaProperty.Register<CommitRefsPresenter, bool>(nameof(ShowTags), true);
78+
79+
public bool ShowTags
80+
{
81+
get => GetValue(ShowTagsProperty);
82+
set => SetValue(ShowTagsProperty, value);
83+
}
84+
8585
static CommitRefsPresenter()
8686
{
8787
AffectsMeasure<CommitRefsPresenter>(
8888
FontFamilyProperty,
8989
FontSizeProperty,
9090
ForegroundProperty,
9191
UseGraphColorProperty,
92-
TagBackgroundProperty,
93-
BackgroundProperty);
92+
BackgroundProperty,
93+
ShowTagsProperty);
9494
}
9595

9696
public override void Render(DrawingContext context)
@@ -171,15 +171,18 @@ protected override Size MeasureOverride(Size availableSize)
171171
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
172172
var fg = Foreground;
173173
var normalBG = UseGraphColor ? commit.Brush : Brushes.Gray;
174-
var tagBG = UseGraphColor ? TagBackground : Brushes.Gray;
175174
var labelSize = FontSize;
176175
var requiredWidth = 0.0;
177176
var requiredHeight = 16.0;
178177
var x = 0.0;
179178
var allowWrap = AllowWrap;
179+
var showTags = ShowTags;
180180

181181
foreach (var decorator in refs)
182182
{
183+
if (!showTags && decorator.Type == Models.DecoratorType.Tag)
184+
continue;
185+
183186
var isHead = decorator.Type == Models.DecoratorType.CurrentBranchHead ||
184187
decorator.Type == Models.DecoratorType.CurrentCommitHead;
185188

@@ -209,7 +212,7 @@ protected override Size MeasureOverride(Size availableSize)
209212
geo = this.FindResource("Icons.Remote") as StreamGeometry;
210213
break;
211214
case Models.DecoratorType.Tag:
212-
item.Brush = tagBG;
215+
item.Brush = Brushes.Gray;
213216
geo = this.FindResource("Icons.Tag") as StreamGeometry;
214217
break;
215218
default:

src/Views/Conflict.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
<StackPanel Orientation="Horizontal">
4747
<Path Width="12" Height="12" Data="{StaticResource Icons.Commit}"/>
4848
<v:CommitRefsPresenter Margin="8,0,0,0"
49-
TagBackground="{DynamicResource Brush.DecoratorTag}"
5049
Foreground="{DynamicResource Brush.FG1}"
5150
FontFamily="{DynamicResource Fonts.Primary}"
5251
FontSize="11"

src/Views/Histories.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@
140140

141141
<v:CommitRefsPresenter Grid.Column="1"
142142
Background="{DynamicResource Brush.Contents}"
143-
TagBackground="{DynamicResource Brush.DecoratorTag}"
144143
Foreground="{DynamicResource Brush.FG1}"
145144
FontFamily="{DynamicResource Fonts.Primary}"
145+
ShowTags="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowTagsInGraph}"
146146
FontSize="11"
147147
VerticalAlignment="Center">
148148
<v:CommitRefsPresenter.UseGraphColor>

src/Views/Repository.axaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,20 @@ private void OnOpenAdvancedHistoriesOption(object sender, RoutedEventArgs e)
447447
ev.Handled = true;
448448
};
449449

450+
var others = new MenuItem();
451+
others.Header = App.Text("Repository.HistoriesOptions");
452+
others.IsEnabled = false;
453+
454+
var showTagsInGraph = new MenuItem();
455+
showTagsInGraph.Header = App.Text("Repository.HistoriesOptions.ShowTagsInGraph");
456+
if (ViewModels.Preferences.Instance.ShowTagsInGraph)
457+
showTagsInGraph.Icon = App.CreateMenuIcon("Icons.Check");
458+
showTagsInGraph.Click += (_, ev) =>
459+
{
460+
ViewModels.Preferences.Instance.ShowTagsInGraph = !ViewModels.Preferences.Instance.ShowTagsInGraph;
461+
ev.Handled = true;
462+
};
463+
450464
var menu = new ContextMenu();
451465
menu.Items.Add(layout);
452466
menu.Items.Add(horizontal);
@@ -455,6 +469,9 @@ private void OnOpenAdvancedHistoriesOption(object sender, RoutedEventArgs e)
455469
menu.Items.Add(order);
456470
menu.Items.Add(dateOrder);
457471
menu.Items.Add(topoOrder);
472+
menu.Items.Add(new MenuItem() { Header = "-" });
473+
menu.Items.Add(others);
474+
menu.Items.Add(showTagsInGraph);
458475
menu.Open(button);
459476
}
460477

0 commit comments

Comments
 (0)