Skip to content

Commit 8ddc8fa

Browse files
Merge pull request #1606 from AaronDavidNewman/master
issue #1603 - key signature on non-treble stave, no glyph
2 parents 7e7eb97 + 770015f commit 8ddc8fa

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/stave.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,14 @@ export class Stave extends Element {
444444
return this;
445445
}
446446

447+
/**
448+
* treat the stave as if the clef is clefSpec, but don't display the clef
449+
*/
450+
setClefLines(clefSpec: string) {
451+
this.clef = clefSpec;
452+
return this;
453+
}
454+
447455
setClef(clefSpec: string, size?: string, annotation?: string, position?: number): this {
448456
if (position === undefined) {
449457
position = StaveModifierPosition.BEGIN;

tests/keysignature_tests.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const KeySignatureTests = {
2626
run('Altered key test', majorKeysAltered);
2727
run('End key with clef test', endKeyWithClef);
2828
run('Key Signature Change test', changeKey);
29+
run('Key Signature with/without clef symbol', clefKeySignature);
2930
},
3031
};
3132

@@ -370,5 +371,33 @@ function changeKey(options: TestOptions): void {
370371
options.assert.ok(true, 'all pass');
371372
}
372373

374+
function clefKeySignature(options: TestOptions): void {
375+
const f = VexFlowTests.makeFactory(options, 900);
376+
const stave = f.Stave({ x: 10, y: 10, width: 800 }).addClef('bass').addTimeSignature('C|').setClefLines('bass');
377+
378+
const voice = f
379+
.Voice()
380+
.setStrict(false)
381+
.addTickables([
382+
f.KeySigNote({ key: 'Bb' }),
383+
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
384+
f.BarNote(),
385+
f.KeySigNote({ key: 'D', cancelKey: 'Bb' }),
386+
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
387+
f.BarNote(),
388+
f.KeySigNote({ key: 'Bb' }),
389+
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
390+
f.BarNote(),
391+
f.KeySigNote({ key: 'D', alterKey: ['b', 'n'] }),
392+
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
393+
]);
394+
395+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
396+
397+
f.draw();
398+
399+
options.assert.ok(true, 'all pass');
400+
}
401+
373402
VexFlowTests.register(KeySignatureTests);
374403
export { KeySignatureTests };

0 commit comments

Comments
 (0)