@@ -526,13 +526,13 @@ void TabBar::_notification(int p_what) {
526526
527527 if (tabs[i].disabled ) {
528528 sb = theme_cache.tab_disabled_style ;
529- col = theme_cache.font_disabled_color ;
529+ col = tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_DISABLED]. a > 0 ? tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_DISABLED] : theme_cache.font_disabled_color ;
530530 } else if (i == hover) {
531531 sb = theme_cache.tab_hovered_style ;
532- col = theme_cache.font_hovered_color ;
532+ col = tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_HOVER]. a > 0 ? tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_HOVER] : theme_cache.font_hovered_color ;
533533 } else {
534534 sb = theme_cache.tab_unselected_style ;
535- col = theme_cache.font_unselected_color ;
535+ col = tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_NORMAL]. a > 0 ? tabs[i]. font_color_overrides [BaseButton::DrawMode::DRAW_NORMAL] : theme_cache.font_unselected_color ;
536536 }
537537
538538 _draw_tab (sb, col, i, rtl ? (size.width - ofs - tab_separation_offset - tabs[i].size_cache ) : (ofs + tab_separation_offset), false );
@@ -550,8 +550,9 @@ void TabBar::_notification(int p_what) {
550550
551551 Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style ;
552552 float x = rtl ? (size.width - tabs[current].ofs_cache - tab_separation_offset - tabs[current].size_cache ) : (tabs[current].ofs_cache + tab_separation_offset);
553+ Color col = tabs[current].font_color_overrides [BaseButton::DrawMode::DRAW_PRESSED].a > 0 ? tabs[current].font_color_overrides [BaseButton::DrawMode::DRAW_PRESSED] : theme_cache.font_selected_color ;
553554
554- _draw_tab (sb, theme_cache. font_selected_color , current, x, has_focus ());
555+ _draw_tab (sb, col , current, x, has_focus ());
555556 }
556557
557558 if (buttons_visible) {
@@ -1007,6 +1008,36 @@ int TabBar::get_tab_icon_max_width(int p_tab) const {
10071008 return tabs[p_tab].icon_max_width ;
10081009}
10091010
1011+ void TabBar::set_font_color_override_all (int p_tab, Color p_color) {
1012+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1013+
1014+ for (int i = 0 ; i < BaseButton::DrawMode::DRAW_HOVER_PRESSED; i++) {
1015+ tabs.write [p_tab].font_color_overrides [i] = p_color;
1016+ }
1017+
1018+ queue_redraw ();
1019+ }
1020+
1021+ void TabBar::set_font_color_override (BaseButton::DrawMode p_draw_mode, int p_tab, Color p_color) {
1022+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1023+ ERR_FAIL_INDEX_EDMSG (p_draw_mode, BaseButton::DrawMode::DRAW_HOVER_PRESSED, " TabBar does not support hover_pressed styles." );
1024+
1025+ if (tabs[p_tab].font_color_overrides [p_draw_mode] == p_color) {
1026+ return ;
1027+ }
1028+
1029+ tabs.write [p_tab].font_color_overrides [p_draw_mode] = p_color;
1030+
1031+ queue_redraw ();
1032+ }
1033+
1034+ Color TabBar::get_font_color_override (BaseButton::DrawMode p_draw_mode, int p_tab) const {
1035+ ERR_FAIL_INDEX_V (p_tab, tabs.size (), Color ());
1036+ ERR_FAIL_INDEX_V_EDMSG (p_draw_mode, BaseButton::DrawMode::DRAW_HOVER_PRESSED, Color (), " TabBar does not support hover_pressed styles." );
1037+
1038+ return tabs[p_tab].font_color_overrides [p_draw_mode];
1039+ }
1040+
10101041void TabBar::set_tab_disabled (int p_tab, bool p_disabled) {
10111042 ERR_FAIL_INDEX (p_tab, tabs.size ());
10121043
@@ -1971,6 +2002,9 @@ void TabBar::_bind_methods() {
19712002 ClassDB::bind_method (D_METHOD (" get_tab_icon_max_width" , " tab_idx" ), &TabBar::get_tab_icon_max_width);
19722003 ClassDB::bind_method (D_METHOD (" set_tab_button_icon" , " tab_idx" , " icon" ), &TabBar::set_tab_button_icon);
19732004 ClassDB::bind_method (D_METHOD (" get_tab_button_icon" , " tab_idx" ), &TabBar::get_tab_button_icon);
2005+ ClassDB::bind_method (D_METHOD (" set_font_color_override_all" , " tab_idx" , " color" ), &TabBar::set_font_color_override_all);
2006+ ClassDB::bind_method (D_METHOD (" set_font_color_override" , " draw_mode" , " tab_idx" , " color" ), &TabBar::set_font_color_override);
2007+ ClassDB::bind_method (D_METHOD (" get_font_color_override" , " draw_mode" , " tab_idx" ), &TabBar::get_font_color_override);
19742008 ClassDB::bind_method (D_METHOD (" set_tab_disabled" , " tab_idx" , " disabled" ), &TabBar::set_tab_disabled);
19752009 ClassDB::bind_method (D_METHOD (" is_tab_disabled" , " tab_idx" ), &TabBar::is_tab_disabled);
19762010 ClassDB::bind_method (D_METHOD (" set_tab_hidden" , " tab_idx" , " hidden" ), &TabBar::set_tab_hidden);
0 commit comments