@@ -8,13 +8,17 @@ namespace TrafficManager.UI.Helpers {
88 using ColossalFramework . UI ;
99
1010 public sealed class ExtUITabstrip : UITabstrip {
11+
12+ public const float V_SCROLLBAR_WIDTH = 18f ;
13+ public const float TAB_STRIP_HEIGHT = 40f ;
14+
1115 private UIScrollbar CreateVerticalScrollbar ( UIPanel panel , UIScrollablePanel scrollablePanel ) {
1216 UIScrollbar verticalScrollbar = panel . AddUIComponent < UIScrollbar > ( ) ;
1317 verticalScrollbar . name = "VerticalScrollbar" ;
14- verticalScrollbar . width = 20f ;
18+ verticalScrollbar . width = V_SCROLLBAR_WIDTH ;
1519 verticalScrollbar . height = tabPages . height ;
1620 verticalScrollbar . orientation = UIOrientation . Vertical ;
17- verticalScrollbar . pivot = UIPivotPoint . TopRight ;
21+ verticalScrollbar . pivot = UIPivotPoint . TopLeft ;
1822 verticalScrollbar . AlignTo ( panel , UIAlignAnchor . TopRight ) ;
1923 verticalScrollbar . minValue = 0 ;
2024 verticalScrollbar . value = 0 ;
@@ -33,7 +37,7 @@ private UIScrollbar CreateVerticalScrollbar(UIPanel panel, UIScrollablePanel scr
3337 thumbSprite . relativePosition = Vector2 . zero ;
3438 thumbSprite . fillDirection = UIFillDirection . Vertical ;
3539 thumbSprite . autoSize = true ;
36- thumbSprite . width = thumbSprite . parent . width - 8 ;
40+ thumbSprite . width = thumbSprite . parent . width ;
3741 thumbSprite . spriteName = "ScrollbarThumb" ;
3842 verticalScrollbar . thumbObject = thumbSprite ;
3943
@@ -63,7 +67,7 @@ private UIScrollablePanel CreateScrollablePanel(UIPanel panel) {
6367 scrollablePanel . autoLayoutPadding = new RectOffset ( 10 , 10 , 0 , 16 ) ;
6468 scrollablePanel . autoLayoutStart = LayoutStart . TopLeft ;
6569 scrollablePanel . wrapLayout = true ;
66- scrollablePanel . size = new Vector2 ( panel . size . x - 50 , panel . size . y + 35 ) ;
70+ scrollablePanel . size = new Vector2 ( panel . size . x - V_SCROLLBAR_WIDTH , panel . size . y ) ;
6771 scrollablePanel . autoLayoutDirection = LayoutDirection . Horizontal ; //Vertical does not work but why?
6872
6973 UIScrollbar verticalScrollbar = CreateVerticalScrollbar ( panel , scrollablePanel ) ;
@@ -102,17 +106,21 @@ public UIHelper AddTabPage(string name, bool scrollBars=true) {
102106
103107 public static ExtUITabstrip Create ( UIHelperBase helperBase ) {
104108 UIHelper actualHelper = helperBase as UIHelper ;
105- UIComponent container = actualHelper . self as UIComponent ;
109+ UIComponent optionsContainer = actualHelper . self as UIComponent ;
110+ float orgOptsContainerWidth = optionsContainer . height ;
111+ float orgOptsContainerHeight = optionsContainer . width ;
112+
113+ int paddingRight = 10 ; //Options container is Scrollable panel itself(reserves space for scroll - which we don't use)
114+ optionsContainer . size = new Vector2 ( orgOptsContainerWidth + paddingRight , orgOptsContainerHeight ) ;
106115
107- ExtUITabstrip tabStrip = container . AddUIComponent < ExtUITabstrip > ( ) ;
116+ ExtUITabstrip tabStrip = optionsContainer . AddUIComponent < ExtUITabstrip > ( ) ;
108117 tabStrip . relativePosition = new Vector3 ( 0 , 0 ) ;
109- tabStrip . size = new Vector2 ( container . width - 20 , 40 ) ;
118+ tabStrip . size = new Vector2 ( orgOptsContainerWidth , TAB_STRIP_HEIGHT ) ;
110119
111- float h = container . height - tabStrip . height * 2 - 40 ;
112- UITabContainer tabContainer = container . AddUIComponent < UITabContainer > ( ) ;
113- tabContainer . relativePosition = new Vector3 ( 0 , 80 ) ;
114- tabContainer . width = tabStrip . width ;
115- tabContainer . height = h ;
120+ UITabContainer tabContainer = optionsContainer . AddUIComponent < UITabContainer > ( ) ;
121+ tabContainer . relativePosition = new Vector3 ( 0 , TAB_STRIP_HEIGHT ) ;
122+ tabContainer . width = ( orgOptsContainerWidth + paddingRight ) - V_SCROLLBAR_WIDTH ;
123+ tabContainer . height = optionsContainer . height - ( TAB_STRIP_HEIGHT - /*padding-top*/ 10 - /*margin-top*/ 10 ) ;
116124 tabStrip . tabPages = tabContainer ;
117125
118126 return tabStrip ;
0 commit comments