diff --git a/src/app/document.cpp b/src/app/document.cpp index 26bd9bcdc..f030732f9 100644 --- a/src/app/document.cpp +++ b/src/app/document.cpp @@ -36,6 +36,7 @@ #include "base/unique_ptr.h" #include "doc/document_event.h" #include "doc/document_observer.h" +#include "doc/document_observer.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/mask.h" @@ -139,6 +140,12 @@ void Document::notifyCelCopied(Layer* fromLayer, FrameNumber fromFrame, Layer* t notifyObservers(&doc::DocumentObserver::onCelCopied, ev); } +void Document::notifySelectionChanged() +{ + doc::DocumentEvent ev(this); + notifyObservers(&doc::DocumentObserver::onSelectionChanged, ev); +} + bool Document::isModified() const { return !m_undo->isSavedState(); @@ -210,6 +217,9 @@ void Document::generateMaskBoundaries(Mask* mask) m_bound.seg[c].y2 += mask->bounds().y; } } + + // TODO move this to the exact place where selection is modified. + notifySelectionChanged(); } ////////////////////////////////////////////////////////////////////// diff --git a/src/app/document.h b/src/app/document.h index 4fc63ab7e..491cff612 100644 --- a/src/app/document.h +++ b/src/app/document.h @@ -93,6 +93,7 @@ namespace app { void notifyLayerMergedDown(Layer* srcLayer, Layer* targetLayer); void notifyCelMoved(Layer* fromLayer, FrameNumber fromFrame, Layer* toLayer, FrameNumber toFrame); void notifyCelCopied(Layer* fromLayer, FrameNumber fromFrame, Layer* toLayer, FrameNumber toFrame); + void notifySelectionChanged(); ////////////////////////////////////////////////////////////////////// // File related properties diff --git a/src/app/ui/timeline.cpp b/src/app/ui/timeline.cpp index 71ac33e6c..d9e5463d3 100644 --- a/src/app/ui/timeline.cpp +++ b/src/app/ui/timeline.cpp @@ -968,6 +968,14 @@ void Timeline::onRemoveFrame(doc::DocumentEvent& ev) invalidate(); } +void Timeline::onSelectionChanged(doc::DocumentEvent& ev) +{ + m_range.disableRange(); + + clearClipboardRange(); + invalidate(); +} + void Timeline::onAfterFrameChanged(Editor* editor) { setFrame(editor->frame()); diff --git a/src/app/ui/timeline.h b/src/app/ui/timeline.h index fa8d99db1..c14b6d565 100644 --- a/src/app/ui/timeline.h +++ b/src/app/ui/timeline.h @@ -108,6 +108,7 @@ namespace app { void onAfterRemoveLayer(doc::DocumentEvent& ev) override; void onAddFrame(doc::DocumentEvent& ev) override; void onRemoveFrame(doc::DocumentEvent& ev) override; + void onSelectionChanged(doc::DocumentEvent& ev) override; // app::Context slots. void onAfterCommandExecution(Command* command); diff --git a/src/doc/document_observer.h b/src/doc/document_observer.h index 8b3d0aa4b..fb60b2ff4 100644 --- a/src/doc/document_observer.h +++ b/src/doc/document_observer.h @@ -55,6 +55,9 @@ namespace doc { // When the number of total frames available is modified. virtual void onTotalFramesChanged(DocumentEvent& ev) { } + // The selection has changed. + virtual void onSelectionChanged(DocumentEvent& ev) { } + // Called to destroy the observable. (Here you could call "delete this".) virtual void dispose() { } };