Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #1603 - key signature on non-treble stave, no glyph #1606

Merged
merged 3 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/stave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ export class Stave extends Element {
return this;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave a space before and after the function.

* treat the stave as if the clef is clefSpec, but don't display the clef
*/
setClefLines(clefSpec: string) {
this.clef = clefSpec;
return this;
}

setClef(clefSpec: string, size?: string, annotation?: string, position?: number): this {
if (position === undefined) {
position = StaveModifierPosition.BEGIN;
Expand Down
29 changes: 29 additions & 0 deletions tests/keysignature_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const KeySignatureTests = {
run('Altered key test', majorKeysAltered);
run('End key with clef test', endKeyWithClef);
run('Key Signature Change test', changeKey);
run('Key Signature with/without clef symbol', clefKeySignature);
},
};

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

function clefKeySignature(options: TestOptions): void {
const f = VexFlowTests.makeFactory(options, 900);
const stave = f.Stave({ x: 10, y: 10, width: 800 }).addClef('bass').addTimeSignature('C|').setClefLines('bass');

const voice = f
.Voice()
.setStrict(false)
.addTickables([
f.KeySigNote({ key: 'Bb' }),
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
f.BarNote(),
f.KeySigNote({ key: 'D', cancelKey: 'Bb' }),
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
f.BarNote(),
f.KeySigNote({ key: 'Bb' }),
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
f.BarNote(),
f.KeySigNote({ key: 'D', alterKey: ['b', 'n'] }),
f.StaveNote({ keys: ['c/4'], duration: '1', clef: 'bass' }),
]);

f.Formatter().joinVoices([voice]).formatToStave([voice], stave);

f.draw();

options.assert.ok(true, 'all pass');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a line after the function.


VexFlowTests.register(KeySignatureTests);
export { KeySignatureTests };