Closed Web-eWorks closed 3 years ago
Indentation should be fixed; for some reason my editor wasn't picking up the file's indentation style!
Thank you for reviewing! While I'm currently tied up and unable to make the requested changes, I'll try to get back to this pull request as soon as I can.
Is having the node snap to grid after releasing the mouse a standard feature in other node editor tools? It could also be possible to have the node snap to the grid as it is being translated. What do you think?
This "feature" is more a consequence of the existing data architecture - most node editors that I've worked with (mostly UE4) snap nodes while they're being dragged, but that would have required tracking the offset of the mouse cursor within the node separately to avoid snapping the actual cursor position mid-drag (and thus make moving nodes impossible). I went for the faster solution to simply snap-on-release to avoid making architectural changes, though I can certainly go back and implement it the "proper" way.
This has lots of conflicts with the master
branch, so I'll close this for now. I'll create a tracking issue for this though, to gauge if this is something people would really like to see get merged at some point. Feel free to reopen this if you find some time 👍
I didn't see any issues related to grid snapping, and since in visual-scripting grid snapping often means the difference between unreadable spaghetti and maintainable graphs, I figured I would try to implement it concisely and upstream it.
Grid snapping uses a simple nearest-point algorithm that works for negative coordinates. It could be fancier, but that would involve snapping the node's position independent of the actual origin or getting the absolute mouse position and original click position in the node and generating the snap from there. It's totally configurable based on the grid square width and the style flags.
Primary line drawing is very simple, just colors the origin lines a lighter (or darker) shade. Could likely be extended to draw every
n
lines instead, but that's outside of the scope of this PR. It's off by default but controllable with style flags and colors for those who like the UE4 grid drawing and aligning their nodes with the graph origin.Also fixed an (overlooked) issue where
StyleColorsLight
was clearing the style flags which resulted in a very suboptimal default experience for light-theme users.