Skip to content

Commit

Permalink
Refactor setting of rest duration
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 26, 2024
1 parent 27b94cd commit 2da0dce
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,22 +1539,17 @@ void View::DrawRest(DeviceContext *dc, LayerElement *element, Layer *layer, Staf
const bool drawingCueSize = rest->GetDrawingCueSize();
const int staffSize = staff->GetDrawingStaffNotationSize();
data_DURATION drawingDur = rest->GetActualDur();
if (drawingDur == DURATION_NONE) {
// in tablature the @dur is in the parent TabGrp
if (staff->IsTablature()) {
TabGrp *tabGrp = vrv_cast<TabGrp *>(rest->GetFirstAncestor(TABGRP));
if (tabGrp != NULL) {
drawingDur = tabGrp->GetActualDur();
}
}

if (drawingDur == DURATION_NONE) {
if (!dc->Is(BBOX_DEVICE_CONTEXT)) {
LogWarning("Missing duration for rest '%s'", rest->GetID().c_str());
}
drawingDur = DURATION_4;
}
// in tablature the @dur is in the parent TabGrp - try to get if from there
if ((drawingDur == DURATION_NONE) && staff->IsTablature()) {
TabGrp *tabGrp = vrv_cast<TabGrp *>(rest->GetFirstAncestor(TABGRP));
if (tabGrp != NULL) drawingDur = tabGrp->GetActualDur();
}
// Make sure we have something to draw
if ((drawingDur == DURATION_NONE) && !dc->Is(BBOX_DEVICE_CONTEXT)) {
LogWarning("Missing duration for rest '%s'", rest->GetID().c_str());
drawingDur = DURATION_4;
}

const char32_t drawingGlyph = rest->GetRestGlyph(drawingDur);

const int x = element->GetDrawingX();
Expand Down

0 comments on commit 2da0dce

Please sign in to comment.