-
-
Notifications
You must be signed in to change notification settings - Fork 579
Migrate node graph UI interaction from frontend to backend #1768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37261f0
to
9aafafe
Compare
524da32
to
8306115
Compare
Keavon
approved these changes
Jun 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1777 and (presumably) fixes #1548.
This PR will migrate click detection, translation/scale and wire calculations from Graph.svelte to the NodeGraphMessageHandler. Instead of relying on the DOM and JavaScript click detection to get positions for various elements and send messages via editor.handle, all logic and calculations will be performed in the NodeGraphMessageHandler. Since Rust only has access to the node and wire data, all positioning functions that previously used the DOM will have to be recreated. This includes
closest()
which will calculate the bounding box for each node using [SDFs](Rounding Corners in SDFs) and offscreen text rendering to check if a click event occurred within a node or node inputgetBoundingClientRect()
, which will get the position of node inputs and outputs in node graph coordinatesa new function
NodeGraphToPixelCoordinates()
, which will convert the node graph position to pixel coordinates that can be compared with the click eventAnother important concept will be to store positions in node graph coordinates, and derive pixel coordinates when needed using the current transform (position/scale). This should solve a current issue where scaling the node graph breaks the automatic node insertion on a wire.
Other features
HashMap<NodeId, ClickTarget>
) and keep them in sync with the visual nodes by making inputs, metadata (position), and is_layer, and eventually name private fields, and creating getters/setters that keep the cache in sync. This removes the 50ms per frame requires to calculate bounding boxes.Also cache the bounding box around the entire node network, and convert to viewport coordinates when rendering scrollbars. Keep all coordinates in node graph coordinates, and only use the transform to convert mouse position to node graph coordinates, or converting the bounding box to viewport coordinates.
Issues: