Let a graph node collapse to its title bar

A chevron in front of the title toggles it without touching the selection,
and right-click offers Collapse node / Expand node for the whole selection
as one undo step. A collapsed node draws its title bar alone; every link of
one side meets at a single point on it, and hidden links there share one
mark per side, since per-port marks would stack on the same pixels. It has
no ports to grab, so a link dropped on it connects nothing.

Like hiding a link this is drawing only: collapsed is saved on the node and
an expanded node leaves no trace in the project file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-11 08:59:19 +02:00
1 parent 631cf54c72
commit 1e2285c545
12 files changed
+366 -14

No files matched your search

+7 -2
View File
@@ -13,9 +13,14 @@ export function foldedEdgeShown(edge: GraphEdge, selected: ReadonlySet<string>,
* Which mark a folded edge end belongs to. One port, one mark: drawn per edge instead, several
* hidden links out of the same port stack their stub, dot and name on the very same pixels.
* The separator is NUL: a printable one merges node "a b" + port "c" with node "a" + port "b c".
* A collapsed node draws all its ports on one point per side, so there it is one mark per side.
*/
export function foldMarkKey(side: { node: string; port: string }, isOutput: boolean): string {
return `${side.node}\0${side.port}\0${isOutput ? 'out' : 'in'}`;
export function foldMarkKey(
side: { node: string; port: string },
isOutput: boolean,
collapsed = false,
): string {
return `${side.node}\0${collapsed ? '' : side.port}\0${isOutput ? 'out' : 'in'}`;
}
/** One name plus a count: three names do not fit, and the count is what says "there is more here". */