Closed DerLando closed 2 years ago
Hi @DerLando! :smile:
I'm happy to share the details of how I achieved the zoom functionality in blackjack, but unfortunately it requires a forked egui backend and it's not something that would be accepted upstream. Basically, it's a hack specific to the wgpu backend, and an ugly one at that: I have two separate egui instances, and render the second instance inside the first as a texture. This also means hijacking the winit integration and translating mouse events, plus adding a few transformations inside egui_wgpu to make sure clip rects are correct when sending them the GPU. On top of that, you need to mess with pixels_per_point at runtime, which can lead to performance issues.
This is why egui_node_graph doesn't support zoom while blackjack does. Because this is currently impossible to do without a very specific application architecture (2 separate egui instances, and a forked backend).
Egui needs a backend-independent mechanism for zooming, but I don't know enough about the egui internals to make that work. Nevertheless, I have reported this to the egui main repo and even volunteered for an implementation: With some guidance, and if someone tells me this has a chance of getting upstreamed, I'll gladly help. But so far things have been quiet.
It might help if you show your support there (even a thumbs up is okay) and expose your use case if you think that's relevant :+1:
Thanks so much for the quick reply, I had a look at the linked feature request upstream and will add my voice.
I'll close this for now as it will likely require changes upstream.
Hello, first of all thank you for extracting this amazing library from
blackjack
and making it available!I was wondering if I might have missed the support for zooming in and out of the node graph, like possible in blackjack? I see panning being implemented by default by pressing middle mouse button and moving, but I don't see any handling for the scroll wheel in the code.
When changing the
scroll
value of thePanZoom
struct manually, there does not seem to be any visual feedback of a change. Is zooming supported as of now and if not, can it be ported over from blackjack, too?I could also work an a PR to port this functionality, but since I don't know the blackjack code well I would not know where to start.