Skip to content
Open
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
27 changes: 27 additions & 0 deletions src/engraving/compat/engravingcompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "engraving/dom/box.h"
#include "engraving/dom/chord.h"
#include "engraving/dom/instrument.h"
#include "engraving/dom/lyrics.h"
#include "engraving/dom/masterscore.h"
#include "engraving/dom/note.h"
#include "engraving/dom/parenthesis.h"
Expand Down Expand Up @@ -295,6 +296,10 @@ void EngravingCompat::doPostLayoutCompatIfNeeded(MasterScore* score)

int mscVersion = score->mscVersion();

if (mscVersion < 470) {
needRelayout |= setLyricLineVisibility(score);
}

if (mscVersion < 440) {
needRelayout |= relayoutUserModifiedCrossStaffBeams(score);
}
Expand Down Expand Up @@ -343,4 +348,26 @@ bool EngravingCompat::relayoutUserModifiedCrossStaffBeams(MasterScore* score)

return found;
}

bool EngravingCompat::setLyricLineVisibility(MasterScore* masterScore)
{
bool needRelayout = false;
for (Score* score : masterScore->scoreList()) {
for (Spanner* sp : score->unmanagedSpanners()) {
if (!sp->isLyricsLine()) {
continue;
}

LyricsLine* ll = toLyricsLine(sp);
if (!ll->lyrics() || ll->visible() == ll->lyrics()->visible()) {
continue;
}

ll->setVisible(ll->lyrics()->visible());
needRelayout = true;
}
}

return needRelayout;
}
} // namespace mu::engraving::compat
1 change: 1 addition & 0 deletions src/engraving/compat/engravingcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ class EngravingCompat
static void migrateNoteParens(MasterScore* masterScore);

static bool relayoutUserModifiedCrossStaffBeams(MasterScore* score);
static bool setLyricLineVisibility(MasterScore* masterScore);
};
} // namespace mu::engraving::compat
18 changes: 9 additions & 9 deletions src/engraving/dom/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,9 @@ void Lyrics::removeFromScore()
}

