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

Disable most toolbar editing options for trill cue notes #19304

Merged
merged 3 commits into from
Nov 9, 2023
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
5 changes: 5 additions & 0 deletions src/engraving/dom/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,11 @@ bool Chord::preOrGraceBendSpacingExceptionInTab() const
return bends.size() < endChord->notes().size();
}

void Chord::setIsTrillCueNote(bool v)
{
m_isTrillCueNote = v;
}

//---------------------------------------------------------
// tremoloChordType
//---------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions src/engraving/dom/chord.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ class Chord final : public ChordRest
bool isPreBendOrGraceBendStart() const;
bool preOrGraceBendSpacingExceptionInTab() const;

bool isTrillCueNote() const { return m_isTrillCueNote; }
void setIsTrillCueNote(bool v);

void setTrack(track_idx_t val) override;

double dotPosX() const { return m_dotPosX; }
Expand Down Expand Up @@ -348,6 +351,8 @@ class Chord final : public ChordRest
mutable GraceNotesGroup m_graceNotesAfter = GraceNotesGroup(this); // will store after-chord grace notes
size_t m_graceIndex = 0; // if this is a grace note, index in parent list

bool m_isTrillCueNote = false;

DirectionV m_stemDirection = DirectionV::AUTO;
NoteType m_noteType = NoteType::NORMAL; // mark grace notes: acciaccatura and appoggiatura
bool m_noStem = false;
Expand Down
8 changes: 8 additions & 0 deletions src/engraving/dom/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,14 @@ mu::PointF Note::posInStaffCoordinates()
return mu::PointF(X, y());
}

void Note::setIsTrillCueNote(bool v)
{
m_isTrillCueNote = v;
if (chord()) {
chord()->setIsTrillCueNote(v);
}
}

void Note::addLineAttachPoint(PointF point, EngravingItem* line)
{
// IMPORTANT: the point is expected in *staff* coordinates
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class Note final : public EngravingItem
mu::PointF posInStaffCoordinates();

bool isTrillCueNote() const { return m_isTrillCueNote; }
void setIsTrillCueNote(bool v) { m_isTrillCueNote = v; }
void setIsTrillCueNote(bool v);

SymId noteHead() const;
bool isNoteName() const;
Expand Down
10 changes: 9 additions & 1 deletion src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2964,6 +2964,14 @@ void Score::cmdConcertPitchChanged(bool flag)

void Score::padToggle(Pad p, const EditData& ed)
{
if (!noteEntryMode()) {
for (ChordRest* cr : getSelectedChordRests()) {
if (cr->isChord() && toChord(cr)->isTrillCueNote()) {
return;
}
}
}

int oldDots = m_is.duration().dots();
switch (p) {
case Pad::NOTE00:
Expand Down Expand Up @@ -5064,7 +5072,7 @@ void Score::changeSelectedNotesVoice(voice_idx_t voice)
Chord* chord = note->chord();

// move grace notes with main chord only
if (chord->isGrace()) {
if (chord->isGrace() || chord->isTrillCueNote()) {
continue;
}

Expand Down
20 changes: 15 additions & 5 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2034,12 +2034,16 @@ void NotationInteraction::doAddSlur(const mu::engraving::Slur* slurTemplate)
}
}

if (firstChordRest && (firstChordRest != secondChordRest)) {
bool firstCrTrill = firstChordRest && firstChordRest->isChord() && toChord(firstChordRest)->isTrillCueNote();
bool secondCrTrill = secondChordRest && secondChordRest->isChord() && toChord(secondChordRest)->isTrillCueNote();

if (firstChordRest && (firstChordRest != secondChordRest)
&& !(firstCrTrill || secondCrTrill)) {
doAddSlur(firstChordRest, secondChordRest, slurTemplate);
}
}
} else if (sel.isSingle()) {
if (sel.element()->isNote()) {
if (sel.element()->isNote() && !toNote(sel.element())->isTrillCueNote()) {
doAddSlur(toNote(sel.element())->chord(), nullptr, slurTemplate);
}
} else {
Expand All @@ -2063,7 +2067,10 @@ void NotationInteraction::doAddSlur(const mu::engraving::Slur* slurTemplate)
secondChordRest = mu::engraving::nextChordRest(firstChordRest);
}

if (firstChordRest) {
bool firstCrTrill = firstChordRest && firstChordRest->isChord() && toChord(firstChordRest)->isTrillCueNote();
bool secondCrTrill = secondChordRest && secondChordRest->isChord() && toChord(secondChordRest)->isTrillCueNote();

if (firstChordRest && !(firstCrTrill || secondCrTrill)) {
doAddSlur(firstChordRest, secondChordRest, slurTemplate);
}
}
Expand Down Expand Up @@ -3889,6 +3896,9 @@ void NotationInteraction::changeSelectedNotesArticulation(SymbolId articulationS

std::set<Chord*> chords;
for (Note* note: notes) {
if (note->isTrillCueNote()) {
return;
}
Chord* chord = note->chord();
if (chords.find(chord) == chords.end()) {
chords.insert(chord);
Expand Down Expand Up @@ -3939,7 +3949,7 @@ void NotationInteraction::addGraceNotesToSelectedNotes(GraceNoteType type)
bool NotationInteraction::canAddTupletToSelectedChordRests() const
{
for (ChordRest* chordRest : score()->getSelectedChordRests()) {
if (chordRest->isGrace()) {
if (chordRest->isGrace() || (chordRest->isChord() && toChord(chordRest)->isTrillCueNote())) {
continue;
}

Expand All @@ -3961,7 +3971,7 @@ void NotationInteraction::addTupletToSelectedChordRests(const TupletOptions& opt
startEdit();

for (ChordRest* chordRest : score()->getSelectedChordRests()) {
if (!chordRest->isGrace()) {
if (!chordRest->isGrace() && !(chordRest->isChord() && toChord(chordRest)->isTrillCueNote())) {
Fraction ratio = options.ratio;
if (options.autoBaseLen) {
ratio.setDenominator(Tuplet::computeTupletDenominator(ratio.numerator(), chordRest->ticks()));
Expand Down