Skip to content

Commit

Permalink
Fix custos drawing and dragging methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yinanazhou committed Apr 9, 2024
1 parent 471e36a commit 0c8fb32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
16 changes: 7 additions & 9 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y)
}
Layer *layer = vrv_cast<Layer *>(element->GetFirstAncestor(LAYER));
layer->ReorderByXPos(); // Reflect position order of elements internally (and in the resulting output file)
if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc();
m_editInfo.import("status", status);
m_editInfo.import("message", message);
return true;
Expand Down Expand Up @@ -4106,15 +4107,12 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef)

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

// Use the same pitchDifference equation for both syllables and custos
const int pitchDifference
= round((double)(staff->GetDrawingY() + (2 * staffSize * (staff->m_drawingLines - clef->GetLine()))
- fi->GetZone()->GetUly()
- ((fi->GetZone()->GetUlx() - staff->GetZone()->GetUlx())
* tan(-staff->GetDrawingRotate() * M_PI / 180.0)))
/ (double)(staffSize));

pi->AdjustPitchByOffset(pitchDifference);
const int pitchDifference = round(
(staff->GetDrawingY() - staff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(fi->GetZone()->GetUlx()))
- m_view->ToLogicalY(fi->GetZone()->GetUly()))
/ staffSize
- (((staff->m_drawingLines - 1) * 2) - clef->GetClefLocOffset()));
pi->AdjustPitchByOffset(-pitchDifference);
return true;
}

Expand Down
18 changes: 1 addition & 17 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,28 +788,12 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St
y -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize);
}

if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) {
double deg = staff->GetDrawingRotate();
int xDiff = x - staff->GetDrawingX();
y -= int(xDiff * tan(deg * M_PI / 180.0));
}
else if (staff->HasDrawingRotation()) {
if (staff->HasDrawingRotation()) {
y -= staff->GetDrawingRotationOffsetFor(x);
}

this->DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false, true);

if (m_doc->IsFacs() && element->HasFacs()) {
const int noteHeight = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / 2);
const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / 1.4);

FacsimileInterface *fi = element->GetFacsimileInterface();
fi->GetZone()->SetUlx(x);
fi->GetZone()->SetUly(ToDeviceContextY(y));
fi->GetZone()->SetLrx(x + noteWidth);
fi->GetZone()->SetLry(ToDeviceContextY(y - noteHeight));
}

/************ Draw children (accidentals, etc) ************/
// Drawing the children should be done before ending the graphic. Otherwise the SVG tree will not match the MEI one
this->DrawLayerChildren(dc, custos, layer, staff, measure);
Expand Down

0 comments on commit 0c8fb32

Please sign in to comment.