@@ -359,6 +359,55 @@ static char32_t usedOttavaSymbol(const FinaleParser& ctx, OttavaType ottavaType)
359359 return ctx.score ()->engravingFont ()->symCode (SymId::ottavaAlta);
360360}
361361
362+ double FinaleParser::musicStartPosForMeasure (const Measure* m) const
363+ {
364+ double pos = 0.0 ;
365+ for (Segment* s = m->first (SegmentType::ChordRest)->prevActive (); s;
366+ s = s->prevActive (SegmentType::TimeSig | SegmentType::KeySig | SegmentType::HeaderClef
367+ | SegmentType::StartRepeatBarLine | SegmentType::BeginBarLine)) {
368+ if (s->allElementsInvisible () || s->hasTimeSigAboveStaves ()) {
369+ continue ;
370+ }
371+ if (s->isTimeSigType ()) {
372+ for (staff_idx_t i = 0 ; i < score ()->nstaves (); ++i) {
373+ if (!m->system ()->staff (i)->show ()) {
374+ continue ;
375+ }
376+ pos = std::max (pos, score ()->staff (i)->spatium (m->tick ()));
377+ }
378+ pos *= evpuToSp (partScore () ? musxOptions ().timeOptions ->timeBackParts : musxOptions ().timeOptions ->timeBack );
379+ } else if (s->isKeySigType ()) {
380+ for (staff_idx_t i = 0 ; i < score ()->nstaves (); ++i) {
381+ if (!m->system ()->staff (i)->show ()) {
382+ continue ;
383+ }
384+ pos = std::max (pos, score ()->staff (i)->spatium (m->tick ()));
385+ }
386+ pos *= evpuToSp (musxOptions ().keyOptions ->keyBack );
387+ } else if (s->isHeaderClefType ()) {
388+ for (staff_idx_t i = 0 ; i < score ()->nstaves (); ++i) {
389+ if (!m->system ()->staff (i)->show ()) {
390+ continue ;
391+ }
392+ pos = std::max (pos, score ()->staff (i)->spatium (m->tick ()));
393+ }
394+ pos *= evpuToSp (musxOptions ().clefOptions ->clefBackSepar );
395+ }
396+ pos += s->x () + s->minRight ();
397+ if (m->isFirstInSystem ()) {
398+ MeasCmper measId = muse::value (m_tick2Meas, m->tick (), MeasCmper ());
399+ if (const auto staffSystem = musxDocument ()->calcSystemFromMeasure (currentMusxPartId (), measId)) {
400+ if (!staffSystem->placeEndSpaceBeforeBarline || !s->isStartRepeatBarLineType ()) {
401+ pos += evpuToSp (staffSystem->extraStartSystemSpace )
402+ * staffSystem->calcEffectiveScaling ().toDouble () * FINALE_DEFAULT_SPATIUM;
403+ }
404+ }
405+ }
406+ break ;
407+ }
408+ return pos;
409+ }
410+
362411void FinaleParser::importSmartShapes ()
363412{
364413 const MusxInstanceList<others::SmartShape> smartShapes = m_doc->getOthers ()->getArray <others::SmartShape>(m_currentMusxPartId);
@@ -834,16 +883,8 @@ void FinaleParser::importSmartShapes()
834883 System* s;
835884 ss->rxoffset () += startSeg->x () + startSeg->measure ()->x () - toSLine (newSpanner)->linePos (Grip::START, &s).x ();
836885 } else {
837- ss->rxoffset () += firstMeasureOfSystem->x () - ss->system ()->firstNoteRestSegmentX (true );
838- for (Segment* s = firstMeasureOfSystem->first (SegmentType::ChordRest)->prevActive (); s;
839- s = s->prev (SegmentType::TimeSig | SegmentType::KeySig | SegmentType::HeaderClef
840- | SegmentType::StartRepeatBarLine | SegmentType::BeginBarLine)) {
841- if (s->allElementsInvisible () || s->hasTimeSigAboveStaves ()) {
842- continue ;
843- }
844- ss->rxoffset () += s->x () + s->minRight ();
845- break ;
846- }
886+ ss->rxoffset () += firstMeasureOfSystem->x () + musicStartPosForMeasure (firstMeasureOfSystem)
887+ - ss->system ()->firstNoteRestSegmentX (true );
847888 }
848889
849890 // In MuseScore, userOff2 is relative/added to offset
0 commit comments