diff --git a/src/engraving/rendering/single/singlelayout.cpp b/src/engraving/rendering/single/singlelayout.cpp index 4904644bd8be..80e5eb03e4b5 100644 --- a/src/engraving/rendering/single/singlelayout.cpp +++ b/src/engraving/rendering/single/singlelayout.cpp @@ -978,6 +978,7 @@ void SingleLayout::layout(GradualTempoChangeSegment* item, const Context& ctx) void SingleLayout::layout(GuitarBend*, const Context&) { NOT_IMPLEMENTED; + //! NOTE: Bends can be removed from disallowed elements in NotationInteraction::dragCopyAllowed once this has been implemented } void SingleLayout::layout(GuitarBendSegment*, const Context&) diff --git a/src/notation/inotationinteraction.h b/src/notation/inotationinteraction.h index 336cef0c2dc5..983d4bf0f2ef 100644 --- a/src/notation/inotationinteraction.h +++ b/src/notation/inotationinteraction.h @@ -95,6 +95,7 @@ class INotationInteraction virtual async::Notification dragChanged() const = 0; virtual bool isDragCopyStarted() const = 0; + virtual bool dragCopyAllowed(const EngravingItem* element) const = 0; virtual void startDragCopy(const EngravingItem* element, QObject* dragSource) = 0; virtual void endDragCopy() = 0; diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 5853bd517bbf..fbc79aa45ee1 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -1131,17 +1131,30 @@ bool NotationInteraction::isDragCopyStarted() const return m_drag != nullptr; } -//! NOTE: Copied from ScoreView::cloneElement -void NotationInteraction::startDragCopy(const EngravingItem* element, QObject* dragSource) +bool NotationInteraction::dragCopyAllowed(const EngravingItem* element) const { if (!element) { - return; + return false; } - if (element->isMeasure() || element->isNote() || element->isVBox()) { - return; + switch (element->type()) { + case ElementType::MEASURE: + case ElementType::NOTE: + case ElementType::VBOX: + // TODO: Bends can't be copy-dragged until corresponding SingleLayout::layout and SingleDraw::draw methods have been implemented + case ElementType::GUITAR_BEND: + case ElementType::GUITAR_BEND_SEGMENT: + case ElementType::GUITAR_BEND_HOLD: + case ElementType::GUITAR_BEND_HOLD_SEGMENT: + case ElementType::GUITAR_BEND_TEXT: + return false; + default: return true; } +} +//! NOTE: Copied from ScoreView::cloneElement +void NotationInteraction::startDragCopy(const EngravingItem* element, QObject* dragSource) +{ if (isDragStarted()) { endDragCopy(); } diff --git a/src/notation/internal/notationinteraction.h b/src/notation/internal/notationinteraction.h index ea6228c8d017..fe5f04d18b3f 100644 --- a/src/notation/internal/notationinteraction.h +++ b/src/notation/internal/notationinteraction.h @@ -103,6 +103,7 @@ class NotationInteraction : public INotationInteraction, public async::Asyncable async::Notification dragChanged() const override; bool isDragCopyStarted() const override; + bool dragCopyAllowed(const EngravingItem* element) const override; void startDragCopy(const EngravingItem* element, QObject* dragSource) override; void endDragCopy() override; diff --git a/src/notation/tests/mocks/notationinteractionmock.h b/src/notation/tests/mocks/notationinteractionmock.h index 9045e7ed4825..d1d155fc22ad 100644 --- a/src/notation/tests/mocks/notationinteractionmock.h +++ b/src/notation/tests/mocks/notationinteractionmock.h @@ -65,6 +65,7 @@ class NotationInteractionMock : public INotationInteraction MOCK_METHOD(async::Notification, dragChanged, (), (const, override)); MOCK_METHOD(bool, isDragCopyStarted, (), (const, override)); + MOCK_METHOD(bool, dragCopyAllowed, (const EngravingItem*), (const, override)); MOCK_METHOD(void, startDragCopy, (const EngravingItem*, QObject*), (override)); MOCK_METHOD(void, endDragCopy, (), (override)); diff --git a/src/notation/view/notationviewinputcontroller.cpp b/src/notation/view/notationviewinputcontroller.cpp index e1fe9bee9a63..52d94af00909 100644 --- a/src/notation/view/notationviewinputcontroller.cpp +++ b/src/notation/view/notationviewinputcontroller.cpp @@ -605,7 +605,9 @@ void NotationViewInputController::mousePressEvent(QMouseEvent* event) } if (keyState == (Qt::ShiftModifier | Qt::ControlModifier)) { - viewInteraction()->startDragCopy(hitElement, m_view->asItem()); + if (viewInteraction()->dragCopyAllowed(hitElement)) { + viewInteraction()->startDragCopy(hitElement, m_view->asItem()); + } return; }