mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +00:00
Fix preview with selection tools in tiles mode
This commit is contained in:
parent
e5bfccbcd2
commit
4eeaad5a69
@ -446,9 +446,18 @@ public:
|
|||||||
gfx::Rect rc(x1, y, x2-x1+1, 1);
|
gfx::Rect rc(x1, y, x2-x1+1, 1);
|
||||||
|
|
||||||
// For tile point shape, the point shape is done in "tiles"
|
// For tile point shape, the point shape is done in "tiles"
|
||||||
// coordinatse, but we want the selection in "canvas" coordinates.
|
// coordinates, but we want the selection in canvas/pixels
|
||||||
if (loop->getPointShape()->isTile())
|
// coordinates.
|
||||||
rc = loop->getGrid().tileToCanvas(rc);
|
if (loop->getPointShape()->isTile()) {
|
||||||
|
const Grid& grid = loop->getGrid();
|
||||||
|
rc = grid.tileToCanvas(rc);
|
||||||
|
if (!m_modify_selection) {
|
||||||
|
// For feedback purposes, the coordinates must be relative to
|
||||||
|
// the getDstImage() and not in absolute sprite canvas
|
||||||
|
// coordinates.
|
||||||
|
rc.offset(-grid.origin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_modify_selection) {
|
if (m_modify_selection) {
|
||||||
int modifiers = int(loop->getModifiers());
|
int modifiers = int(loop->getModifiers());
|
||||||
|
@ -512,6 +512,9 @@ public:
|
|||||||
// pixels. See ExpandCelCanvas::commit() for details about this flag.
|
// pixels. See ExpandCelCanvas::commit() for details about this flag.
|
||||||
(getController()->isFreehand() ?
|
(getController()->isFreehand() ?
|
||||||
ExpandCelCanvas::UseModifiedRegionAsUndoInfo:
|
ExpandCelCanvas::UseModifiedRegionAsUndoInfo:
|
||||||
|
ExpandCelCanvas::None) |
|
||||||
|
(!m_tilesMode || m_ink->isSelection() ?
|
||||||
|
ExpandCelCanvas::PixelsBounds:
|
||||||
ExpandCelCanvas::None)));
|
ExpandCelCanvas::None)));
|
||||||
|
|
||||||
if (!m_floodfillSrcImage)
|
if (!m_floodfillSrcImage)
|
||||||
@ -550,10 +553,6 @@ public:
|
|||||||
// Setup the new grid of ExpandCelCanvas which can be displaced to
|
// Setup the new grid of ExpandCelCanvas which can be displaced to
|
||||||
// match the new temporal cel position (m_celOrigin).
|
// match the new temporal cel position (m_celOrigin).
|
||||||
m_grid = m_expandCelCanvas->getGrid();
|
m_grid = m_expandCelCanvas->getGrid();
|
||||||
|
|
||||||
if (m_tilesMode)
|
|
||||||
m_celOrigin = m_grid.origin();
|
|
||||||
else
|
|
||||||
m_celOrigin = m_expandCelCanvas->getCel()->position();
|
m_celOrigin = m_expandCelCanvas->getCel()->position();
|
||||||
|
|
||||||
m_mask = m_document->mask();
|
m_mask = m_document->mask();
|
||||||
@ -768,9 +767,8 @@ tools::ToolLoop* create_tool_loop(
|
|||||||
if (params.ink->isSelection() &&
|
if (params.ink->isSelection() &&
|
||||||
!params.tool->getPointShape(
|
!params.tool->getPointShape(
|
||||||
button != tools::Pointer::Left ? 1: 0)->isFloodFill()) {
|
button != tools::Pointer::Left ? 1: 0)->isFloodFill()) {
|
||||||
// TODO improve the selection preview without using a preview
|
// Don't call site.layer(nullptr) because we want to keep the
|
||||||
// image (e.g. we could use a gfx::Path)
|
// site.layer() to know if we are in a tilemap layer
|
||||||
site.layer(nullptr);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Layer* layer = site.layer();
|
Layer* layer = site.layer();
|
||||||
|
@ -118,7 +118,8 @@ ExpandCelCanvas::ExpandCelCanvas(
|
|||||||
m_origCelPos = m_cel->position();
|
m_origCelPos = m_cel->position();
|
||||||
|
|
||||||
// Region to draw
|
// Region to draw
|
||||||
gfx::Rect celBounds = (m_celCreated ? m_sprite->bounds(): m_cel->bounds());
|
gfx::Rect celBounds = (m_celCreated ? m_sprite->bounds():
|
||||||
|
m_cel->bounds());
|
||||||
|
|
||||||
gfx::Rect spriteBounds(0, 0,
|
gfx::Rect spriteBounds(0, 0,
|
||||||
m_sprite->width(),
|
m_sprite->width(),
|
||||||
@ -131,20 +132,28 @@ ExpandCelCanvas::ExpandCelCanvas(
|
|||||||
m_bounds = spriteBounds;
|
m_bounds = spriteBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_tilemapMode == TilemapMode::Tiles) {
|
if ((m_tilemapMode == TilemapMode::Tiles) ||
|
||||||
|
((m_flags & PixelsBounds) == PixelsBounds)) {
|
||||||
// Bounds of the canvas in tiles.
|
// Bounds of the canvas in tiles.
|
||||||
m_bounds = m_grid.canvasToTile(m_bounds);
|
m_bounds = m_grid.canvasToTile(m_bounds);
|
||||||
|
|
||||||
|
// New tiles bounds in pixels coordinates.
|
||||||
|
gfx::Rect newBoundsFromTiles = m_grid.tileToCanvas(m_bounds);
|
||||||
|
|
||||||
// As the grid origin depends on the current cel position (see
|
// As the grid origin depends on the current cel position (see
|
||||||
// Site::grid()), and we're going to modify the m_cel position
|
// Site::grid()), and we're going to modify the m_cel position
|
||||||
// temporarily, we need to adjust the grid to the new temporal
|
// temporarily, we need to adjust the grid to the new temporal
|
||||||
// grid origin matching the new m_dstImage position.
|
// grid origin matching the new m_dstImage position.
|
||||||
auto newCelPosition = m_grid.tileToCanvas(m_bounds.origin());
|
m_grid.origin(newBoundsFromTiles.origin());
|
||||||
m_grid.origin(newCelPosition);
|
|
||||||
|
|
||||||
|
|
||||||
// The origin of m_bounds must be in canvas position
|
// The origin of m_bounds must be in canvas position
|
||||||
m_bounds.setOrigin(newCelPosition);
|
if ((m_flags & PixelsBounds) == PixelsBounds) {
|
||||||
|
m_bounds = newBoundsFromTiles;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Bounds for the new cel which is a tilemap
|
||||||
|
m_bounds.setOrigin(newBoundsFromTiles.origin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to adjust the cel position to match the m_dstImage
|
// We have to adjust the cel position to match the m_dstImage
|
||||||
|
@ -47,6 +47,9 @@ namespace app {
|
|||||||
None = 0,
|
None = 0,
|
||||||
NeedsSource = 1,
|
NeedsSource = 1,
|
||||||
UseModifiedRegionAsUndoInfo = 2,
|
UseModifiedRegionAsUndoInfo = 2,
|
||||||
|
// Use tiles mode but with pixels bounds in dst image (e.g. for
|
||||||
|
// selection preview)
|
||||||
|
PixelsBounds = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpandCelCanvas(Site site, Layer* layer,
|
ExpandCelCanvas(Site site, Layer* layer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user