egui_node_graph icon indicating copy to clipboard operation
egui_node_graph copied to clipboard

Node zoom

Open hakolao opened this issue 2 years ago • 5 comments

The node graph needs zoom badly.

So here is an implementation inspired by https://github.com/gzp-crey/shine, and the style scaling was copied from there as well.

Because this is just me updating stuff from a fork, this also contains egui 0.22, and placement of node rather to finder window pos than mouse pos (mouse can be outside graph area when finder window is large).

  • The zoomed style during runtime is retained in PanZoom, it uses parent ui's style by default, but when in a zoomed state, a scaled style is used
  • And the zoom is towards center of the ui area. I find towards mouse zoom unintutive, but feel free to change that.
  • Node positions are updated by the delta when zoomed
  • I like this, because the we can keep the pan untouched.

All in all, this seems to work pretty well... though not optimal, pan_zoom's scale needs to be used in a couple of places... But better than having double egui context in my opinion.

What it looks like:

https://github.com/setzer22/egui_node_graph/assets/12234005/5cb8c57a-8864-4aca-94de-57589f20dd98

Feel free to edit MAX, MIN zooms and anything that should be changed...

hakolao avatar Jun 13 '23 21:06 hakolao

I have merged this into my own fork and it works great.

One problem I encountered though is that the node graph flows out the top of the TopBottomPanel I have put it into here.

Peek 2024-01-04 11-08

Not sure if I am doing something wrong or if the clip rect needs to be adjusted?

ttddee avatar Jan 04 '24 11:01 ttddee

Might be that the clip rect should be adjusted. Don't mind a fix!

hakolao avatar Jan 11 '24 14:01 hakolao

This fixes the problem for me but I am still wondering why the clip_rect is wrong in the first place.

Still learning egui...

ttddee avatar Jan 11 '24 18:01 ttddee

Hello @setzer22 , is there a chance this PR will be accepted?

plfort avatar Feb 02 '24 14:02 plfort

Because I use this in my project, I've kept the fork up to date. Still find it very usable :)

hakolao avatar Feb 02 '24 14:02 hakolao