Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/notation/inotationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ class INotationInteraction

virtual void setGetViewRectFunc(const std::function<muse::RectF()>& func) = 0;

virtual void checkAndShowError() = 0;

virtual void toggleDebugShowGapRests() = 0;
};

Expand Down
34 changes: 21 additions & 13 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
#include "engraving/rw/rwregister.h"
#include "engraving/rw/xmlreader.h"

#include "mscoreerrorscontroller.h"
#include "notationerrors.h"
#include "notation.h"
#include "notationnoteinput.h"
Expand Down Expand Up @@ -238,6 +237,8 @@ NotationInteraction::NotationInteraction(Notation* notation, INotationUndoStackP
notifyAboutSelectionChangedIfNeed();
});

m_errorsController = std::make_shared<MScoreErrorsController>(iocContext());

m_noteInput->stateChanged().onNotify(this, [this]() {
if (!m_noteInput->isNoteInputMode()) {
hideShadowNote();
Expand Down Expand Up @@ -1379,8 +1380,7 @@ void NotationInteraction::endDrag()
}

notifyAboutDragChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

muse::async::Notification NotationInteraction::dragChanged() const
Expand Down Expand Up @@ -2079,7 +2079,7 @@ bool NotationInteraction::dropSingle(const PointF& pos, Qt::KeyboardModifiers mo
notifyAboutDropChanged();
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return accepted;
}
Expand Down Expand Up @@ -2196,7 +2196,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
endDrop();
notifyAboutDropChanged();
//MScore::setError(MsError::DEST_TUPLET);
//MScoreErrorsController(iocContext()).checkAndShowMScoreError();
// checkAndShowError();
// NOTE: if we show the error popup here it seems that the mouse-release event is missed
// so the dragged region stays sticked to the mouse and move around. Don't know how to fix it. [M.S.]
return false;
Expand Down Expand Up @@ -2231,7 +2231,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
endDrop();
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return true;
}
Expand Down Expand Up @@ -2332,7 +2332,7 @@ bool NotationInteraction::applyPaletteElement(mu::engraving::EngravingItem* elem

setDropTarget(nullptr);

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return true;
}
Expand Down Expand Up @@ -4870,7 +4870,7 @@ void NotationInteraction::splitSelectedMeasure()
SplitJoinMeasure::splitMeasure(score()->masterScore(), chordRest->tick());
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

void NotationInteraction::joinSelectedMeasures()
Expand All @@ -4885,7 +4885,7 @@ void NotationInteraction::joinSelectedMeasures()
SplitJoinMeasure::joinMeasures(score()->masterScore(), measureRange.startMeasure->tick(), measureRange.endMeasure->tick());
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

Ret NotationInteraction::canAddBoxes() const
Expand Down Expand Up @@ -5077,7 +5077,7 @@ void NotationInteraction::addBoxes(BoxType boxType, int count, int beforeBoxInde
void NotationInteraction::copySelection()
{
if (!selection()->canCopy()) {
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
return;
}

Expand Down Expand Up @@ -5224,7 +5224,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)
selectAndStartEditIfNeeded(pastedElement);
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

void NotationInteraction::swapSelection()
Expand Down Expand Up @@ -5267,7 +5267,7 @@ void NotationInteraction::deleteSelection()
score()->cmdDeleteSelection();
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
apply();
resetHitElementContext();
}
Expand Down Expand Up @@ -5886,7 +5886,7 @@ void NotationInteraction::addIntervalToSelectedNotes(int interval)

if (notes.empty()) {
MScore::setError(MsError::NO_NOTE_SELECTED);
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
return;
}

Expand Down Expand Up @@ -8208,3 +8208,11 @@ void NotationInteraction::setGetViewRectFunc(const std::function<RectF()>& func)
{
static_cast<NotationNoteInput*>(m_noteInput.get())->setGetViewRectFunc(func);
}

void NotationInteraction::checkAndShowError()
{
IF_ASSERT_FAILED(m_errorsController) {
return;
}
m_errorsController->checkAndShowMScoreError();
}
6 changes: 6 additions & 0 deletions src/notation/internal/notationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../iselectinstrumentscenario.h"
#include "inotationundostack.h"

#include "mscoreerrorscontroller.h"

#include "engraving/dom/engravingitem.h"
#include "engraving/dom/elementgroup.h"
#include "engraving/rendering/paintoptions.h"
Expand Down Expand Up @@ -336,6 +338,8 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable

void setGetViewRectFunc(const std::function<muse::RectF()>& func) override;

void checkAndShowError() override;

void toggleDebugShowGapRests() override;

private:
Expand Down Expand Up @@ -524,6 +528,8 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable

std::shared_ptr<NotationSelectionFilter> m_selectionFilter = nullptr;

std::shared_ptr<MScoreErrorsController> m_errorsController = nullptr;

DragData m_dragData;
muse::async::Notification m_dragChanged;
std::vector<muse::LineF> m_anchorLines;
Expand Down
27 changes: 10 additions & 17 deletions src/notation/internal/notationnoteinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "engraving/dom/drumset.h"
#include "engraving/dom/utils.h"

#include "mscoreerrorscontroller.h"

#include "log.h"

using namespace mu::notation;
Expand Down Expand Up @@ -464,8 +462,7 @@ void NotationNoteInput::addNote(const NoteInputParams& params, NoteAddingMode ad
notifyNoteAddedChanged();
notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();

m_interaction->checkAndShowError();
m_interaction->showItem(state().cr());
}

Expand All @@ -481,7 +478,7 @@ void NotationNoteInput::padNote(const Pad& pad)

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

Ret NotationNoteInput::putNote(const PointF& pos, bool replace, bool insert)
Expand All @@ -501,7 +498,7 @@ Ret NotationNoteInput::putNote(const PointF& pos, bool replace, bool insert)
notifyNoteAddedChanged();
notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();

return ret;
}
Expand All @@ -521,7 +518,7 @@ void NotationNoteInput::removeNote(const PointF& pos)

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

