Skip to content

Commit e9c5c71

Browse files
committed
Fix Group Enable Hover Display
1 parent 53be3b7 commit e9c5c71

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

editor/inspector/editor_inspector.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,8 +1893,8 @@ void EditorInspectorSection::_notification(int p_what) {
18931893
Rect2 header_rect = Rect2(Vector2(header_offset_x, 0.0), Vector2(header_width, header_height));
18941894
Color c = bg_color;
18951895
c.a *= 0.4;
1896-
if (foldable && header_rect.has_point(get_local_mouse_position())) {
1897-
c = c.lightened((can_click_unfold && Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT)) ? -0.05 : 0.2);
1896+
if (header_hover) {
1897+
c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT) ? -0.05 : 0.2);
18981898
}
18991899
draw_rect(header_rect, c);
19001900

@@ -2059,14 +2059,18 @@ void EditorInspectorSection::_notification(int p_what) {
20592059
queue_redraw();
20602060
} break;
20612061

2062+
case NOTIFICATION_MOUSE_EXIT_SELF:
20622063
case NOTIFICATION_MOUSE_EXIT: {
20632064
if (dropping_for_unfold) {
20642065
dropping_unfold_timer->stop();
20652066
}
20662067

2067-
check_hover = false;
2068-
keying_hover = false;
2069-
queue_redraw();
2068+
if (header_hover || check_hover || keying_hover) {
2069+
header_hover = false;
2070+
check_hover = false;
2071+
keying_hover = false;
2072+
queue_redraw();
2073+
}
20702074
} break;
20712075
}
20722076
}
@@ -2166,11 +2170,11 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe
21662170

21672171
void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
21682172
ERR_FAIL_COND(p_event.is_null());
2169-
bool has_children_to_show = vbox->get_child_count(false) != 0;
2173+
bool can_click_unfold = vbox->get_child_count(false) != 0 && !(!checkbox_only && checkable && !checked);
21702174

2171-
Ref<InputEventMouse> me = p_event;
2172-
if (me.is_valid()) {
2173-
Vector2 mpos = me->get_position();
2175+
Ref<InputEventMouseMotion> mm = p_event;
2176+
if (mm.is_valid()) {
2177+
Vector2 mpos = mm->get_position();
21742178

21752179
bool new_check_hover = check_rect.has_point(mpos);
21762180
if (new_check_hover != check_hover) {
@@ -2183,11 +2187,17 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
21832187
keying_hover = new_keying_hover;
21842188
queue_redraw();
21852189
}
2190+
2191+
bool new_header_hover = foldable && can_click_unfold && (get_local_mouse_position().y < _get_header_height());
2192+
if (new_header_hover != header_hover) {
2193+
header_hover = new_header_hover;
2194+
queue_redraw();
2195+
}
21862196
}
21872197

21882198
Ref<InputEventKey> k = p_event;
21892199
if (k.is_valid() && k->is_pressed()) {
2190-
if (foldable && has_children_to_show && !(checkable && !checked && !checkbox_only) && k->is_action("ui_accept", true)) {
2200+
if (foldable && can_click_unfold && k->is_action("ui_accept", true)) {
21912201
accept_event();
21922202

21932203
bool should_unfold = !object->editor_is_section_unfolded(section);
@@ -2224,7 +2234,7 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
22242234
} else if (keying && keying_rect.has_point(pos)) {
22252235
emit_signal(SNAME("property_keyed"), related_enable_property, false);
22262236
} else if (foldable) {
2227-
bool should_unfold = has_children_to_show && !(checkable && !checked && !checkbox_only) && !object->editor_is_section_unfolded(section);
2237+
bool should_unfold = can_click_unfold && !object->editor_is_section_unfolded(section);
22282238
if (should_unfold) {
22292239
unfold();
22302240
} else {
@@ -2234,15 +2244,6 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
22342244
} else if (mb.is_valid() && !mb->is_pressed()) {
22352245
queue_redraw();
22362246
}
2237-
2238-
Ref<InputEventMouseMotion> mm = p_event;
2239-
if (mm.is_valid()) {
2240-
int header_height = _get_header_height();
2241-
Vector2 previous = mm->get_position() - mm->get_relative();
2242-
if (has_children_to_show && ((mm->get_position().y >= header_height) != (previous.y >= header_height))) {
2243-
queue_redraw();
2244-
}
2245-
}
22462247
}
22472248

22482249
String EditorInspectorSection::get_section() const {

editor/inspector/editor_inspector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ class EditorInspectorSection : public Container {
384384
bool check_hover = false;
385385
Rect2 keying_rect;
386386
bool keying_hover = false;
387+
bool header_hover = false;
387388

388389
bool checkbox_only = false;
389390

0 commit comments

Comments
 (0)