Explorar el Código

Corrected label.
Added ActivitySymbols

Matthias hace 9 años
padre
commit
5f4571312d

+ 8 - 8
src/MusicalScore/Graphical/GraphicalLabel.ts

@@ -11,15 +11,15 @@ export class GraphicalLabel extends Clickable {
     constructor(label: Label, textHeight: number, alignment: TextAlignment) {
         this.label = label;
         this.boundingBox = new BoundingBox(this);
-        this.label.FontHeight = textHeight;
-        this.label.TextAlignment = alignment;
+        this.label.fontHeight = textHeight;
+        this.label.textAlignment = alignment;
     }
 
     constructor(label: Label, textHeight: number, alignment: TextAlignment, parent: BoundingBox) {
         this.label = label;
         this.boundingBox = new BoundingBox(parent, this);
-        this.label.FontHeight = textHeight;
-        this.label.TextAlignment = alignment;
+        this.label.fontHeight = textHeight;
+        this.label.textAlignment = alignment;
     }
 
     public get Label(): Label {
@@ -27,17 +27,17 @@ export class GraphicalLabel extends Clickable {
     }
 
     public setLabelPositionAndShapeBorders(): void {
-        if (this.Label.Text.trim() === "") {
+        if (this.Label.text.trim() === "") {
             return;
         }
         let labelMarginBorderFactor: number = EngravingRules.Rules.LabelMarginBorderFactor;
 
         let widthToHeightRatio: number =
-            MusicSheetCalculator.TextMeasurer.computeTextWidthToHeightRatio(this.Label.Text, this.Label.Font, this.Label.FontStyle);
-        let height: number = this.Label.FontHeight;
+            MusicSheetCalculator.TextMeasurer.computeTextWidthToHeightRatio(this.Label.text, this.Label.font, this.Label.fontStyle);
+        let height: number = this.Label.fontHeight;
         let width: number = height * widthToHeightRatio;
         let psi: BoundingBox = this.PositionAndShape;
-        switch (this.Label.TextAlignment) {
+        switch (this.Label.textAlignment) {
             case TextAlignment.CenterBottom:
                 psi.BorderTop = -height;
                 psi.BorderLeft = -width / 2;

+ 7 - 0
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -282,6 +282,13 @@ export class MusicSheetCalculator {
                 let newPosition: PointF2D = new PointF2D(musicSystem.PositionAndShape.RelativePosition.x, musicSystem.PositionAndShape.RelativePosition.y - distance);
                 musicSystem.PositionAndShape.RelativePosition = newPosition;
             }
+            for (var idx2: number = 0, len2 = graphicalMusicPage.MusicSystems.length; idx2 < len2; ++idx2) {
+                var musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
+                for (var idx3: number = 0, len3 = musicSystem.StaffLines.length; idx3 < len3; ++idx3) {
+                    var staffLine: StaffLine = musicSystem.StaffLines[idx3];
+                    staffLine.addActivitySymbolClickArea();
+                }
+            }
             if (graphicalMusicPage === this.graphicalMusicSheet.MusicPages[0])
                 this.calculatePageLabels(graphicalMusicPage);
             graphicalMusicPage.PositionAndShape.calculateTopBottomBorders();

+ 9 - 0
src/MusicalScore/Graphical/StaffLine.ts

@@ -6,6 +6,8 @@ import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {GraphicalObject} from "./GraphicalObject";
 import {StaffMeasure} from "./StaffMeasure";
 import {MusicSystem} from "./MusicSystem";
+import {StaffLineActivitySymbol} from "./StaffLineActivitySymbol";
+import {PointF2D} from "../../Common/DataObjects/PointF2D";
 
 export class StaffLine extends GraphicalObject {
     protected measures: StaffMeasure[] = [];
@@ -69,6 +71,13 @@ export class StaffLine extends GraphicalObject {
         this.bottomLine = value;
     }
 
+    public addActivitySymbolClickArea(): void {
+        var activitySymbol: StaffLineActivitySymbol = new StaffLineActivitySymbol(this);
+        var staffLinePsi: BoundingBox = this.PositionAndShape;
+        activitySymbol.PositionAndShape.RelativePosition = new PointF2D(staffLinePsi.RelativePosition.x + staffLinePsi.BorderRight + 0.5, staffLinePsi.RelativePosition.y + 0.5);
+        this.parentMusicSystem.PositionAndShape.ChildElements.push(activitySymbol.PositionAndShape);
+    }
+
     public isPartOfMultiStaffInstrument(): boolean {
         let instrument: Instrument = this.parentStaff.ParentInstrument;
         if (instrument.Staves.length > 1) {

+ 15 - 0
src/MusicalScore/Graphical/StaffLineActivitySymbol.ts

@@ -0,0 +1,15 @@
+import {GraphicalObject} from "./GraphicalObject";
+import {StaffLine} from "./StaffLine";
+import {BoundingBox} from "./BoundingBox";
+export class StaffLineActivitySymbol extends GraphicalObject {
+    constructor(staffLine: StaffLine) {
+        this.ParentStaffLine = staffLine;
+        var staffLinePsi: BoundingBox = staffLine.PositionAndShape;
+        this.boundingBox = new BoundingBox(staffLinePsi, this);
+        this.boundingBox.BorderRight = 6;
+        this.boundingBox.BorderBottom = 4.5;
+        this.boundingBox.BorderLeft = -1.5;
+        this.boundingBox.BorderTop = -1.5;
+    }
+    public ParentStaffLine: StaffLine;
+}

+ 2 - 2
src/MusicalScore/Instrument.ts

@@ -57,10 +57,10 @@ export class Instrument extends InstrumentalGroup {
         this.lyricVersesNumbers = value;
     }
     public get Name(): string {
-        return this.nameLabel.Text;
+        return this.nameLabel.text;
     }
     public set Name(value: string) {
-        this.nameLabel.Text = value;
+        this.nameLabel.text = value;
     }
     public get IdString(): string {
         return this.idString;

+ 11 - 57
src/MusicalScore/Label.ts

@@ -4,63 +4,17 @@ import {Fonts} from "../Common/Enums/Fonts";
 import {FontStyles} from "../Common/Enums/FontStyles";
 
 export class Label {
-    // FIXME contructor
-    constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: TextAlignment) {
-      //if (arg1 instanceof string) {
-      this.text = <string>arg1;
-      //} else if (arg1 instanceof FontInfo.MusicFontSymbol) {
-      //    this.font = PSFonts.PhonicScore;
-      //    let symbolInfo: FontInfo.SymbolInfo = FontInfo.Info.getSymbolInfo(<FontInfo.MusicFontSymbol>arg1);
-      //    this.text = symbolInfo.symbol;
-      //}
-      if (alignment !== undefined) {
-          this.textAlignment = alignment;
-      }
-    }
-
-    private text: string; // FIXME:
-    private color: OSMDColor = OSMDColor.Black;
-    private font: Fonts = Fonts.TimesNewRoman;
-    private fontStyle: FontStyles = FontStyles.Regular;
-    private textAlignment: TextAlignment = TextAlignment.LeftBottom;
-    private fontHeight: number = 2;
-
-    public get Text(): string {
-        return this.text;
-    }
-    public set Text(value: string) {
-        this.text = value;
-    }
-    public get Color(): OSMDColor {
-        return this.color;
-    }
-    public set Color(value: OSMDColor) {
-        this.color = value;
-    }
-    public get Font(): Fonts {
-        return this.font;
-    }
-    public set Font(value: Fonts) {
-        this.font = value;
-    }
-    public get FontStyle(): FontStyles {
-        return this.fontStyle;
-    }
-    public set FontStyle(value: FontStyles) {
-        this.fontStyle = value;
-    }
-    public get FontHeight(): number {
-        return this.fontHeight;
-    }
-    public set FontHeight(value: number) {
-        this.fontHeight = value;
-    }
-    public get TextAlignment(): TextAlignment {
-        return this.textAlignment;
-    }
-    public set TextAlignment(value: TextAlignment) {
-        this.textAlignment = value;
-    }
+    constructor(text: string = "", alignment: TextAlignment = TextAlignment.LeftBottom, font: Fonts = Fonts.TimesNewRoman) {
+        this.text = text;
+        this.textAlignment = alignment;
+        this.font = font;
+    }
+    public text: string;
+    public color: OSMDColor;
+    public font: Fonts;
+    public fontStyle: FontStyles;
+    public fontHeight: number;
+    public textAlignment: TextAlignment;
     public ToString(): string {
         return this.text;
     }

+ 5 - 5
src/MusicalScore/MusicSheet.ts

@@ -147,28 +147,28 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     }
     public get TitleString(): string {
         if (this.title !== undefined) {
-            return this.title.Text;
+            return this.title.text;
         } else {
             return "";
         }
     }
     public get SubtitleString(): string {
         if (this.subtitle !== undefined) {
-            return this.subtitle.Text;
+            return this.subtitle.text;
         } else {
             return "";
         }
     }
     public get ComposerString(): string {
         if (this.composer !== undefined) {
-            return this.composer.Text;
+            return this.composer.text;
         } else {
             return "";
         }
     }
     public get LyricistString(): string {
         if (this.lyricist !== undefined) {
-            return this.lyricist.Text;
+            return this.lyricist.text;
         } else {
             return "";
         }
@@ -339,7 +339,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
         return undefined;
     }
     public CompareTo(other: MusicSheet): number {
-        return this.Title.Text.localeCompare(other.Title.Text);
+        return this.Title.text.localeCompare(other.Title.text);
     }
     // (*)
     //public get IInstruments(): IInstrument[] {