zakarumych / egui-snarl

Customizable egui node-graph library
https://crates.io/crates/egui-snarl
MIT License
252 stars 25 forks source link

Can I move multiple nodes at once? #7

Open plasticbox opened 8 months ago

plasticbox commented 8 months ago

Hello. It's a good library. I'm doing some testing and it would be nice to have the ability to drag and select multiple nodes to move them all at once. I just want to make sure I'm not missing something.

zakarumych commented 8 months ago

Right, it'd be nice feature to have.

Do you have an idea how it can be controlled?

I also want to create control map to not make a mess of weird combinations which library user can't modify.

plasticbox commented 8 months ago

I actually tried to use https://github.com/setzer22/egui_node_graph before using snarl.

The project doesn't seem to be active, and it's a bit difficult to use.

If you look at the egui_node_graph, you can select multiple nodes by dragging. snarl can background drag, you can select a specific key and drag to specify an area to select a node, or on the contrary, you can select the default as a node selection drag and press a specific key to make it a background drag. Then you can select the selected nodes and change the pos at once?

https://github.com/Sollimann/bonsai I'm trying to use this bt, but json edit is too hard, so I'm trying to make an internal tool with snarl. I'm trying to read the bonsai bt json, draw the node, and then save the edited node according to the bonsai bt json. This is a bit difficult, so the primary goal is to read and draw the nodes.

After reading from the json, I added the node and added the connection information, but it was harder than I thought because I tried to position the node beautifully. It would be nice to have a function that automatically aligns them, so I thought about it, but I didn't come up with a good idea.

zakarumych commented 8 months ago

By automatic aligning do you mean something like snapping to common coordinates?

plasticbox commented 8 months ago
스크린샷 2024-01-31 오후 5 47 55

I've attached a screenshot of my implementation.

When nodes are added by reading them from BT JSON rather than adding them in the editor, it's hard to determine their location. Certain nodes have multiple outputs and it's hard to see where the depth will go at first. So I just put the node in with a slight change in position and it looks like the screenshot. I was thinking that the nodes shouldn't be cluttered and the lines should look nice.

https://www.youtube.com/watch?v=JKk7LRGJrfQ I was thinking something similar to unreal blueprint's quick align.

zakarumych commented 8 months ago

I see, so pick a few nodes and align them in certain way once. That seems doable when we have multi selection.

And your use case requires auto-layout to place nodes nicely after creating them from some description with no positions.

Maybe some iterative algorithm that would push nodes away from each other and attempt to keep them on the same height if connected.

zakarumych commented 5 months ago

Node selection feature added and moving selected node moves all selected nodes at once.