Fix preview of certain tools in tiled mode (fix #2145)

Fixes #2145 and https://community.aseprite.org/t/3833
Regression introduced in: 6a88713213
This commit is contained in:
David Capello 2019-09-05 18:04:05 -03:00
parent 1c68c25594
commit 3e391670b9
3 changed files with 26 additions and 2 deletions

View File

@ -2692,6 +2692,26 @@ void Editor::expandRegionByTiledMode(gfx::Region& rgn,
}
}
void Editor::collapseRegionByTiledMode(gfx::Region& rgn) const
{
auto canvasSize = this->canvasSize();
rgn &= gfx::Region(gfx::Rect(canvasSize));
const int sprW = m_sprite->width();
const int sprH = m_sprite->height();
gfx::Region newRgn;
for (int v=0; v<canvasSize.h; v+=sprH) {
for (int u=0; u<canvasSize.w; u+=sprW) {
gfx::Region tmp(gfx::Rect(u, v, sprW, sprH));
tmp &= rgn;
tmp.offset(-u, -v);
newRgn |= tmp;
}
}
rgn = newRgn;
}
bool Editor::isMovingPixels() const
{
return (dynamic_cast<MovingPixelsState*>(m_state.get()) != nullptr);

View File

@ -192,6 +192,7 @@ namespace app {
gfx::Point mainTilePosition() const;
void expandRegionByTiledMode(gfx::Region& rgn,
const bool withProj) const;
void collapseRegionByTiledMode(gfx::Region& rgn) const;
// Changes the scroll to see the given point as the center of the editor.
void centerInSpritePoint(const gfx::Point& spritePos);

View File

@ -279,8 +279,11 @@ public:
for (auto e : UIContext::instance()->getAllEditorsIncludingPreview(m_document)) {
gfx::Region viewportRegion;
e->getDrawableRegion(viewportRegion, Widget::kCutTopWindows);
for (auto rc : viewportRegion)
allVisibleRgn |= gfx::Region(e->screenToEditor(rc).inflate(1, 1));
for (auto rc : viewportRegion) {
gfx::Region subrgn(e->screenToEditor(rc).inflate(1, 1));
e->collapseRegionByTiledMode(subrgn);
allVisibleRgn |= subrgn;
}
}
rgn &= allVisibleRgn;