miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.38k stars 224 forks source link

Fix wrong connector position for knot nodes when using step connection #112

Closed miroiu closed 5 months ago

miroiu commented 5 months ago

📝 Description of the Change

Closes #110

step default

🐛 Possible Drawbacks

No.

hendrikp commented 5 months ago

This partly fixes the handling for steps, but not for backwards going connections (it still is doing the looping, while in such cases it best just switch the sides of the knot). I think in general the knot doesnt need to have a orientation but more should have like some logic to handle based on relative position to source/target connectors, where connector should ingest the connection without doing such unneeded steeps curves or or crossings.

image

image

Step connection knot handling however now at least working well (when not considering those backward facing connections):

image

And i just checked, the Orientation for knot nodes i take from the outgoing connector atm, that way i avoid having to have any orientation on nodes or knots.

miroiu commented 5 months ago

Ok.. now I understand what you mean with the backward-going connections. It would be ideal to have something like this, but I believe it is hard to implement and probably needs a new parameter added to BaseConnection since we don't have node information inside connections:

flip

Notice the wire flip at the end of the gif. I think it's based on node positions, rather than connectors, because it does not happen when I move the knot node unless it's considering only the start connector and end connectors, ignoring the knot connector.

For normal connection flows it's behaving the same (which would break if I changed direction based on connector position):

image

Screenshots are taken from Unreal Engine 5.3.2 Blueprints editor.

I wouldn't really want to try implementing this, at least for the moment, because I consider the current behavior to be sufficient for most use cases. And anyway, the library does not restrict connections to the ones provided. Creating custom connections is as simple as this:

<nodify:NodifyEditor.ConnectionTemplate>
     <Line X1="{Binding Input.Anchor.X}"
          Y1="{Binding Input.Anchor.Y}"
          X2="{Binding Output.Anchor.X}"
          Y2="{Binding Output.Anchor.Y}"
          Stroke="DodgerBlue" 
          StrokeThickness="2" />
</nodify:NodifyEditor.ConnectionTemplate>

However, if you have time to invest in this, I'd be more than happy to review your PR.

hendrikp commented 4 months ago

Yeah definitly based on positions of source+target node/connector, not of orientations of either.