@@ -62,6 +62,7 @@ public class ChangeStatusIcon : Control
6262 ] ;
6363
6464 private static readonly string [ ] INDICATOR = [ "?" , "±" , "T" , "+" , "−" , "➜" , "❏" , "U" , "★" ] ;
65+ private static readonly string [ ] TIPS = [ "Unknown" , "Modified" , "Type Changed" , "Added" , "Deleted" , "Renamed" , "Copied" , "Unmerged" , "Untracked" ] ;
6566
6667 public static readonly StyledProperty < bool > IsUnstagedChangeProperty =
6768 AvaloniaProperty . Register < ChangeStatusIcon , bool > ( nameof ( IsUnstagedChange ) ) ;
@@ -81,11 +82,6 @@ public Models.Change Change
8182 set => SetValue ( ChangeProperty , value ) ;
8283 }
8384
84- static ChangeStatusIcon ( )
85- {
86- AffectsRender < ChangeStatusIcon > ( IsUnstagedChangeProperty , ChangeProperty ) ;
87- }
88-
8985 public override void Render ( DrawingContext context )
9086 {
9187 if ( Change == null || Bounds . Width <= 0 )
@@ -122,10 +118,33 @@ public override void Render(DrawingContext context)
122118 Bounds . Width * 0.8 ,
123119 Brushes . White ) ;
124120
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 ) ;
127123 context . DrawRectangle ( background , null , new Rect ( 0 , 0 , Bounds . Width , Bounds . Height ) , corner , corner ) ;
128124 context . DrawText ( txt , textOrigin ) ;
129125 }
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+ }
130149 }
131150}
0 commit comments