Skip to content

Commit

Permalink
keysignote migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Apr 22, 2021
1 parent f6224c8 commit b372227
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
21 changes: 14 additions & 7 deletions src/keysignote.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
// Author Mark Meeus 2019

import { Vex } from './vex';
import { Note } from './note';
import { KeySignature } from './keysignature';
import { BoundingBox } from './boundingbox';

export class KeySigNote extends Note {
constructor(keySpec, cancelKeySpec, alterKeySpec) {
protected keySignature: KeySignature;
constructor(keySpec: string, cancelKeySpec: string, alterKeySpec: string) {
super({ duration: 'b' });
this.setAttribute('type', 'KeySigNote');

Expand All @@ -15,28 +18,32 @@ export class KeySigNote extends Note {
this.ignore_ticks = true;
}

getBoundingBox() {
getBoundingBox(): BoundingBox | undefined {
return super.getBoundingBox();
}

addToModifierContext() {
addToModifierContext(): this {
/* overridden to ignore */
return this;
}

preFormat() {
preFormat(): this {
this.setPreFormatted(true);
this.keySignature.setStave(this.stave);
this.keySignature.format();
this.setWidth(this.keySignature.width);
return this;
}

draw() {
this.stave.checkContext();
draw(): void {
if (!this.stave) {
throw new Vex.RERR('NoStave', 'No stave attached to this note.');
}

const ctx = this.stave.checkContext();
this.setRendered();
this.keySignature.x = this.getAbsoluteX();
this.keySignature.setContext(this.context);
this.keySignature.setContext(ctx);
this.keySignature.draw();
}
}
14 changes: 7 additions & 7 deletions src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export interface ParsedNote {
}

export interface NoteStruct {
line: number;
line?: number;
/** The number of dots, which affects the duration. */
dots: number;
keys: string[];
dots?: number;
keys?: string[];
/** The note type (e.g., `r` for rest, `s` for slash notes, etc.). */
type: string;
align_center: boolean;
duration_override: Fraction;
type?: string;
align_center?: boolean;
duration_override?: Fraction;
/** The time length (e.g., `q` for quarter, `h` for half, `8` for eighth etc.). */
duration: string;
}
Expand Down Expand Up @@ -206,7 +206,7 @@ export abstract class Note extends Tickable {
noteStruct.keys.forEach((k, i) => {
const result = k.split('/');
// We have a custom glyph specified after the note eg. /X2
customTypes[i] = result && result.length === 3 ? result[2] : type;
customTypes[i] = (result && result.length === 3 ? result[2] : type) as string;
});
}
}
Expand Down

0 comments on commit b372227

Please sign in to comment.