setzer22 / egui_node_graph

Build your node graph applications in Rust, using egui
MIT License
711 stars 132 forks source link

Update to egui 0.21 & fix the interaction bug #85

Closed hakolao closed 1 year ago

hakolao commented 1 year ago

Trying a fix here for #79

So, I'm pretty sure https://github.com/emilk/egui/pull/2244 broke the movement etc. Because the hover interaction never takes place on the responses for areas covered by other widgets. You can see this by debugging the overlapping widgets with styles. Maybe there is some way to tweak the layers / order of widgets, but dunno. So the solution:

Perhaps there is a better fix, and I'm not sure if this breaks the dynamic rect size of the widgets, but the example works.

This could at least point someone more knowledgeable towards a better direction so we can update to newer egui.

kamirr commented 1 year ago

Thanks for the PR, I've tested it against the project I'm working on.

Perhaps there is a better fix, and I'm not sure if this breaks the dynamic rect size of the widgets, but the example works.

That is correct, after resizing a node you can still grab only grab it by the rectangle it was created with. Otherwise everything I've needed seems to work fine:

I needed some egui 0.21 features and this allowed me to drop my fork with them backported, so I'll be working off this PR for the time being. If I find any issues I'll leave a comment.

hakolao commented 1 year ago

Great @kamirr , if you can figure out a fix for the rect bounds, that would be great :)

kamirr commented 1 year ago

This patch does the trick: 0001-Update-interactable-node-area.txt (note that this is a .patch file as generated by git format-patch, the .txt extension is due to GitHub's attachment policy.)

Feel free to add it to this PR if you like it. tl;dr it stores the outer rect in memory after populating child_ui and then uses this value during the next frame.

hakolao commented 1 year ago

I'll add those fixes

hakolao commented 1 year ago

Had no clue how to use the patch..., copied it... Thanks for the fix!

kamirr commented 1 year ago

One thing I’ve noticed is that after some use my program enters a state in which I cannot edit values in DragValues in nodes by keyboard (dragging works fine) and it’s persistent across restarts of the program, until I drop the saved state.

Not yet sure if it’s a bug in egui, this PR or my shenanigans. Will update.

kamirr commented 1 year ago

One thing I’ve noticed is that after some use my program enters a state in which I cannot edit values in DragValues in nodes by keyboard (dragging works fine) and it’s persistent across restarts of the program, until I drop the saved state.

Not yet sure if it’s a bug in egui, this PR or my shenanigans. Will update.

Turned out to be a bug in egui (https://github.com/emilk/egui/pull/2959). I haven't found any other issues.

setzer22 commented 1 year ago

Thanks a lot @hakolao and @kamirr for taking care of this! :smile: I have tested the changes and I can't spot any UX issues on my end either. I'll have a quick look at the code and then we can merge this :+1: