@@ -2736,14 +2736,16 @@ void ChordLayout::resolveVerticalRestConflicts(Score* score, Segment* segment, s
2736
2736
2737
2737
collectChordsAndRest (segment, staffIdx, chords, rests);
2738
2738
2739
- for (Rest* rest : rests) {
2740
- rest->verticalClearance ().reset ();
2741
- }
2742
-
2743
2739
if (rests.empty ()) {
2744
2740
return ;
2745
2741
}
2746
2742
2743
+ collectChordsOverlappingRests (segment, staffIdx, chords);
2744
+
2745
+ for (Rest* rest : rests) {
2746
+ rest->verticalClearance ().reset ();
2747
+ }
2748
+
2747
2749
if (!chords.empty ()) {
2748
2750
resolveRestVSChord (rests, chords, score, segment, staffIdx);
2749
2751
}
@@ -2763,7 +2765,7 @@ void ChordLayout::resolveRestVSChord(std::vector<Rest*>& rests, std::vector<Chor
2763
2765
int lines = staff->lines (tick);
2764
2766
double spatium = staff->spatium (tick);
2765
2767
double lineDistance = staff->lineDistance (tick) * spatium;
2766
- const double minRestToChordClearance = 0.35 * spatium;
2768
+ double minRestToChordClearance = 0.35 * spatium;
2767
2769
2768
2770
for (Rest* rest : rests) {
2769
2771
if (!rest->visible () || !rest->autoplace ()) {
@@ -2774,14 +2776,25 @@ void ChordLayout::resolveRestVSChord(std::vector<Rest*>& rests, std::vector<Chor
2774
2776
if (!chord->visible () || !chord->autoplace ()) {
2775
2777
continue ;
2776
2778
}
2779
+
2777
2780
bool restAbove = rest->voice () < chord->voice () || (chord->slash () && !(rest->voice () % 2 ));
2778
2781
int upSign = restAbove ? -1 : 1 ;
2779
2782
double restYOffset = rest->offset ().y ();
2780
2783
bool ignoreYOffset = (restAbove && restYOffset > 0 ) || (!restAbove && restYOffset < 0 );
2781
2784
PointF offset = ignoreYOffset ? PointF (0 , restYOffset) : PointF (0 , 0 );
2785
+
2786
+ double clearance = 0.0 ;
2782
2787
Shape restShape = rest->shape ().translated (rest->pos () - offset);
2783
- Shape chordShape = chord->shape ().translated (chord->pos ());
2784
- double clearance = restAbove ? restShape.verticalClearance (chordShape) : chordShape.verticalClearance (restShape);
2788
+ if (chord->segment () == rest->segment ()) {
2789
+ Shape chordShape = chord->shape ().translated (chord->pos ());
2790
+ clearance = restAbove ? restShape.verticalClearance (chordShape) : chordShape.verticalClearance (restShape);
2791
+ } else {
2792
+ Note* limitNote = restAbove ? chord->upNote () : chord->downNote ();
2793
+ Shape noteShape = limitNote->shape ().translate (limitNote->pos ());
2794
+ clearance = restAbove ? noteShape.top () - restShape.bottom () : restShape.top () - noteShape.bottom ();
2795
+ minRestToChordClearance = 0.0 ;
2796
+ }
2797
+
2785
2798
double margin = clearance - minRestToChordClearance;
2786
2799
int marginInSteps = floor (margin / lineDistance);
2787
2800
if (restAbove) {
@@ -2792,6 +2805,7 @@ void ChordLayout::resolveRestVSChord(std::vector<Rest*>& rests, std::vector<Chor
2792
2805
if (margin > 0 ) {
2793
2806
continue ;
2794
2807
}
2808
+
2795
2809
rest->verticalClearance ().setLocked (true );
2796
2810
bool isWholeOrHalf = rest->isWholeRest () || rest->durationType () == DurationType::V_HALF;
2797
2811
bool outAboveStaff = restAbove && restShape.bottom () + margin < minRestToChordClearance;
0 commit comments