diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index e322e3adc0b1..bf5a504aba1a 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -506,6 +506,9 @@ Default text [Color] of the item. + + Text [Color] for a [constant TreeItem.CELL_MODE_CHECK] mode cell when it's non-editable (see [method TreeItem.set_editable]). + The tint of text outline of the item. @@ -619,16 +622,25 @@ The arrow icon used when a foldable item is collapsed (for right-to-left layouts). - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked. + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked and editable (see [method TreeItem.set_editable]). + + + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked and non-editable (see [method TreeItem.set_editable]). - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate. + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate and editable (see [method TreeItem.set_editable]). + + + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate and non-editable (see [method TreeItem.set_editable]). The arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked. + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked and editable (see [method TreeItem.set_editable]). + + + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked and non-editable (see [method TreeItem.set_editable]). The updown arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 96d2abf20288..ef68554a3daa 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1423,8 +1423,11 @@ Ref create_editor_theme(const Ref p_theme) { // Tree theme->set_icon("checked", "Tree", theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons))); + theme->set_icon("checked_disabled", "Tree", theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons))); theme->set_icon("indeterminate", "Tree", theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons))); + theme->set_icon("indeterminate_disabled", "Tree", theme->get_icon(SNAME("GuiIndeterminateDisabled"), EditorStringName(EditorIcons))); theme->set_icon("unchecked", "Tree", theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons))); + theme->set_icon("unchecked_disabled", "Tree", theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons))); theme->set_icon("arrow", "Tree", theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons))); theme->set_icon("arrow_collapsed", "Tree", theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons))); theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons))); @@ -1437,6 +1440,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("custom_button_font_highlight", "Tree", font_hover_color); theme->set_color("font_color", "Tree", font_color); theme->set_color("font_selected_color", "Tree", mono_color); + theme->set_color("font_disabled_color", "Tree", font_disabled_color); theme->set_color("font_outline_color", "Tree", font_outline_color); theme->set_color("title_button_color", "Tree", font_color); theme->set_color("drop_position_color", "Tree", accent_color); diff --git a/editor/icons/GuiIndeterminateDisabled.svg b/editor/icons/GuiIndeterminateDisabled.svg new file mode 100644 index 000000000000..edaf69f7a1cd --- /dev/null +++ b/editor/icons/GuiIndeterminateDisabled.svg @@ -0,0 +1 @@ + diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 8a243fd68f23..18ee39aeec70 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2195,27 +2195,38 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color); } break; case TreeItem::CELL_MODE_CHECK: { - Ref checked = theme_cache.checked; - Ref unchecked = theme_cache.unchecked; - Ref indeterminate = theme_cache.indeterminate; Point2i check_ofs = item_rect.position; - check_ofs.y += Math::floor((real_t)(item_rect.size.y - checked->get_height()) / 2); + check_ofs.y += Math::floor((real_t)(item_rect.size.y - theme_cache.checked->get_height()) / 2); - if (p_item->cells[i].indeterminate) { - indeterminate->draw(ci, check_ofs); - } else if (p_item->cells[i].checked) { - checked->draw(ci, check_ofs); + if (p_item->cells[i].editable) { + if (p_item->cells[i].indeterminate) { + theme_cache.indeterminate->draw(ci, check_ofs); + } else if (p_item->cells[i].checked) { + theme_cache.checked->draw(ci, check_ofs); + } else { + theme_cache.unchecked->draw(ci, check_ofs); + } } else { - unchecked->draw(ci, check_ofs); + if (p_item->cells[i].indeterminate) { + theme_cache.indeterminate_disabled->draw(ci, check_ofs); + } else if (p_item->cells[i].checked) { + theme_cache.checked_disabled->draw(ci, check_ofs); + } else { + theme_cache.unchecked_disabled->draw(ci, check_ofs); + } } - int check_w = checked->get_width() + theme_cache.h_separation; + int check_w = theme_cache.checked->get_width() + theme_cache.h_separation; text_pos.x += check_w; item_rect.size.x -= check_w; item_rect.position.x += check_w; + if (!p_item->cells[i].editable) { + cell_color = theme_cache.font_disabled_color; + } + draw_item_rect(p_item->cells.write[i], item_rect, cell_color, icon_col, outline_size, font_outline_color); } break; @@ -5535,7 +5546,10 @@ void Tree::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, checked); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, unchecked); + BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, checked_disabled); + BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, unchecked_disabled); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, indeterminate); + BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, indeterminate_disabled); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow_collapsed); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow_collapsed_mirrored); @@ -5549,6 +5563,7 @@ void Tree::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_color); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_selected_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_disabled_color); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, drop_position_color); BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, h_separation); BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, Tree, v_separation); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 4a5814c45cb0..2dda408dd758 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -536,7 +536,10 @@ class Tree : public Control { Ref checked; Ref unchecked; + Ref checked_disabled; + Ref unchecked_disabled; Ref indeterminate; + Ref indeterminate_disabled; Ref arrow; Ref arrow_collapsed; Ref arrow_collapsed_mirrored; @@ -545,6 +548,7 @@ class Tree : public Control { Color font_color; Color font_selected_color; + Color font_disabled_color; Color guide_color; Color drop_position_color; Color relationship_line_color; diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index ddec5e826b28..09fb5aba0def 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -773,8 +773,11 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_stylebox("custom_button_hover", "Tree", button_hover); theme->set_icon("checked", "Tree", icons["checked"]); + theme->set_icon("checked_disabled", "Tree", icons["checked_disabled"]); theme->set_icon("unchecked", "Tree", icons["unchecked"]); + theme->set_icon("unchecked_disabled", "Tree", icons["unchecked_disabled"]); theme->set_icon("indeterminate", "Tree", icons["indeterminate"]); + theme->set_icon("indeterminate_disabled", "Tree", icons["indeterminate_disabled"]); theme->set_icon("updown", "Tree", icons["updown"]); theme->set_icon("select_arrow", "Tree", icons["option_button_arrow"]); theme->set_icon("arrow", "Tree", icons["arrow_down"]); @@ -789,6 +792,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_color("title_button_color", "Tree", control_font_color); theme->set_color("font_color", "Tree", control_font_low_color); theme->set_color("font_selected_color", "Tree", control_font_pressed_color); + theme->set_color("font_disabled_color", "Tree", control_font_disabled_color); theme->set_color("font_outline_color", "Tree", Color(1, 1, 1)); theme->set_color("guide_color", "Tree", Color(0.7, 0.7, 0.7, 0.25)); theme->set_color("drop_position_color", "Tree", Color(1, 1, 1)); diff --git a/scene/theme/icons/indeterminate.svg b/scene/theme/icons/indeterminate.svg index 2a742e14753e..e6e8dec5edfd 100644 --- a/scene/theme/icons/indeterminate.svg +++ b/scene/theme/icons/indeterminate.svg @@ -1 +1 @@ - + diff --git a/scene/theme/icons/indeterminate_disabled.svg b/scene/theme/icons/indeterminate_disabled.svg new file mode 100644 index 000000000000..f238f6f31c16 --- /dev/null +++ b/scene/theme/icons/indeterminate_disabled.svg @@ -0,0 +1 @@ +