void MapDocument::autocropMap() { if (!mCurrentLayer || !mCurrentLayer->isTileLayer()) return; TileLayer *tileLayer = static_cast<TileLayer*>(mCurrentLayer); const QRect bounds = tileLayer->region().boundingRect(); if (bounds.isNull()) return; resizeMap(bounds.size(), -bounds.topLeft(), true); }
void SelectSameTileTool::tilePositionChanged(const QPoint &tilePos) { // Make sure that a tile layer is selected and contains current tile pos. TileLayer *tileLayer = currentTileLayer(); if (!tileLayer) return; QRegion resultRegion; if (tileLayer->contains(tilePos)) { const Cell &matchCell = tileLayer->cellAt(tilePos); resultRegion = tileLayer->region([&] (const Cell &cell) { return cell == matchCell; }); } mSelectedRegion = resultRegion; brushItem()->setTileRegion(mSelectedRegion); }