|
@@ -8,6 +8,7 @@ import { VexFlowVoiceEntry } from "./VexFlow/VexFlowVoiceEntry";
|
|
import { EngravingRules } from "./EngravingRules";
|
|
import { EngravingRules } from "./EngravingRules";
|
|
import { ColoringModes } from "./DrawingParameters";
|
|
import { ColoringModes } from "./DrawingParameters";
|
|
import { NoteEnum } from "../../Common/DataObjects/Pitch";
|
|
import { NoteEnum } from "../../Common/DataObjects/Pitch";
|
|
|
|
+import { Note } from "..";
|
|
|
|
|
|
/**
|
|
/**
|
|
* The graphical counterpart of a [[VoiceEntry]].
|
|
* The graphical counterpart of a [[VoiceEntry]].
|
|
@@ -46,12 +47,13 @@ export class GraphicalVoiceEntry extends GraphicalObject {
|
|
const defaultColorRest: string = EngravingRules.Rules.DefaultColorRest;
|
|
const defaultColorRest: string = EngravingRules.Rules.DefaultColorRest;
|
|
const defaultColorStem: string = EngravingRules.Rules.DefaultColorStem;
|
|
const defaultColorStem: string = EngravingRules.Rules.DefaultColorStem;
|
|
const transparentColor: string = "#00000000"; // transparent color in vexflow
|
|
const transparentColor: string = "#00000000"; // transparent color in vexflow
|
|
|
|
+ let noteheadColor: string; // if null: no noteheadcolor to set (stays black)
|
|
|
|
|
|
const vfStaveNote: any = (<VexFlowVoiceEntry>(this as any)).vfStaveNote;
|
|
const vfStaveNote: any = (<VexFlowVoiceEntry>(this as any)).vfStaveNote;
|
|
for (let i: number = 0; i < this.notes.length; i++) {
|
|
for (let i: number = 0; i < this.notes.length; i++) {
|
|
const note: GraphicalNote = this.notes[i];
|
|
const note: GraphicalNote = this.notes[i];
|
|
|
|
|
|
- let noteheadColor: string = note.sourceNote.NoteheadColor;
|
|
|
|
|
|
+ noteheadColor = note.sourceNote.NoteheadColor;
|
|
// Switch between XML colors and automatic coloring
|
|
// Switch between XML colors and automatic coloring
|
|
if (EngravingRules.Rules.ColoringMode === ColoringModes.AutoColoring ||
|
|
if (EngravingRules.Rules.ColoringMode === ColoringModes.AutoColoring ||
|
|
EngravingRules.Rules.ColoringMode === ColoringModes.CustomColorSet) {
|
|
EngravingRules.Rules.ColoringMode === ColoringModes.CustomColorSet) {
|
|
@@ -90,11 +92,27 @@ export class GraphicalVoiceEntry extends GraphicalObject {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // color notebeam if all noteheads have same color and stem coloring enabled
|
|
|
|
+ if (note.sourceNote.NoteBeam && EngravingRules.Rules.ColorStemsLikeNoteheads) {
|
|
|
|
+ const beamNotes: Note[] = note.sourceNote.NoteBeam.Notes;
|
|
|
|
+ let colorBeam: boolean = true;
|
|
|
|
+ for (let j: number = 0; j < beamNotes.length; j++) {
|
|
|
|
+ if (beamNotes[j].NoteheadColor !== noteheadColor) {
|
|
|
|
+ colorBeam = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (colorBeam) {
|
|
|
|
+ if (vfStaveNote.beam !== null && vfStaveNote.beam.setStyle) {
|
|
|
|
+ vfStaveNote.beam.setStyle({ fillStyle: noteheadColor, strokeStyle: noteheadColor});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (vfStaveNote) {
|
|
if (vfStaveNote) {
|
|
if (vfStaveNote.note_heads) { // see VexFlowConverter, needs Vexflow PR
|
|
if (vfStaveNote.note_heads) { // see VexFlowConverter, needs Vexflow PR
|
|
const notehead: any = vfStaveNote.note_heads[i];
|
|
const notehead: any = vfStaveNote.note_heads[i];
|
|
if (notehead) {
|
|
if (notehead) {
|
|
- vfStaveNote.note_heads[i].setStyle({ fillStyle: noteheadColor, strokeStyle: noteheadColor });
|
|
|
|
|
|
+ notehead.setStyle({ fillStyle: noteheadColor, strokeStyle: noteheadColor });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -102,8 +120,13 @@ export class GraphicalVoiceEntry extends GraphicalObject {
|
|
|
|
|
|
// color stems
|
|
// color stems
|
|
let stemColor: string = this.parentVoiceEntry.StemColor;
|
|
let stemColor: string = this.parentVoiceEntry.StemColor;
|
|
- if (!stemColor && defaultColorStem) {
|
|
|
|
- stemColor = defaultColorStem;
|
|
|
|
|
|
+ const autoColoring: boolean = EngravingRules.Rules.ColoringMode !== ColoringModes.XML; // TODO: once custom color set gets stem color, respect it
|
|
|
|
+ if (!stemColor || autoColoring) {
|
|
|
|
+ if (EngravingRules.Rules.ColorStemsLikeNoteheads && noteheadColor) {
|
|
|
|
+ stemColor = noteheadColor;
|
|
|
|
+ } else if (defaultColorStem) {
|
|
|
|
+ stemColor = defaultColorStem;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
let stemTransparent: boolean = true;
|
|
let stemTransparent: boolean = true;
|
|
for (const note of this.parentVoiceEntry.Notes) {
|
|
for (const note of this.parentVoiceEntry.Notes) {
|