void NotationNoteInput::setInputNote(const NoteInputParams& params)
Expand Down Expand Up @@ -646,7 +643,7 @@ void NotationNoteInput::setAccidental(AccidentalType accidentalType)

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

void NotationNoteInput::setArticulation(SymbolId articulationSymbolId)
Expand All @@ -661,7 +658,7 @@ void NotationNoteInput::setArticulation(SymbolId articulationSymbolId)

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

void NotationNoteInput::setDrumNote(int note)
Expand Down Expand Up @@ -870,8 +867,7 @@ void NotationNoteInput::addTie()
score()->cmdAddTie();

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

void NotationNoteInput::addLaissezVib()
Expand All @@ -882,8 +878,7 @@ void NotationNoteInput::addLaissezVib()
score()->cmdToggleLaissezVib();

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

Notification NotationNoteInput::noteAdded() const
Expand Down Expand Up @@ -965,8 +960,7 @@ void NotationNoteInput::doubleNoteInputDuration()
apply();

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}

void NotationNoteInput::halveNoteInputDuration()
Expand All @@ -978,6 +972,5 @@ void NotationNoteInput::halveNoteInputDuration()
apply();

notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
m_interaction->checkAndShowError();
}
1 change: 1 addition & 0 deletions src/notation/tests/mocks/notationinteractionmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class NotationInteractionMock : public INotationInteraction
MOCK_METHOD(muse::async::Channel<ShowItemRequest>, showItemRequested, (), (const, override));

MOCK_METHOD(void, setGetViewRectFunc, (const std::function<muse::RectF()>&), (override));
MOCK_METHOD(void, checkAndShowError, (), (override));
MOCK_METHOD(void, toggleDebugShowGapRests, (), (override));
};
}
Loading