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

Add the ability to select connections #139

Closed miroiu closed 1 month ago

miroiu commented 1 month ago

📝 Description of the Change

Adds the ability to select connections.

Relevant properties:

(click to expand) Example of selectable custom connection: ```xml ```

select-connection

Closes #138

ndegheselle commented 1 month ago

I was checking how everything work to implement connection selection on my side, I was thinking of using the same logic as the nodes with a custom Selector class (or MultiSelector to support shift click ?) maybe use a state to handle the overlap of selection between nodes and connections. Was simply wondering if that would be a good way to do so and if I understood how your code work correctly :)

Only change I would make is to doesn't allow a connection and node to be selected together, but that's opinionated and it's possible to handle the events to do so anyway.

miroiu commented 1 month ago

Using a Selector derived class should work, but that involves more work. I did it this way because I don't need all the features of a Selector, for example, virtualization, and I can also extend this solution to allow multiple selections.

However, since NodifyEditor supports custom connections (not derived from BaseConnection), I'm wondering what's the best solution in terms of developer experience to have the custom connections selectable as well.

ndegheselle commented 1 month ago

However, since NodifyEditor supports custom connections (not derived from BaseConnection), I'm wondering what's the best solution in terms of developer experience to have the custom connections selectable as well.

My two cents: if someone use your library but want to have a fully custom element they can't expect to have the same functionnalities than if they use the base classes provided. That the same as why you don't use the Selector class, if you need the features it provide then you just inherit the class, otherwise you have to implement the rest yourself.

miroiu commented 1 month ago

I totally agree with your perspective. If a developer chooses to use custom elements, it's reasonable to expect that some functionality from the base classes might need to be re-implemented. However, when it's not overly complex to support those features, I try to include them for a better developer experience — and in this case, I did just that. Regarding the multi-selection, I ended up using the MultiSelector class because, it turns out that it's not so easy to implement multi-selection from scratch.