Skip to content

Commit

Permalink
Fix StaffSort() for neme lines
Browse files Browse the repository at this point in the history
  • Loading branch information
yinanazhou committed Apr 25, 2024
1 parent a2712fa commit 8294255
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions include/vrv/editortoolkit_neume.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "doc.h"
#include "editortoolkit.h"
#include "measure.h"
#include "view.h"
#include "vrv.h"
#include "zone.h"
Expand Down Expand Up @@ -179,11 +180,26 @@ struct ClosestNeume {
struct StaffSort {
// Sort staves left-to-right and top-to-bottom
// Sort by y if there is no intersection, by x if there is x intersection is smaller than half length of staff line

// Update 2024-04:
// Used only in neume lines,
// System->(Measure->Staff)
// Need to sort Measure to sort staff
bool operator()(Object *a, Object *b)
{
if (!a->GetFacsimileInterface() || !b->GetFacsimileInterface()) return true;
Zone *zoneA = a->GetFacsimileInterface()->GetZone();
Zone *zoneB = b->GetFacsimileInterface()->GetZone();
if (!a->Is(MEASURE) || !b->Is(MEASURE)) return false;
Measure *measureA = dynamic_cast<Measure *>(a);
Measure *measureB = dynamic_cast<Measure *>(b);

if (!measureA->IsNeumeLine() || !measureB->IsNeumeLine()) return true;
Object *staffA = a->FindDescendantByType(STAFF);
Object *staffB = b->FindDescendantByType(STAFF);
assert(staffA);
assert(staffB);
Zone *zoneA = staffA->GetFacsimileInterface()->GetZone();
Zone *zoneB = staffB->GetFacsimileInterface()->GetZone();
assert(zoneA);
assert(zoneB);

int aLowest, bLowest, aHighest, bHighest;

Expand Down
2 changes: 1 addition & 1 deletion src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y)
(*it)->ShiftByXY(x, -y);
}

staff->GetParent()->StableSort(StaffSort());
staff->GetParent()->GetParent()->StableSort(StaffSort());
if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc();

return true; // Can't reorder by layer since staves contain layers
Expand Down

0 comments on commit 8294255

Please sign in to comment.