lapce / floem

A native Rust UI library with fine-grained reactivity
https://docs.rs/floem
MIT License
2.69k stars 122 forks source link

Absolute positioning layout widget for node graphs #506

Open giannissc opened 1 month ago

giannissc commented 1 month ago

Hi there! I was wondering if someone can give me some pointers on how to implement a absolute layout widget to be used with something like a node graph? I have used the PanZoom widget that was posted on discord and modified it to implement snapping and show a grid, but it currently doesn't support adding other widgets to it. Following the virtualList and VirtualStack it is unclear to me what exactly is needed.

https://github.com/lapce/floem/assets/20277283/0ae09b68-fe18-4919-ba72-61674b3e9c72

dzhou121 commented 1 month ago

It feels like the best approach would probably be a custom widget, e.g., you'd paint the grid yourself.

giannissc commented 1 month ago

That's what I am trying to do but I am not sure which aspects of the other layout widgets to copy? The two virtual widget currently in floem have some differences. For example the stack uses a diff and stores the children in it's strict definition as well as in the ECS so I am not sure which of the two more closely follows the way thing should be done in floem

dzhou121 commented 1 month ago

Does this need to contain other widgets? If so, the logic would be similar to the virtual list.

giannissc commented 1 month ago

Are there any plans to add a virtual_canvas widget to floem at some point?