Skip to content

Fix PROPERTY_HINT_GROUP_ENABLE display on hover #108264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions editor/inspector/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,8 +1893,8 @@ void EditorInspectorSection::_notification(int p_what) {
Rect2 header_rect = Rect2(Vector2(header_offset_x, 0.0), Vector2(header_width, header_height));
Color c = bg_color;
c.a *= 0.4;
if (foldable && header_rect.has_point(get_local_mouse_position())) {
c = c.lightened((can_click_unfold && Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT)) ? -0.05 : 0.2);
if (header_hover) {
c = c.lightened(Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT) ? -0.05 : 0.2);
}
draw_rect(header_rect, c);

Expand Down Expand Up @@ -2059,14 +2059,18 @@ void EditorInspectorSection::_notification(int p_what) {
queue_redraw();
} break;

case NOTIFICATION_MOUSE_EXIT_SELF:
case NOTIFICATION_MOUSE_EXIT: {
if (dropping_for_unfold) {
dropping_unfold_timer->stop();
}

check_hover = false;
keying_hover = false;
queue_redraw();
if (header_hover || check_hover || keying_hover) {
header_hover = false;
check_hover = false;
keying_hover = false;
queue_redraw();
}
} break;
}
}
Expand Down Expand Up @@ -2166,11 +2170,11 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe

void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
bool has_children_to_show = vbox->get_child_count(false) != 0;
bool can_click_unfold = vbox->get_child_count(false) != 0 && !(!checkbox_only && checkable && !checked);
Copy link
Member

@KoBeWi KoBeWi Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, double negation. I think the condition can be something like

Suggested change
bool can_click_unfold = vbox->get_child_count(false) != 0 && !(!checkbox_only && checkable && !checked);
bool can_click_unfold = vbox->get_child_count(false) != 0 && (checkbox_only || !checkable || checked);

Though it's arguable which one is more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the double negation is more readable because it is checking against a single case (is how I thought about it), I reorganized it which made the double negation more apparent, I could change it back to:

Suggested change
bool can_click_unfold = vbox->get_child_count(false) != 0 && !(!checkbox_only && checkable && !checked);
bool can_click_unfold = vbox->get_child_count(false) != 0 && !(checkable && !checked && !checkbox_only);


Ref<InputEventMouse> me = p_event;
if (me.is_valid()) {
Vector2 mpos = me->get_position();
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
Vector2 mpos = mm->get_position();

bool new_check_hover = check_rect.has_point(mpos);
if (new_check_hover != check_hover) {
Expand All @@ -2183,11 +2187,17 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
keying_hover = new_keying_hover;
queue_redraw();
}

bool new_header_hover = foldable && can_click_unfold && (get_local_mouse_position().y < _get_header_height());
if (new_header_hover != header_hover) {
header_hover = new_header_hover;
queue_redraw();
}
}

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

bool should_unfold = !object->editor_is_section_unfolded(section);
Expand Down Expand Up @@ -2224,7 +2234,7 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
} else if (keying && keying_rect.has_point(pos)) {
emit_signal(SNAME("property_keyed"), related_enable_property, false);
} else if (foldable) {
bool should_unfold = has_children_to_show && !(checkable && !checked && !checkbox_only) && !object->editor_is_section_unfolded(section);
bool should_unfold = can_click_unfold && !object->editor_is_section_unfolded(section);
if (should_unfold) {
unfold();
} else {
Expand All @@ -2234,15 +2244,6 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
} else if (mb.is_valid() && !mb->is_pressed()) {
queue_redraw();
}

Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
int header_height = _get_header_height();
Vector2 previous = mm->get_position() - mm->get_relative();
if (has_children_to_show && ((mm->get_position().y >= header_height) != (previous.y >= header_height))) {
queue_redraw();
}
}
}

String EditorInspectorSection::get_section() const {
Expand Down
1 change: 1 addition & 0 deletions editor/inspector/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ class EditorInspectorSection : public Container {
bool check_hover = false;
Rect2 keying_rect;
bool keying_hover = false;
bool header_hover = false;

bool checkbox_only = false;

Expand Down