@@ -507,13 +507,8 @@ void TabBar::_notification(int p_what) {
507507
508508 int limit_minus_buttons = size.width - theme_cache.increment_icon ->get_width () - theme_cache.decrement_icon ->get_width ();
509509
510- int ofs = tabs[offset].ofs_cache ;
511- int tab_separation_offset = 0 ;
512-
513510 // Draw unselected tabs in the back.
514511 for (int i = offset; i <= max_drawn_tab; i++) {
515- tab_separation_offset = (i - offset) * theme_cache.tab_separation ;
516-
517512 if (tabs[i].hidden ) {
518513 continue ;
519514 }
@@ -533,23 +528,15 @@ void TabBar::_notification(int p_what) {
533528 col = theme_cache.font_unselected_color ;
534529 }
535530
536- _draw_tab (sb, col, i, rtl ? (size.width - ofs - tab_separation_offset - tabs[i].size_cache ) : (ofs + tab_separation_offset) , false );
531+ _draw_tab (sb, col, i, rtl ? (size.width - tabs[i]. ofs_cache - tabs[i].size_cache ) : tabs[i]. ofs_cache , false );
537532 }
538-
539- ofs += tabs[i].size_cache ;
540533 }
541534
542535 // Draw selected tab in the front, but only if it's visible.
543536 if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden ) {
544- tab_separation_offset = (current - offset) * theme_cache.tab_separation ;
545- if (tab_alignment == ALIGNMENT_LEFT && (current - offset) > 1 ) {
546- tab_separation_offset = theme_cache.tab_separation ;
547- }
548-
549537 Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style ;
550- float x = rtl ? (size.width - tabs[current].ofs_cache - tab_separation_offset - tabs[current].size_cache ) : (tabs[current].ofs_cache + tab_separation_offset);
551538
552- _draw_tab (sb, theme_cache.font_selected_color , current, x , has_focus ());
539+ _draw_tab (sb, theme_cache.font_selected_color , current, rtl ? (size. width - tabs[current]. ofs_cache - tabs[current]. size_cache ) : tabs[current]. ofs_cache , has_focus ());
553540 }
554541
555542 if (buttons_visible) {
@@ -1187,7 +1174,7 @@ void TabBar::_update_cache(bool p_update_hover) {
11871174 }
11881175
11891176 w += tabs[i].size_cache ;
1190- if ((i - offset) > 0 ) {
1177+ if (i < max_drawn_tab ) {
11911178 w += theme_cache.tab_separation ;
11921179 }
11931180
@@ -1196,7 +1183,6 @@ void TabBar::_update_cache(bool p_update_hover) {
11961183 tabs.write [i].ofs_cache = 0 ;
11971184
11981185 w -= tabs[i].size_cache ;
1199- w -= theme_cache.tab_separation ;
12001186
12011187 max_drawn_tab = i - 1 ;
12021188
@@ -1236,6 +1222,7 @@ void TabBar::_update_cache(bool p_update_hover) {
12361222
12371223 if (!tabs[i].hidden ) {
12381224 w += tabs[i].size_cache ;
1225+ w += theme_cache.tab_separation ;
12391226 }
12401227 }
12411228
@@ -1827,14 +1814,11 @@ void TabBar::ensure_tab_visible(int p_idx) {
18271814
18281815Rect2 TabBar::get_tab_rect (int p_tab) const {
18291816 ERR_FAIL_INDEX_V (p_tab, tabs.size (), Rect2 ());
1830- int tab_separation_offset = (p_tab - offset) * theme_cache.tab_separation ;
1831- if (tab_alignment == ALIGNMENT_LEFT && (p_tab - offset) > 1 ) {
1832- tab_separation_offset = theme_cache.tab_separation ;
1833- }
1817+
18341818 if (is_layout_rtl ()) {
1835- return Rect2 (get_size ().width - tabs[p_tab].ofs_cache - tab_separation_offset - tabs[p_tab].size_cache , 0 , tabs[p_tab].size_cache , get_size ().height );
1819+ return Rect2 (get_size ().width - tabs[p_tab].ofs_cache - tabs[p_tab].size_cache , 0 , tabs[p_tab].size_cache , get_size ().height );
18361820 } else {
1837- return Rect2 (tabs[p_tab].ofs_cache + tab_separation_offset , 0 , tabs[p_tab].size_cache , get_size ().height );
1821+ return Rect2 (tabs[p_tab].ofs_cache , 0 , tabs[p_tab].size_cache , get_size ().height );
18381822 }
18391823}
18401824
0 commit comments