diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 9fad1ca9a85..76e5a6fd5e0 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -513,11 +513,14 @@
Text [Color] for a [constant TreeItem.CELL_MODE_CHECK] mode cell when it's non-editable (see [method TreeItem.set_editable]).
- Text [Color] used when the item is hovered.
+ Text [Color] used when the item is hovered and not selected yet.
Text [Color] used when the item is hovered, while a button of the same item is hovered as the same time.
+
+ Text [Color] used when the item is hovered and selected.
+
The tint of text outline of the item.
@@ -679,11 +682,17 @@
The focused style for the [Tree], drawn on top of everything.
- [StyleBox] for the item being hovered.
+ [StyleBox] for the item being hovered, but not selected.
[StyleBox] for the item being hovered, while a button of the same item is hovered as the same time.
+
+ [StyleBox] for the hovered and selected items, used when the [Tree] is not being focused.
+
+
+ [StyleBox] for the hovered and selected items, used when the [Tree] is being focused.
+
The background style for the [Tree].
diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp
index fb7dab8d76e..a050d45f50a 100644
--- a/editor/themes/editor_theme_manager.cpp
+++ b/editor/themes/editor_theme_manager.cpp
@@ -957,6 +957,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref &p_the
p_theme->set_color(SceneStringName(font_color), "Tree", p_config.font_color);
p_theme->set_color("font_hovered_color", "Tree", p_config.mono_color);
p_theme->set_color("font_hovered_dimmed_color", "Tree", p_config.font_color);
+ p_theme->set_color("font_hovered_selected_color", "Tree", p_config.mono_color);
p_theme->set_color("font_selected_color", "Tree", p_config.mono_color);
p_theme->set_color("font_disabled_color", "Tree", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "Tree", p_config.font_outline_color);
@@ -1017,6 +1018,13 @@ void EditorThemeManager::_populate_standard_styles(const Ref &p_the
style_tree_hover_dimmed->set_border_width_all(0);
p_theme->set_stylebox("hovered_dimmed", "Tree", style_tree_hover_dimmed);
+ Ref style_tree_hover_selected = style_tree_selected->duplicate();
+ style_tree_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));
+ style_tree_hover_selected->set_border_width_all(0);
+
+ p_theme->set_stylebox("hovered_selected", "Tree", style_tree_hover_selected);
+ p_theme->set_stylebox("hovered_selected_focus", "Tree", style_tree_hover_selected);
+
p_theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
p_theme->set_stylebox("selected", "Tree", style_tree_selected);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5de64bbe3fd..f944047df10 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2241,10 +2241,18 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (p_item->cells[0].selected) {
- if (has_focus()) {
- theme_cache.selected_focus->draw(ci, row_rect);
+ if (is_row_hovered) {
+ if (has_focus()) {
+ theme_cache.hovered_selected_focus->draw(ci, row_rect);
+ } else {
+ theme_cache.hovered_selected->draw(ci, row_rect);
+ }
} else {
- theme_cache.selected->draw(ci, row_rect);
+ if (has_focus()) {
+ theme_cache.selected_focus->draw(ci, row_rect);
+ } else {
+ theme_cache.selected->draw(ci, row_rect);
+ }
}
} else if (!drop_mode_flags) {
if (is_cell_button_hovered) {
@@ -2281,10 +2289,18 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
r.position.x = get_size().width - r.position.x - r.size.x;
}
if (p_item->cells[i].selected) {
- if (has_focus()) {
- theme_cache.selected_focus->draw(ci, r);
+ if (is_cell_hovered) {
+ if (has_focus()) {
+ theme_cache.hovered_selected_focus->draw(ci, r);
+ } else {
+ theme_cache.hovered_selected->draw(ci, r);
+ }
} else {
- theme_cache.selected->draw(ci, r);
+ if (has_focus()) {
+ theme_cache.selected_focus->draw(ci, r);
+ } else {
+ theme_cache.selected->draw(ci, r);
+ }
}
}
} else {
@@ -2347,7 +2363,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
} else {
bool draw_as_hover = !drop_mode_flags && (select_mode == SELECT_ROW ? is_row_hovered : is_cell_hovered);
bool draw_as_hover_dim = draw_as_hover && is_cell_button_hovered;
- cell_color = p_item->cells[i].selected ? theme_cache.font_selected_color : (draw_as_hover_dim ? theme_cache.font_hovered_dimmed_color : (draw_as_hover ? theme_cache.font_hovered_color : theme_cache.font_color));
+ cell_color = p_item->cells[i].selected && draw_as_hover ? theme_cache.font_hovered_selected_color : (p_item->cells[i].selected ? theme_cache.font_selected_color : (draw_as_hover_dim ? theme_cache.font_hovered_dimmed_color : (draw_as_hover ? theme_cache.font_hovered_color : theme_cache.font_color)));
}
Color font_outline_color = theme_cache.font_outline_color;
@@ -5989,6 +6005,8 @@ void Tree::_bind_methods() {
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, hovered);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, hovered_dimmed);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, hovered_selected);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, hovered_selected_focus);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, selected);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, selected_focus);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, cursor);
@@ -6016,6 +6034,7 @@ void Tree::_bind_methods() {
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_hovered_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_hovered_dimmed_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, Tree, font_hovered_selected_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);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index db100f5430c..a501270b870 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -551,6 +551,8 @@ private:
Ref hovered;
Ref hovered_dimmed;
+ Ref hovered_selected;
+ Ref hovered_selected_focus;
Ref selected;
Ref selected_focus;
Ref cursor;
@@ -581,6 +583,7 @@ private:
Color font_color;
Color font_hovered_color;
Color font_hovered_dimmed_color;
+ Color font_hovered_selected_color;
Color font_selected_color;
Color font_disabled_color;
Color guide_color;
diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp
index 5ae1e9baa37..e9d31d00185 100644
--- a/scene/theme/default_theme.cpp
+++ b/scene/theme/default_theme.cpp
@@ -846,6 +846,8 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const
theme->set_stylebox("focus", "Tree", focus);
theme->set_stylebox("hovered", "Tree", make_flat_stylebox(Color(1, 1, 1, 0.07)));
theme->set_stylebox("hovered_dimmed", "Tree", make_flat_stylebox(Color(1, 1, 1, 0.03)));
+ theme->set_stylebox("hovered_selected", "Tree", make_flat_stylebox(style_hover_selected_color));
+ theme->set_stylebox("hovered_selected_focus", "Tree", make_flat_stylebox(style_hover_selected_color));
theme->set_stylebox("selected", "Tree", make_flat_stylebox(style_selected_color));
theme->set_stylebox("selected_focus", "Tree", make_flat_stylebox(style_selected_color));
theme->set_stylebox("cursor", "Tree", focus);
@@ -880,6 +882,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const
theme->set_color(SceneStringName(font_color), "Tree", control_font_low_color);
theme->set_color("font_hovered_color", "Tree", control_font_hover_color);
theme->set_color("font_hovered_dimmed_color", "Tree", control_font_color);
+ theme->set_color("font_hovered_selected_color", "Tree", control_font_pressed_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(0, 0, 0));