@@ -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,9 +1174,6 @@ void TabBar::_update_cache(bool p_update_hover) {
11871174 }
11881175
11891176 w += tabs[i].size_cache ;
1190- if ((i - offset) > 0 ) {
1191- w += theme_cache.tab_separation ;
1192- }
11931177
11941178 // Check if all tabs would fit inside the area.
11951179 if (clip_tabs && i > offset && (w > limit || (offset > 0 && w > limit_minus_buttons))) {
@@ -1210,6 +1194,9 @@ void TabBar::_update_cache(bool p_update_hover) {
12101194
12111195 max_drawn_tab--;
12121196 }
1197+ } else {
1198+ // Only add the tab separation if this isn't the last tab drawn.
1199+ w += theme_cache.tab_separation ;
12131200 }
12141201
12151202 tabs.write [i].accessibility_item_dirty = true ;
@@ -1236,6 +1223,7 @@ void TabBar::_update_cache(bool p_update_hover) {
12361223
12371224 if (!tabs[i].hidden ) {
12381225 w += tabs[i].size_cache ;
1226+ w += theme_cache.tab_separation ;
12391227 }
12401228 }
12411229
@@ -1827,14 +1815,11 @@ void TabBar::ensure_tab_visible(int p_idx) {
18271815
18281816Rect2 TabBar::get_tab_rect (int p_tab) const {
18291817 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- }
1818+
18341819 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 );
1820+ return Rect2 (get_size ().width - tabs[p_tab].ofs_cache - tabs[p_tab].size_cache , 0 , tabs[p_tab].size_cache , get_size ().height );
18361821 } else {
1837- return Rect2 (tabs[p_tab].ofs_cache + tab_separation_offset , 0 , tabs[p_tab].size_cache , get_size ().height );
1822+ return Rect2 (tabs[p_tab].ofs_cache , 0 , tabs[p_tab].size_cache , get_size ().height );
18381823 }
18391824}
18401825
0 commit comments