Pārlūkot izejas kodu

Documenting other various objects

Andrea Condoluci 8 gadi atpakaļ
vecāks
revīzija
277ac9a0d5

+ 1 - 0
src/MusicalScore/Exceptions.ts

@@ -1,3 +1,4 @@
+
 export class MusicSheetReadingException implements Error {
     public name: string;
     public message: string;

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

@@ -1,4 +1,5 @@
 import {GraphicalLabel} from "./GraphicalLabel";
+
 export class GraphicalComment {
     constructor(label: GraphicalLabel, settingsLabel: GraphicalLabel) {
         this.label = label;

+ 1 - 2
src/MusicalScore/Graphical/GraphicalLabel.ts

@@ -6,8 +6,7 @@ import {EngravingRules} from "./EngravingRules";
 import {MusicSheetCalculator} from "./MusicSheetCalculator";
 
 /**
- * A text label on the graphical music sheet.
- * It is used e.g. for titles, composer names, instrument names and dynamic instructions.
+ * The graphical counterpart of a Label
  */
 export class GraphicalLabel extends Clickable {
     private label: Label;

+ 1 - 0
src/MusicalScore/InstrumentalGroup.ts

@@ -6,6 +6,7 @@ export class InstrumentalGroup {
         this.musicSheet = musicSheet;
         this.parent = parent;
     }
+
     private name: string;
     private musicSheet: MusicSheet;
     private parent: InstrumentalGroup;

+ 1 - 0
src/MusicalScore/Interfaces/IGraphicalSymbolFactory.ts

@@ -12,6 +12,7 @@ import {OctaveEnum} from "../VoiceData/Expressions/ContinuousExpressions/OctaveS
 import {GraphicalNote} from "../Graphical/GraphicalNote";
 import {Pitch} from "../../Common/DataObjects/Pitch";
 import {TechnicalInstruction} from "../VoiceData/Instructions/TechnicalInstruction";
+
 export interface IGraphicalSymbolFactory {
     createMusicSystem(page: GraphicalMusicPage, systemIndex: number): MusicSystem;
     createStaffLine(parentSystem: MusicSystem, parentStaff: Staff): StaffLine;

+ 4 - 0
src/MusicalScore/Label.ts

@@ -3,6 +3,10 @@ import {OSMDColor} from "../Common/DataObjects/OSMDColor";
 import {Fonts} from "../Common/Enums/Fonts";
 import {FontStyles} from "../Common/Enums/FontStyles";
 
+/**
+ * A text label on the graphical music sheet.
+ * It is used e.g. for titles, composer names, instrument names and dynamic instructions.
+ */
 export class Label {
     constructor(text: string = "", alignment: TextAlignment = TextAlignment.LeftBottom, font: Fonts = Fonts.TimesNewRoman) {
         this.text = text;

+ 9 - 17
src/MusicalScore/MusicSheet.ts

@@ -18,30 +18,21 @@ import {Note} from "./VoiceData/Note";
 import {VoiceEntry} from "./VoiceData/VoiceEntry";
 import {Logging} from "../Common/Logging";
 
-// FIXME
-//type MusicSheetParameters = any;
-//type MultiTempoExpression = any;
-//type PlaybackSettings = any;
-//type MusicSheetParameterObject = any;
-//type EngravingRules = any;
-//type MusicSheetErrors = any;
-//type IPhonicScoreInterface = any;
-//type MusicSheetParameterChangedDelegate = any;
-//type IInstrument = any;
-//type ISettableInstrument = any;
-//type IRepetition = any;
-
-// FIXME Andrea: Commented out some things, have a look at (*)
+// FIXME Andrea: Commented out some unnecessary/not-ported-yet code, have a look at (*)
 
 export class PlaybackSettings {
     public rhythm: Fraction;
 }
 
+/**
+ * This is the representation of a complete piece of sheet music.
+ * It includes the contents of a MusicXML file after the reading.
+ */
 export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet>*/ {
     constructor() {
         this.rules = EngravingRules.Rules;
         this.playbackSettings = new PlaybackSettings();
-        // FIXME:
+        // FIXME?
         this.playbackSettings.rhythm = new Fraction(4, 4, false);
         this.userStartTempoInBPM = 100;
         this.pageWidth = 120;
@@ -365,7 +356,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     //        }
     //        return repetitions;
     //    } catch (ex) {
-    //        console.log(/*Logger.DefaultLogger.LogError(LogLevel.NORMAL, FIXME */ "MusicSheet.IRepetitions get: ", ex);
+    //        Logging.log("MusicSheet.IRepetitions get: ", ex);
     //        return undefined;
     //    }
     //
@@ -451,11 +442,12 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public set IdString(value: string) {
        this.idString = value;
     }
+    // (*)
     // public Dispose(): void {
     //    this.MusicSheetParameterChanged = undefined;
     //    for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
     //        let instrument: Instrument = this.instruments[idx];
-    //        instrument.dispose(); // FIXME
+    //        instrument.dispose();
     //    }
     // }
     public getEnrolledSelectionStartTimeStampWorkaround(): Fraction {

+ 4 - 0
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -45,6 +45,10 @@ import {MidiInstrument} from "../VoiceData/Instructions/ClefInstruction";
 
 export type repetitionInstructionReader = any;
 
+/**
+ * An InstrumentReader is used during the reading phase to keep parsing new measures from the MusicXML file
+ * with the readNextXmlMeasure method.
+ */
 export class InstrumentReader {
     constructor(repetitionInstructionReader: repetitionInstructionReader, xmlMeasureList: IXmlElement[], instrument: Instrument) {
         // (*) this.repetitionInstructionReader = repetitionInstructionReader;

+ 13 - 6
src/OSMD/Cursor.ts

@@ -6,7 +6,9 @@ import {MusicSystem} from "../MusicalScore/Graphical/MusicSystem";
 import {OSMD} from "./OSMD";
 import {GraphicalMusicSheet} from "../MusicalScore/Graphical/GraphicalMusicSheet";
 
-
+/**
+ * A cursor which can iterate through the music sheet.
+ */
 export class Cursor {
     constructor(container: HTMLElement, osmd: OSMD) {
         this.container = container;
@@ -33,15 +35,19 @@ export class Cursor {
         this.hide();
     }
 
+    /**
+     * Make the cursor visible
+     */
     public show(): void {
         this.hidden = false;
         this.update();
-        // Forcing the sheet to re-render is not necessary anymore
-        //this.osmd.render();
+        // Forcing the sheet to re-render is not necessary anymore,
+        // since the cursor is an HTML element.
+        // this.osmd.render();
     }
 
     public update(): void {
-        // Should NEVER call this.osmd.render()
+        // Warning! This should NEVER call this.osmd.render()
         if (this.hidden) {
             return;
         }
@@ -65,7 +71,8 @@ export class Cursor {
                     musicSystem.StaffLines[musicSystem.StaffLines.length - 1].PositionAndShape.RelativePosition.y + 4.0;
                 height = endY - y;
             }
-            // The following code is not necessary (for now); it highlights the current notes.
+            // The following code is not necessary (for now, but it could come useful later):
+            // it highlights the notes under the cursor.
             //let vfNotes: { [voiceID: number]: Vex.Flow.StaveNote; } = gse.vfNotes;
             //for (let voiceId in vfNotes) {
             //    if (vfNotes.hasOwnProperty(voiceId)) {
@@ -91,7 +98,7 @@ export class Cursor {
             this.updateStyle(newWidth);
         }
 
-        // Show cursors
+        // Show cursor
         // // Old cursor: this.graphic.Cursors.push(cursor);
         this.cursorElement.style.display = "";
     }

+ 3 - 7
src/OSMD/ResizeHandler.ts

@@ -1,11 +1,7 @@
 /**
- * Created by acondolu on 15/07/16.
- */
-
-/**
  * Helper function for managing window's onResize events
- * @param startCallback
- * @param endCallback
+ * @param startCallback is the function called when resizing starts
+ * @param endCallback is the function called when resizing (kind-of) ends
  */
 export function handleResize(startCallback: () => void, endCallback: () => void): void {
     "use strict";
@@ -14,7 +10,7 @@ export function handleResize(startCallback: () => void, endCallback: () => void)
     let delta: number = 200;
 
     function resizeEnd(): void {
-        //timeout = undefined;
+        timeout = undefined;
         window.clearTimeout(timeout);
         if ((new Date()).getTime() - rtime < delta) {
             timeout = window.setTimeout(resizeEnd, delta);