mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-23 04:20:56 +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) {
|
if (command->id() != CommandId::Copy) {
|
||||||
m_pixelsMovement->trim();
|
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.
|
// Discard the dragged image.
|
||||||
m_pixelsMovement->discardImage();
|
m_pixelsMovement->discardImage(PixelsMovement::CommitChanges, keepMask);
|
||||||
m_discarded = true;
|
m_discarded = true;
|
||||||
|
|
||||||
// Quit from MovingPixelsState, back to standby.
|
// Quit from MovingPixelsState, back to standby.
|
||||||
@ -610,7 +617,7 @@ void MovingPixelsState::onDropPixels(ContextBarObserver::DropAction action)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ContextBarObserver::CancelDrag:
|
case ContextBarObserver::CancelDrag:
|
||||||
m_pixelsMovement->discardImage(false);
|
m_pixelsMovement->discardImage(PixelsMovement::DontCommitChanges);
|
||||||
m_discarded = true;
|
m_discarded = true;
|
||||||
|
|
||||||
// Quit from MovingPixelsState, back to standby.
|
// Quit from MovingPixelsState, back to standby.
|
||||||
|
@ -581,14 +581,16 @@ void PixelsMovement::dropImage()
|
|||||||
m_document->setExtraCel(ExtraCelRef(nullptr));
|
m_document->setExtraCel(ExtraCelRef(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelsMovement::discardImage(bool commit)
|
void PixelsMovement::discardImage(const CommitChangesOption commit,
|
||||||
|
const KeepMaskOption keepMask)
|
||||||
{
|
{
|
||||||
m_isDragging = false;
|
m_isDragging = false;
|
||||||
|
|
||||||
// Deselect the mask (here we don't stamp the image)
|
// 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();
|
m_transaction.commit();
|
||||||
|
|
||||||
// Destroy the extra cel and regenerate the mask boundaries (we've
|
// Destroy the extra cel and regenerate the mask boundaries (we've
|
||||||
|
@ -47,6 +47,16 @@ namespace app {
|
|||||||
ScaleFromPivot = 32,
|
ScaleFromPivot = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CommitChangesOption {
|
||||||
|
DontCommitChanges,
|
||||||
|
CommitChanges,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum KeepMaskOption {
|
||||||
|
DontKeepMask,
|
||||||
|
KeepMask,
|
||||||
|
};
|
||||||
|
|
||||||
PixelsMovement(Context* context,
|
PixelsMovement(Context* context,
|
||||||
Site site,
|
Site site,
|
||||||
const Image* moveThis,
|
const Image* moveThis,
|
||||||
@ -76,7 +86,8 @@ namespace app {
|
|||||||
|
|
||||||
void dropImageTemporarily();
|
void dropImageTemporarily();
|
||||||
void dropImage();
|
void dropImage();
|
||||||
void discardImage(bool commit = true);
|
void discardImage(const CommitChangesOption commit = CommitChanges,
|
||||||
|
const KeepMaskOption keepMask = DontKeepMask);
|
||||||
bool isDragging() const;
|
bool isDragging() const;
|
||||||
|
|
||||||
gfx::Rect getImageBounds();
|
gfx::Rect getImageBounds();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user