Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: get rid of m_scoreCallbacks in NotationNoteInput #26795

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
4 changes: 1 addition & 3 deletions src/engraving/dom/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5009,7 +5009,7 @@ bool Score::resolveNoteInputParams(int note, bool addFlag, NoteInputParams& out)
// cmdAddPitch
/// insert note or add note to chord
//---------------------------------------------------------
void Score::cmdAddPitch(const EditData& ed, const NoteInputParams& params, bool addFlag, bool insert)
void Score::cmdAddPitch(const NoteInputParams& params, bool addFlag, bool insert)
{
InputState& is = inputState();
if (!is.isValid()) {
Expand Down Expand Up @@ -5041,8 +5041,6 @@ void Score::cmdAddPitch(const EditData& ed, const NoteInputParams& params, bool
}

cmdAddPitch(params.step, addFlag, insert);

ed.view()->adjustCanvasPosition(is.cr());
}

void Score::cmdAddPitch(int step, bool addFlag, bool insert)
Expand Down
14 changes: 4 additions & 10 deletions src/engraving/dom/mscoreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,17 @@
#ifndef MU_ENGRAVING_MSCOREVIEW_H
#define MU_ENGRAVING_MSCOREVIEW_H

#include <list>

#include "draw/painter.h"

#include "../types/types.h"

namespace muse::draw {
class Painter;
}

namespace mu::engraving {
class EngravingItem;
class Page;
class Score;

//---------------------------------------------------------
// MuseScoreView
//---------------------------------------------------------

class MuseScoreView
{
public:
Expand All @@ -62,8 +58,6 @@ class MuseScoreView

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

virtual const muse::Rect geometry() const = 0;

const std::vector<EngravingItem*> elementsAt(const PointF&) const;
EngravingItem* elementNear(const PointF& pos) const;
virtual void adjustCanvasPosition(const EngravingItem*, int /*staffIdx*/ = -1) {}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class Score : public EngravingObject, public muse::Injectable

bool resolveNoteInputParams(int noteIdx, bool addFlag, NoteInputParams& out) const;

void cmdAddPitch(const EditData&, const NoteInputParams& params, bool addFlag, bool insert);
void cmdAddPitch(const NoteInputParams& params, bool addFlag, bool insert);
void cmdAddPitch(int note, bool addFlag, bool insert);

void cmdAddStretch(double);
Expand Down
15 changes: 3 additions & 12 deletions src/notation/internal/notationnoteinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "engraving/dom/utils.h"

#include "mscoreerrorscontroller.h"
#include "scorecallbacks.h"

#include "log.h"

Expand All @@ -57,9 +56,6 @@ NotationNoteInput::NotationNoteInput(const IGetScore* getScore, INotationInterac
, const modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx), m_getScore(getScore), m_interaction(interaction), m_undoStack(undoStack)
{
m_scoreCallbacks = new ScoreCallbacks();
m_scoreCallbacks->setNotationInteraction(interaction);

m_interaction->selectionChanged().onNotify(this, [this]() {
if (!isNoteInputMode()) {
updateInputState();
Expand All @@ -74,11 +70,6 @@ NotationNoteInput::NotationNoteInput(const IGetScore* getScore, INotationInterac
});
}

NotationNoteInput::~NotationNoteInput()
{
delete m_scoreCallbacks;
}

bool NotationNoteInput::isNoteInputMode() const
{
return score()->inputState().noteEntryMode();
Expand Down Expand Up @@ -430,13 +421,11 @@ void NotationNoteInput::addNote(const NoteInputParams& params, NoteAddingMode ad
{
TRACEFUNC;

mu::engraving::EditData editData(m_scoreCallbacks);

startEdit(TranslatableString("undoableAction", "Enter note"));

bool addToUpOnCurrentChord = addingMode == NoteAddingMode::CurrentChord;
bool insertNewChord = addingMode == NoteAddingMode::InsertChord;
score()->cmdAddPitch(editData, params, addToUpOnCurrentChord, insertNewChord);
score()->cmdAddPitch(params, addToUpOnCurrentChord, insertNewChord);

apply();

Expand All @@ -448,6 +437,8 @@ void NotationNoteInput::addNote(const NoteInputParams& params, NoteAddingMode ad
notifyAboutStateChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();

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

void NotationNoteInput::padNote(const Pad& pad)
Expand Down
3 changes: 0 additions & 3 deletions src/notation/internal/notationnoteinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ class Score;
}

namespace mu::notation {
class ScoreCallbacks;
class NotationNoteInput : public INotationNoteInput, public muse::Injectable, public muse::async::Asyncable
{
muse::Inject<INotationConfiguration> configuration = { this };

public:
NotationNoteInput(const IGetScore* getScore, INotationInteraction* interaction, INotationUndoStackPtr undoStack,
const muse::modularity::ContextPtr& iocCtx);
~NotationNoteInput() override;

bool isNoteInputMode() const override;

Expand Down Expand Up @@ -121,7 +119,6 @@ class NotationNoteInput : public INotationNoteInput, public muse::Injectable, pu
muse::async::Channel</*focusNotation*/ bool> m_noteInputStarted;
muse::async::Notification m_noteInputEnded;

ScoreCallbacks* m_scoreCallbacks = nullptr;
std::function<muse::RectF()> m_getViewRectFunc;
};
}
Expand Down
10 changes: 0 additions & 10 deletions src/notation/internal/scorecallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
#include "scorecallbacks.h"

#include "engraving/dom/engravingitem.h"
#include "engraving/dom/lyrics.h"
#include "engraving/dom/system.h"

#include "inotationinteraction.h"
#include "igetscore.h"

#include "log.h"

Expand All @@ -47,12 +43,6 @@ void ScoreCallbacks::drawBackground(muse::draw::Painter*, const muse::RectF&) co
NOT_IMPLEMENTED;
}

const muse::Rect ScoreCallbacks::geometry() const
{
NOT_IMPLEMENTED;
return muse::Rect();
}

qreal ScoreCallbacks::selectionProximity() const
{
return m_selectionProximity;
Expand Down
7 changes: 0 additions & 7 deletions src/notation/internal/scorecallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,16 @@

#include "engraving/dom/mscoreview.h"

#include "notation/inotationconfiguration.h"
#include "modularity/ioc.h"

namespace mu::notation {
class INotationInteraction;
class IGetScore;
class ScoreCallbacks : public mu::engraving::MuseScoreView
{
INJECT(INotationConfiguration, configuration)

public:
ScoreCallbacks() = default;

void dataChanged(const muse::RectF&) override;
void updateAll() override;
void drawBackground(muse::draw::Painter*, const muse::RectF&) const override;
const muse::Rect geometry() const override;
qreal selectionProximity() const override;
void setDropTarget(mu::engraving::EngravingItem* dropTarget) override;
void setDropRectangle(const muse::RectF& rect) override;
Expand Down
4 changes: 0 additions & 4 deletions src/notation/view/widgets/exampleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ void ExampleView::setDropRectangle(const RectF&)
{
}

void ExampleView::cmdAddSlur(Note* /*firstNote*/, Note* /*lastNote*/)
{
}

void ExampleView::drawBackground(Painter* p, const RectF& r) const
{
if (m_backgroundPixmap == 0 || m_backgroundPixmap->isNull()) {
Expand Down
2 changes: 0 additions & 2 deletions src/notation/view/widgets/exampleview.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ class ExampleView : public QFrame, public engraving::MuseScoreView, public muse:

void changeEditElement(engraving::EngravingItem*) override;
void setDropRectangle(const muse::RectF&) override;
void cmdAddSlur(engraving::Note* firstNote, Note* lastNote);
void drawBackground(muse::draw::Painter*, const muse::RectF&) const override;
void dragExampleView(QMouseEvent* ev);
const muse::Rect geometry() const override { return muse::Rect(QFrame::geometry()); }

protected:
void mousePressEvent(QMouseEvent*) override;
Expand Down
Loading