1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Update GraphNode selection logic if not visible

This commit is contained in:
Tibo
2025-07-31 18:38:03 +02:00
parent 0dd9178269
commit 2aa76439ce
2 changed files with 17 additions and 0 deletions

View File

@@ -587,6 +587,12 @@ void GraphEdit::_graph_element_deselected(Node *p_node) {
emit_signal(SNAME("node_deselected"), graph_element); emit_signal(SNAME("node_deselected"), graph_element);
} }
void GraphEdit::_graph_element_visibility_changed(GraphElement *p_graph_element) {
if (p_graph_element->is_selected() && !p_graph_element->is_visible()) {
p_graph_element->set_selected(false);
}
}
void GraphEdit::_graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node) { void GraphEdit::_graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node) {
GraphElement *graph_element = Object::cast_to<GraphElement>(p_node); GraphElement *graph_element = Object::cast_to<GraphElement>(p_node);
ERR_FAIL_NULL(graph_element); ERR_FAIL_NULL(graph_element);
@@ -700,6 +706,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
graph_element->connect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved).bind(graph_element)); graph_element->connect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved).bind(graph_element));
graph_element->connect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected).bind(graph_element)); graph_element->connect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected).bind(graph_element));
graph_element->connect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected).bind(graph_element)); graph_element->connect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected).bind(graph_element));
graph_element->connect(SceneStringName(visibility_changed), callable_mp(this, &GraphEdit::_graph_element_visibility_changed).bind(graph_element));
GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element); GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element);
if (graph_node) { if (graph_node) {
@@ -756,6 +763,7 @@ void GraphEdit::remove_child_notify(Node *p_child) {
graph_element->disconnect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved)); graph_element->disconnect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_element_moved));
graph_element->disconnect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected)); graph_element->disconnect("node_selected", callable_mp(this, &GraphEdit::_graph_element_selected));
graph_element->disconnect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected)); graph_element->disconnect("node_deselected", callable_mp(this, &GraphEdit::_graph_element_deselected));
graph_element->disconnect(SceneStringName(visibility_changed), callable_mp(this, &GraphEdit::_graph_element_visibility_changed));
GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element); GraphNode *graph_node = Object::cast_to<GraphNode>(graph_element);
if (graph_node) { if (graph_node) {
@@ -2041,6 +2049,10 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
continue; continue;
} }
if (!graph_element->is_visible()) {
continue;
}
// Only select frames when the box selection is fully enclosing them. // Only select frames when the box selection is fully enclosing them.
bool is_frame = Object::cast_to<GraphFrame>(graph_element); bool is_frame = Object::cast_to<GraphFrame>(graph_element);
Rect2 r = graph_element->get_rect(); Rect2 r = graph_element->get_rect();
@@ -2174,6 +2186,10 @@ void GraphEdit::gui_input(const Ref<InputEvent> &p_ev) {
continue; continue;
} }
if (!selected_element->is_visible()) {
continue;
}
if (selected_element->is_resizing()) { if (selected_element->is_resizing()) {
continue; continue;
} }

View File

@@ -322,6 +322,7 @@ private:
void _graph_element_selected(Node *p_node); void _graph_element_selected(Node *p_node);
void _graph_element_deselected(Node *p_node); void _graph_element_deselected(Node *p_node);
void _graph_element_visibility_changed(GraphElement *p_graph_element);
void _graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node); void _graph_element_resize_request(const Vector2 &p_new_minsize, Node *p_node);
void _graph_frame_autoshrink_changed(const Vector2 &p_new_minsize, GraphFrame *p_frame); void _graph_frame_autoshrink_changed(const Vector2 &p_new_minsize, GraphFrame *p_frame);
void _graph_element_moved(Node *p_node); void _graph_element_moved(Node *p_node);