Skip to content

Commit

Permalink
open context for barnote
Browse files Browse the repository at this point in the history
  • Loading branch information
judocode committed Apr 19, 2024
1 parent 8ddc8fa commit 198b802
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/barnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class BarNote extends Note {
protected metrics: { widths: Record<string, number> };
// Initialized by the constructor via this.setType(type)
protected type!: BarlineType;
public barline!: Barline;

constructor(type: string | BarlineType = BarlineType.SINGLE) {
super({ duration: 'b' });
Expand All @@ -52,6 +53,7 @@ export class BarNote extends Note {
// Tell the formatter that bar notes have no duration.
this.ignore_ticks = true;
this.setType(type);
this.barline = new Barline(type);
}

/** Get the type of bar note.*/
Expand Down Expand Up @@ -86,9 +88,13 @@ export class BarNote extends Note {
const ctx = this.checkContext();
L('Rendering bar line at: ', this.getAbsoluteX());
this.applyStyle(ctx);
const barline = new Barline(this.type);
barline.setX(this.getAbsoluteX());
barline.draw(this.checkStave());

ctx.openGroup('barnote', this.getAttribute('id'));
this.barline.setType(this.type);
this.barline.setX(this.getAbsoluteX());
this.barline.draw(this.checkStave());
ctx.closeGroup();

this.restoreStyle(ctx);
this.setRendered();
}
Expand Down

0 comments on commit 198b802

Please sign in to comment.