Sfoglia il codice sorgente

Added classes needed for Label

Oliver 9 anni fa
parent
commit
719c2a4ac5

+ 52 - 0
src/Common/DataObjects/osmdColor.ts

@@ -0,0 +1,52 @@
+export class OSMDColor {
+    public alpha: number;
+    public red: number;
+    public green: number;
+    public blue: number;
+
+    constructor(alpha: number, red: number, green: number, blue: number) {
+        this.alpha = alpha;
+        this.red = red;
+        this.green = green;
+        this.blue = blue;
+    }
+    constructor(red: number, green: number, blue: number) {
+        this.alpha = 255;
+        this.red = red;
+        this.green = green;
+        this.blue = blue;
+    }
+    public static get Black(): OSMDColor {
+        return new OSMDColor(0, 0, 0);
+    }
+    public static get DeepSkyBlue(): OSMDColor {
+        return new OSMDColor(0, 191, 255);
+    }
+    public static get Green(): OSMDColor {
+        return new OSMDColor(20, 160, 20);
+    }
+    public static get Magenta(): OSMDColor {
+        return new OSMDColor(255, 0, 255);
+    }
+    public static get Orange(): OSMDColor {
+        return new OSMDColor(255, 128, 0);
+    }
+    public static get Red(): OSMDColor {
+        return new OSMDColor(240, 20, 20);
+    }
+    public static get Disabled(): OSMDColor {
+        return new OSMDColor(225, 225, 225);
+    }
+    public static get DarkBlue(): OSMDColor {
+        return new OSMDColor(0, 0, 140);
+    }
+    public static get Debug1(): OSMDColor {
+        return new OSMDColor(200, 0, 140);
+    }
+    public static get Debug2(): OSMDColor {
+        return new OSMDColor(100, 100, 200);
+    }
+    public static get Debug3(): OSMDColor {
+        return new OSMDColor(0, 50, 140);
+    }
+}

+ 7 - 0
src/Common/Enums/osmdFontStyles.ts

@@ -0,0 +1,7 @@
+export enum OSMDFontStyles {
+    Regular = 0,
+    Bold = 1,
+    Italic = 2,
+    BoldItalic = 3,
+    Underlined = 4
+}

+ 4 - 0
src/Common/Enums/osmdFonts.ts

@@ -0,0 +1,4 @@
+export enum OSMDFonts {
+    TimesNewRoman,
+    Kokila
+}

+ 11 - 0
src/Common/Enums/osmdTextAlignment.ts

@@ -0,0 +1,11 @@
+export enum OSMDTextAlignment {
+    LeftTop,
+    LeftCenter,
+    LeftBottom,
+    CenterTop,
+    CenterCenter,
+    CenterBottom,
+    RightTop,
+    RightCenter,
+    RightBottom
+}

+ 17 - 18
src/MusicalScore/Label.ts

@@ -1,11 +1,10 @@
-// FIXME
-type PSTextAlignment = any;
-type PSFontStyles = any;
-type PSColor = any;
-type PSFonts = any;
+import {OSMDTextAlignment} from "../Common/Enums/osmdTextAlignment";
+import {OSMDColor} from "../Common/DataObjects/osmdColor";
+import {OSMDFonts} from "../Common/Enums/osmdFonts";
+import {OSMDFontStyles} from "../Common/Enums/osmdFontStyles";
 
 export class Label {
-  constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: PSTextAlignment) {
+  constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: OSMDTextAlignment) {
       //if (arg1 instanceof string) {
       this.text = <string>arg1;
       //} else if (arg1 instanceof FontInfo.MusicFontSymbol) {
@@ -19,10 +18,10 @@ export class Label {
     }
 
     private text: string; // FIXME:
-    private color: PSColor; //= PSColor.Black;
-    private font: PSFonts; // = PSFonts.TimesNewRoman;
-    private fontStyle: PSFontStyles; // = PSFontStyles.Regular;
-    private textAlignment: PSTextAlignment; // = PSTextAlignment.LeftBottom;
+    private color: OSMDColor; //= PSColor.Black;
+    private font: OSMDFonts; // = PSFonts.TimesNewRoman;
+    private fontStyle: OSMDFontStyles; // = PSFontStyles.Regular;
+    private textAlignment: OSMDTextAlignment; // = PSTextAlignment.LeftBottom;
     private fontHeight: number = 2;
 
     public get Text(): string {
@@ -31,22 +30,22 @@ export class Label {
     public set Text(value: string) {
         this.text = value;
     }
-    public get Color(): PSColor {
+    public get Color(): OSMDColor {
         return this.color;
     }
-    public set Color(value: PSColor) {
+    public set Color(value: OSMDColor) {
         this.color = value;
     }
-    public get Font(): PSFonts {
+    public get Font(): OSMDFonts {
         return this.font;
     }
-    public set Font(value: PSFonts) {
+    public set Font(value: OSMDFonts) {
         this.font = value;
     }
-    public get FontStyle(): PSFontStyles {
+    public get FontStyle(): OSMDFontStyles {
         return this.fontStyle;
     }
-    public set FontStyle(value: PSFontStyles) {
+    public set FontStyle(value: OSMDFontStyles) {
         this.fontStyle = value;
     }
     public get FontHeight(): number {
@@ -55,10 +54,10 @@ export class Label {
     public set FontHeight(value: number) {
         this.fontHeight = value;
     }
-    public get TextAlignment(): PSTextAlignment {
+    public get TextAlignment(): OSMDTextAlignment {
         return this.textAlignment;
     }
-    public set TextAlignment(value: PSTextAlignment) {
+    public set TextAlignment(value: OSMDTextAlignment) {
         this.textAlignment = value;
     }
     public ToString(): string {