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
@@ -526,13 +530,13 @@ void TabBar::_notification(int p_what) {
526530
527531 if (tabs[i].disabled ) {
528532 sb = theme_cache.tab_disabled_style ;
529- col = theme_cache.font_disabled_color ;
533+ col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_DISABLED], theme_cache.font_disabled_color ) ;
530534 } else if (i == hover) {
531535 sb = theme_cache.tab_hovered_style ;
532- col = theme_cache.font_hovered_color ;
536+ col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_HOVER], theme_cache.font_hovered_color ) ;
533537 } else {
534538 sb = theme_cache.tab_unselected_style ;
535- col = theme_cache.font_unselected_color ;
539+ col = _select_color (tabs[i]. font_color_overrides [DrawMode::DRAW_NORMAL], theme_cache.font_unselected_color ) ;
536540 }
537541
538542 _draw_tab (sb, col, i, rtl ? (size.width - tabs[i].ofs_cache - tabs[i].size_cache ) : tabs[i].ofs_cache , false );
@@ -542,8 +546,9 @@ void TabBar::_notification(int p_what) {
542546 // Draw selected tab in the front, but only if it's visible.
543547 if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden ) {
544548 Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style ;
549+ Color col = _select_color (tabs[current].font_color_overrides [DrawMode::DRAW_PRESSED], theme_cache.font_selected_color );
545550
546- _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 (true ));
551+ _draw_tab (sb, col , current, rtl ? (size.width - tabs[current].ofs_cache - tabs[current].size_cache ) : tabs[current].ofs_cache , has_focus (true ));
547552 }
548553
549554 if (buttons_visible) {
@@ -1005,6 +1010,37 @@ int TabBar::get_tab_icon_max_width(int p_tab) const {
10051010 return tabs[p_tab].icon_max_width ;
10061011}
10071012
1013+ void TabBar::set_font_color_override_all (int p_tab, const Color &p_color) {
1014+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1015+
1016+ Tab &tab = tabs.write [p_tab];
1017+ for (int i = 0 ; i < DrawMode::DRAW_MAX; i++) {
1018+ tab.font_color_overrides [i] = p_color;
1019+ }
1020+
1021+ queue_redraw ();
1022+ }
1023+
1024+ void TabBar::set_font_color_override (int p_tab, DrawMode p_draw_mode, const Color &p_color) {
1025+ ERR_FAIL_INDEX (p_tab, tabs.size ());
1026+ ERR_FAIL_INDEX (p_draw_mode, DrawMode::DRAW_MAX);
1027+
1028+ if (tabs[p_tab].font_color_overrides [p_draw_mode] == p_color) {
1029+ return ;
1030+ }
1031+
1032+ tabs.write [p_tab].font_color_overrides [p_draw_mode] = p_color;
1033+
1034+ queue_redraw ();
1035+ }
1036+
1037+ Color TabBar::get_font_color_override (int p_tab, DrawMode p_draw_mode) const {
1038+ ERR_FAIL_INDEX_V (p_tab, tabs.size (), Color ());
1039+ ERR_FAIL_INDEX_V (p_draw_mode, DrawMode::DRAW_MAX, Color ());
1040+
1041+ return tabs[p_tab].font_color_overrides [p_draw_mode];
1042+ }
1043+
10081044void TabBar::set_tab_disabled (int p_tab, bool p_disabled) {
10091045 ERR_FAIL_INDEX (p_tab, tabs.size ());
10101046
0 commit comments