save node sizes as node metadata (#21)

fixes #16

Reviewed-on: https://codeberg.org/Eroax/StreamGraph/pulls/21
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2023-12-18 19:36:37 +00:00 committed by yagich
parent 12fb61a330
commit f84f5b3a32

View file

@ -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: