Browse Source

feat(Cursor): add rules.DefaultColorCursor (#961)

sschmidTU 4 năm trước cách đây
mục cha
commit
317048691f

+ 2 - 0
src/MusicalScore/Graphical/EngravingRules.ts

@@ -248,6 +248,7 @@ export class EngravingRules {
     public DefaultColorStem: string;
     public DefaultColorLabel: string;
     public DefaultColorTitle: string;
+    public DefaultColorCursor: string;
     public DefaultFontFamily: string;
     public DefaultFontStyle: FontStyles;
     public DefaultVexFlowNoteFont: string;
@@ -559,6 +560,7 @@ export class EngravingRules {
         this.DefaultColorStem = this.DefaultColorNotehead;
         this.DefaultColorLabel = this.DefaultColorNotehead;
         this.DefaultColorTitle = this.DefaultColorNotehead;
+        this.DefaultColorCursor = "#33e02f"; // green
         this.DefaultFontFamily = "Times New Roman"; // what OSMD was initially optimized for
         this.DefaultFontStyle = FontStyles.Regular;
         this.DefaultVexFlowNoteFont = "gonville"; // was the default vexflow font up to vexflow 1.2.93, now it's Bravura, which is more cursive/bold

+ 4 - 1
src/OpenSheetMusicDisplay/Cursor.ts

@@ -210,7 +210,10 @@ export class Cursor {
     this.update();
   }
 
-  private updateStyle(width: number, color: string = "#33e02f"): void {
+  private updateStyle(width: number, color: string = undefined): void {
+    if (!color) {
+      color = this.rules.DefaultColorCursor;
+    }
     // Create a dummy canvas to generate the gradient for the cursor
     // FIXME This approach needs to be improved
     const c: HTMLCanvasElement = document.createElement("canvas");