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

Fix staff rotation offset for inserted syllables #120

Merged
merged 1 commit into from
Dec 21, 2023
Merged
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
30 changes: 14 additions & 16 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,40 +880,38 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in
= (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO);
const int noteWidth
= (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO);
ulx -= noteWidth / 2;

// calculate staff rotation offset
double theta = staff->GetDrawingRotate();
int offsetY = 0;
if (theta) {
double factor = 1.3;
offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0)
/ factor);
}

// Set up facsimile
zone->SetUlx(ulx);
zone->SetUly(uly + offsetY);
zone->SetUly(uly);
zone->SetLrx(ulx + noteWidth);
zone->SetLry(uly + offsetY + noteHeight);
zone->SetLry(uly + noteHeight);

// add syl bounding box if Facs
if (m_doc->GetType() == Facs) {
FacsimileInterface *fi = vrv_cast<FacsimileInterface *>(syl->GetFacsimileInterface());
assert(fi);
sylZone = new Zone();

int draw_h = staff->GetHeight();
int staffUly = staff->GetDrawingY();
int staffLry = staff->GetFacsimileInterface()->GetZone()->GetLry();

// width height and offset can be adjusted
int bboxHeight = 175;
int bboxOffsetX = 50;

// calculate staff rotation offset
double theta = staff->GetDrawingRotate();
int offsetY = 0;
if (theta) {
double factor = 1.3;
offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0)
/ factor);
}

sylZone->SetUlx(ulx);
sylZone->SetUly(staffUly + draw_h + offsetY);
sylZone->SetUly(staffLry + offsetY);
sylZone->SetLrx(ulx + noteWidth + bboxOffsetX);
sylZone->SetLry(staffUly + draw_h + offsetY + bboxHeight);
sylZone->SetLry(staffLry + offsetY + bboxHeight);
surface->AddChild(sylZone);
fi->AttachZone(sylZone);
}
Expand Down