Remove the marching ants effect from Timeline after paste

This is a simple fix for a recurrent problem where users don't know
how to remove/deselect the copied selection from the timeline after
pressing Ctrl+C. Generally the solution is pressing the Escape key,
but just pasting with Ctrl+V in some destination will disable the
effect now (just like spreadsheet apps work).

Related to:
https://community.aseprite.org/t/3941
https://community.aseprite.org/t/5038
https://community.aseprite.org/t/17281
https://github.com/aseprite/aseprite/issues/1498
This commit is contained in:
David Capello 2023-03-27 20:46:52 -03:00
parent 637632eafb
commit 668a3d8159

View File

@ -2073,12 +2073,11 @@ void Timeline::drawClipboardRange(ui::Graphics* g)
&clipboard_document,
&clipboard_range);
if (!m_document || clipboard_document != m_document)
if (!m_document ||
clipboard_document != m_document ||
!m_clipboard_timer.isRunning())
return;
if (!m_clipboard_timer.isRunning())
m_clipboard_timer.start();
IntersectClip clip(g, getRangeClipBounds(clipboard_range));
if (clip) {
ui::Paint paint;
@ -4272,6 +4271,14 @@ bool Timeline::onPaste(Context* ctx)
{
auto clipboard = ctx->clipboard();
if (clipboard->format() == ClipboardFormat::DocRange) {
// After a paste action, we just remove the marching ant
// (following paste commands will paste the same source range, but
// we just disable the marching ants effect).
if (m_clipboard_timer.isRunning()) {
m_clipboard_timer.stop();
m_redrawMarchingAntsOnly = false;
invalidate();
}
clipboard->paste(ctx, true);
return true;
}