|
1 | 1 | import { Logger } from '@coderline/alphatab/Logger'; |
2 | 2 | import { AccentuationType } from '@coderline/alphatab/model/AccentuationType'; |
| 3 | +import { AccidentalHelper } from '@coderline/alphatab/rendering/utils/AccidentalHelper'; |
3 | 4 | import { BeatSubElement } from '@coderline/alphatab/model/Beat'; |
4 | 5 | import { Duration } from '@coderline/alphatab/model/Duration'; |
5 | 6 | import { GraceType } from '@coderline/alphatab/model/GraceType'; |
@@ -301,18 +302,23 @@ export class ScoreBeatGlyph extends BeatOnNoteGlyphBase { |
301 | 302 |
|
302 | 303 | private _createRestGlyphs() { |
303 | 304 | const sr = this.renderer as ScoreBarRenderer; |
304 | | - |
305 | | - let steps = Math.ceil((this.renderer.bar.staff.standardNotationLineCount - 1) / 2) * 2; |
306 | | - |
307 | | - // this positioning is quite strange, for most staff line counts |
308 | | - // the whole/rest are aligned as half below the whole rest. |
309 | | - // but for staff line count 1 and 3 they are aligned centered on the same line. |
310 | | - if ( |
311 | | - this.container.beat.duration === Duration.Whole && |
312 | | - this.renderer.bar.staff.standardNotationLineCount !== 1 && |
313 | | - this.renderer.bar.staff.standardNotationLineCount !== 3 |
314 | | - ) { |
315 | | - steps -= 2; |
| 305 | + const beat = this.container.beat; |
| 306 | + const lineCount = this.renderer.bar.staff.standardNotationLineCount; |
| 307 | + |
| 308 | + let steps: number; |
| 309 | + if (beat.restDisplayTone !== -1 && beat.restDisplayOctave !== -1) { |
| 310 | + // Per-beat override: same step as a note at that pitch. SMuFL rest glyphs use the same |
| 311 | + // baseline convention as note heads, so no further adjustment is applied. |
| 312 | + steps = AccidentalHelper.calculateRestDisplaySteps(sr.bar, beat.restDisplayTone, beat.restDisplayOctave); |
| 313 | + } else { |
| 314 | + // Default placement: centred on the staff. Whole rests sit one line above (per SMuFL/Guitar Pro |
| 315 | + // convention) so their hanging body lines up with where half/shorter rest bodies appear. |
| 316 | + // 1- and 3-line staves keep the whole rest on the default rest line (Guitar Pro convention; |
| 317 | + // see musescore/MuseScore#25279). |
| 318 | + steps = Math.ceil((lineCount - 1) / 2) * 2; |
| 319 | + if (beat.duration === Duration.Whole && lineCount !== 1 && lineCount !== 3) { |
| 320 | + steps -= 2; |
| 321 | + } |
316 | 322 | } |
317 | 323 |
|
318 | 324 | const restGlyph = new ScoreRestGlyph(0, sr.getScoreY(steps), this.container.beat.duration); |
|
0 commit comments