Ver Fonte

fix bounding boxes not drawn after new backend creation change

sschmid há 5 anos atrás
pai
commit
a60d993b17

+ 0 - 1
src/MusicalScore/Graphical/MusicSheetDrawer.ts

@@ -484,7 +484,6 @@ export abstract class MusicSheetDrawer {
         if (this.drawableBoundingBoxElement) {
             this.drawBoundingBoxes(page.PositionAndShape, 0, this.drawableBoundingBoxElement);
         }
-
     }
 
     /**

+ 7 - 4
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -70,6 +70,7 @@ export class OpenSheetMusicDisplay {
     private needBackendUpdate: boolean;
     private sheet: MusicSheet;
     private drawer: VexFlowMusicSheetDrawer;
+    private drawBoundingBox: string;
     private graphic: GraphicalMusicSheet;
     private drawingParameters: DrawingParameters;
     private autoResizeEnabled: boolean;
@@ -236,7 +237,8 @@ export class OpenSheetMusicDisplay {
             this.drawer.Backends.clear();
         }
         // Create the drawer
-        this.drawer = new VexFlowMusicSheetDrawer(this.drawingParameters);
+        this.drawer = new VexFlowMusicSheetDrawer(this.drawingParameters); // note that here the drawer.drawableBoundingBoxElement is lost. now saved in OSMD.
+        this.drawer.drawableBoundingBoxElement = this.DrawBoundingBox;
 
         // Set page width
         const width: number = this.container.offsetWidth;
@@ -737,11 +739,12 @@ export class OpenSheetMusicDisplay {
     }
 
     public set DrawBoundingBox(value: string) {
-        this.drawer.drawableBoundingBoxElement = value;
-        this.render();
+        this.drawBoundingBox = value;
+        this.drawer.drawableBoundingBoxElement = value; // drawer is sometimes created anew, losing this value, so it's saved in OSMD now.
+        this.render(); // may create new Drawer.
     }
     public get DrawBoundingBox(): string {
-        return this.drawer.drawableBoundingBoxElement;
+        return this.drawBoundingBox;
     }
 
     public get AutoResizeEnabled(): boolean {