implemented actions for adding grace notes

This commit is contained in:
RomanPudashkin 2021-03-03 13:55:11 +02:00
parent 0e36ab44d1
commit e2c7fc2ce1
8 changed files with 91 additions and 14 deletions

View file

@ -34,12 +34,6 @@
#include "property.h"
#include "sym.h"
namespace mu {
namespace notation {
class NotationNoteInput;
}
}
namespace Ms {
namespace Avs {
class AvsOmr;
@ -514,10 +508,6 @@ private:
QString accInfo; ///< information about selected element(s) for use by screen-readers
QString accMessage; ///< temporary status message for use by screen-readers
//------------------
friend class mu::notation::NotationNoteInput;
ChordRest* nextMeasure(ChordRest* element, bool selectBehavior = false, bool mmRest = false);
ChordRest* prevMeasure(ChordRest* element, bool mmRest = false);
void cmdSetBeamMode(Beam::Mode);
@ -529,12 +519,10 @@ private:
ChordRest* nextTrack(ChordRest* cr, bool skipMeasureRepeatRests = true);
ChordRest* prevTrack(ChordRest* cr, bool skipMeasureRepeatRests = true);
void padToggle(Pad p, const EditData& ed);
void addTempo();
void addMetronome();
void cmdInsertClef(ClefType);
void cmdAddGrace(NoteType, int);
void removeChordRest(ChordRest* cr, bool clearSegment);
void cmdMoveRest(Rest*, Direction);
void cmdMoveLyrics(Lyrics*, Direction);
@ -562,7 +550,6 @@ private:
void selectAdd(Element* e);
void selectRange(Element* e, int staffIdx);
void cmdAddPitch(const EditData&, int note, bool addFlag, bool insert);
void cmdAddFret(int fret);
void cmdToggleVisible();
@ -656,7 +643,10 @@ public:
void cmdAddOttava(OttavaType);
void addHairpin(HairpinType);
void addNoteLine();
void padToggle(Pad p, const EditData& ed);
void cmdAddPitch(const EditData&, int note, bool addFlag, bool insert);
void cmdAddStretch(qreal);
void cmdAddGrace(NoteType, int);
void cmdResetNoteAndRestGroupings();
void cmdResetAllPositions(bool undoable = true);
void cmdDoubleDuration() { cmdIncDecDuration(-1, false); }

View file

@ -108,6 +108,7 @@ public:
virtual void addAccidentalToSelection(AccidentalType type) = 0;
virtual void changeSelectedNotesArticulation(SymbolId articulationSymbolId) = 0;
virtual void addTupletToSelectedChords(const TupletOptions& options) = 0;
virtual void addGraceNotesToSelectedNotes(GraceNoteType type) = 0;
virtual void setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval = 0) = 0;
virtual void transpose(const TransposeOptions& options) = 0;

View file

@ -37,6 +37,7 @@ static const ActionCode REDO_ACTION_CODE = "redo";
void NotationActionController::init()
{
//! NOTE For historical reasons, the name of the action does not match what needs to be done
dispatcher()->reg(this, ESCAPE_ACTION_CODE, this, &NotationActionController::resetState);
dispatcher()->reg(this, "note-input", [this]() { toggleNoteInputMethod(NoteInputMethod::STEPTIME); });
@ -112,7 +113,6 @@ void NotationActionController::init()
dispatcher()->reg(this, "put-note", this, &NotationActionController::putNote);
//! NOTE For historical reasons, the name of the action does not match what needs to be done.
dispatcher()->reg(this, "next-element", [this](const ActionCode& actionCode) { moveAction(actionCode); });
dispatcher()->reg(this, "prev-element", [this](const ActionCode& actionCode) { moveAction(actionCode); });
dispatcher()->reg(this, "next-chord", [this](const ActionCode& actionCode) { moveAction(actionCode); });
@ -226,6 +226,15 @@ void NotationActionController::init()
dispatcher()->reg(this, "unroll-repeats", this, &NotationActionController::unrollRepeats);
dispatcher()->reg(this, "copy-lyrics-to-clipboard", this, &NotationActionController::copyLyrics);
dispatcher()->reg(this, "acciaccatura", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::ACCIACCATURA); });
dispatcher()->reg(this, "appoggiatura", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::APPOGGIATURA); });
dispatcher()->reg(this, "grace4", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE4); });
dispatcher()->reg(this, "grace16", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE16); });
dispatcher()->reg(this, "grace32", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE32); });
dispatcher()->reg(this, "grace8after", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE8_AFTER); });
dispatcher()->reg(this, "grace16after", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE16_AFTER); });
dispatcher()->reg(this, "grace32after", [this]() { addGraceNotesToSelectedNotes(GraceNoteType::GRACE32_AFTER); });
for (int i = MIN_NOTES_INTERVAL; i <= MAX_NOTES_INTERVAL; ++i) {
if (isNotesIntervalValid(i)) {
dispatcher()->reg(this, "interval" + std::to_string(i), [this, i]() { addInterval(i); });
@ -1119,6 +1128,16 @@ void NotationActionController::copyLyrics()
interaction->copyLyrics();
}
void NotationActionController::addGraceNotesToSelectedNotes(GraceNoteType type)
{
auto interaction = currentNotationInteraction();
if (!interaction) {
return;
}
interaction->addGraceNotesToSelectedNotes(type);
}
void NotationActionController::addStretch(qreal value)
{
auto interaction = currentNotationInteraction();

View file

@ -124,6 +124,7 @@ private:
void resequenceRehearsalMarks();
void unrollRepeats();
void copyLyrics();
void addGraceNotesToSelectedNotes(GraceNoteType type);
void resetState();
void resetStretch();

View file

@ -377,6 +377,38 @@ const ActionList NotationActions::m_actions = {
QT_TRANSLATE_NOOP("action", "Append Text Frame"),
QT_TRANSLATE_NOOP("action", "Append text frame")
),
ActionItem("acciaccatura",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Acciaccatura")
),
ActionItem("appoggiatura",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Appoggiatura")
),
ActionItem("grace4",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: quarter")
),
ActionItem("grace16",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: 16th")
),
ActionItem("grace32",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: 32nd")
),
ActionItem("grace8after",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: 8th after")
),
ActionItem("grace16after",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: 16th after")
),
ActionItem("grace32after",
ShortcutContext::NotationActive,
QT_TRANSLATE_NOOP("action", "Grace: 32nd after")
),
ActionItem("interval1",
ShortcutContext::NotationHasSelection,
QT_TRANSLATE_NOOP("action", "Unison Above"),

View file

@ -2220,6 +2220,38 @@ void NotationInteraction::addTupletToSelectedChords(const TupletOptions& options
notifyAboutSelectionChanged();
}
void NotationInteraction::addGraceNotesToSelectedNotes(GraceNoteType type)
{
int denominator = 1;
switch (type) {
case GraceNoteType::GRACE4:
case GraceNoteType::INVALID:
case GraceNoteType::NORMAL:
denominator = 1;
break;
case GraceNoteType::ACCIACCATURA:
case GraceNoteType::APPOGGIATURA:
case GraceNoteType::GRACE8_AFTER:
denominator = 2;
break;
case GraceNoteType::GRACE16:
case GraceNoteType::GRACE16_AFTER:
denominator = 4;
break;
case GraceNoteType::GRACE32:
case GraceNoteType::GRACE32_AFTER:
denominator = 8;
break;
}
startEdit();
score()->cmdAddGrace(type, Ms::MScore::division / denominator);
apply();
notifyAboutNotationChanged();
}
void NotationInteraction::setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval)
{
interval = intervalType == BreaksSpawnIntervalType::MeasuresInterval ? interval : 0;

View file

@ -125,6 +125,7 @@ public:
void addAccidentalToSelection(AccidentalType type) override;
void changeSelectedNotesArticulation(SymbolId articulationSymbolId) override;
void addTupletToSelectedChords(const TupletOptions& options) override;
void addGraceNotesToSelectedNotes(GraceNoteType type) override;
void setBreaksSpawnInterval(BreaksSpawnIntervalType intervalType, int interval = 0) override;
void transpose(const TransposeOptions& options) override;

View file

@ -88,6 +88,7 @@ using HairpinType = Ms::HairpinType;
using TextType = Ms::Tid;
using TupletNumberType = Ms::TupletNumberType;
using TupletBracketType = Ms::TupletBracketType;
using GraceNoteType = Ms::NoteType;
using PageList = std::vector<const Page*>;
using StaffList = QList<const Staff*>;