Forráskód Böngészése

feat(options): implement DrawCredits

OSMDOption and DrawingParameters method to enable or disable rendering Composer, Title, Subtitle, Lyricist.
improve docs, comments
sschmidTU 6 éve
szülő
commit
8c6df97584

+ 18 - 4
src/MusicalScore/Graphical/DrawingParameters.ts

@@ -16,6 +16,7 @@ export enum DrawingParametersEnum {
     thumbnail = "thumbnail",
 }
 
+/** Internal drawing/rendering parameters and broad modes like compact and thumbnail. Overlap with EngravingRules. */
 export class DrawingParameters {
     /** will set other settings if changed with set method */
     private drawingParametersEnum: DrawingParametersEnum;
@@ -110,11 +111,8 @@ export class DrawingParameters {
     public setForCompactMode(): void {
         this.setForDefault();
         EngravingRules.Rules.CompactMode = true;
-        this.DrawTitle = false;
-        this.DrawComposer = false;
-        this.DrawLyricist = false;
+        this.DrawCredits = false; // sets DrawComposer, DrawTitle, DrawLyricist to false
         // this.DrawPartNames = true; // unnecessary
-        this.drawCredits = false;
         this.drawHiddenNotes = false;
     }
 
@@ -131,6 +129,22 @@ export class DrawingParameters {
     }
 
     //#region GETTER / SETTER
+    public get DrawCredits(): boolean {
+        return this.drawCredits;
+    }
+
+    public set DrawCredits(value: boolean) {
+        this.drawCredits = value;
+        this.DrawComposer = value;
+        this.DrawTitle = value;
+        this.DrawSubtitle = value;
+        this.DrawLyricist = value;
+    }
+    // TODO these drawCredits settings are duplicate in drawingParameters and EngravingRules. Maybe we only need them in EngravingRules.
+    // this sets the parameter in DrawingParameters, which in turn sets the parameter in EngravingRules.
+    // see settings below that don't call drawingParameters for the immediate approach.
+    // on the other hand, DrawingParameters has the added option of setting broad modes (e.g. compact), though they aren't that useful
+
     public get DrawTitle(): boolean {
         return this.drawTitle;
     }

+ 6 - 4
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -13,7 +13,7 @@ export interface IOSMDOptions {
     autoResize?: boolean;
     /** Render Backend, will be SVG if given undefined, SVG or svg, otherwise Canvas. */
     backend?: string;
-    /** Defines the mode that is used for coloring: XML, Boomwhacker. Default XML (0).
+    /** Defines the mode that is used for coloring: XML (0), Boomwhacker(1), CustomColorSet (2). Default XML.
      *  If coloringMode.CustomColorSet (2) is chosen, a coloringSetCustom parameter must be added.
      */
     coloringMode?: ColoringModes;
@@ -35,13 +35,15 @@ export interface IOSMDOptions {
     disableCursor?: boolean;
     /** Broad Parameters like compact or preview mode. */
     drawingParameters?: string | DrawingParametersEnum;
+    /** Whether to draw credits (title, subtitle, composer, lyricist) (in future: copyright etc., see <credit>). */
+    drawCredits?: boolean;
     /** Whether to draw the title of the piece. If false, disables drawing Subtitle as well. */
     drawTitle?: boolean;
     /** Whether to draw the subtitle of the piece. If true, enables drawing Title as well. */
     drawSubtitle?: boolean;
-    /** Whether to draw credits (title, composer, arranger, copyright etc., see <credit>. Not yet supported. */ // TODO
-    drawCredits?: boolean;
-    /** Whether to draw the lyricist's name, if given. */
+    /** Whether to draw the composer name (top right of the score). */
+    drawComposer?: boolean;
+    /** Whether to draw the lyricist's name, if given (top left of the score). */
     drawLyricist?: boolean;
     /** Whether to draw part (instrument) names. */
     drawPartNames?: boolean;

+ 6 - 6
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -261,11 +261,14 @@ export class OpenSheetMusicDisplay {
         if (options.drawHiddenNotes) {
             this.drawingParameters.drawHiddenNotes = true;
         }
+        if (options.drawCredits !== undefined) {
+            this.drawingParameters.DrawCredits = options.drawCredits; // sets DrawComposer, DrawTitle, DrawSubtitle, DrawLyricist.
+        }
+        if (options.drawComposer !== undefined) {
+            this.drawingParameters.DrawComposer = options.drawComposer;
+        }
         if (options.drawTitle !== undefined) {
             this.drawingParameters.DrawTitle = options.drawTitle;
-            // TODO these settings are duplicate in drawingParameters and EngravingRules. Maybe we only need them in EngravingRules.
-            // this sets the parameter in DrawingParameters, which in turn sets the parameter in EngravingRules.
-            // see settings below that don't call drawingParameters for the immediate approach
         }
         if (options.drawSubtitle !== undefined) {
             this.drawingParameters.DrawSubtitle = options.drawSubtitle;
@@ -273,9 +276,6 @@ export class OpenSheetMusicDisplay {
         if (options.drawLyricist !== undefined) {
             this.drawingParameters.DrawLyricist = options.drawLyricist;
         }
-        if (options.drawCredits !== undefined) {
-            this.drawingParameters.drawCredits = options.drawCredits;
-        }
         if (options.drawPartNames !== undefined) {
             this.drawingParameters.DrawPartNames = options.drawPartNames; // indirectly writes to EngravingRules
         }