3636#include " scene/main/viewport.h"
3737#include " scene/theme/theme_db.h"
3838
39+ static inline Color _select_color (const Color &p_override_color, const Color &p_default_color) {
40+ return p_override_color.a > 0 ? p_override_color : p_default_color;
41+ }
42+
3943Size2 TabBar::get_minimum_size () const {
4044 Size2 ms;
4145
@@ -527,15 +531,15 @@ void TabBar::_notification(int p_what) {
527531
528532 if (tabs[i].disabled ) {
529533 sb = theme_cache.tab_disabled_style ;
530- fnt_col = theme_cache.font_disabled_color ;
534+ fnt_col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_DISABLED], theme_cache.font_disabled_color ) ;
531535 icn_col = theme_cache.icon_disabled_color ;
532536 } else if (i == hover) {
533537 sb = theme_cache.tab_hovered_style ;
534- fnt_col = theme_cache.font_hovered_color ;
538+ fnt_col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_HOVER], theme_cache.font_hovered_color ) ;
535539 icn_col = theme_cache.icon_hovered_color ;
536540 } else {
537541 sb = theme_cache.tab_unselected_style ;
538- fnt_col = theme_cache.font_unselected_color ;
542+ fnt_col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_NORMAL], theme_cache.font_unselected_color ) ;
539543 icn_col = theme_cache.icon_unselected_color ;
540544 }
541545
@@ -546,8 +550,9 @@ void TabBar::_notification(int p_what) {
546550 // Draw selected tab in the front, but only if it's visible.
547551 if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden ) {
548552 Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style ;
553+ Color col = _select_color (tabs[current].font_color_overrides [DrawMode::DRAW_PRESSED], theme_cache.font_selected_color );
549554
550- _draw_tab (sb, theme_cache. font_selected_color , theme_cache.icon_selected_color , current, rtl ? (size.width - tabs[current].ofs_cache - tabs[current].size_cache ) : tabs[current].ofs_cache , has_focus (true ));
555+ _draw_tab (sb, col , theme_cache.icon_selected_color , current, rtl ? (size.width - tabs[current].ofs_cache - tabs[current].size_cache ) : tabs[current].ofs_cache , has_focus (true ));
551556 }
552557
553558 if (buttons_visible) {
@@ -1009,6 +1014,37 @@ int TabBar::get_tab_icon_max_width(int p_tab) const {
10091014 return tabs[p_tab].icon_max_width ;
10101015}
10111016
1017+ void TabBar::set_font_color_override_all (int p_tab, const Color &p_color) {
1018+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1019+
1020+ Tab &tab = tabs.write [p_tab];
1021+ for (int i = 0 ; i < DrawMode::DRAW_MAX; i++) {
1022+ tab.font_color_overrides [i] = p_color;
1023+ }
1024+
1025+ queue_redraw ();
1026+ }
1027+
1028+ void TabBar::set_font_color_override (int p_tab, DrawMode p_draw_mode, const Color &p_color) {
1029+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1030+ ERR_FAIL_INDEX (p_draw_mode, DrawMode::DRAW_MAX);
1031+
1032+ if (tabs[p_tab].font_color_overrides [p_draw_mode] == p_color) {
1033+ return ;
1034+ }
1035+
1036+ tabs.write [p_tab].font_color_overrides [p_draw_mode] = p_color;
1037+
1038+ queue_redraw ();
1039+ }
1040+
1041+ Color TabBar::get_font_color_override (int p_tab, DrawMode p_draw_mode) const {
1042+ ERR_FAIL_INDEX_V (p_tab, tabs.size (), Color ());
1043+ ERR_FAIL_INDEX_V (p_draw_mode, DrawMode::DRAW_MAX, Color ());
1044+
1045+ return tabs[p_tab].font_color_overrides [p_draw_mode];
1046+ }
1047+
10121048void TabBar::set_tab_disabled (int p_tab, bool p_disabled) {
10131049 ERR_FAIL_INDEX (p_tab, tabs.size ());
10141050
0 commit comments