mirror of
https://github.com/enso-org/enso.git
synced 2024-11-27 06:32:30 +03:00
Do not adjust node position when created under mouse cursor. (#7136)
Fixes #7064 Because our position adjusting mechanism was very confusing for users, especially on edge drops, this PR disables this adjusting for the cases where node is about to be put under the mouse pointer.
This commit is contained in:
parent
bf5ddf3de0
commit
24bdb1cf8a
@ -3710,6 +3710,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
// The alignment is disabled for mouse-oriented node placement. See [`new_node_position`] docs.
|
||||
#[ignore]
|
||||
fn test_magnet_alignment_when_adding_node_by_shortcut() {
|
||||
test_magnet_alignment_when_adding_node(move_mouse_and_add_node_by_shortcut);
|
||||
}
|
||||
|
@ -31,6 +31,11 @@ pub mod free_place_finder;
|
||||
/// Return a position for a newly created node. The position is calculated by establishing a
|
||||
/// reference position and then aligning it to existing nodes.
|
||||
///
|
||||
/// **Note** The aligning nodes is currently disabled for nodes which were created under mouse
|
||||
/// position (including dropping an edge), as it turned out to be confusing for users. It may be
|
||||
/// brought back once the algorithm will be improved (the [`at_mouse_aligned_to_close_nodes`]
|
||||
/// function)
|
||||
///
|
||||
/// The reference position is chosen from among:
|
||||
/// - the position of a source node of the dropped edge (if available),
|
||||
/// - the bottom-most selected node (if available),
|
||||
@ -63,13 +68,12 @@ pub fn new_node_position(
|
||||
AddNodeEvent => default(),
|
||||
StartCreationEvent | ClickingButton if some_nodes_are_selected =>
|
||||
under_selected_nodes(graph_editor),
|
||||
StartCreationEvent => at_mouse_aligned_to_close_nodes(graph_editor, mouse_position),
|
||||
StartCreationEvent => mouse_position,
|
||||
ClickingButton => {
|
||||
let pos = on_ray(graph_editor, screen_center, Vector2(0.0, -1.0)).unwrap();
|
||||
magnet_alignment(graph_editor, pos, HorizontallyAndVertically)
|
||||
}
|
||||
DroppingEdge { endpoint } =>
|
||||
at_mouse_aligned_to_source_node(graph_editor, endpoint.node_id, mouse_position),
|
||||
DroppingEdge { .. } => mouse_position,
|
||||
StartCreationFromPortEvent { endpoint } => under(graph_editor, endpoint.node_id),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user