From 9c4751e8ea2817da8c6a1ffc06dbfeeacd861c3e Mon Sep 17 00:00:00 2001 From: "Maurizio M. Gavioli" Date: Sun, 15 Sep 2013 01:07:24 +0200 Subject: [PATCH] If another staff is linked to a TAB staff, entering the 2nd digit of a 2-digit fret number has no effect in the linked staff. Fixed by iterating the fret no. change on all the notes linked to the note being edited. Note: is it reliable to assume that elements linked to a Note are also Note's? --- libmscore/edit.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/libmscore/edit.cpp b/libmscore/edit.cpp index a1e8669f6b..5e019d7fee 100644 --- a/libmscore/edit.cpp +++ b/libmscore/edit.cpp @@ -682,7 +682,7 @@ void Score::putNote(const Position& p, bool replace) const Instrument* instr = st->part()->instr(); MScore::Direction stemDirection = MScore::AUTO; NoteVal nval; - Tablature* neck = 0; + Tablature* stringData = 0; StaffTypeTablature * tab = 0; switch(st->staffType()->group()) { @@ -702,10 +702,10 @@ void Score::putNote(const Position& p, bool replace) case TAB_STAFF_GROUP: { if (_is.rest) return; - neck = instr->tablature(); + stringData = instr->tablature(); tab = (StaffTypeTablature*)st->staffType(); int string = tab->VisualStringToPhys(line); - if (string < 0 || string >= neck->strings()) + if (string < 0 || string >= stringData->strings()) return; // build a default NoteVal for that line nval.string = string; @@ -715,7 +715,7 @@ void Score::putNote(const Position& p, bool replace) _is.setString(line); nval.fret = 0; } - nval.pitch = neck->getPitch(string, nval.fret); + nval.pitch = stringData->getPitch(string, nval.fret); break; } @@ -746,21 +746,32 @@ void Score::putNote(const Position& p, bool replace) if (st->isTabStaff()) { // TAB // if a note on same string already exists, update to new pitch/fret foreach(Note * note, static_cast(cr)->notes()) - if(note->string() == nval.string) { // if string is the same - // if adding a new digit will keep fret number within fret limit - // add a digit - if (neck && tab->useNumbers() && note->fret() >= 1) { + if(note->string() == nval.string) { // if string is the same + // if adding a new digit will keep fret number within fret limit, + // add a digit to existing fret number + if (stringData && tab->useNumbers() && note->fret() >= 1) { int fret = note->fret() * 10 + nval.fret; - if (fret <= neck->frets() ) { + if (fret <= stringData->frets() ) { nval.fret = fret; - nval.pitch = neck->getPitch(nval.string, nval.fret); + nval.pitch = stringData->getPitch(nval.string, nval.fret); } else qDebug("can't increase fret to %d", fret); } - // otherwise, replace with new fret - note->undoChangeProperty(P_PITCH, nval.pitch); - note->undoChangeProperty(P_FRET, nval.fret); + // set fret number (orignal or combined) in all linked notes + nval.tpc = pitch2tpc(nval.pitch, KEY_C, PREFER_NEAREST); + foreach (Element* e, note->linkList()) { + Note* linkedNote = static_cast(e); + Staff* staff = linkedNote->staff(); + if (staff->isTabStaff()) { + (static_cast(linkedNote))->undoChangeProperty(P_PITCH, nval.pitch); + (static_cast(linkedNote))->undoChangeProperty(P_TPC, nval.tpc); + (static_cast(linkedNote))->undoChangeProperty(P_FRET, nval.fret); + (static_cast(linkedNote))->undoChangeProperty(P_STRING,nval.string); + } + else if (staff->isPitchedStaff()) + undoChangePitch(linkedNote, nval.pitch, nval.tpc, linkedNote->line()); + } return; } }