@@ -859,8 +859,11 @@ static void addElemOffset(Element* el, int track, const QString& placement, Meas
859859 el->setPlacement(placement == "above" ? Placement::ABOVE : Placement::BELOW);
860860 }
861861#endif
862- el->setPlacement (placement == " above" ? Placement::ABOVE : Placement::BELOW);
863- el->setPropertyFlags (Pid::PLACEMENT, PropertyFlags::UNSTYLED);
862+ if (placement != " " ) {
863+ el->setPlacement (placement == " above" ? Placement::ABOVE : Placement::BELOW);
864+ el->setPropertyFlags (Pid::PLACEMENT, PropertyFlags::UNSTYLED);
865+ }
866+
864867
865868 el->setTrack (el->isTempoText () ? 0 : track); // TempoText must be in track 0
866869 Segment* s = measure->getSegment (SegmentType::ChordRest, tick);
@@ -2490,6 +2493,8 @@ void MusicXMLParserDirection::direction(const QString& partId,
24902493
24912494 _placement = _e.attributes ().value (" placement" ).toString ();
24922495 int track = _pass1.trackForPart (partId);
2496+ bool isVocalStaff = _pass1.isVocalStaff (partId);
2497+ bool isExpressionText = false ;
24932498 // qDebug("direction track %d", track);
24942499 QList<MusicXmlSpannerDesc> starts;
24952500 QList<MusicXmlSpannerDesc> stops;
@@ -2574,6 +2579,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
25742579 if (_wordsText != " " || _metroText != " " ) {
25752580 t = new StaffText (_score);
25762581 t->setXmlText (_wordsText + _metroText);
2582+ isExpressionText = _wordsText.contains (" <i>" ) && _metroText.isEmpty ();
25772583 }
25782584 else {
25792585 t = new RehearsalMark (_score);
@@ -2598,10 +2604,17 @@ void MusicXMLParserDirection::direction(const QString& partId,
25982604 t->setFrameType (FrameType::SQUARE);
25992605 t->setFrameRound (0 );
26002606 }
2607+
2608+ QString wordsPlacement = placement ();
2609+ // Case-based defaults
2610+ if (wordsPlacement.isEmpty ()) {
2611+ if (isVocalStaff) wordsPlacement = " above" ;
2612+ else if (isExpressionText) wordsPlacement = " below" ;
2613+ }
26012614
26022615 if (isLikelyFingering ()) {
26032616 _logger->logDebugInfo (QString (" Inferring fingering: %1" ).arg (_wordsText));
2604- MusicXMLInferredFingering* inferredFingering = new MusicXMLInferredFingering (totalY (), t, _wordsText, track, placement () , measure, tick + _offset);
2617+ MusicXMLInferredFingering* inferredFingering = new MusicXMLInferredFingering (totalY (), t, _wordsText, track, wordsPlacement , measure, tick + _offset);
26052618 inferredFingerings.push_back (inferredFingering);
26062619 }
26072620 else if (directionToDynamic ()) {
@@ -2610,7 +2623,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
26102623 else {
26112624 // Add element to score later, after collecting all the others and sorting by default-y
26122625 // This allows default-y to be at least respected by the order of elements
2613- MusicXMLDelayedDirectionElement* delayedDirection = new MusicXMLDelayedDirectionElement (hasTotalY () ? totalY () : 100 , t, track, placement () , measure, tick + _offset);
2626+ MusicXMLDelayedDirectionElement* delayedDirection = new MusicXMLDelayedDirectionElement (hasTotalY () ? totalY () : 100 , t, track, wordsPlacement , measure, tick + _offset);
26142627 delayedDirections.push_back (delayedDirection);
26152628 }
26162629 }
@@ -2650,9 +2663,14 @@ void MusicXMLParserDirection::direction(const QString& partId,
26502663 dyn->setVelocity ( dynaValue );
26512664 }
26522665
2666+ QString dynamicsPlacement = placement ();
2667+ // Case-based defaults
2668+ if (dynamicsPlacement.isEmpty ())
2669+ dynamicsPlacement = isVocalStaff ? " above" : " below" ;
2670+
26532671 // Add element to score later, after collecting all the others and sorting by default-y
26542672 // This allows default-y to be at least respected by the order of elements
2655- MusicXMLDelayedDirectionElement* delayedDirection = new MusicXMLDelayedDirectionElement (hasTotalY () ? totalY () : 100 , dyn, track, placement () , measure, tick + _offset);
2673+ MusicXMLDelayedDirectionElement* delayedDirection = new MusicXMLDelayedDirectionElement (hasTotalY () ? totalY () : 100 , dyn, track, dynamicsPlacement , measure, tick + _offset);
26562674 delayedDirections.push_back (delayedDirection);
26572675 }
26582676
0 commit comments