Skip to content

Commit 6809eaf

Browse files
committed
enhance: different icons for annotated and lightweight tags (#1942)
Signed-off-by: leo <[email protected]>
1 parent 9713a59 commit 6809eaf

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

src/Views/TagsView.axaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,17 @@
8787
<Path Grid.Column="0"
8888
Margin="8,0,0,0"
8989
Width="12" Height="12"
90-
Data="{StaticResource Icons.Tag}"/>
90+
Data="{StaticResource Icons.Tag}"
91+
IsVisible="{Binding Tag.IsAnnotated}"/>
92+
93+
<Path Grid.Column="0"
94+
Margin="8,0,0,0"
95+
Width="12" Height="12"
96+
Data="{StaticResource Icons.Tag}"
97+
Fill="Transparent"
98+
Stroke="{DynamicResource Brush.FG1}"
99+
StrokeThickness="1"
100+
IsVisible="{Binding !Tag.IsAnnotated}"/>
91101

92102
<TextBlock Grid.Column="1"
93103
Text="{Binding Tag.Name}"
@@ -105,8 +115,16 @@
105115
<DataTemplate DataType="vm:TagToolTip">
106116
<StackPanel Orientation="Vertical" Spacing="6">
107117
<StackPanel Orientation="Horizontal">
108-
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
109-
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
118+
<Path Width="12" Height="12"
119+
Data="{StaticResource Icons.Tag}"
120+
IsVisible="{Binding IsAnnotated}"/>
121+
<Path Width="12" Height="12"
122+
Data="{StaticResource Icons.Tag}"
123+
Fill="Transparent"
124+
Stroke="{DynamicResource Brush.FG1}"
125+
StrokeThickness="1"
126+
IsVisible="{Binding !IsAnnotated}"/>
127+
<TextBlock FontWeight="Bold" Margin="6,0,0,0" Text="{Binding Name}"/>
110128
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
111129
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Margin="4,0" Foreground="White"/>
112130
</Border>

src/Views/TagsView.axaml.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ private void UpdateContent()
6363
}
6464

6565
if (node.Tag != null)
66-
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Tag");
66+
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Tag", node.ToolTip is { IsAnnotated: false });
6767
else if (node.IsExpanded)
68-
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open");
68+
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open", false);
6969
else
70-
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder");
70+
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder", false);
7171
}
7272

73-
private void CreateContent(Thickness margin, string iconKey)
73+
private void CreateContent(Thickness margin, string iconKey, bool stroke)
7474
{
7575
if (this.FindResource(iconKey) is not StreamGeometry geo)
7676
return;
7777

78-
Content = new Avalonia.Controls.Shapes.Path()
78+
var path = new Avalonia.Controls.Shapes.Path()
7979
{
8080
Width = 12,
8181
Height = 12,
@@ -84,6 +84,15 @@ private void CreateContent(Thickness margin, string iconKey)
8484
Margin = margin,
8585
Data = geo,
8686
};
87+
88+
if (stroke)
89+
{
90+
path.Fill = Brushes.Transparent;
91+
path.Stroke = this.FindResource("Brush.FG1") as IBrush;
92+
path.StrokeThickness = 1;
93+
}
94+
95+
Content = path;
8796
}
8897
}
8998

0 commit comments

Comments
 (0)