summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2023-01-04 16:48:01 -0800
committerK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2023-01-04 16:48:01 -0800
commit8302f17adf66b569ebe55a71b1fb8b84e5b2064a (patch)
tree4db63949e479aba987408218b6b8809b7ea31b49
parentf382a2b59bb9606f958ccaf7be7ac98f45607c9f (diff)
Update graph_edit.cpp to automatically arrange nodes if nothing is selected.
-rw-r--r--scene/gui/graph_edit.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 1c4c8c2574..4c1ef644a4 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -2134,6 +2134,7 @@ void GraphEdit::arrange_nodes() {
Dictionary node_names;
HashSet<StringName> selected_nodes;
+ bool arrange_entire_graph = true;
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn) {
@@ -2141,6 +2142,10 @@ void GraphEdit::arrange_nodes() {
}
node_names[gn->get_name()] = gn;
+
+ if (gn->is_selected()) {
+ arrange_entire_graph = false;
+ }
}
HashMap<StringName, HashSet<StringName>> upper_neighbours;
@@ -2156,12 +2161,12 @@ void GraphEdit::arrange_nodes() {
continue;
}
- if (gn->is_selected()) {
+ if (gn->is_selected() || arrange_entire_graph) {
selected_nodes.insert(gn->get_name());
HashSet<StringName> s;
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
GraphNode *p_from = Object::cast_to<GraphNode>(node_names[E->get().from]);
- if (E->get().to == gn->get_name() && p_from->is_selected() && E->get().to != E->get().from) {
+ if (E->get().to == gn->get_name() && (p_from->is_selected() || arrange_entire_graph) && E->get().to != E->get().from) {
if (!s.has(p_from->get_name())) {
s.insert(p_from->get_name());
}