Jelajahi Sumber

merge osmd-public: add rules.DefaultColorChordSymbol, fix group bracket shown on single instrument

sschmid 3 tahun lalu
induk
melakukan
c0eb8013ed

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

@@ -262,6 +262,7 @@ export class EngravingRules {
     public DefaultColorRest: string;
     public DefaultColorStem: string;
     public DefaultColorLabel: string;
+    public DefaultColorChordSymbol: string;
     public DefaultColorTitle: string;
     public DefaultColorCursor: string;
     public DefaultFontFamily: string;

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

@@ -30,5 +30,6 @@ export class GraphicalChordSymbolContainer extends GraphicalObject {
         const text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones, keyInstruction);
         this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, this.rules.ChordSymbolTextAlignment, this.rules, this.boundingBox);
         this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(this.rules.ChordSymbolRelativeXOffset, 0.0);
+        this.graphicalLabel.Label.colorDefault = this.rules.DefaultColorChordSymbol;
     }
 }

+ 16 - 2
src/MusicalScore/Graphical/MusicSheetDrawer.ts

@@ -25,6 +25,7 @@ import {MusicSymbolDrawingStyle, PhonicScoreModes} from "./DrawingMode";
 import {GraphicalObject} from "./GraphicalObject";
 import { GraphicalInstantaneousDynamicExpression } from "./GraphicalInstantaneousDynamicExpression";
 import { GraphicalContinuousDynamicExpression } from "./GraphicalContinuousDynamicExpression";
+import { VexFlowInstrumentBracket } from "./VexFlow";
 // import { FontStyles } from "../../Common/Enums/FontStyles";
 
 export class LabelRenderSpecs {
@@ -331,12 +332,25 @@ export abstract class MusicSheetDrawer {
                 label.SVGNode = this.drawLabel(label, <number>GraphicalLayers.Notes);
             }
         }
+
+        const instruments: Instrument[] = this.graphicalMusicSheet.ParentMusicSheet.Instruments;
+        const instrumentsVisible: number = instruments.filter((instrument) => instrument.Visible).length;
         for (const bracket of musicSystem.InstrumentBrackets) {
             this.drawInstrumentBrace(bracket, musicSystem);
         }
-        for (const bracket of musicSystem.GroupBrackets) {
-            this.drawGroupBracket(bracket, musicSystem);
+
+        if (instruments.length > 0) {
+            if (instrumentsVisible > 1) {
+                for (const bracket of musicSystem.GroupBrackets) {
+                    this.drawGroupBracket(bracket, musicSystem);
+                }
+            } else {
+                for (const bracket of musicSystem.GroupBrackets) {
+                    (bracket as VexFlowInstrumentBracket).Visible = false; //.setType(Vex.Flow.StaveConnector.type.NONE);
+                }
+            }
         }
+
         if (!this.leadSheet) {
             for (const measureNumberLabel of musicSystem.MeasureNumberLabels) {
                 measureNumberLabel.SVGNode = this.drawLabel(measureNumberLabel, <number>GraphicalLayers.Notes);

+ 5 - 2
src/MusicalScore/Graphical/VexFlow/VexFlowInstrumentBracket.ts

@@ -10,7 +10,8 @@ import { unitInPixels } from "./VexFlowMusicSheetDrawer";
  */
 export class VexFlowInstrumentBracket extends GraphicalObject {
 
-    protected vexflowConnector: Vex.Flow.StaveConnector;
+    public vexflowConnector: Vex.Flow.StaveConnector;
+    public Visible: boolean = true;
 
     constructor(firstVexFlowStaffLine: VexFlowStaffLine, lastVexFlowStaffLine: VexFlowStaffLine, depth: number = 0) {
         super();
@@ -26,7 +27,9 @@ export class VexFlowInstrumentBracket extends GraphicalObject {
      */
     public draw(ctx: Vex.IRenderContext): void {
         // Draw vexflow brace. This sets the positions inside the connector.
-        this.vexflowConnector.setContext(ctx).draw();
+        if (this.Visible) {
+            this.vexflowConnector.setContext(ctx).draw();
+        }
         // Set bounding box
         const con: Vex.Flow.StaveConnector = this.vexflowConnector;
         // First line in first stave