-
Notifications
You must be signed in to change notification settings - Fork 318
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
Placement of newly opened Component Browser dictated by the mouse pointer. #3301
Placement of newly opened Component Browser dictated by the mouse pointer. #3301
Conversation
…node-button-180887253
…node-button-180887253
…ement-by-mouse-181076066
use crate::free_place_finder::find_free_place; | ||
use crate::free_place_finder::OccupiedArea; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the free_place_finder
module can be made a submodule of new_node_position
. So far, the finder is used solely for searching for new node positions.
app/gui/view/graph-editor/src/lib.rs
Outdated
let position: Vector2 = match way { | ||
AddNodeEvent => default(), | ||
StartCreationEvent | ClickingButton if selection.is_some() => | ||
self.find_free_place_under(selection.unwrap()), | ||
StartCreationEvent => mouse_position, | ||
new_node_position::under(self, selection.unwrap()), | ||
StartCreationEvent => | ||
new_node_position::at_mouse_aligned_to_close_nodes(self, mouse_position), | ||
ClickingButton => | ||
self.find_free_place_for_node(screen_center, Vector2(0.0, -1.0)).unwrap(), | ||
DroppingEdge { .. } => mouse_position, | ||
new_node_position::on_ray(self, screen_center, Vector2(0.0, -1.0)).unwrap(), | ||
DroppingEdge { edge_id } => | ||
new_node_position::at_mouse_aligned_to_source_node(self, edge_id, mouse_position), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separate module made it look so nice! Perhaps this whole match should also be refactored to function inside new_node_position
.
(Process note: the code-review is now Approved, therefore the PR is waiting for Review by @farmaazon on Task https://www.pivotaltracker.com/story/show/181076066 before merging.) |
…ement-by-mouse-181076066
…ement-by-mouse-181076066
…ement-by-mouse-181076066
…ement-by-mouse-181076066
…3361) When a new node is created with the <kbd>TAB</kbd> key or by clicking the `(+)` on-screen button while multiple nodes are selected, place the new node below all the selected nodes. (Previously, the new node was placed below the node that was selected earliest.) Additionally, when placing a new node below an existing non-error node with a visualization enabled, place the new node below the visualization. (Previously, the new node was placed to the left of the visualization.) https://www.pivotaltracker.com/story/show/180887079 #### Visuals The following screencast demonstrates the feature on various arrangements of selected nodes, with visualization enabled and disabled. https://user-images.githubusercontent.com/273837/159971452-148aa4d7-c0f3-4b48-871a-a2783989f403.mov The following screencast demonstrates that new nodes created by double-clicking an output port of a node with visualization enabled are now placed below the visualization: https://user-images.githubusercontent.com/273837/160107733-e3f7d0f9-0161-49d1-8cbd-06e18c843a20.mov # Important Notes - Some refactorings that were needed for this PR were ported from the #3301 PR: - the code responsible for calculating the positions of new nodes was moved to a separate module (`new_node_position`); - the `free_place_finder` module was made a submodule of the `new_node_position` module, due to the latter being its only user.
Pull Request Description
Use a new algorithm for placement of new nodes in cases when:
TAB
key is pressed while the mouse pointer is near an existing node (especially in an area below an existing node);In both cases mentioned above, the new node will now be placed in a location suggested by an internal algorithm, aligned to existing nodes. Specifically, the placement algorithm used is similar to when pressing
TAB
with a node selected.For more details, see: https://www.pivotaltracker.com/story/show/181076066
Visuals
A demo of
TAB
key and edge dropping behavior:Screen.Recording.2022-03-03.at.23.20.48.mov
Important Notes
Checklist
Please include the following checklist in your PR:
./run dist
and./run watch
.