-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Autocrop feature #1574
Adds Autocrop feature #1574
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some comments for now
src/tiled/mapdocument.cpp
Outdated
if (bounds.isNull()) | ||
return; | ||
|
||
resizeMap(bounds.size(), -bounds.topLeft(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... The boundary check only considers tiles... @bjorn Is it fine to silently delete objects (the third parameter) which are not in the area here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option of Crop to Selection
behaves in a similar way. It also deletes the objects outside the selected region. I took that under consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's reasonable for this to be consistent with "Crop to Selection". There isn't really an opportunity to ask the user here, unless we'd introduce a popup, which I don't really want to.
} | ||
} else { | ||
mActionSelectNone->setEnabled(false); | ||
mActionAutocrop->setEnabled(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be more readable to put one line below together with mActionCropToSelection
like this:
mActionAutocrop->setEnabled(currentLayer && currentLayer->isTileLayer());
The mActionSelectNone
needed all this special code only because the condition on whether it should be enabled or not varies depending on the type of the selected layer, but let's not "abuse" all those cases for setting the state of mActionAutocrop
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from two small nitpicks about whitespace, this change is ready to go in.
I will wait with merging it until I have created the 1.0
branch, since due to the string freeze this feature will go to Tiled 1.1.
Thanks!
@bjorn I think you forgot this one 🙂 |
This addresses #642. The option is available in the 'Map' menu and is available only when a Tile Layer is selected. The implementation is pretty straightforward:
(minX, minY)
and(maxX, maxY)
by checking all the cells of the current layer.Crop to Selection
, except, the region is calculated usingTileLayer::computeAutocropRegion()