Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Prevent the layer tree from allowing layer drag group formation of incompatible types

Open Keavon opened this issue 1 year ago • 0 comments

We display a grayed out expansion arrow for empty layers. This also means other layers can be dragged into that layer, becoming a child.

Image

That's because we want to indicate to users that this potentially could have a child. If it gains a child, it would become a group and the expansion arrow would get un-grayed out. Or, it can become a content layer fed by a chain starting with a generator node, in which case it can't gain a child.

But there is confusing behavior with the Path node, since it isn't a generator node. That is, it takes an optional primary input. Since now it becomes possible to attach a child layer to the start of that chain (feeding into the Path node), we display the grayed out expansion arrow. However, the user won't ever be dragging one layer (which outputs group data) into the layer (since the Path node takes vector data).

However, if it's just a Transform node feeding into the otherwise empty layer, that chain has no content. It still makes perfect sense to drag another layer into this layer to turn it into a group (which is transformed by the Transform node).

So there are two situations here:

  • The layer's left input at the start of the node chain accepts group input (such as no chain, or the Transform node, or the Flatten Vector Elements node). Keep the current behavior with the grayed out expansion arrow and ability to drag layers into it.
  • The Path node doesn't (currently) accept group data. Upon dragging another layer into the vector data layer, this becomes a type error (but this will change with #1822, negating this specific example, but there will be other examples this concept should still be implemented for). So we don't want to allow dragging layers (which output group data) into a node which begins with the Path node, or any other node with a primary input incompatible with group data. In that case, the grayed out expansion arrow shouldn't show in the Layers panel, and users shouldn't be able to drag a layer into it. (In the future, if we have layers that output a specific other type besides group, we should aim to allow dragging compatible types into compatible inputs even if they don't show the grayed out expansion arrow normally.) This change will prevent the user from using the WYSIWYG tooling to break the graph (which should be considered a bug: #2214).

Lastly, when reordering layers by dragging them around in the Layers panel, we want to turn the insertion bar red if the type would be invalid, causing a graph error.

Keavon avatar Jan 24 '25 07:01 Keavon