44using Avalonia . Controls ;
55using Avalonia . Input ;
66using Avalonia . Interactivity ;
7+ using Avalonia . Media ;
78
89namespace SourceGit . Views
910{
@@ -14,6 +15,98 @@ public LauncherTabBar()
1415 InitializeComponent ( ) ;
1516 }
1617
18+ public override void Render ( DrawingContext context )
19+ {
20+ base . Render ( context ) ;
21+
22+ if ( LauncherTabsList == null || LauncherTabsList . SelectedIndex == - 1 )
23+ return ;
24+
25+ var startX = LauncherTabsScroller . Offset . X ;
26+ var endX = startX + LauncherTabsScroller . Viewport . Width ;
27+ var height = LauncherTabsScroller . Viewport . Height ;
28+
29+ var selectedIdx = LauncherTabsList . SelectedIndex ;
30+ var count = LauncherTabsList . ItemCount ;
31+ var separatorPen = new Pen ( this . FindResource ( "Brush.FG2" ) as IBrush , 0.5 ) ;
32+ var separatorY = ( height - 20 ) * 0.5 ;
33+ for ( var i = 0 ; i < count ; i ++ )
34+ {
35+ if ( i == selectedIdx || i == selectedIdx - 1 )
36+ continue ;
37+
38+ var container = LauncherTabsList . ContainerFromIndex ( i ) ;
39+ var containerEndX = container . Bounds . Right ;
40+ if ( containerEndX < startX || containerEndX > endX )
41+ continue ;
42+
43+ var separatorX = containerEndX - startX + LauncherTabsScroller . Bounds . X ;
44+ context . DrawLine ( separatorPen , new Point ( separatorX , separatorY ) , new Point ( separatorX , separatorY + 20 ) ) ;
45+ }
46+
47+ var selected = LauncherTabsList . ContainerFromIndex ( selectedIdx ) ;
48+ var activeStartX = selected . Bounds . X ;
49+ var activeEndX = activeStartX + selected . Bounds . Width ;
50+ if ( activeStartX > endX + 6 || activeEndX < startX - 6 )
51+ return ;
52+
53+ var geo = new StreamGeometry ( ) ;
54+ var angle = Math . PI / 2 ;
55+ var x = 0.0 ;
56+ var y = height + 0.5 ;
57+ using ( var ctx = geo . Open ( ) )
58+ {
59+ var drawLeftX = activeStartX - startX + LauncherTabsScroller . Bounds . X ;
60+ var drawRightX = activeEndX - startX + LauncherTabsScroller . Bounds . X ;
61+ if ( drawLeftX < LauncherTabsScroller . Bounds . X )
62+ {
63+ x = LauncherTabsScroller . Bounds . X ;
64+ ctx . BeginFigure ( new Point ( x , y ) , true ) ;
65+ y = 0 ;
66+ ctx . LineTo ( new Point ( x , y ) ) ;
67+ x = drawRightX - 6 ;
68+ }
69+ else
70+ {
71+ x = drawLeftX - 6 ;
72+ ctx . BeginFigure ( new Point ( x , y ) , true ) ;
73+ x = drawLeftX ;
74+ y -= 6 ;
75+ ctx . ArcTo ( new Point ( x , y ) , new Size ( 6.5 , 6.5 ) , angle , false , SweepDirection . CounterClockwise ) ;
76+ y = 6 ;
77+ ctx . LineTo ( new Point ( x , y ) ) ;
78+ x += 6 ;
79+ y = 0 ;
80+ ctx . ArcTo ( new Point ( x , y ) , new Size ( 6 , 6 ) , angle , false , SweepDirection . Clockwise ) ;
81+ x = drawRightX - 6 ;
82+ }
83+
84+ if ( drawRightX < LauncherTabsScroller . Bounds . Right )
85+ {
86+ ctx . LineTo ( new Point ( x , y ) ) ;
87+ x = drawRightX ;
88+ y = 6 ;
89+ ctx . ArcTo ( new Point ( x , y ) , new Size ( 6 , 6 ) , angle , false , SweepDirection . Clockwise ) ;
90+ y = height - 6 ;
91+ ctx . LineTo ( new Point ( x , y ) ) ;
92+ x += 6 ;
93+ y = height + 0.5 ;
94+ ctx . ArcTo ( new Point ( x , y ) , new Size ( 6.5 , 6.5 ) , angle , false , SweepDirection . CounterClockwise ) ;
95+ }
96+ else
97+ {
98+ x = LauncherTabsScroller . Bounds . Right ;
99+ ctx . LineTo ( new Point ( x , y ) ) ;
100+ y = height + 0.5 ;
101+ ctx . LineTo ( new Point ( x , y ) ) ;
102+ }
103+ }
104+
105+ var fill = this . FindResource ( "Brush.ToolBar" ) as IBrush ;
106+ var stroke = new Pen ( this . FindResource ( "Brush.Border0" ) as IBrush , 1 ) ;
107+ context . DrawGeometry ( fill , stroke , geo ) ;
108+ }
109+
17110 private void ScrollTabs ( object sender , PointerWheelEventArgs e )
18111 {
19112 if ( ! e . KeyModifiers . HasFlag ( KeyModifiers . Shift ) )
@@ -52,6 +145,13 @@ private void OnTabsLayoutUpdated(object sender, EventArgs e)
52145 LeftScrollIndicator . IsVisible = false ;
53146 RightScrollIndicator . IsVisible = false ;
54147 }
148+
149+ InvalidateVisual ( ) ;
150+ }
151+
152+ private void OnTabsSelectionChanged ( object sender , SelectionChangedEventArgs e )
153+ {
154+ InvalidateVisual ( ) ;
55155 }
56156
57157 private void SetupDragAndDrop ( object sender , RoutedEventArgs e )
0 commit comments