瀏覽代碼

Prepared method to set stem of voice entries.

Matthias Uiberacker 7 年之前
父節點
當前提交
457c4c2bc1
共有 1 個文件被更改,包括 37 次插入1 次删除
  1. 37 1
      src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

+ 37 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -29,6 +29,8 @@ import Vex = require("vexflow");
 import {Logging} from "../../../Common/Logging";
 import {unitInPixels} from "./VexFlowMusicSheetDrawer";
 import {VexFlowGraphicalNote} from "./VexFlowGraphicalNote";
+import {Voice} from "../../VoiceData/Voice";
+import {LinkedVoice} from "../../VoiceData/LinkedVoice";
 
 export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
     constructor() {
@@ -139,7 +141,41 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
      */
     protected layoutVoiceEntry(voiceEntry: VoiceEntry, graphicalNotes: GraphicalNote[], graphicalStaffEntry: GraphicalStaffEntry,
                                hasPitchedNote: boolean, isGraceStaffEntry: boolean): void {
-        return;
+        const firstNote: GraphicalNote = graphicalNotes[0];
+        const hasLink: boolean = graphicalStaffEntry.sourceStaffEntry.Link !== undefined;
+        if (hasLink) {
+            if (firstNote.sourceNote.ParentVoiceEntry === graphicalStaffEntry.sourceStaffEntry.VoiceEntries[0]) {
+                // set stem up:
+                //graphicalStaffEntry.setStemDirection(firstNote, StemEnum.StemUp);
+                return;
+            } else {
+                // set stem down:
+                //const last: GraphicalNote = graphicalNotes[graphicalNotes.length - 1];
+                //graphicalStaffEntry.setStemDirection(last, StemEnum.StemDown);
+                return;
+            }
+        } else {
+            const isMainVoice: boolean = !(firstNote.sourceNote.ParentVoiceEntry.ParentVoice instanceof LinkedVoice);
+            if (isMainVoice) {
+                const mainVoice: Voice = graphicalStaffEntry.getMainVoice();
+
+                if (firstNote.sourceNote.ParentVoiceEntry.ParentVoice === mainVoice) {
+                    // set stem up:
+                    //graphicalStaffEntry.setStemDirection(firstNote, StemEnum.StemUp);
+                    return;
+                } else {
+                    // set stem down:
+                    //const last: GraphicalNote = graphicalNotes[graphicalNotes.length - 1];
+                    //graphicalStaffEntry.setStemDirection(last, StemEnum.StemDown);
+                    return;
+                }
+            } else {
+                // set stem down:
+                //const last: GraphicalNote = graphicalNotes[graphicalNotes.length - 1];
+                //graphicalStaffEntry.setStemDirection(last, StemEnum.StemDown);
+                return;
+            }
+        }
     }
 
     /**