@@ -121,6 +121,15 @@ public bool UseCompactBranchNames
121121 set => SetValue ( UseCompactBranchNamesProperty , value ) ;
122122 }
123123
124+ public static readonly StyledProperty < bool > HasSingleRemoteProperty =
125+ AvaloniaProperty . Register < CommitRefsPresenter , bool > ( nameof ( HasSingleRemote ) ) ;
126+
127+ public bool HasSingleRemote
128+ {
129+ get => GetValue ( HasSingleRemoteProperty ) ;
130+ set => SetValue ( HasSingleRemoteProperty , value ) ;
131+ }
132+
124133 public static readonly StyledProperty < bool > UseGraphColorProperty =
125134 AvaloniaProperty . Register < CommitRefsPresenter , bool > ( nameof ( UseGraphColor ) ) ;
126135
@@ -173,6 +182,7 @@ public override void Render(DrawingContext context)
173182 var x = 1.5 ;
174183 var y = 0.5 ;
175184 var remoteIcon = CommitRefsIconCache . Instance . GetIcon ( Models . DecoratorType . RemoteBranchHead ) ;
185+ var hasSingleRemote = HasSingleRemote ;
176186
177187 context . FillRectangle ( Brushes . Transparent , Bounds ) ;
178188
@@ -212,13 +222,23 @@ public override void Render(DrawingContext context)
212222 if ( item . Remotes . Count > 0 )
213223 {
214224 var rx = x + 20 + item . Label . WidthIncludingTrailingWhitespace + 4 ;
215- foreach ( var remote in item . Remotes )
225+
226+ if ( hasSingleRemote )
216227 {
217228 context . DrawLine ( new Pen ( item . Brush ) , new Point ( rx , y ) , new Point ( rx , y + 16 ) ) ;
218229 using ( context . PushTransform ( Matrix . CreateTranslation ( rx + 4 , y + 4 ) ) )
219230 context . DrawGeometry ( fg , null , remoteIcon ) ;
220- context . DrawText ( remote , new Point ( rx + 16 , y + 8.0 - remote . Height * 0.5 ) ) ;
221- rx += remote . WidthIncludingTrailingWhitespace + 22 ;
231+ }
232+ else
233+ {
234+ foreach ( var remote in item . Remotes )
235+ {
236+ context . DrawLine ( new Pen ( item . Brush ) , new Point ( rx , y ) , new Point ( rx , y + 16 ) ) ;
237+ using ( context . PushTransform ( Matrix . CreateTranslation ( rx + 4 , y + 4 ) ) )
238+ context . DrawGeometry ( fg , null , remoteIcon ) ;
239+ context . DrawText ( remote , new Point ( rx + 16 , y + 8.0 - remote . Height * 0.5 ) ) ;
240+ rx += remote . WidthIncludingTrailingWhitespace + 22 ;
241+ }
222242 }
223243 }
224244
@@ -241,6 +261,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
241261 change . Property == ForegroundProperty ||
242262 change . Property == UseGraphColorProperty ||
243263 change . Property == UseCompactBranchNamesProperty ||
264+ change . Property == HasSingleRemoteProperty ||
244265 change . Property == BackgroundProperty ||
245266 change . Property == ShowTagsProperty )
246267 InvalidateMeasure ( ) ;
@@ -268,6 +289,7 @@ protected override Size MeasureOverride(Size availableSize)
268289 }
269290
270291 var useCompactBranchNames = UseCompactBranchNames ;
292+ var hasSingleRemote = HasSingleRemote ;
271293 var typeface = new Typeface ( FontFamily ) ;
272294 var typefaceHead = new Typeface ( FontFamily , FontStyle . Normal , FontWeight . Bold ) ;
273295 var typefaceRemote = new Typeface ( FontFamily , FontStyle . Italic , FontWeight . Bold ) ;
@@ -345,7 +367,12 @@ protected override Size MeasureOverride(Size availableSize)
345367 fg ) ;
346368
347369 item . Remotes . Add ( remote ) ;
348- item . Width += remote . WidthIncludingTrailingWhitespace + 22 ;
370+
371+ if ( hasSingleRemote )
372+ item . Width += 18 ;
373+ else
374+ item . Width += remote . WidthIncludingTrailingWhitespace + 22 ;
375+
349376 skippedIdx . Add ( j ) ;
350377 }
351378 }
0 commit comments