diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 7275b1d1f49e3..8ac045ca66f6b 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -5777,6 +5777,9 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool if (newEnd) { ne = element->linkedClone(); toSpanner(ne)->setNoteSpan(toNote(e), newEnd); + if (element->isGuitarBend() && element->staffType()->isTabStaff()) { + toGuitarBend(ne)->endNote()->setVisible(true); + } } else { //couldn't find suitable start note continue; } diff --git a/src/engraving/dom/guitarbend.cpp b/src/engraving/dom/guitarbend.cpp index 12d593f2b7803..83f94be46c470 100644 --- a/src/engraving/dom/guitarbend.cpp +++ b/src/engraving/dom/guitarbend.cpp @@ -632,6 +632,42 @@ mu::draw::Color GuitarBend::uiColor() const return curColor(); } +void GuitarBend::adaptBendsFromTabToStandardStaff(const Staff* staff) +{ + // On tabs, bends force end notes to be invisible. When switching to + // normal staff we need to turn all the end notes visible again. + + auto processBends = [](Chord* chord) { + for (Note* note : chord->notes()) { + GuitarBend* bend = note->bendFor(); + if (!bend) { + continue; + } + bend->endNote()->setVisible(true); + } + }; + + staff_idx_t staffIdx = staff->idx(); + track_idx_t startTrack = staff2track(staffIdx); + track_idx_t endTrack = startTrack + VOICES; + for (Segment* segment = staff->score()->firstSegment(SegmentType::ChordRest); segment; segment = segment->next1()) { + if (!segment->isChordRestType()) { + continue; + } + for (track_idx_t track = startTrack; track < endTrack; ++track) { + EngravingItem* item = segment->elementAt(track); + if (!item || !item->isChord()) { + continue; + } + Chord* chord = toChord(item); + processBends(chord); + for (Chord* grace : chord->graceNotes()) { + processBends(grace); + } + } + } +} + /**************************************** * GuitarBendHold * **************************************/ diff --git a/src/engraving/dom/guitarbend.h b/src/engraving/dom/guitarbend.h index 48840916f99ef..f1b2b3797c674 100644 --- a/src/engraving/dom/guitarbend.h +++ b/src/engraving/dom/guitarbend.h @@ -94,6 +94,8 @@ class GuitarBend final : public SLine mu::draw::Color uiColor() const; + static void adaptBendsFromTabToStandardStaff(const Staff* staff); + struct LayoutData : public SLine::LayoutData { public: diff --git a/src/engraving/dom/note.cpp b/src/engraving/dom/note.cpp index 2d0314ad56c8c..f98c9177a811a 100644 --- a/src/engraving/dom/note.cpp +++ b/src/engraving/dom/note.cpp @@ -2928,6 +2928,11 @@ PropertyValue Note::propertyDefault(Pid propertyId) const case Pid::PITCH: case Pid::TPC1: return PropertyValue(); + case Pid::VISIBLE: + if (staffType() && staffType()->isTabStaff() && bendBack()) { + return false; + } + return EngravingItem::propertyDefault(propertyId); default: break; } diff --git a/src/engraving/dom/undo.cpp b/src/engraving/dom/undo.cpp index 524c5b80939a0..5d075616154a0 100644 --- a/src/engraving/dom/undo.cpp +++ b/src/engraving/dom/undo.cpp @@ -45,6 +45,7 @@ #include "engravingitem.h" #include "excerpt.h" #include "fret.h" +#include "guitarbend.h" #include "harmony.h" #include "harppedaldiagram.h" #include "input.h" @@ -1839,6 +1840,7 @@ void ChangeStaffType::flip(EditData*) staff->setStaffType(Fraction(0, 1), staffType); bool invisibleChanged = oldStaffType.invisible() != staffType.invisible(); + bool fromTabToStandard = oldStaffType.isTabStaff() && !staffType.isTabStaff(); staffType = oldStaffType; @@ -1850,6 +1852,10 @@ void ChangeStaffType::flip(EditData*) } } + if (fromTabToStandard) { + GuitarBend::adaptBendsFromTabToStandardStaff(staff); + } + staff->triggerLayout(); }