lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
120 stars 28 forks source link

Fix middle spanner segments being displayed on a wrong page in some cases #302

Closed dmitrio95 closed 3 years ago

dmitrio95 commented 3 years ago

This pull request fixes a case when a middle spanner segment is shown on a wrong page. The issue can be illustrated, for example, with this score: slur.musicxml.txt

To reproduce the issue two conditions are necessary:

  1. A slur spans for several systems (because page width is small or a slur is particularly long)
  2. A system somewhere in the middle of the slur range is moved to another page.

If these conditions are met a slur segment which belongs to the first system on the second page is instead displayed on the first page:

Page 1 Page 2
before1 before2

The reason why this happens is that the shape for this slur segment is bound to a wrong system box because an incorrect column number for this shape is used. Therefore when its system gets moved to the next page a coordinate shift applied to this system does not get propagated to this slur segment's shape. This PR fixes it by ensuring that the column number the RelObj shape is bound to belongs to the column range of the current system. As a result, all slur segments in the example shown above get rendered on correct pages.

Page 1 Page 2
after1 after2
cecilios commented 3 years ago

Thank you by this PR. I will review it soon.

cecilios commented 3 years ago

Thank you. Great work!