From f84f5b3a3262eabfa9534e63f7dc975c5abd3d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Mon, 18 Dec 2023 19:36:37 +0000 Subject: [PATCH] save node sizes as node metadata (#21) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #16 Reviewed-on: https://codeberg.org/Eroax/StreamGraph/pulls/21 Co-authored-by: Lera ElvoƩ Co-committed-by: Lera ElvoƩ --- graph_node_renderer/deck_node_renderer_graph_node.gd | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd index 49ddd69..f985006 100644 --- a/graph_node_renderer/deck_node_renderer_graph_node.gd +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -10,11 +10,13 @@ class_name DeckNodeRendererGraphNode ## are based off. var node: DeckNode + ## Setups up all the properties based off [member node]. Including looping through ## [method DeckNode.get_all_ports()] and setting up all the descriptors. func _ready() -> void: title = node.name node.position_updated.connect(_on_node_position_updated) + resize_request.connect(_on_resize_request) #node.port_added.connect(_on_node_port_added) #node.port_removed.connect(_on_node_port_removed) node.ports_updated.connect(_on_node_ports_updated) @@ -24,6 +26,9 @@ func _ready() -> void: node.renamed.connect(_on_node_renamed) if node.node_type == "group_node": get_titlebar_hbox().tooltip_text = "Group %s" % node.group_id.left(8) + + size = node.get_meta("size", Vector2()) + ## Connected to [signal GraphElement.position_offset_updated] and updates the ## [member node]s properties @@ -33,6 +38,7 @@ func _on_position_offset_changed() -> void: node.position_updated.emit(node.position) (get_parent() as DeckRendererGraphEdit).dirty = true + ## Connected to [member node]s [signal position_updated] to keep parity with the ## data position. func _on_node_position_updated(new_position: Dictionary) -> void: @@ -43,6 +49,11 @@ func _on_node_position_updated(new_position: Dictionary) -> void: (get_parent() as DeckRendererGraphEdit).dirty = true +func _on_resize_request(new_minsize: Vector2) -> void: + node.set_meta(&"size", new_minsize) + (get_parent() as DeckRendererGraphEdit).dirty = true + + ## Connected to [member node]s [signal port_added] handles setting up the specified ## [member Port.descriptor] with it's required nodes/signals etc. + adding the port ## using [method GraphNode.set_slot] @@ -66,6 +77,7 @@ func _on_node_port_removed(port_idx: int) -> void: get_child(port_idx).queue_free() + ## Connected to [member node]s [signal ports_updated]. Remakes all of the ports ## + their descriptors whenever this is received to allow keeping the Renderers ports up to date. func _on_node_ports_updated() -> void: