mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-23 00:40:04 +00:00
Fix position of the pasted image
This commit is contained in:
parent
ae9e2d173b
commit
8fc01593f7
@ -970,7 +970,8 @@ Rect Editor::getVisibleSpriteBounds()
|
|||||||
screenToEditor(vp.x, vp.y, &x1, &y1);
|
screenToEditor(vp.x, vp.y, &x1, &y1);
|
||||||
screenToEditor(vp.x+vp.w-1, vp.y+vp.h-1, &x2, &y2);
|
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.
|
// 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.
|
// 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.
|
// Then we check if the image will be visible by the user.
|
||||||
Rect visibleBounds = getVisibleSpriteBounds();
|
Rect visibleBounds = getVisibleSpriteBounds();
|
||||||
x = MID(visibleBounds.x-image->width(), x, visibleBounds.x+visibleBounds.w-1);
|
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;
|
x = visibleBounds.x + visibleBounds.w/2 - image->width()/2;
|
||||||
y = visibleBounds.y + visibleBounds.h/2 - image->height()/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(
|
PixelsMovementPtr pixelsMovement(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user