Meshroom icon indicating copy to clipboard operation
Meshroom copied to clipboard

[ui] Paste nodes at the center of the Graph Editor when using the Edit > Paste menu

Open cbentejac opened this issue 1 year ago • 1 comments

Description

When using the Edit > Paste action menu, the Graph Editor does not have the focus, so there is no current mouse position within the GraphEditor. The position that is provided to the "pasteNodes" function is the last known mouse position within the Graph Editor, which oftentimes corresponds to its borders.

Instead of using the border of the Graph Editor as the top-left corner of the pasting zone (the zone in which all the nodes contained in the clipboard will be pasted, with their original distance to one another preserved), this PR simulates the mouse's position and sets it at the center of the Graph Editor. This position is then used as the center of the pasting zone instead of its top-left corner. Distances between the pasted nodes remains unchanged.

cbentejac avatar Sep 30 '22 14:09 cbentejac

Can we not just check if the mouse position is in the GraphEditor? If it's not inside, the paste is done at the center.

fabiencastan avatar Sep 30 '22 21:09 fabiencastan

Can we not just check if the mouse position is in the GraphEditor? If it's not inside, the paste is done at the center.

You're right: that way, we can also paste nodes at the center when the Graph Editor still has the focus but does not contain the mouse.

cbentejac avatar Oct 03 '22 09:10 cbentejac