From 8fc01593f76f811f1ae5d199fbabed85ffbd9b5c Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 12 Nov 2014 11:32:18 -0300 Subject: [PATCH] Fix position of the pasted image --- src/app/ui/editor/editor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index f074af76a..db7991bb1 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -970,7 +970,8 @@ Rect Editor::getVisibleSpriteBounds() screenToEditor(vp.x, vp.y, &x1, &y1); screenToEditor(vp.x+vp.w-1, vp.y+vp.h-1, &x2, &y2); - return Rect(x1, y1, x2-x1+1, y2-y1+1); + return Rect(0, 0, m_sprite->width(), m_sprite->height()) + .createIntersect(Rect(x1, y1, x2-x1+1, y2-y1+1)); } // Changes the scroll to see the given point as the center of the editor. @@ -1365,10 +1366,6 @@ void Editor::pasteImage(const Image* image, int x, int y) // Check bounds where the image will be pasted. { - // First we limit the image inside the sprite's bounds. - x = MID(0, x, sprite->width() - image->width()); - y = MID(0, y, sprite->height() - image->height()); - // Then we check if the image will be visible by the user. Rect visibleBounds = getVisibleSpriteBounds(); x = MID(visibleBounds.x-image->width(), x, visibleBounds.x+visibleBounds.w-1); @@ -1385,6 +1382,10 @@ void Editor::pasteImage(const Image* image, int x, int y) x = visibleBounds.x + visibleBounds.w/2 - image->width()/2; y = visibleBounds.y + visibleBounds.h/2 - image->height()/2; } + + // We limit the image inside the sprite's bounds. + x = MID(0, x, sprite->width() - image->width()); + y = MID(0, y, sprite->height() - image->height()); } PixelsMovementPtr pixelsMovement(