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