DigiScore / neoscore

A python library for notating music in a graphics-first paradigm
https://neoscore.org
BSD 3-Clause "New" or "Revised" License
108 stars 9 forks source link

Key signature change in one staff but not others in group can break flowable margins #28

Open ajyoon opened 2 years ago

ajyoon commented 2 years ago

Given a number of staves in a staff group in a flowable, if the staves have different key signatures that are not declared at the same point, the calculated flowable margin can be incorrect. This is because flowable margin calculation uses a system of margin layers where each key signature in the flowable resets the key signature margin layer to its width. If multiple key signatures are declared at the same x location, this is not a problem because the margin calculation uses the largest margin value provided in such cases. But if the key signatures are declared at different points the value is overwritten.

A similar problem likely exists for other objects which declare variable flowable margins - like if a percussion clef is added after pitched clefs are - but I believe this is the most common case.

from neoscore.common import *

neoscore.setup()

flowable = Flowable(ORIGIN, None, Mm(1000), Mm(35))
staff_group = StaffGroup()
staff_1 = Staff((Mm(0), Mm(0)), flowable, Mm(1000), staff_group)
staff_2 = Staff((Mm(0), Mm(15)), flowable, Mm(1000), staff_group)

Clef(Mm(0), staff_1, "treble")
Clef(Mm(0), staff_2, "bass")

KeySignature(ZERO, staff_1, "af_major")
KeySignature(Mm(250), staff_2, "f_major")

neoscore.show()

bug

Fixing this is likely to be pretty involved, and I think this is probably a fairly narrow use-case, so leaving this as a tracking issue for now.

ajyoon commented 2 years ago

See Staff._register_layout_controllers