if (!plainText().isEmpty()) {
for (auto sp : score()->spannerMap().findOverlapping(tick().ticks(), tick().ticks())) {
if (!sp.value->isPartialLyricsLine() || sp.value->track() != track()) {
continue;
}
PartialLyricsLine* partialLine = toPartialLyricsLine(sp.value);
if (partialLine->isEndMelisma() || partialLine->verse() != verse() || partialLine->placement() != placement()) {
continue;
}
score()->undoRemoveElement(partialLine);
PartialLyricsLine* partialDash = findPrevPartialLyricsLineDash(this);
if (partialDash) {
score()->undoRemoveElement(partialDash);
}
}

Expand Down Expand Up @@ -471,6 +465,12 @@ bool Lyrics::setProperty(Pid propertyId, const PropertyValue& v)
case Pid::AVOID_BARLINES:
m_avoidBarlines = v.toBool();
break;
case Pid::VISIBLE:
setVisible(v.toBool());
if (separator()) {
separator()->setVisible(v.toBool());
}
break;
default:
if (!TextBase::setProperty(propertyId, v)) {
return false;
Expand Down
17 changes: 17 additions & 0 deletions src/engraving/dom/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,23 @@ bool isValidBarLineForRepeatSection(const Segment* firstSeg, const Segment* seco
return segEndsWithBl && adjacentAndSecondShareSegment;
}

PartialLyricsLine* findPrevPartialLyricsLineDash(Lyrics* lyrics)
{
Score* score = lyrics->score();
for (auto sp : score->spannerMap().findOverlapping(lyrics->tick().ticks(), lyrics->tick().ticks())) {
if (!sp.value->isPartialLyricsLine() || sp.value->track() != lyrics->track()) {
continue;
}
PartialLyricsLine* partialLine = toPartialLyricsLine(sp.value);
if (partialLine->isEndMelisma() || partialLine->verse() != lyrics->verse() || partialLine->placement() != lyrics->placement()) {
continue;
}
return partialLine;
}

return nullptr;
}

MeasureBeat findBeat(const Score* score, int tick)
{
MeasureBeat measureBeat;
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/dom/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class KeySig;
class Lyrics;
class Measure;
class Note;
class PartialLyricsLine;
class Rest;
class Score;
class Score;
Expand Down Expand Up @@ -124,6 +125,8 @@ extern bool segmentsAreAdjacent(const Segment* firstSeg, const Segment* secondSe
extern bool segmentsAreInDifferentRepeatSegments(const Segment* firstSeg, const Segment* secondSeg);
extern bool isValidBarLineForRepeatSection(const Segment* firstSeg, const Segment* secondSeg);

extern PartialLyricsLine* findPrevPartialLyricsLineDash(Lyrics* lyrics);

extern bool isElementInFretBox(const EngravingItem* item);

extern std::vector<EngravingItem*> filterTargetElements(const Selection& sel, EngravingItem* dropElement, bool& unique);
Expand Down
11 changes: 11 additions & 0 deletions src/engraving/editing/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../dom/navigate.h"
#include "../dom/score.h"
#include "../dom/symbol.h"
#include "../dom/utils.h"

#include "log.h"

Expand Down Expand Up @@ -200,6 +201,16 @@ void TextBase::endEdit(EditData& ed)
ted->deleteText = true;
} else {
score()->undoRemoveElement(this);

if (isLyrics()) {
PartialLyricsLine* partialDash = findPrevPartialLyricsLineDash(toLyrics(this));
if (partialDash) {
// TODO: Making this operation undoable only makes sense if the text is restored too which is currently isn't
// Otherwise, we end up with a trailing partial dash with no ending syllable
score()->removeElement(partialDash);
}
}

commitText();
}
ed.element = 0;
Expand Down
1 change: 0 additions & 1 deletion src/engraving/rendering/score/lyricslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ void LyricsLayout::createOrRemoveLyricsLine(Lyrics* item, LayoutContext& ctx)
item->separator()->setTicks(lyricsLineTicks);
item->separator()->setTrack(item->track());
item->separator()->setTrack2(item->track());
item->separator()->setVisible(item->visible());
item->separator()->styleChanged();
} else {
if (item->separator()) {
Expand Down
18 changes: 4 additions & 14 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6992,6 +6992,8 @@ void NotationInteraction::navigateToNextSyllable()
return;
}

PartialLyricsLine* prevPartialLyricsLine = findPrevPartialLyricsLineDash(lyrics);

endEditText();

// look for the lyrics we are moving from; may be the current lyrics or a previous one
Expand Down Expand Up @@ -7034,6 +7036,7 @@ void NotationInteraction::navigateToNextSyllable()

if (hasPrecedingRepeat) {
score()->endCmd();
score()->startCmd(TranslatableString("undoableAction", "Add partial lyrics dash"));
// No from lyrics - create incoming partial dash
PartialLyricsLine* dash = Factory::createPartialLyricsLine(score()->dummy());
dash->setIsEndMelisma(false);
Expand Down Expand Up @@ -7119,20 +7122,6 @@ void NotationInteraction::navigateToNextSyllable()
}
}

PartialLyricsLine* prevPartialLyricsLine = nullptr;

for (auto sp : score()->spannerMap().findOverlapping(initialCR->tick().ticks(), initialCR->tick().ticks())) {
if (!sp.value->isPartialLyricsLine() || sp.value->track() != track) {
continue;
}
PartialLyricsLine* partialLine = toPartialLyricsLine(sp.value);
if (partialLine->isEndMelisma() || partialLine->verse() != lyrics->verse() || partialLine->placement() != lyrics->placement()) {
continue;
}
prevPartialLyricsLine = partialLine;
break;
}

bool newLyrics = (toLyrics == 0);
if (!toLyrics || hasPrecedingRepeat) {
// Don't advance cursor if we are after a repeat, there is no partial dash present and we are inputting a dash
Expand Down Expand Up @@ -7190,6 +7179,7 @@ void NotationInteraction::navigateToNextSyllable()
} else if (prevPartialLyricsLine) {
const Fraction tickDiff = cr->tick() - prevPartialLyricsLine->tick2();
prevPartialLyricsLine->undoMoveEnd(tickDiff);
score()->undoAddElement(prevPartialLyricsLine);
prevPartialLyricsLine->triggerLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "editpercussionshortcutmodel.h"
#include "shortcuts/shortcutstypes.h"

#include "translation.h"

using namespace muse;
using namespace mu::notation;

Expand Down
Binary file added vtest/scores/lyrics-32.mscz
Binary file not shown.
Binary file added vtest/scores/lyrics-33.mscz
Binary file not shown.
Loading