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
23 changes: 16 additions & 7 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,10 @@ void Score::createCRSequence(const Fraction& f, ChordRest* cr, const Fraction& t
// return segment of last created note/rest
//---------------------------------------------------------

Segment* Score::setNoteRest(Segment* segment, int track, NoteVal nval, Fraction sd, Direction stemDirection, bool forceAccidental, bool rhythmic)
Segment* Score::setNoteRest(Segment* segment, int track, NoteVal nval, Fraction sd, Direction stemDirection, bool forceAccidental, bool rhythmic, InputState* externalInputState)
{
Q_ASSERT(segment->segmentType() == SegmentType::ChordRest);
InputState& is = externalInputState ? (*externalInputState) : _is;

bool isRest = nval.pitch == -1;
Fraction tick = segment->tick();
Expand Down Expand Up @@ -825,18 +826,18 @@ Segment* Score::setNoteRest(Segment* segment, int track, NoteVal nval, Fraction
if (tie)
connectTies();
if (nr) {
if (_is.slur() && nr->type() == ElementType::NOTE) {
if (is.slur() && nr->type() == ElementType::NOTE) {
// If the start element was the same as the end element when the slur was created,
// the end grip of the front slur segment was given an x-offset of 3.0 * spatium().
// Now that the slur is about to be given a new end element, this should be reset.
if (_is.slur()->endElement() == _is.slur()->startElement())
_is.slur()->frontSegment()->reset();
if (is.slur()->endElement() == is.slur()->startElement())
is.slur()->frontSegment()->reset();
//
// extend slur
//
Chord* chord = toNote(nr)->chord();
_is.slur()->undoChangeProperty(Pid::SPANNER_TICKS, chord->tick() - _is.slur()->tick());
for (ScoreElement* se : _is.slur()->linkList()) {
is.slur()->undoChangeProperty(Pid::SPANNER_TICKS, chord->tick() - is.slur()->tick());
for (ScoreElement* se : is.slur()->linkList()) {
Slur* slur = toSlur(se);
for (ScoreElement* ee : chord->linkList()) {
Element* e = static_cast<Element*>(ee);
Expand All @@ -847,7 +848,15 @@ Segment* Score::setNoteRest(Segment* segment, int track, NoteVal nval, Fraction
}
}
}
select(nr, SelectType::SINGLE, 0);
if (externalInputState) {
is.setTrack(nr->track());
ChordRest* cr = nr->isRest() ? toChordRest(nr) : toNote(nr)->chord();
is.setLastSegment(is.segment());
is.setSegment(cr->segment());
}
else {
select(nr, SelectType::SINGLE, 0);
}
}
return segment;
}
Expand Down
19 changes: 15 additions & 4 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ Rest* Score::setRest(const Fraction& _tick, int track, const Fraction& _l, bool
// addNote from NoteVal
//---------------------------------------------------------

Note* Score::addNote(Chord* chord, const NoteVal& noteVal, bool forceAccidental)
Note* Score::addNote(Chord* chord, const NoteVal& noteVal, bool forceAccidental, InputState* externalInputState)
{
InputState& is = externalInputState ? (*externalInputState) : _is;

Note* note = new Note(this);
note->setParent(chord);
note->setTrack(chord->track());
Expand All @@ -388,11 +390,20 @@ Note* Score::addNote(Chord* chord, const NoteVal& noteVal, bool forceAccidental)
}
setPlayNote(true);
setPlayChord(true);
select(note, SelectType::SINGLE, 0);

if (externalInputState) {
is.setTrack(note->track());
is.setLastSegment(is.segment());
is.setSegment(note->chord()->segment());
}
else {
select(note, SelectType::SINGLE, 0);
}

if (!chord->staff()->isTabStaff(chord->tick())) {
NoteEntryMethod entryMethod = _is.noteEntryMethod();
NoteEntryMethod entryMethod = is.noteEntryMethod();
if (entryMethod != NoteEntryMethod::REALTIME_AUTO && entryMethod != NoteEntryMethod::REALTIME_MANUAL)
_is.moveToNextInputPos();
is.moveToNextInputPos();
}
return note;
}
Expand Down
10 changes: 5 additions & 5 deletions libmscore/noteentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ Note* Score::addPitch(NoteVal& nval, bool addFlag, InputState* externalInputStat
InputState& is = externalInputState ? (*externalInputState) : _is;

if (addFlag) {
Chord* c = toChord(is.lastSegment()->element(is.track()));
ChordRest* c = toChordRest(is.lastSegment()->element(is.track()));

if (c == 0 || !c->isChord()) {
qDebug("Score::addPitch: cr %s", c ? c->name() : "zero");
return 0;
}
Note* note = addNote(c, nval);
Note* note = addNote(toChord(c), nval, /* forceAccidental */ false, externalInputState);
if (is.lastSegment() == is.segment()) {
NoteEntryMethod entryMethod = is.noteEntryMethod();
if (entryMethod != NoteEntryMethod::REALTIME_AUTO && entryMethod != NoteEntryMethod::REALTIME_MANUAL)
is.moveToNextInputPos();
}
return note;
}
expandVoice();
expandVoice(is.segment(), is.track());

// insert note
Direction stemDirection = Direction::AUTO;
Expand All @@ -152,7 +152,7 @@ Note* Score::addPitch(NoteVal& nval, bool addFlag, InputState* externalInputStat
stemDirection = ds->stemDirection(nval.pitch);
track = ds->voice(nval.pitch) + (is.track() / VOICES) * VOICES;
is.setTrack(track);
expandVoice();
expandVoice(is.segment(), is.track());
}
if (!is.cr())
return 0;
Expand Down Expand Up @@ -235,7 +235,7 @@ Note* Score::addPitch(NoteVal& nval, bool addFlag, InputState* externalInputStat
select(lastTiedNote);
}
else if (!is.usingNoteEntryMethod(NoteEntryMethod::REPITCH)) {
Segment* seg = setNoteRest(is.segment(), track, nval, duration, stemDirection);
Segment* seg = setNoteRest(is.segment(), track, nval, duration, stemDirection, /* forceAccidental */ false, /* rhythmic */ false, externalInputState);
if (seg) {
note = toChord(seg->element(track))->upNote();
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class Score : public QObject, public ScoreElement {

Note* setGraceNote(Chord*, int pitch, NoteType type, int len);

Segment* setNoteRest(Segment*, int track, NoteVal nval, Fraction, Direction stemDirection = Direction::AUTO, bool forceAccidental = false, bool rhythmic = false);
Segment* setNoteRest(Segment*, int track, NoteVal nval, Fraction, Direction stemDirection = Direction::AUTO, bool forceAccidental = false, bool rhythmic = false, InputState* externalInputState = nullptr);
Segment* setChord(Segment*, int track, Chord* chord, Fraction, Direction stemDirection = Direction::AUTO);
void changeCRlen(ChordRest* cr, const TDuration&);
void changeCRlen(ChordRest* cr, const Fraction&, bool fillWithRest=true);
Expand Down Expand Up @@ -724,7 +724,7 @@ class Score : public QObject, public ScoreElement {
void addPitch(int pitch, bool addFlag, bool insert);
Note* addTiedMidiPitch(int pitch, bool addFlag, Chord* prevChord);
Note* addMidiPitch(int pitch, bool addFlag);
Note* addNote(Chord*, const NoteVal& noteVal, bool forceAccidental = false);
Note* addNote(Chord*, const NoteVal& noteVal, bool forceAccidental = false, InputState* externalInputState = nullptr);

NoteVal noteValForPosition(Position pos, AccidentalType at, bool &error);

Expand Down