Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo layout after neume actions #3736

Merged
merged 4 commits into from
Aug 2, 2024
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
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
6 changes: 4 additions & 2 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y)

SortStaves();

m_doc->GetDrawingPage()->ResetAligners();
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 Expand Up @@ -1250,7 +1250,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in
}
layer->ReorderByXPos();

m_doc->GetDrawingPage()->LayOutPitchPos();
m_doc->GetDrawingPage()->LayOutTranscription(true);

if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc();

m_editInfo.import("status", status);
Expand Down Expand Up @@ -3517,6 +3518,7 @@ bool EditorToolkitNeume::ToggleLigature(std::vector<std::string> elementIds)
return false;
}

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

m_editInfo.import("status", "OK");
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