Highlight hovered inspector categories

This commit is contained in:
Jummit 2021-11-15 19:08:46 +01:00
parent 77416d5806
commit 8ec2d86e5e

View file

@ -31,6 +31,7 @@
#include "editor_inspector.h" #include "editor_inspector.h"
#include "array_property_edit.h" #include "array_property_edit.h"
#include "core/os/input.h"
#include "dictionary_property_edit.h" #include "dictionary_property_edit.h"
#include "editor_feature_profile.h" #include "editor_feature_profile.h"
#include "editor_node.h" #include "editor_node.h"
@ -970,7 +971,8 @@ void EditorInspectorSection::_test_unfold() {
} }
void EditorInspectorSection::_notification(int p_what) { void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) { switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
Ref<Font> font = get_font("font", "Tree"); Ref<Font> font = get_font("font", "Tree");
Ref<Texture> arrow; Ref<Texture> arrow;
@ -1011,9 +1013,9 @@ void EditorInspectorSection::_notification(int p_what) {
} }
update(); //need to redraw text update(); //need to redraw text
} } break;
if (p_what == NOTIFICATION_DRAW) { case NOTIFICATION_DRAW: {
Ref<Texture> arrow; Ref<Texture> arrow;
if (foldable) { if (foldable) {
@ -1032,7 +1034,13 @@ void EditorInspectorSection::_notification(int p_what) {
} }
h += get_constant("vseparation", "Tree"); h += get_constant("vseparation", "Tree");
draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), bg_color); Rect2 header_rect = Rect2(Vector2(), Vector2(get_size().width, h));
Color c = bg_color;
c.a *= 0.4;
if (foldable && header_rect.has_point(get_local_mouse_position())) {
c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) ? -0.05 : 0.2);
}
draw_rect(header_rect, c);
const int arrow_margin = 3; const int arrow_margin = 3;
Color color = get_color("font_color", "Tree"); Color color = get_color("font_color", "Tree");
@ -1041,6 +1049,11 @@ void EditorInspectorSection::_notification(int p_what) {
if (arrow.is_valid()) { if (arrow.is_valid()) {
draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor()); draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
} }
} break;
case NOTIFICATION_MOUSE_ENTER:
case NOTIFICATION_MOUSE_EXIT: {
update();
} break;
} }
} }
@ -1112,6 +1125,8 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
} else { } else {
vbox->hide(); vbox->hide();
} }
} else if (mb.is_valid() && !mb->is_pressed()) {
update();
} }
} }