diff --git a/src/app/document.cpp b/src/app/document.cpp index fbdfc5933..2cce9881e 100644 --- a/src/app/document.cpp +++ b/src/app/document.cpp @@ -114,11 +114,12 @@ void Document::notifyGeneralUpdate() notifyObservers(&doc::DocumentObserver::onGeneralUpdate, ev); } -void Document::notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region) +void Document::notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region, frame_t frame) { doc::DocumentEvent ev(this); ev.sprite(sprite); ev.region(region); + ev.frame(frame); notifyObservers(&doc::DocumentObserver::onSpritePixelsModified, ev); } diff --git a/src/app/document.h b/src/app/document.h index 1bb92eda0..f6ed80e63 100644 --- a/src/app/document.h +++ b/src/app/document.h @@ -79,7 +79,7 @@ namespace app { // Notifications void notifyGeneralUpdate(); - void notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region); + void notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region, frame_t frame); void notifyExposeSpritePixels(Sprite* sprite, const gfx::Region& region); void notifyLayerMergedDown(Layer* srcLayer, Layer* targetLayer); void notifyCelMoved(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame); diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp index d716a2c46..1ea8faa19 100644 --- a/src/app/ui/document_view.cpp +++ b/src/app/ui/document_view.cpp @@ -373,7 +373,8 @@ void DocumentView::onGeneralUpdate(doc::DocumentEvent& ev) void DocumentView::onSpritePixelsModified(doc::DocumentEvent& ev) { - if (m_editor->isVisible()) + if (m_editor->isVisible() && + m_editor->frame() == ev.frame()) m_editor->drawSpriteClipped(ev.region()); } diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp index b19cf2f5f..d34a6b667 100644 --- a/src/app/ui/editor/brush_preview.cpp +++ b/src/app/ui/editor/brush_preview.cpp @@ -155,7 +155,7 @@ void BrushPreview::show(const gfx::Point& screenPos) if (cel) opacity = MUL_UN8(opacity, cel->opacity(), t); if (layer) opacity = MUL_UN8(opacity, static_cast(layer)->opacity(), t); - document->prepareExtraCel(brushBounds, m_editor->frame(), opacity); + document->prepareExtraCel(brushBounds, site.frame(), opacity); document->setExtraCelType(render::ExtraType::NONE); document->setExtraCelBlendMode( (layer ? static_cast(layer)->blendMode(): @@ -168,7 +168,7 @@ void BrushPreview::show(const gfx::Point& screenPos) if (layer) { render::Render().renderLayer( - extraImage, layer, m_editor->frame(), + extraImage, layer, site.frame(), gfx::Clip(0, 0, brushBounds), BlendMode::SRC); @@ -192,7 +192,7 @@ void BrushPreview::show(const gfx::Point& screenPos) } document->notifySpritePixelsModified( - sprite, gfx::Region(m_lastBounds = brushBounds)); + sprite, gfx::Region(m_lastBounds = brushBounds), site.frame()); m_withRealPreview = true; } @@ -246,9 +246,11 @@ void BrushPreview::hide() // Clean pixel/brush preview if (m_withRealPreview) { + frame_t frame = document->getExtraCel()->frame(); + document->destroyExtraCel(); document->notifySpritePixelsModified( - sprite, gfx::Region(m_lastBounds)); + sprite, gfx::Region(m_lastBounds), frame); m_withRealPreview = false; } diff --git a/src/app/ui/editor/pixels_movement.cpp b/src/app/ui/editor/pixels_movement.cpp index 165b48117..aa47ff4f5 100644 --- a/src/app/ui/editor/pixels_movement.cpp +++ b/src/app/ui/editor/pixels_movement.cpp @@ -409,7 +409,8 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier) // If "fullBounds" is empty is because the cel was not moved if (!fullBounds.isEmpty()) { // Notify the modified region. - m_document->notifySpritePixelsModified(m_sprite, gfx::Region(fullBounds)); + m_document->notifySpritePixelsModified(m_sprite, gfx::Region(fullBounds), + m_site.frame()); } } diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index 1b7b81927..e54c8c2d6 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -192,7 +192,8 @@ public: void updateDirtyArea() override { // TODO find a way to avoid calling hide/show brush preview here HideBrushPreview hide(m_editor->brushPreview()); - m_document->notifySpritePixelsModified(m_sprite, m_dirtyArea); + m_document->notifySpritePixelsModified(m_sprite, m_dirtyArea, + m_frame); } void updateStatusBar(const char* text) override {