@@ -5,8 +5,8 @@ namespace Terminal.Gui.Views;
5
5
internal class TabRow : View
6
6
{
7
7
private readonly TabView _host ;
8
- private readonly View _leftScrollIndicator ;
9
- private readonly View _rightScrollIndicator ;
8
+ private readonly View _leftUpScrollIndicator ;
9
+ private readonly View _rightDownScrollIndicator ;
10
10
11
11
public TabRow ( TabView host )
12
12
{
@@ -18,27 +18,25 @@ public TabRow (TabView host)
18
18
TabStop = TabBehavior . TabGroup ;
19
19
Width = Dim . Fill ( ) ;
20
20
21
- _rightScrollIndicator = new View
21
+ _rightDownScrollIndicator = new View
22
22
{
23
- Id = "rightScrollIndicator " ,
23
+ Id = "rightDownScrollIndicator " ,
24
24
Width = 1 ,
25
25
Height = 1 ,
26
- Visible = false ,
27
- Text = Glyphs . RightArrow . ToString ( )
26
+ Visible = false
28
27
} ;
29
- _rightScrollIndicator . MouseClick += _host . Tab_MouseClick ! ;
28
+ _rightDownScrollIndicator . MouseClick += _host . Tab_MouseClick ! ;
30
29
31
- _leftScrollIndicator = new View
30
+ _leftUpScrollIndicator = new View
32
31
{
33
- Id = "leftScrollIndicator " ,
32
+ Id = "leftUpScrollIndicator " ,
34
33
Width = 1 ,
35
34
Height = 1 ,
36
- Visible = false ,
37
- Text = Glyphs . LeftArrow . ToString ( )
35
+ Visible = false
38
36
} ;
39
- _leftScrollIndicator . MouseClick += _host . Tab_MouseClick ! ;
37
+ _leftUpScrollIndicator . MouseClick += _host . Tab_MouseClick ! ;
40
38
41
- Add ( _rightScrollIndicator , _leftScrollIndicator ) ;
39
+ Add ( _rightDownScrollIndicator , _leftUpScrollIndicator ) ;
42
40
}
43
41
44
42
/// <inheritdoc />
@@ -84,11 +82,11 @@ protected override bool OnMouseEvent (MouseEventArgs me)
84
82
{
85
83
var scrollIndicatorHit = 0 ;
86
84
87
- if ( me . View is { Id : "rightScrollIndicator " } || me . Flags . HasFlag ( MouseFlags . WheeledDown ) || me . Flags . HasFlag ( MouseFlags . WheeledRight ) )
85
+ if ( me . View is { Id : "rightDownScrollIndicator " } || me . Flags . HasFlag ( MouseFlags . WheeledDown ) || me . Flags . HasFlag ( MouseFlags . WheeledRight ) )
88
86
{
89
87
scrollIndicatorHit = 1 ;
90
88
}
91
- else if ( me . View is { Id : "leftScrollIndicator " } || me . Flags . HasFlag ( MouseFlags . WheeledUp ) || me . Flags . HasFlag ( MouseFlags . WheeledLeft ) )
89
+ else if ( me . View is { Id : "leftUpScrollIndicator " } || me . Flags . HasFlag ( MouseFlags . WheeledUp ) || me . Flags . HasFlag ( MouseFlags . WheeledLeft ) )
92
90
{
93
91
scrollIndicatorHit = - 1 ;
94
92
}
@@ -672,7 +670,7 @@ private void RenderTabLineCanvas ()
672
670
int lineLength = tabsBarVts . Right - vts . Right ;
673
671
674
672
// Right horizontal line
675
- if ( ShouldDrawRightScrollIndicator ( ) )
673
+ if ( ShouldDrawRightDownScrollIndicator ( ) )
676
674
{
677
675
if ( lineLength - arrowOffset > 0 )
678
676
{
@@ -784,20 +782,30 @@ private void RenderTabLineCanvas ()
784
782
LineCanvas . Merge ( lc ) ;
785
783
}
786
784
787
- private int GetUnderlineYPosition ( )
785
+ private int GetUnderlineXOrYPosition ( )
788
786
{
789
- if ( _host . Style . TabsSide == TabSide . Bottom )
787
+ switch ( _host . Style . TabsSide )
790
788
{
791
- return 0 ;
792
- }
789
+ case TabSide . Top :
790
+
791
+ return _host . Style . ShowInitialLine ? 2 : 1 ;
792
+ case TabSide . Bottom :
793
+
794
+ return 0 ;
795
+ case TabSide . Left :
793
796
794
- return _host . Style . ShowInitialLine ? 2 : 1 ;
797
+ return _host . Style . ShowInitialLine ? Frame . Right - 1 : Frame . Right ;
798
+ case TabSide . Right :
799
+ return 0 ;
800
+ default :
801
+ throw new ArgumentOutOfRangeException ( ) ;
802
+ }
795
803
}
796
804
797
805
/// <summary>Renders the line of the tab that adjoins the content of the tab.</summary>
798
806
private void RenderUnderline ( )
799
807
{
800
- int y = GetUnderlineYPosition ( ) ;
808
+ int xOrY = GetUnderlineXOrYPosition ( ) ;
801
809
802
810
Tab ? selected = _host . _tabLocations ? . FirstOrDefault ( t => t == _host . SelectedTab ) ;
803
811
@@ -806,42 +814,91 @@ private void RenderUnderline ()
806
814
return ;
807
815
}
808
816
809
- // draw scroll indicators
817
+ // Set the correct glyphs for scroll indicators
818
+ switch ( _host . Style . TabsSide )
819
+ {
820
+ case TabSide . Top :
821
+ case TabSide . Bottom :
822
+ _rightDownScrollIndicator . Text = Glyphs . RightArrow . ToString ( ) ;
823
+ _leftUpScrollIndicator . Text = Glyphs . LeftArrow . ToString ( ) ;
824
+
825
+ break ;
826
+ case TabSide . Left :
827
+ case TabSide . Right :
828
+ _rightDownScrollIndicator . Text = Glyphs . DownArrow . ToString ( ) ;
829
+ _leftUpScrollIndicator . Text = Glyphs . UpArrow . ToString ( ) ;
830
+
831
+ break ;
832
+ default :
833
+ throw new ArgumentOutOfRangeException ( ) ;
834
+ }
835
+
836
+ // position scroll indicators
810
837
811
838
// if there are more tabs to the left not visible
812
839
if ( _host . TabScrollOffset > 0 )
813
840
{
814
- _leftScrollIndicator . X = 0 ;
815
- _leftScrollIndicator . Y = y ;
841
+ switch ( _host . Style . TabsSide )
842
+ {
843
+ case TabSide . Top :
844
+ case TabSide . Bottom :
845
+ _leftUpScrollIndicator . X = 0 ;
846
+ _leftUpScrollIndicator . Y = xOrY ;
847
+
848
+ break ;
849
+ case TabSide . Left :
850
+ case TabSide . Right :
851
+ _leftUpScrollIndicator . X = xOrY ;
852
+ _leftUpScrollIndicator . Y = 0 ;
853
+
854
+ break ;
855
+ default :
856
+ throw new ArgumentOutOfRangeException ( ) ;
857
+ }
816
858
817
859
// indicate that
818
- _leftScrollIndicator . Visible = true ;
860
+ _leftUpScrollIndicator . Visible = true ;
819
861
820
862
// Ensures this is clicked instead of the first tab
821
- MoveSubViewToEnd ( _leftScrollIndicator ) ;
863
+ MoveSubViewToEnd ( _leftUpScrollIndicator ) ;
822
864
}
823
865
else
824
866
{
825
- _leftScrollIndicator . Visible = false ;
867
+ _leftUpScrollIndicator . Visible = false ;
826
868
}
827
869
828
870
// if there are more tabs to the right not visible
829
- if ( ShouldDrawRightScrollIndicator ( ) )
871
+ if ( ShouldDrawRightDownScrollIndicator ( ) )
830
872
{
831
- _rightScrollIndicator . X = Viewport . Width - 1 ;
832
- _rightScrollIndicator . Y = y ;
873
+ switch ( _host . Style . TabsSide )
874
+ {
875
+ case TabSide . Top :
876
+ case TabSide . Bottom :
877
+ _rightDownScrollIndicator . X = Viewport . Width - 1 ;
878
+ _rightDownScrollIndicator . Y = xOrY ;
879
+
880
+ break ;
881
+ case TabSide . Left :
882
+ case TabSide . Right :
883
+ _rightDownScrollIndicator . X = xOrY ;
884
+ _rightDownScrollIndicator . Y = Viewport . Height - 1 ;
885
+
886
+ break ;
887
+ default :
888
+ throw new ArgumentOutOfRangeException ( ) ;
889
+ }
833
890
834
891
// indicate that
835
- _rightScrollIndicator . Visible = true ;
892
+ _rightDownScrollIndicator . Visible = true ;
836
893
837
894
// Ensures this is clicked instead of the last tab if under this
838
- MoveSubViewToStart ( _rightScrollIndicator ) ;
895
+ MoveSubViewToStart ( _rightDownScrollIndicator ) ;
839
896
}
840
897
else
841
898
{
842
- _rightScrollIndicator . Visible = false ;
899
+ _rightDownScrollIndicator . Visible = false ;
843
900
}
844
901
}
845
902
846
- private bool ShouldDrawRightScrollIndicator ( ) { return _host . _tabLocations ! . LastOrDefault ( ) != _host . Tabs . LastOrDefault ( ) ; }
903
+ private bool ShouldDrawRightDownScrollIndicator ( ) { return _host . _tabLocations ! . LastOrDefault ( ) != _host . Tabs . LastOrDefault ( ) ; }
847
904
}
0 commit comments