Skip to content

Commit

Permalink
Fix nc and staff jumping after staff dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
yinanazhou committed Aug 1, 2024
1 parent 1c02c63 commit c63d38e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
21 changes: 12 additions & 9 deletions src/calcligatureorneumeposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,19 @@ FunctorCode CalcLigatureOrNeumePosFunctor::VisitNeume(Neume *neume)
}
}

// If the nc overlaps with the previous, move it back from a line width
if (overlapWithPrevious) {
xRel -= lineWidth;
}
// xRel remains unset with facsimile
if (!m_doc->HasFacsimile()) {
// If the nc overlaps with the previous, move it back from a line width
if (overlapWithPrevious) {
xRel -= lineWidth;
}

nc->SetDrawingXRel(xRel);
// The first glyph set the spacing - unless we are starting a ligature, in which case no spacing should be added
// between the two nc
if (!previousLig) {
xRel += m_doc->GetGlyphWidth(nc->m_drawingGlyphs.at(0).m_fontNo, staffSize, false);
nc->SetDrawingXRel(xRel);
// The first glyph set the spacing - unless we are starting a ligature, in which case no spacing should be
// added between the two nc
if (!previousLig) {
xRel += m_doc->GetGlyphWidth(nc->m_drawingGlyphs.at(0).m_fontNo, staffSize, false);
}
}

previousNc = nc;
Expand Down
1 change: 1 addition & 0 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y)

SortStaves();

m_doc->GetDrawingPage()->LayOutTranscription(true);
if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc();

return true; // Can't reorder by layer since staves contain layers
Expand Down
19 changes: 12 additions & 7 deletions src/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ void Page::LayOutTranscription(bool force)
CalcAlignmentPitchPosFunctor calcAlignmentPitchPos(doc);
this->Process(calcAlignmentPitchPos);

CalcLigatureOrNeumePosFunctor calcLigatureOrNeumePos(doc);
this->Process(calcLigatureOrNeumePos);

CalcStemFunctor calcStem(doc);
this->Process(calcStem);

Expand All @@ -262,13 +265,15 @@ void Page::LayOutTranscription(bool force)
CalcDotsFunctor calcDots(doc);
this->Process(calcDots);

// Render it for filling the bounding box
View view;
view.SetDoc(doc);
BBoxDeviceContext bBoxDC(&view, 0, 0, BBOX_HORIZONTAL_ONLY);
// Do not do the layout in this view - otherwise we will loop...
view.SetPage(this->GetIdx(), false);
view.DrawCurrentPage(&bBoxDC, false);
if (!m_layoutDone) {
// Render it for filling the bounding box
View view;
view.SetDoc(doc);
BBoxDeviceContext bBoxDC(&view, 0, 0, BBOX_HORIZONTAL_ONLY);
// Do not do the layout in this view - otherwise we will loop...
view.SetPage(this->GetIdx(), false);
view.DrawCurrentPage(&bBoxDC, false);
}

AdjustXRelForTranscriptionFunctor adjustXRelForTranscription;
this->Process(adjustXRelForTranscription);
Expand Down

0 comments on commit c63d38e

Please sign in to comment.