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.27k stars 205 forks source link

[Feature] Fit selected nodes into view #88

Open jpk6789 opened 6 months ago

jpk6789 commented 6 months ago

Hi,

currently, there is a function to try to fit all elements in the nodify editor into view. This function can also fit an area into view. There is also a function to jump to a specific location. However, there is currently no function to fit the selected nodes into view. This would be a great to find the selected nodes.

I started to implement this feature with a new RoutedUICommand for a PR but was a little bit uncertain, how to get the actual area, the selected ItemContainers use. The calculation should in some parts be similar to the ArrangeOverride function in the NodifyCanvas class. However, can I use the Location and DesiredSize properties of the ItemContainers for that calculation or is there a better way to implement such a feature?

miroiu commented 6 months ago

Hi,

You can get the selected containers by using the NodifyEditor.SelectedContainers property. And you're right! The calculation is similar to how NodifyCanvas calculates the Extent (by using Location and RenderSize).

Let me know if you need more information.