mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-21 16:20:53 +00:00
Keep selection after clear moving pixels (fix #1334)
If Aseprite is configured to keep the selection actived after clearing the selection, we must keep the selection active anyway if we've moved it.
This commit is contained in:
parent
dcb27c38d7
commit
efce7d56a8
@ -525,8 +525,15 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev)
|
||||
if (command->id() != CommandId::Copy) {
|
||||
m_pixelsMovement->trim();
|
||||
|
||||
// Should we keep the mask after an Edit > Clear command?
|
||||
auto keepMask = PixelsMovement::DontKeepMask;
|
||||
if (command->id() == CommandId::Clear &&
|
||||
Preferences::instance().selection.keepSelectionAfterClear()) {
|
||||
keepMask = PixelsMovement::KeepMask;
|
||||
}
|
||||
|
||||
// Discard the dragged image.
|
||||
m_pixelsMovement->discardImage();
|
||||
m_pixelsMovement->discardImage(PixelsMovement::CommitChanges, keepMask);
|
||||
m_discarded = true;
|
||||
|
||||
// Quit from MovingPixelsState, back to standby.
|
||||
@ -610,7 +617,7 @@ void MovingPixelsState::onDropPixels(ContextBarObserver::DropAction action)
|
||||
break;
|
||||
|
||||
case ContextBarObserver::CancelDrag:
|
||||
m_pixelsMovement->discardImage(false);
|
||||
m_pixelsMovement->discardImage(PixelsMovement::DontCommitChanges);
|
||||
m_discarded = true;
|
||||
|
||||
// Quit from MovingPixelsState, back to standby.
|
||||
|
@ -581,14 +581,16 @@ void PixelsMovement::dropImage()
|
||||
m_document->setExtraCel(ExtraCelRef(nullptr));
|
||||
}
|
||||
|
||||
void PixelsMovement::discardImage(bool commit)
|
||||
void PixelsMovement::discardImage(const CommitChangesOption commit,
|
||||
const KeepMaskOption keepMask)
|
||||
{
|
||||
m_isDragging = false;
|
||||
|
||||
// Deselect the mask (here we don't stamp the image)
|
||||
m_transaction.execute(new cmd::DeselectMask(m_document));
|
||||
if (keepMask == DontKeepMask)
|
||||
m_transaction.execute(new cmd::DeselectMask(m_document));
|
||||
|
||||
if (commit)
|
||||
if (commit == CommitChanges)
|
||||
m_transaction.commit();
|
||||
|
||||
// Destroy the extra cel and regenerate the mask boundaries (we've
|
||||
|
@ -47,6 +47,16 @@ namespace app {
|
||||
ScaleFromPivot = 32,
|
||||
};
|
||||
|
||||
enum CommitChangesOption {
|
||||
DontCommitChanges,
|
||||
CommitChanges,
|
||||
};
|
||||
|
||||
enum KeepMaskOption {
|
||||
DontKeepMask,
|
||||
KeepMask,
|
||||
};
|
||||
|
||||
PixelsMovement(Context* context,
|
||||
Site site,
|
||||
const Image* moveThis,
|
||||
@ -76,7 +86,8 @@ namespace app {
|
||||
|
||||
void dropImageTemporarily();
|
||||
void dropImage();
|
||||
void discardImage(bool commit = true);
|
||||
void discardImage(const CommitChangesOption commit = CommitChanges,
|
||||
const KeepMaskOption keepMask = DontKeepMask);
|
||||
bool isDragging() const;
|
||||
|
||||
gfx::Rect getImageBounds();
|
||||
|
Loading…
x
Reference in New Issue
Block a user