Skip to content

Commit 17bedef

Browse files
authored
fix: Simile Mark cursor and highlighting (#2025)
1 parent 9d5b64a commit 17bedef

16 files changed

+28
-15
lines changed

src/importer/MusicXmlImporter.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,9 @@ export class MusicXmlImporter extends ScoreImporter {
10581058
for (const s of track.staves) {
10591059
const bar = this.getOrCreateBar(s, masterBar);
10601060
bar.simileMark = this._simileMarkAllStaves!;
1061+
if(bar.simileMark !== SimileMark.None) {
1062+
this.clearBar(bar);
1063+
}
10611064
}
10621065

10631066
if (this._simileMarkAllStaves == SimileMark.FirstOfDouble) {
@@ -1074,6 +1077,10 @@ export class MusicXmlImporter extends ScoreImporter {
10741077
const bar = this.getOrCreateBar(s, masterBar);
10751078
bar.simileMark = this._simileMarkPerStaff!.get(i)!;
10761079

1080+
if(bar.simileMark !== SimileMark.None) {
1081+
this.clearBar(bar);
1082+
}
1083+
10771084
if (bar.simileMark == SimileMark.FirstOfDouble) {
10781085
this._simileMarkPerStaff!.set(i, SimileMark.SecondOfDouble);
10791086
} else {
@@ -1085,6 +1092,14 @@ export class MusicXmlImporter extends ScoreImporter {
10851092
}
10861093
}
10871094
}
1095+
1096+
private clearBar(bar: Bar) {
1097+
for(const v of bar.voices) {
1098+
const emptyBeat: Beat = new Beat();
1099+
emptyBeat.isEmpty = true;
1100+
v.addBeat(emptyBeat);
1101+
}
1102+
}
10881103

10891104
private parseBarLine(element: XmlNode, masterBar: MasterBar) {
10901105
for (const c of element.childElements()) {

src/rendering/BarRendererBase.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,26 +577,38 @@ export class BarRendererBase {
577577

578578
protected paintSimileMark(cx: number, cy: number, canvas: ICanvas): void {
579579
using _ = ElementStyleHelper.voice(canvas, VoiceSubElement.Glyphs, this.bar.voices[0], true);
580+
581+
580582
switch (this.bar.simileMark) {
581583
case SimileMark.Simple:
584+
canvas.beginGroup(BeatContainerGlyph.getGroupId(this.bar.voices[0].beats[0]));
582585
canvas.fillMusicFontSymbol(
583586
cx + this.x + (this.width - 20) / 2,
584587
cy + this.y + this.height / 2,
585588
1,
586589
MusicFontSymbol.Repeat1Bar,
587590
false
588591
);
592+
canvas.endGroup();
589593
break;
590594
case SimileMark.SecondOfDouble:
595+
canvas.beginGroup(BeatContainerGlyph.getGroupId(this.bar.voices[0].beats[0]));
596+
canvas.beginGroup(BeatContainerGlyph.getGroupId(this.bar.previousBar!.voices[0].beats[0]));
597+
591598
canvas.fillMusicFontSymbol(
592599
cx + this.x - 28 / 2,
593600
cy + this.y + this.height / 2,
594601
1,
595602
MusicFontSymbol.Repeat2Bars,
596603
false
597604
);
605+
606+
canvas.endGroup();
607+
canvas.endGroup();
608+
598609
break;
599610
}
611+
600612
}
601613

602614
public completeBeamingHelper(helper: BeamingHelper) {

src/rendering/ScoreBarRenderer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { KeySignature } from '@src/model/KeySignature';
2525
import { LineBarRenderer } from './LineBarRenderer';
2626
import { KeySignatureGlyph } from './glyphs/KeySignatureGlyph';
2727
import { ElementStyleHelper } from './utils/ElementStyleHelper';
28-
import { SimileMark } from '@src/model';
2928

3029
/**
3130
* This BarRenderer renders a bar using standard music notation.
@@ -603,10 +602,6 @@ export class ScoreBarRenderer extends LineBarRenderer {
603602
}
604603

605604
protected override createVoiceGlyphs(v: Voice): void {
606-
if(this.bar.simileMark !== SimileMark.None) {
607-
return;
608-
}
609-
610605
for (const b of v.beats) {
611606
let container: ScoreBeatContainerGlyph = new ScoreBeatContainerGlyph(b, this.getVoiceContainer(v)!);
612607
container.preNotes = new ScoreBeatPreNotesGlyph();

src/rendering/SlashBarRenderer.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { SpacingGlyph } from './glyphs/SpacingGlyph';
1616
import { ScoreTimeSignatureGlyph } from './glyphs/ScoreTimeSignatureGlyph';
1717
import { ElementStyleHelper } from './utils/ElementStyleHelper';
1818
import { MusicFontSymbolSizes } from './utils/MusicFontSymbolSizes';
19-
import { MusicFontSymbol, SimileMark } from '@src/model';
19+
import { MusicFontSymbol } from '@src/model';
2020

2121
/**
2222
* This BarRenderer renders a bar using Slash Rhythm notation
@@ -163,10 +163,6 @@ export class SlashBarRenderer extends LineBarRenderer {
163163
}
164164

165165
protected override createVoiceGlyphs(v: Voice): void {
166-
if (this.bar.simileMark !== SimileMark.None) {
167-
return;
168-
}
169-
170166
for (const b of v.beats) {
171167
let container: SlashBeatContainerGlyph = new SlashBeatContainerGlyph(b, this.getVoiceContainer(v)!);
172168
container.preNotes = new BeatGlyphBase();

src/rendering/TabBarRenderer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { GraceType } from '@src/model/GraceType';
2121
import { ReservedLayoutAreaSlot } from './utils/BarCollisionHelper';
2222
import { MultiBarRestBeatContainerGlyph } from './MultiBarRestBeatContainerGlyph';
2323
import { ElementStyleHelper } from './utils/ElementStyleHelper';
24-
import { SimileMark } from '@src/model';
2524

2625
/**
2726
* This BarRenderer renders a bar using guitar tablature notation
@@ -196,10 +195,6 @@ export class TabBarRenderer extends LineBarRenderer {
196195
}
197196

198197
protected override createVoiceGlyphs(v: Voice): void {
199-
if (this.bar.simileMark !== SimileMark.None) {
200-
return;
201-
}
202-
203198
// multibar rest
204199
if (this.additionalMultiRestBars) {
205200
let container = new MultiBarRestBeatContainerGlyph(this.getVoiceContainer(v)!);
-327 Bytes
Loading
-498 Bytes
Loading
505 Bytes
Loading
567 Bytes
Loading
-47 Bytes
Loading

0 commit comments

Comments
 (0)