From cd61daf869780e1302de1a34bca7b79485ca69c3 Mon Sep 17 00:00:00 2001 From: 0hypercube <0hypercube@gmail.com> Date: Mon, 4 Dec 2023 20:31:09 +0000 Subject: [PATCH] Fix issue with pasting an image in the centre --- .../messages/portfolio/document/document_message_handler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index cd41fd28d..f0263f391 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -539,8 +539,8 @@ impl MessageHandler> for DocumentMessageHand let image_size = DVec2::new(image.width as f64, image.height as f64); // Align the layer with the mouse or center of viewport - let viewport_location = mouse.map_or(ipp.viewport_bounds.center(), |pos| pos.into()); - let center_in_viewport = DAffine2::from_translation(viewport_location - ipp.viewport_bounds.top_left); + let viewport_location = mouse.map_or(ipp.viewport_bounds.center() + ipp.viewport_bounds.top_left, |pos| pos.into()); + let center_in_viewport = DAffine2::from_translation(self.metadata().document_to_viewport.inverse().transform_point2(viewport_location - ipp.viewport_bounds.top_left)); let center_in_viewport_layerspace = center_in_viewport; // Scale the image to fit into a 512x512 box