Skip to content

Commit afc8a77

Browse files
committed
ux: new style for tag's tooltip (#1305)
1 parent 8a45e25 commit afc8a77

File tree

5 files changed

+66
-26
lines changed

5 files changed

+66
-26
lines changed

src/Commands/Discard.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void All(string repo, bool includeIgnored, Models.ICommandLog log)
3535
App.RaiseException(repo, $"Failed to discard changes. Reason: {e.Message}");
3636
});
3737
}
38-
38+
3939
new Restore(repo) { Log = log }.Exec();
4040
if (includeIgnored)
4141
new Clean(repo) { Log = log }.Exec();

src/Commands/QueryTags.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public QueryTags(string repo)
1111

1212
Context = repo;
1313
WorkingDirectory = repo;
14-
Args = $"tag -l --format=\"{_boundary}%(refname)%00%(objectname)%00%(*objectname)%00%(creatordate:unix)%00%(contents:subject)%0a%0a%(contents:body)\"";
14+
Args = $"tag -l --format=\"{_boundary}%(refname)%00%(objecttype)%00%(objectname)%00%(*objectname)%00%(creatordate:unix)%00%(contents:subject)%0a%0a%(contents:body)\"";
1515
}
1616

1717
public List<Models.Tag> Result()
@@ -25,16 +25,17 @@ public QueryTags(string repo)
2525
foreach (var record in records)
2626
{
2727
var subs = record.Split('\0', StringSplitOptions.None);
28-
if (subs.Length != 5)
28+
if (subs.Length != 6)
2929
continue;
3030

3131
var name = subs[0].Substring(10);
32-
var message = subs[4].Trim();
32+
var message = subs[5].Trim();
3333
tags.Add(new Models.Tag()
3434
{
3535
Name = name,
36-
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
37-
CreatorDate = ulong.Parse(subs[3]),
36+
IsAnnotated = subs[1].Equals("tag", StringComparison.Ordinal),
37+
SHA = string.IsNullOrEmpty(subs[3]) ? subs[2] : subs[3],
38+
CreatorDate = ulong.Parse(subs[4]),
3839
Message = string.IsNullOrEmpty(message) ? name : message,
3940
});
4041
}

src/Models/Tag.cs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public enum TagSortMode
1212
public class Tag : ObservableObject
1313
{
1414
public string Name { get; set; } = string.Empty;
15+
public bool IsAnnotated { get; set; } = false;
1516
public string SHA { get; set; } = string.Empty;
1617
public ulong CreatorDate { get; set; } = 0;
1718
public string Message { get; set; } = string.Empty;

src/ViewModels/TagCollection.cs

+16-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,28 @@
55

66
namespace SourceGit.ViewModels
77
{
8+
public class TagTreeNodeToolTip
9+
{
10+
public string Name { get; private set; }
11+
public bool IsAnnotated { get; private set; }
12+
public string Message { get; private set; }
13+
14+
public TagTreeNodeToolTip(Models.Tag t)
15+
{
16+
Name = t.Name;
17+
IsAnnotated = t.IsAnnotated;
18+
Message = t.Message;
19+
}
20+
}
21+
822
public class TagTreeNode : ObservableObject
923
{
1024
public string FullPath { get; set; }
1125
public int Depth { get; private set; } = 0;
1226
public Models.Tag Tag { get; private set; } = null;
27+
public TagTreeNodeToolTip ToolTip { get; private set; } = null;
1328
public List<TagTreeNode> Children { get; private set; } = [];
1429

15-
public object ToolTip
16-
{
17-
get => Tag?.Message;
18-
}
19-
2030
public bool IsFolder
2131
{
2232
get => Tag == null;
@@ -33,6 +43,7 @@ public TagTreeNode(Models.Tag t, int depth)
3343
FullPath = t.Name;
3444
Depth = depth;
3545
Tag = t;
46+
ToolTip = new TagTreeNodeToolTip(t);
3647
IsExpanded = false;
3748
}
3849

src/Views/TagsView.axaml

+42-15
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,26 @@
2626
SelectionChanged="OnRowSelectionChanged">
2727
<ListBox.ItemTemplate>
2828
<DataTemplate DataType="vm:TagTreeNode">
29-
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" DoubleTapped="OnDoubleTappedNode" ContextRequested="OnRowContextRequested">
29+
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" DoubleTapped="OnDoubleTappedNode" ContextRequested="OnRowContextRequested" ToolTip.Tip="{Binding ToolTip}">
30+
<Border.DataTemplates>
31+
<DataTemplate DataType="vm:TagTreeNodeToolTip">
32+
<StackPanel Orientation="Vertical" MinWidth="200">
33+
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
34+
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
35+
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
36+
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
37+
<TextBlock Text="annotated" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
38+
</Border>
39+
</StackPanel>
40+
41+
<TextBlock Text="{Binding Message}"/>
42+
</StackPanel>
43+
</DataTemplate>
44+
</Border.DataTemplates>
45+
3046
<Grid ColumnDefinitions="16,Auto,*,Auto"
3147
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
32-
VerticalAlignment="Center"
33-
ToolTip.Tip="{Binding ToolTip}">
48+
VerticalAlignment="Center">
3449
<v:TagTreeNodeToggleButton Grid.Column="0"
3550
Classes="tree_expander"
3651
Focusable="False"
@@ -42,11 +57,10 @@
4257
Node="{Binding .}"
4358
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
4459

45-
<Border Grid.Column="2" Background="Transparent">
46-
<TextBlock Classes="primary"
47-
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
48-
Margin="8,0,0,0"/>
49-
</Border>
60+
<TextBlock Grid.Column="2"
61+
Classes="primary"
62+
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
63+
Margin="8,0,0,0"/>
5064

5165
<ContentControl Grid.Column="3" Content="{Binding Tag}">
5266
<ContentControl.DataTemplates>
@@ -71,18 +85,31 @@
7185
<ListBox.ItemTemplate>
7286
<DataTemplate DataType="m:Tag">
7387
<Border Height="24" Background="Transparent" PointerPressed="OnRowPointerPressed" ContextRequested="OnRowContextRequested">
74-
<Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center" ToolTip.Tip="{Binding Message}">
88+
<ToolTip.Tip>
89+
<StackPanel Orientation="Vertical" MinWidth="200">
90+
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
91+
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
92+
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
93+
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
94+
<TextBlock Text="annotated" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
95+
</Border>
96+
</StackPanel>
97+
98+
<TextBlock Text="{Binding Message}"/>
99+
</StackPanel>
100+
</ToolTip.Tip>
101+
102+
<Grid ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center">
75103
<Path Grid.Column="0"
76104
Margin="8,0,0,0"
77105
Width="12" Height="12"
78106
Data="{StaticResource Icons.Tag}"/>
79107

80-
<Border Grid.Column="1" Background="Transparent">
81-
<TextBlock Classes="primary"
82-
Text="{Binding Name}"
83-
Margin="8,0,0,0"
84-
TextTrimming="CharacterEllipsis"/>
85-
</Border>
108+
<TextBlock Grid.Column="1"
109+
Classes="primary"
110+
Text="{Binding Name}"
111+
Margin="8,0,0,0"
112+
TextTrimming="CharacterEllipsis"/>
86113

87114
<v:FilterModeSwitchButton Grid.Column="2" Margin="0,0,12,0" Mode="{Binding FilterMode}"/>
88115
</Grid>

0 commit comments

Comments
 (0)