@@ -62,6 +62,7 @@ public class ChangeStatusIcon : Control
62
62
] ;
63
63
64
64
private static readonly string [ ] INDICATOR = [ "?" , "±" , "T" , "+" , "−" , "➜" , "❏" , "U" , "★" ] ;
65
+ private static readonly string [ ] TIPS = [ "Unknown" , "Modified" , "Type Changed" , "Added" , "Deleted" , "Renamed" , "Copied" , "Unmerged" , "Untracked" ] ;
65
66
66
67
public static readonly StyledProperty < bool > IsUnstagedChangeProperty =
67
68
AvaloniaProperty . Register < ChangeStatusIcon , bool > ( nameof ( IsUnstagedChange ) ) ;
@@ -81,11 +82,6 @@ public Models.Change Change
81
82
set => SetValue ( ChangeProperty , value ) ;
82
83
}
83
84
84
- static ChangeStatusIcon ( )
85
- {
86
- AffectsRender < ChangeStatusIcon > ( IsUnstagedChangeProperty , ChangeProperty ) ;
87
- }
88
-
89
85
public override void Render ( DrawingContext context )
90
86
{
91
87
if ( Change == null || Bounds . Width <= 0 )
@@ -122,10 +118,33 @@ public override void Render(DrawingContext context)
122
118
Bounds . Width * 0.8 ,
123
119
Brushes . White ) ;
124
120
125
- float corner = ( float ) Math . Max ( 2 , Bounds . Width / 16 ) ;
126
- Point textOrigin = new Point ( ( Bounds . Width - txt . Width ) * 0.5 , ( Bounds . Height - txt . Height ) * 0.5 ) ;
121
+ var corner = ( float ) Math . Max ( 2 , Bounds . Width / 16 ) ;
122
+ var textOrigin = new Point ( ( Bounds . Width - txt . Width ) * 0.5 , ( Bounds . Height - txt . Height ) * 0.5 ) ;
127
123
context . DrawRectangle ( background , null , new Rect ( 0 , 0 , Bounds . Width , Bounds . Height ) , corner , corner ) ;
128
124
context . DrawText ( txt , textOrigin ) ;
129
125
}
126
+
127
+ protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
128
+ {
129
+ base . OnPropertyChanged ( change ) ;
130
+
131
+ if ( change . Property == IsUnstagedChangeProperty || change . Property == ChangeProperty )
132
+ {
133
+ var isUnstaged = IsUnstagedChange ;
134
+ var c = Change ;
135
+ if ( c == null )
136
+ {
137
+ ToolTip . SetTip ( this , null ) ;
138
+ return ;
139
+ }
140
+
141
+ if ( isUnstaged )
142
+ ToolTip . SetTip ( this , c . IsConflit ? "Conflict" : TIPS [ ( int ) c . WorkTree ] ) ;
143
+ else
144
+ ToolTip . SetTip ( this , TIPS [ ( int ) c . Index ] ) ;
145
+
146
+ InvalidateVisual ( ) ;
147
+ }
148
+ }
130
149
}
131
150
}
0 commit comments