Implement pasting nodes at cursor position in graph
Closes #3798
This PR implements cursor-based paste by calculating the offset of the first selected node to be copied from the location of the most recent click. The following changes were added:
- The copied nodes are sorted by new id, so that we know the selection order of the nodes.
- Calculate the difference between the mouse position (
ipp.mouse.position) and the location of the first selected node. - Add the nodes to the graph (
NodeGraphMessage::AddNodes), and then shift by the offset (NodeGraphMessage::ShiftSelectedNodesByAmount)
One thing I'm not sure about is that one needs to actually click the desired paste location in order for ipp.mouse.position to update. Is there another something else tracking the cursor location?
Here's two examples of copy and paste
First we select the Transform node at (-15,3) as well as the Path node.
Next, I click (-16,4) based on eyeballing the grid, then paste the nodes with Ctrl+v. The Transform node is pasted to (-16,4), while the pasted Path node maintains the relative distance to the Transform node, without any wires to the Transform node.
Next, I select Stroke -> Transform -> Path and then copy the nodes. Stroke is at (-22, 3).
Finally, I click at (-16, 8) then paste with Ctrl+v. We paste Stroke node at (-16, 8), and the other selected nodes are copied as well with wires maintained.