Deduplicate code

This commit is contained in:
Fingercomp 2025-08-01 20:51:39 +03:00
parent 3315764951
commit 0dac2b2f1f
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37

View File

@ -493,28 +493,16 @@ class WorkspaceView extends Widget with Persistable with MouseHandler with Hover
g.setSmallFont()
val iconBoundsInflate = -(node.bounds.w - 22) / 2
g.rect(node.bounds.inflate(-10), RGBAColor(0, 0, 0, 150))
g.sprite(port.getIcon, node.bounds.inflate(iconBoundsInflate), port.getColor)
drawCenteredConnectionHintLabel(
g,
node.bounds,
port.direction.map(node.directionLabel(_)).getOrElse("Any"),
port.getColor
)
newConnectionTarget match {
case Some((targetNode, targetPort)) =>
g.rect(targetNode.bounds.inflate(-10), RGBAColor(0, 0, 0, 150))
g.sprite(targetPort.getIcon, targetNode.bounds.inflate(iconBoundsInflate), targetPort.getColor)
drawCenteredConnectionHintLabel(
g,
targetNode.bounds,
targetPort.direction.map(targetNode.directionLabel(_)).getOrElse("Any"),
targetPort.getColor
)
case _ =>
for ((node, port) <- Some((node, port)) ++ newConnectionTarget) {
val iconBoundsInflate = -(node.bounds.w - 22) / 2
g.rect(node.bounds.inflate(-10), RGBAColor(0, 0, 0, 150))
g.sprite(port.getIcon, node.bounds.inflate(iconBoundsInflate), port.getColor)
drawCenteredConnectionHintLabel(
g,
node.bounds,
port.direction.map(node.directionLabel(_)).getOrElse("Any"),
port.getColor
)
}
g.setNormalFont()