Skip to content

Commit

Permalink
Fix drop from palette to multimeasure rest
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Sep 23, 2024
1 parent 9dd3adb commit 4f5169a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/mscoreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MuseScoreView
virtual void setDropRectangle(const RectF&) {}
virtual void startNoteEntryMode() {}
virtual void drawBackground(muse::draw::Painter*, const RectF&) const = 0;
virtual void setDropTarget(const EngravingItem*) {}
virtual void setDropTarget(EngravingItem*) {}

virtual void textTab(bool /*back*/) {}

Expand Down
2 changes: 1 addition & 1 deletion src/notation/inotationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class INotationInteraction
virtual bool startDrop(const QUrl& url) = 0;
virtual bool isDropAccepted(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0; //! NOTE Also may set drop target
virtual bool drop(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) = 0;
virtual void setDropTarget(const EngravingItem* item, bool notify = true) = 0;
virtual void setDropTarget(EngravingItem* item, bool notify = true) = 0;
virtual void setDropRect(const muse::RectF& rect) = 0;
virtual void endDrop() = 0;
virtual muse::async::Notification dropChanged() const = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ bool NotationInteraction::drop(const PointF& pos, Qt::KeyboardModifiers modifier
//! NOTE: Helper method for NotationInteraction::drop. Handles drop logic for majority of elements (returns "accepted")
bool NotationInteraction::doDropStandard()
{
EngravingItem* el = dropTarget(m_dropData.ed);
EngravingItem* el = m_dropData.dropTarget ? m_dropData.dropTarget : dropTarget(m_dropData.ed);
if (!el) {
if (!dropCanvas(m_dropData.ed.dropElement)) {
LOGD("cannot drop %s(%p) to canvas", m_dropData.ed.dropElement->typeName(), m_dropData.ed.dropElement);
Expand Down Expand Up @@ -2441,7 +2441,7 @@ bool NotationInteraction::dragTimeAnchorElement(const PointF& pos)
}

//! NOTE Copied from ScoreView::setDropTarget
void NotationInteraction::setDropTarget(const EngravingItem* item, bool notify)
void NotationInteraction::setDropTarget(EngravingItem* item, bool notify)
{
if (m_dropData.dropTarget != item) {
if (m_dropData.dropTarget) {
Expand Down
4 changes: 2 additions & 2 deletions src/notation/internal/notationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable
bool startDrop(const QUrl& url) override;
bool isDropAccepted(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) override;
bool drop(const muse::PointF& pos, Qt::KeyboardModifiers modifiers) override;
void setDropTarget(const EngravingItem* item, bool notify = true) override;
void setDropTarget(EngravingItem* item, bool notify = true) override;
void setDropRect(const muse::RectF& rect) override;
void endDrop() override;
muse::async::Notification dropChanged() const override;
Expand Down Expand Up @@ -417,7 +417,7 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable
struct DropData
{
mu::engraving::EditData ed;
const EngravingItem* dropTarget = nullptr;
EngravingItem* dropTarget = nullptr;
muse::RectF dropRect;
};

Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/scorecallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ScoreCallbacks::setSelectionProximity(qreal proximity)
m_selectionProximity = proximity;
}

void ScoreCallbacks::setDropTarget(const mu::engraving::EngravingItem* dropTarget)
void ScoreCallbacks::setDropTarget(mu::engraving::EngravingItem* dropTarget)
{
IF_ASSERT_FAILED(m_interaction) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/scorecallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ScoreCallbacks : public mu::engraving::MuseScoreView
void drawBackground(muse::draw::Painter*, const muse::RectF&) const override;
const muse::Rect geometry() const override;
qreal selectionProximity() const override;
void setDropTarget(const mu::engraving::EngravingItem* dropTarget) override;
void setDropTarget(mu::engraving::EngravingItem* dropTarget) override;
void setDropRectangle(const muse::RectF& rect) override;
void changeEditElement(mu::engraving::EngravingItem* newElement) override;
void adjustCanvasPosition(const mu::engraving::EngravingItem*, int staffIdx = -1) override;
Expand Down
2 changes: 1 addition & 1 deletion src/notation/tests/mocks/notationinteractionmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class NotationInteractionMock : public INotationInteraction
MOCK_METHOD(bool, startDrop, (const QUrl&), (override));
MOCK_METHOD(bool, isDropAccepted, (const muse::PointF&, Qt::KeyboardModifiers), (override));
MOCK_METHOD(bool, drop, (const muse::PointF&, Qt::KeyboardModifiers), (override));
MOCK_METHOD(void, setDropTarget, (const EngravingItem*, bool), (override));
MOCK_METHOD(void, setDropTarget, (EngravingItem*, bool), (override));
MOCK_METHOD(void, setDropRect, (const muse::RectF&), (override));
MOCK_METHOD(void, endDrop, (), (override));
MOCK_METHOD(muse::async::Notification, dropChanged, (), (const, override));
Expand Down
6 changes: 3 additions & 3 deletions src/palette/view/widgets/notegroupsexampleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ void NoteGroupsExampleView::dragMoveEvent(QDragMoveEvent* event)
return;
}

const EngravingItem* newDropTarget = nullptr;
EngravingItem* newDropTarget = nullptr;

PointF position = toLogical(event->position());
std::vector<EngravingItem*> el = elementsAt(position);

for (const EngravingItem* e : el) {
for (EngravingItem* e : el) {
if (e->type() == ElementType::NOTE) {
newDropTarget = e;
break;
Expand All @@ -123,7 +123,7 @@ void NoteGroupsExampleView::dragMoveEvent(QDragMoveEvent* event)
return;
}

void NoteGroupsExampleView::setDropTarget(const EngravingItem* el)
void NoteGroupsExampleView::setDropTarget(EngravingItem* el)
{
if (m_dropTarget != el) {
if (m_dropTarget) {
Expand Down
2 changes: 1 addition & 1 deletion src/palette/view/widgets/notegroupsexampleview.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class NoteGroupsExampleView : public notation::ExampleView
void beamPropertyDropped(engraving::Chord*, engraving::ActionIcon*);

private:
void setDropTarget(const engraving::EngravingItem* el) override;
void setDropTarget(engraving::EngravingItem* el) override;

void dragEnterEvent(QDragEnterEvent*) override;
void dragLeaveEvent(QDragLeaveEvent*) override;
Expand Down

0 comments on commit 4f5169a

Please sign in to comment.