From 940450b79513f07a818704d6fc22dbd068a766af Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Thu, 2 Jul 2020 11:18:11 +0100 Subject: [PATCH] Use correct cursor position for node dragging and node instantiation. (https://github.com/enso-org/ide/pull/627) Original commit: https://github.com/enso-org/ide/commit/59a2e8f57d0dfe207743373dda0e3d1542cc5fc5 --- gui/src/rust/lib/graph-editor/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/src/rust/lib/graph-editor/src/lib.rs b/gui/src/rust/lib/graph-editor/src/lib.rs index 6ab418d64c..62bda447fb 100644 --- a/gui/src/rust/lib/graph-editor/src/lib.rs +++ b/gui/src/rust/lib/graph-editor/src/lib.rs @@ -1702,7 +1702,7 @@ fn new_graph_editor(world:&World) -> GraphEditor { new_node <- add_node.map(f_!([model,node_cursor_style] model.new_node(&node_cursor_style,&node_output_touch.down,&node_input_touch.down))); outputs.node_added <+ new_node; - node_with_position <- add_node_at_cursor.map3(&new_node,&mouse.position,|_,id,pos| (*id,*pos)); + node_with_position <- add_node_at_cursor.map3(&new_node,&cursor_pos_in_scene,|_,id,pos| (*id,*pos)); outputs.node_position_set <+ node_with_position; outputs.node_position_set_batched <+ node_with_position; @@ -1777,7 +1777,7 @@ fn new_graph_editor(world:&World) -> GraphEditor { // === Move Nodes === // ================== - mouse_pos_fix <- mouse.position.map(|p| Vector2(p.x,p.y)); + cursor_pos_fix <- cursor_pos_in_scene.map(|p| Vector2(p.x,p.y)); // === Discovering drag targets === @@ -1791,9 +1791,9 @@ fn new_graph_editor(world:&World) -> GraphEditor { eval tgts ((ids) model.disable_grid_snapping_for(ids)); main_pos_on_press <- main.map(f!((id) model.node_position(id))); - mouse_pos_on_press <- mouse_pos_fix.sample(&main); - mouse_pos_diff <- mouse_pos_fix.map2(&mouse_pos_on_press,|t,s|t-s).gate(&main_pressed); - main_tgt_pos_rt_changed <- mouse_pos_diff.map2(&main_pos_on_press,|t,s|t+s); + cursor_pos_on_press <- cursor_pos_fix.sample(&main); + cursor_pos_diff <- cursor_pos_fix.map2(&cursor_pos_on_press,|t,s|t-s).gate(&main_pressed); + main_tgt_pos_rt_changed <- cursor_pos_diff.map2(&cursor_pos_on_press,|t,s|t+s); just_pressed <- bool (&main_tgt_pos_rt_changed,&main_pos_on_press); main_tgt_pos_rt <- any (&main_tgt_pos_rt_changed,&main_pos_on_press);