Skip to content

Commit c8a9298

Browse files
committed
Documentation improvements
1 parent 94592d4 commit c8a9298

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

src/element.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export abstract class Element {
6464
return Category.Element;
6565
}
6666

67+
// all Element objects keep a list of children that they are responsible and which
68+
// inherit the style of their parents.
69+
// Currently used by StaveNote for noteheads and
6770
protected children: Element[] = [];
6871
protected static ID: number = 1000;
6972
protected static newID(): string {
@@ -108,6 +111,15 @@ export abstract class Element {
108111
Registry.getDefaultRegistry()?.register(this);
109112
}
110113

114+
/**
115+
* Adds a child Element to the Element, which lets it inherit the
116+
* same style as the parent when setGroupStyle() is called.
117+
*
118+
* Examples of children are noteheads and stems. Modifiers such
119+
* as Accidentals are generally not set as children.
120+
*
121+
* Note that StaveNote calls setGroupStyle() when setStyle() is called.
122+
*/
111123
addChildElement(child: Element): this {
112124
this.children.push(child);
113125
return this;
@@ -186,7 +198,7 @@ export abstract class Element {
186198

187199
/**
188200
* Draw the element and all its sub-elements (ie.: Modifiers in a Stave)
189-
* with the element style.
201+
* with the element's style (see `getStyle()` and `setStyle()`)
190202
*/
191203
drawWithStyle(): void {
192204
this.checkContext();

src/glyphnote.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// [VexFlow](https://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
2+
//
3+
// Any glyph that is set to appear on a Stave and take up musical time and graphical space.
24

35
import { BoundingBox } from './boundingbox';
46
import { Glyph } from './glyph';

src/modifiercontext.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
// ## Description
44
//
55
// This class implements various types of members to notes (e.g. bends,
6-
// fingering positions etc.)
6+
// fingering positions etc.). The ModifierContext works with tickables
7+
// that are at the same tick to ensure that they and their modifiers
8+
// all have proper alignment. (Note that the ModifierContext also
9+
// runs the spacing of the tickable).
10+
//
11+
// see https://github.com/0xfe/vexflow/wiki/How-Formatting-Works
712

813
import { Accidental } from './accidental';
914
import { Annotation } from './annotation';
@@ -58,7 +63,8 @@ export class ModifierContext {
5863
top_text_line: 0,
5964
};
6065

61-
// Current members
66+
// Current members -- a mapping of Category (string) to a list of Tickables, Modifiers,
67+
// StaveNotes, TabNotes, etc.
6268
protected members: Record<string, ModifierContextMember[]> = {};
6369

6470
protected preFormatted: boolean = false;
@@ -102,6 +108,9 @@ export class ModifierContext {
102108
return this.members[category] ?? [];
103109
}
104110

111+
/**
112+
* Get the width of the entire
113+
*/
105114
getWidth(): number {
106115
return this.width;
107116
}

src/tickable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ export abstract class Tickable extends Element {
205205
return this.tuplet;
206206
}
207207

208-
/** Return the intrinsic ticks. */
208+
/** Return a list of Tuplets. */
209209
getTupletStack(): Tuplet[] {
210210
return this.tupletStack;
211211
}
212212

213213
/**
214-
* Reset the specific Tuplet if this is not provided, all tuplets are reset.
214+
* Reset the specific Tuplet (if this is not provided, all tuplets are reset).
215215
* Remove any prior tuplets from the tick calculation and
216216
* reset the intrinsic tick value.
217217
*/

0 commit comments

Comments
 (0)