This PR fixes layout errors due to overlaps in notes, chords and rests when there are two voices in the same staff (e.g. test score 00633):
Lomse (before this PR):
Lomse (after this PR):
The solution has been to create a NoterestsCollisionsFixer object that will receive all note/rest shapes at a given staff and timepos, to check for overlaps and solve any detected issue by moving sideways the conflicting objects. The NoterestsCollisionsFixer object is created in the spacing algorithm in the TimeSliceNoterest objects.
When this task was started, the collision scenarios I had in mind were very simple, just unisons, notes a second apart and rests and notes collisions. But as I started to work and studied collision scenarios and engraving rules in these situations, it resulted that there are many engraving rules involved and the number of collision scenarios is overwhelming, requiring in practice near a case by case solution.
Therefore, this PR is a first step, fixing most collision cases between chords, notes, rests and accidentals. But not cases involving dots and collisions with flags, that introduce an extra level of complexity. So I prefer to take a rest on this issue for a while.
Limitations
Current implementation has some limitations:
The solution is currently restricted to fix overlaps in two voices. If there are more than two voices in the same staff the collisions will be fixed for two voices but nothing will ensure that there are no overlaps with the other voices.
Overlaps between noteheads one third apart are considered false positives as both noteheads should touch each other. But when the noteheads are of different types (e.g. a quarter note and a half note) it can be a real overlap and this is not fixed in this PR.
I preferred not to deal with these two cases until having real scores displaying these types of problems, to confirm the need and to have more knowledge about the specific problems and the possible solutions.
Also, as commented, this PR does not deal with dots and with cases involving collisions with flags.
This PR fixes layout errors due to overlaps in notes, chords and rests when there are two voices in the same staff (e.g. test score 00633):
Lomse (before this PR):
Lomse (after this PR):
The solution has been to create a NoterestsCollisionsFixer object that will receive all note/rest shapes at a given staff and timepos, to check for overlaps and solve any detected issue by moving sideways the conflicting objects. The NoterestsCollisionsFixer object is created in the spacing algorithm in the TimeSliceNoterest objects.
When this task was started, the collision scenarios I had in mind were very simple, just unisons, notes a second apart and rests and notes collisions. But as I started to work and studied collision scenarios and engraving rules in these situations, it resulted that there are many engraving rules involved and the number of collision scenarios is overwhelming, requiring in practice near a case by case solution.
Therefore, this PR is a first step, fixing most collision cases between chords, notes, rests and accidentals. But not cases involving dots and collisions with flags, that introduce an extra level of complexity. So I prefer to take a rest on this issue for a while.
Limitations
Current implementation has some limitations:
The solution is currently restricted to fix overlaps in two voices. If there are more than two voices in the same staff the collisions will be fixed for two voices but nothing will ensure that there are no overlaps with the other voices.
Overlaps between noteheads one third apart are considered false positives as both noteheads should touch each other. But when the noteheads are of different types (e.g. a quarter note and a half note) it can be a real overlap and this is not fixed in this PR.
I preferred not to deal with these two cases until having real scores displaying these types of problems, to confirm the need and to have more knowledge about the specific problems and the possible solutions.
Also, as commented, this PR does not deal with dots and with cases involving collisions with flags.