mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Add icon color theme items for TabBar and TabContainer
This commit is contained in:
parent
6d33ad2917
commit
8973c91293
8 changed files with 81 additions and 10 deletions
|
|
@ -522,20 +522,24 @@ void TabBar::_notification(int p_what) {
|
|||
|
||||
if (i != current) {
|
||||
Ref<StyleBox> sb;
|
||||
Color col;
|
||||
Color fnt_col;
|
||||
Color icn_col;
|
||||
|
||||
if (tabs[i].disabled) {
|
||||
sb = theme_cache.tab_disabled_style;
|
||||
col = theme_cache.font_disabled_color;
|
||||
fnt_col = theme_cache.font_disabled_color;
|
||||
icn_col = theme_cache.icon_disabled_color;
|
||||
} else if (i == hover) {
|
||||
sb = theme_cache.tab_hovered_style;
|
||||
col = theme_cache.font_hovered_color;
|
||||
fnt_col = theme_cache.font_hovered_color;
|
||||
icn_col = theme_cache.icon_hovered_color;
|
||||
} else {
|
||||
sb = theme_cache.tab_unselected_style;
|
||||
col = theme_cache.font_unselected_color;
|
||||
fnt_col = theme_cache.font_unselected_color;
|
||||
icn_col = theme_cache.icon_unselected_color;
|
||||
}
|
||||
|
||||
_draw_tab(sb, col, i, rtl ? (size.width - tabs[i].ofs_cache - tabs[i].size_cache) : tabs[i].ofs_cache, false);
|
||||
_draw_tab(sb, fnt_col, icn_col, i, rtl ? (size.width - tabs[i].ofs_cache - tabs[i].size_cache) : tabs[i].ofs_cache, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +547,7 @@ void TabBar::_notification(int p_what) {
|
|||
if (current >= offset && current <= max_drawn_tab && !tabs[current].hidden) {
|
||||
Ref<StyleBox> sb = tabs[current].disabled ? theme_cache.tab_disabled_style : theme_cache.tab_selected_style;
|
||||
|
||||
_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));
|
||||
_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));
|
||||
}
|
||||
|
||||
if (buttons_visible) {
|
||||
|
|
@ -625,7 +629,7 @@ void TabBar::_draw_tab_drop(RID p_canvas_item) {
|
|||
theme_cache.drop_mark_icon->draw(p_canvas_item, Point2(x - theme_cache.drop_mark_icon->get_width() / 2, (size.height - theme_cache.drop_mark_icon->get_height()) / 2), theme_cache.drop_mark_color);
|
||||
}
|
||||
|
||||
void TabBar::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x, bool p_focus) {
|
||||
void TabBar::_draw_tab(Ref<StyleBox> &p_tab_style, const Color &p_font_color, const Color &p_icon_color, int p_index, float p_x, bool p_focus) {
|
||||
RID ci = get_canvas_item();
|
||||
bool rtl = is_layout_rtl();
|
||||
|
||||
|
|
@ -651,7 +655,7 @@ void TabBar::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_in
|
|||
if (icon.is_valid()) {
|
||||
const Size2 icon_size = _get_tab_icon_size(p_index);
|
||||
const Point2 icon_pos = Point2i(rtl ? p_x - icon_size.width : p_x, p_tab_style->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - icon_size.height) / 2);
|
||||
icon->draw_rect(ci, Rect2(icon_pos, icon_size));
|
||||
icon->draw_rect(ci, Rect2(icon_pos, icon_size), false, p_icon_color);
|
||||
|
||||
p_x = rtl ? p_x - icon_size.width - theme_cache.h_separation : p_x + icon_size.width + theme_cache.h_separation;
|
||||
}
|
||||
|
|
@ -2081,6 +2085,11 @@ void TabBar::_bind_methods() {
|
|||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, font_disabled_color);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, font_outline_color);
|
||||
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, icon_selected_color);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, icon_hovered_color);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, icon_unselected_color);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TabBar, icon_disabled_color);
|
||||
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_FONT, TabBar, font);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_FONT_SIZE, TabBar, font_size);
|
||||
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TabBar, outline_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue