@@ -85,6 +85,101 @@ protected override void OnKeyDown(KeyEventArgs e)
8585 }
8686 }
8787
88+ public class InteractiveRebasePath : Control
89+ {
90+ public static readonly StyledProperty < IBrush > FillProperty =
91+ AvaloniaProperty . Register < InteractiveRebasePath , IBrush > ( nameof ( Fill ) , Brushes . Transparent ) ;
92+
93+ public IBrush Fill
94+ {
95+ get => GetValue ( FillProperty ) ;
96+ set => SetValue ( FillProperty , value ) ;
97+ }
98+
99+ public static readonly StyledProperty < Models . InteractiveRebaseAction > ActionProperty =
100+ AvaloniaProperty . Register < InteractiveRebasePath , Models . InteractiveRebaseAction > ( nameof ( Action ) ) ;
101+
102+ public Models . InteractiveRebaseAction Action
103+ {
104+ get => GetValue ( ActionProperty ) ;
105+ set => SetValue ( ActionProperty , value ) ;
106+ }
107+
108+ public static readonly StyledProperty < bool > CanRewordProperty =
109+ AvaloniaProperty . Register < InteractiveRebasePath , bool > ( nameof ( CanReword ) ) ;
110+
111+ public bool CanReword
112+ {
113+ get => GetValue ( CanRewordProperty ) ;
114+ set => SetValue ( CanRewordProperty , value ) ;
115+ }
116+
117+ public override void Render ( DrawingContext context )
118+ {
119+ base . Render ( context ) ;
120+
121+ var startW = 4 ;
122+ var endW = Bounds . Width - 4 ;
123+ var height = Bounds . Height ;
124+ var halfH = height * 0.5 ;
125+ var action = Action ;
126+ var fill = Fill ;
127+
128+ if ( CanReword )
129+ {
130+ if ( action == Models . InteractiveRebaseAction . Squash || action == Models . InteractiveRebaseAction . Fixup )
131+ {
132+ var center = new Point ( startW , halfH ) ;
133+ context . DrawEllipse ( fill , null , center , 4 , 4 ) ;
134+ context . DrawLine ( new Pen ( fill , 2 ) , center , new Point ( startW , height ) ) ;
135+ }
136+ }
137+ else
138+ {
139+ if ( action == Models . InteractiveRebaseAction . Squash || action == Models . InteractiveRebaseAction . Fixup )
140+ {
141+ context . DrawEllipse ( fill , null , new Point ( startW , halfH ) , 4 , 4 ) ;
142+ context . DrawLine ( new Pen ( fill , 2 ) , new Point ( startW , 0 ) , new Point ( startW , height ) ) ;
143+ }
144+ else if ( action == Models . InteractiveRebaseAction . Drop )
145+ {
146+ context . DrawLine ( new Pen ( fill , 2 ) , new Point ( startW , 0 ) , new Point ( startW , height ) ) ;
147+ }
148+ else
149+ {
150+ var geoPath = new StreamGeometry ( ) ;
151+ using ( var ctx = geoPath . Open ( ) )
152+ {
153+ ctx . BeginFigure ( new Point ( startW , 0 ) , false ) ;
154+ ctx . QuadraticBezierTo ( new Point ( startW , halfH ) , new Point ( endW , halfH ) ) ;
155+ ctx . EndFigure ( false ) ;
156+ }
157+ context . DrawGeometry ( null , new Pen ( fill , 2 ) , geoPath ) ;
158+
159+ var geoArrow = new StreamGeometry ( ) ;
160+ using ( var ctx = geoPath . Open ( ) )
161+ {
162+ ctx . BeginFigure ( new Point ( endW , halfH ) , true ) ;
163+ ctx . LineTo ( new Point ( endW - 4 , halfH + 2 ) ) ;
164+ ctx . LineTo ( new Point ( endW - 4 , halfH - 2 ) ) ;
165+ ctx . EndFigure ( true ) ;
166+ }
167+ context . DrawGeometry ( fill , null , geoArrow ) ;
168+ }
169+ }
170+ }
171+
172+ protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
173+ {
174+ base . OnPropertyChanged ( change ) ;
175+
176+ if ( change . Property == FillProperty ||
177+ change . Property == ActionProperty ||
178+ change . Property == CanRewordProperty )
179+ InvalidateVisual ( ) ;
180+ }
181+ }
182+
88183 public partial class InteractiveRebase : ChromelessWindow
89184 {
90185 public InteractiveRebase ( )
@@ -312,7 +407,9 @@ private void OnShowActionsDropdownMenu(object sender, RoutedEventArgs e)
312407
313408 CreateActionMenuItem ( flyout , item , Models . InteractiveRebaseAction . Pick , Brushes . Green , "Use this commit" , "P" ) ;
314409 CreateActionMenuItem ( flyout , item , Models . InteractiveRebaseAction . Edit , Brushes . Orange , "Stop for amending" , "E" ) ;
315- CreateActionMenuItem ( flyout , item , Models . InteractiveRebaseAction . Reword , Brushes . Orange , "Edit the commit message" , "R" ) ;
410+
411+ if ( item . CanReword )
412+ CreateActionMenuItem ( flyout , item , Models . InteractiveRebaseAction . Reword , Brushes . Orange , "Edit the commit message" , "R" ) ;
316413
317414 if ( item . CanSquashOrFixup )
318415 {
0 commit comments