Skip to content

Commit

Permalink
Merge pull request #967 from rvilarl/migration/tabnote
Browse files Browse the repository at this point in the history
Migration/tabnote
  • Loading branch information
0xfe authored May 9, 2021
2 parents 8362d35 + 904417d commit 0b6d276
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 74 deletions.
5 changes: 2 additions & 3 deletions src/gracetabnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
//
// See `tests/gracetabnote_tests.js` for usage examples.

import { TabNote } from './tabnote';
import { StaveNoteStruct } from './stavenote';
import { TabNote, TabNoteStruct } from './tabnote';

/** Implements Crace Tab Note. */
export class GraceTabNote extends TabNote {
Expand All @@ -18,7 +17,7 @@ export class GraceTabNote extends TabNote {
}

/** Constructor providing a stave note struct */
constructor(note_struct: StaveNoteStruct) {
constructor(note_struct: TabNoteStruct) {
super(note_struct, false);
this.setAttribute('type', 'GraceTabNote');

Expand Down
6 changes: 3 additions & 3 deletions src/stavenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,11 +871,11 @@ export class StaveNote extends StemmableNote {
// Add self to modifier context. `mContext` is the `ModifierContext`
// to be added to.
addToModifierContext(mContext: ModifierContext): this {
this.setModifierContext(mContext);
this.modifierContext = mContext;
for (let i = 0; i < this.modifiers.length; ++i) {
mContext.addMember(this.modifiers[i]);
this.modifierContext.addMember(this.modifiers[i]);
}
mContext.addMember(this);
this.modifierContext.addMember(this);
this.setPreFormatted(false);
return this;
}
Expand Down
5 changes: 3 additions & 2 deletions src/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Flow = {
durationToNumber: durationToNumber,
getGlyphProps: getGlyphProps,
textWidth: textWidth,
tabToGlyph: tabToGlyph,
};

Flow.clefProperties = (clef) => {
Expand Down Expand Up @@ -215,7 +216,7 @@ Flow.integerToNote.table = {
11: 'B',
};

Flow.tabToGlyph = (fret, scale = 1.0) => {
function tabToGlyph(fret, scale = 1.0) {
let glyph = null;
let width = 0;
let shift_y = 0;
Expand All @@ -235,7 +236,7 @@ Flow.tabToGlyph = (fret, scale = 1.0) => {
getWidth: () => width * scale,
shift_y,
};
};
}

function textWidth(text) {
return 7 * text.toString().length;
Expand Down
Loading

0 comments on commit 0b6d276

Please sign in to comment.