feat(engraving): add configurable rest position settings#2693
feat(engraving): add configurable rest position settings#2693roscopeeco wants to merge 2 commits into
Conversation
Adds `restPositionMain` and `restPositionSecondary` properties to `EngravingSettings`, allowing the vertical position of rests to be overridden per-voice via the `RestPosition` enum. The `RestPosition` enum provides named staff-line positions (Line1-Line5 and the spaces between) calibrated to a 5-line staff. Positions are adjusted automatically for staves with fewer than 5 lines using the formula `override - (5 - lineCount) * 2`. When either property is null (the default), rest positioning falls back to the existing auto-calculated behaviour so there is no change to existing scores. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I'm thinking we could make this more granular and add per track settings for restPositionMain and restPositionSecondary. This would be done on a per track basis in the score...something like track.settings.restPositionMain etc. |
Adds RestPosition.test.ts with 21 visual tests covering: - Default rendering (single voice and multi-voice) with no settings applied - All RestPosition enum values for restPositionMain - All rest durations with an override applied - Multi-voice scenarios (both set, main only, secondary only) - Staff line counts 1-5 to verify the line count adjustment formula Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Just added a set of tests. There is one pre-existing issue that the second test shows. The image rest-position-default-multi-voice.png highlights the issue. The test doesn't apply any settings but in the image the secondary voice rest on bars 3 & 6 is above the staff |
|
I had a look at the code and the base already looks quite good. The biggest design contradiction currently is in where to configure rest positions. Looking at MusicXML the position of rests can be overridden for every rest individually via
Having a "primary/secondary" displacement like you propose it, is still possible via a rewrite pass in the Importer wise we should then support:
You can try to make an overall implementation if you like. Otherwise if you take care of the base (model + rendering) I can take over the importer support. |
Issues
#2572
Fixes #
Proposed changes
Adds
restPositionMainandrestPositionSecondaryproperties toEngravingSettings, allowing the vertical position of rests to be overridden per-voice via theRestPositionenum.The
RestPositionenum provides named staff-line positions (Line1-Line5 and the spaces between) calibrated to a 5-line staff. Positions are adjusted automatically for staves with fewer than 5 lines using the formulaoverride - (5 - lineCount) * 2.When either property is null (the default), rest positioning falls back to the existing auto-calculated behaviour so there is no change to existing scores.
These changes are purely to the typescript source code.
Checklist
I've tested it using creating a restPositionMain setting in the playground/demo/control app (this was not included in the pr). The test just dealt with a 5 line staff case. If you are happy with the content of the changes but need test i can investigate your test suite to see how they should be applied.
Further details