Ax9D / pw-viz

Pipewire graph editor written in Rust. WIP⚠️
GNU General Public License v3.0
234 stars 14 forks source link

Support dropping nodes in the middle of existing links #14

Open jansol opened 2 years ago

jansol commented 2 years ago

Another feature from Blender's node editor that would be neat to have.

When dragging a node and dropping it on top of an existing link, the Blender node editor tries to insert that node between the two endpoints of that link. This should be fairly usable for stuff like building effect chains.

Say you have a graph: A-->B where A has a mono output or monitor and B has a mono input. Now dragging a node with a mono input and output in top of that link would make it easy to disconnect the link and create links A-->C-->B using the matching port names. This can be extended to stereo, 5.1, 7.1 etc as long as the port name suffixes match.

AUXn ports could be considered to match named ones with a simple heuristic like, if there is only one link whatever AUXn is involved matches MONO, if there are two then the one with the lower AUXn number matches FL and the higher one FR, if there are more they match the named ports for 5.1, 7.1 etc in a fixed order starting from the first AUXn index of the existing links between the A and B.

Ports marked as UNK are more complicated, not sure what can be done about those. Is there a port number regardless of names in the pipewire API? Those could be used in this case.

Worst case (i.e. when it's not possible to infer the right ports) could be something like flash the dragged node and the link in question and then not doing anything.

Not sure if/how much modding this requires in egui-nodes. The heuristic for choosing the relevant ports should classify as "good first issue" so the difficulty is going to depend largely on how to do it in egui-nodes.

jansol commented 2 years ago

This would be particularly relevant for building effect chains, like in the screenshot in the readme.