Skip to content

Commit

Permalink
GH-467 Only save node size when manually resized (Godot 4.3+)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Aug 26, 2024
1 parent a994dff commit 5a0d577
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/editor/graph/graph_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ void OrchestratorGraphNode::_notification(int p_what)

// Used to replicate size/position state to underlying node resource
connect("dragged", callable_mp(this, &OrchestratorGraphNode::_on_node_moved));

// Godot 4.3 introduced a new resize_end callback that we will use now to handle triggering the
// final size of a node. This helps avoid issues with editor scale changes being problematic by
// leaving nodes too large after scale up.
#if GODOT_VERSION < 0x040300
connect("resized", callable_mp(this, &OrchestratorGraphNode::_on_node_resized));
#else
connect("resize_end", callable_mp(this, &OrchestratorGraphNode::_on_resize_end));
#endif

// Used to replicate state changes from node resource to the UI
_node->connect("pins_changed", callable_mp(this, &OrchestratorGraphNode::_on_pins_changed));
Expand Down Expand Up @@ -671,10 +679,17 @@ void OrchestratorGraphNode::_on_node_moved([[maybe_unused]] Vector2 p_old_pos, V
_node->set_position(p_new_pos);
}

#if GODOT_VERSION < 0x040300
void OrchestratorGraphNode::_on_node_resized()
{
_node->set_size(get_size());
}
#else
void OrchestratorGraphNode::_on_resize_end(const Vector2& p_size)
{
_node->set_size(p_size);
}
#endif

void OrchestratorGraphNode::_on_pins_changed()
{
Expand Down
6 changes: 6 additions & 0 deletions src/editor/graph/graph_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,14 @@ class OrchestratorGraphNode : public GraphNode
/// @param p_new_pos new position
void _on_node_moved(Vector2 p_old_pos, Vector2 p_new_pos);

#if GODOT_VERSION < 0x040300
/// Called when the graph node is resized
void _on_node_resized();
#else
/// Called when the graph node manual resize finishes
/// @param p_size the new size
void _on_resize_end(const Vector2& p_size);
#endif

/// Called when any pin detail has changed for this node
void _on_pins_changed();
Expand Down

0 comments on commit 5a0d577

Please sign in to comment.