@@ -521,13 +521,13 @@ void TabBar::_notification(int p_what) {
521521
522522 if (tabs[i].disabled ) {
523523 sb = theme_cache.tab_disabled_style ;
524- col = theme_cache.font_disabled_color ;
524+ 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 ;
525525 } else if (i == hover) {
526526 sb = theme_cache.tab_hovered_style ;
527- col = theme_cache.font_hovered_color ;
527+ 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 ;
528528 } else {
529529 sb = theme_cache.tab_unselected_style ;
530- col = theme_cache.font_unselected_color ;
530+ 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 ;
531531 }
532532
533533 _draw_tab (sb, col, i, rtl ? (size.width - tabs[i].ofs_cache - tabs[i].size_cache ) : tabs[i].ofs_cache , false );
@@ -537,8 +537,9 @@ void TabBar::_notification(int p_what) {
537537 // Draw selected tab in the front, but only if it's visible.
538538 if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden ) {
539539 Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style ;
540+ 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 ;
540541
541- _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 ());
542+ _draw_tab (sb, col , current, rtl ? (size.width - tabs[current].ofs_cache - tabs[current].size_cache ) : tabs[current].ofs_cache , has_focus ());
542543 }
543544
544545 if (buttons_visible) {
@@ -994,6 +995,36 @@ int TabBar::get_tab_icon_max_width(int p_tab) const {
994995 return tabs[p_tab].icon_max_width ;
995996}
996997
998+ void TabBar::set_font_color_override_all (int p_tab, Color p_color) {
999+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1000+
1001+ for (int i = 0 ; i < BaseButton::DrawMode::DRAW_HOVER_PRESSED; i++) {
1002+ tabs.write [p_tab].font_color_overrides [i] = p_color;
1003+ }
1004+
1005+ queue_redraw ();
1006+ }
1007+
1008+ void TabBar::set_font_color_override (BaseButton::DrawMode p_draw_mode, int p_tab, Color p_color) {
1009+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1010+ ERR_FAIL_INDEX_EDMSG (p_draw_mode, BaseButton::DrawMode::DRAW_HOVER_PRESSED, " TabBar does not support hover_pressed styles." );
1011+
1012+ if (tabs[p_tab].font_color_overrides [p_draw_mode] == p_color) {
1013+ return ;
1014+ }
1015+
1016+ tabs.write [p_tab].font_color_overrides [p_draw_mode] = p_color;
1017+
1018+ queue_redraw ();
1019+ }
1020+
1021+ Color TabBar::get_font_color_override (BaseButton::DrawMode p_draw_mode, int p_tab) const {
1022+ ERR_FAIL_INDEX_V (p_tab, tabs.size (), Color ());
1023+ ERR_FAIL_INDEX_V_EDMSG (p_draw_mode, BaseButton::DrawMode::DRAW_HOVER_PRESSED, Color (), " TabBar does not support hover_pressed styles." );
1024+
1025+ return tabs[p_tab].font_color_overrides [p_draw_mode];
1026+ }
1027+
9971028void TabBar::set_tab_disabled (int p_tab, bool p_disabled) {
9981029 ERR_FAIL_INDEX (p_tab, tabs.size ());
9991030
@@ -1966,6 +1997,9 @@ void TabBar::_bind_methods() {
19661997 ClassDB::bind_method (D_METHOD (" get_tab_icon_max_width" , " tab_idx" ), &TabBar::get_tab_icon_max_width);
19671998 ClassDB::bind_method (D_METHOD (" set_tab_button_icon" , " tab_idx" , " icon" ), &TabBar::set_tab_button_icon);
19681999 ClassDB::bind_method (D_METHOD (" get_tab_button_icon" , " tab_idx" ), &TabBar::get_tab_button_icon);
2000+ ClassDB::bind_method (D_METHOD (" set_font_color_override_all" , " tab_idx" , " color" ), &TabBar::set_font_color_override_all);
2001+ ClassDB::bind_method (D_METHOD (" set_font_color_override" , " draw_mode" , " tab_idx" , " color" ), &TabBar::set_font_color_override);
2002+ ClassDB::bind_method (D_METHOD (" get_font_color_override" , " draw_mode" , " tab_idx" ), &TabBar::get_font_color_override);
19692003 ClassDB::bind_method (D_METHOD (" set_tab_disabled" , " tab_idx" , " disabled" ), &TabBar::set_tab_disabled);
19702004 ClassDB::bind_method (D_METHOD (" is_tab_disabled" , " tab_idx" ), &TabBar::is_tab_disabled);
19712005 ClassDB::bind_method (D_METHOD (" set_tab_hidden" , " tab_idx" , " hidden" ), &TabBar::set_tab_hidden);
0 commit comments