Skip to content

Commit

Permalink
Merge pull request #3739 from rism-digital/develop-neon
Browse files Browse the repository at this point in the history
Integrate latest changes for the neume editor
  • Loading branch information
lpugin authored Aug 2, 2024
2 parents ae08e3a + 884c75c commit 4c62d6e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 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
15 changes: 13 additions & 2 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ 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 +1251,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 +3519,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 Expand Up @@ -4248,6 +4251,14 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef)
}
pi->SetOct(3);

// The default octave = 3, but the actual octave is calculated by
// taking into account the displacement of the clef
int octave = 3;
if (clef->GetDis() && clef->GetDisPlace()) {
octave += (clef->GetDisPlace() == STAFFREL_basic_above ? 1 : -1) * (clef->GetDis() / 7);
}
pi->SetOct(octave);

const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize);

const int pitchDifference
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 4c62d6e

Please sign in to comment.