notations 0.0.49 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/beats.d.ts +3 -3
- package/lib/cjs/beats.js +57 -3
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/beatview.js +2 -2
- package/lib/cjs/beatview.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.d.ts +4 -3
- package/lib/cjs/carnatic/NotationView.js +26 -9
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +19 -0
- package/lib/cjs/carnatic/beatviews.js +71 -1
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.js +1 -1
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/parser.js +11 -6
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/esm/beats.d.ts +3 -3
- package/lib/esm/beats.js +58 -4
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatview.js +2 -2
- package/lib/esm/beatview.js.map +1 -1
- package/lib/esm/carnatic/NotationView.d.ts +4 -3
- package/lib/esm/carnatic/NotationView.js +27 -10
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +19 -0
- package/lib/esm/carnatic/beatviews.js +46 -0
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.js +1 -1
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/parser.js +11 -6
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/beats.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as TSU from "@panyam/tsutils";
|
|
2
|
-
import { Line, Atom, Role } from "./";
|
|
2
|
+
import { Marker, Line, Atom, Role } from "./";
|
|
3
3
|
import { CycleIterator } from "./cycle";
|
|
4
4
|
import { WindowIterator } from "./iterators";
|
|
5
5
|
import { LayoutParams } from "./layouts";
|
|
@@ -17,8 +17,6 @@ export declare class Beat {
|
|
|
17
17
|
nextBeat: null | Beat;
|
|
18
18
|
private static idCounter;
|
|
19
19
|
readonly uuid: number;
|
|
20
|
-
layoutLine: number;
|
|
21
|
-
layoutColumn: number;
|
|
22
20
|
atom: Atom;
|
|
23
21
|
protected atomIsPlaceholder: boolean;
|
|
24
22
|
constructor(index: number, role: Role, offset: Fraction, duration: Fraction, barIndex: number, beatIndex: number, instance: number, prevBeat: null | Beat, nextBeat: null | Beat);
|
|
@@ -27,6 +25,8 @@ export declare class Beat {
|
|
|
27
25
|
get filled(): boolean;
|
|
28
26
|
get remaining(): Fraction;
|
|
29
27
|
add(atom: Atom): boolean;
|
|
28
|
+
get preMarkers(): Marker[];
|
|
29
|
+
get postMarkers(): Marker[];
|
|
30
30
|
}
|
|
31
31
|
export declare class BeatsBuilder {
|
|
32
32
|
readonly role: Role;
|
package/lib/cjs/beats.js
CHANGED
|
@@ -42,8 +42,6 @@ class Beat {
|
|
|
42
42
|
this.prevBeat = prevBeat;
|
|
43
43
|
this.nextBeat = nextBeat;
|
|
44
44
|
this.uuid = Beat.idCounter++;
|
|
45
|
-
this.layoutLine = -1;
|
|
46
|
-
this.layoutColumn = -1;
|
|
47
45
|
this.atomIsPlaceholder = false;
|
|
48
46
|
}
|
|
49
47
|
debugValue() {
|
|
@@ -83,6 +81,36 @@ class Beat {
|
|
|
83
81
|
}
|
|
84
82
|
return true;
|
|
85
83
|
}
|
|
84
|
+
get preMarkers() {
|
|
85
|
+
const out = [];
|
|
86
|
+
let curr = this.atom;
|
|
87
|
+
while (curr != null) {
|
|
88
|
+
for (const marker of curr.markersBefore || []) {
|
|
89
|
+
out.push(marker);
|
|
90
|
+
}
|
|
91
|
+
if (curr.type == _1.AtomType.GROUP) {
|
|
92
|
+
curr = curr.atoms.first;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
curr = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
get postMarkers() {
|
|
101
|
+
const out = [];
|
|
102
|
+
let curr = this.atom;
|
|
103
|
+
while (curr != null) {
|
|
104
|
+
out.splice(0, 0, ...(curr.markersAfter || []));
|
|
105
|
+
if (curr.type == _1.AtomType.GROUP) {
|
|
106
|
+
curr = curr.atoms.last;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
curr = null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
86
114
|
}
|
|
87
115
|
exports.Beat = Beat;
|
|
88
116
|
Beat.idCounter = 0;
|
|
@@ -254,7 +282,33 @@ class GlobalBeatLayout {
|
|
|
254
282
|
const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);
|
|
255
283
|
const roleIndex = beat.role.line.indexOfRole(beat.role.name);
|
|
256
284
|
const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;
|
|
257
|
-
const realCol = layoutColumn * 3;
|
|
285
|
+
const realCol = 1 + layoutColumn * 3;
|
|
286
|
+
const preMarkers = beat.preMarkers;
|
|
287
|
+
if (preMarkers.length > 0) {
|
|
288
|
+
const val = {
|
|
289
|
+
beat: beat,
|
|
290
|
+
markers: preMarkers,
|
|
291
|
+
};
|
|
292
|
+
const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);
|
|
293
|
+
gridModel.setValue(realRow, realCol - 1, val, (gridRow, col) => {
|
|
294
|
+
const cell = new grids_1.GridCell(gridRow, col);
|
|
295
|
+
cell.colAlign = precol;
|
|
296
|
+
return cell;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
const postMarkers = beat.postMarkers;
|
|
300
|
+
if (postMarkers.length > 0) {
|
|
301
|
+
const val = {
|
|
302
|
+
beat: beat,
|
|
303
|
+
markers: postMarkers,
|
|
304
|
+
};
|
|
305
|
+
const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);
|
|
306
|
+
gridModel.setValue(realRow, realCol + 1, val, (gridRow, col) => {
|
|
307
|
+
const cell = new grids_1.GridCell(gridRow, col);
|
|
308
|
+
cell.colAlign = postcol;
|
|
309
|
+
return cell;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
258
312
|
return gridModel.setValue(realRow, realCol, beat, (gridRow, col) => {
|
|
259
313
|
const cell = new grids_1.GridCell(gridRow, col);
|
|
260
314
|
cell.colAlign = bcol;
|
package/lib/cjs/beats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yBAAoD;AAEpD,2CAA6C;AAE7C,mCAAkF;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC,MAAa,IAAI;IASf,YACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAM;QACV,WAAM,GAAN,MAAM,CAAU;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAa;QAC9B,aAAQ,GAAR,QAAQ,CAAa;QAhBrB,SAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACjC,eAAU,GAAG,CAAC,CAAC,CAAC;QAChB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AAK,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;QACtG,MAAM,OAAO,GAAG,YAAY,GAAG,CAAC,CAAC;QACjC,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvFD,4CAuFC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n layoutLine = -1;\n layoutColumn = -1;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;\n const realCol = layoutColumn * 3;\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yBAAsE;AAEtE,2CAA6C;AAE7C,mCAAkF;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,G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CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;gBAC9E,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlHD,4CAkHC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Marker, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.type == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const realRow = line.roles.length * (layoutLine + Math.floor(beat.index / lp.totalBeats)) + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
package/lib/cjs/beatview.js
CHANGED
|
@@ -35,9 +35,9 @@ class BeatView extends shapes_1.ElementShape {
|
|
|
35
35
|
beatId: "" + beat.uuid,
|
|
36
36
|
id: "" + beat.uuid,
|
|
37
37
|
roleName: beat.role.name,
|
|
38
|
-
layoutLine: "" + beat.layoutLine,
|
|
39
|
-
layoutColumn: "" + beat.layoutColumn,
|
|
40
38
|
beatIndex: "" + beat.index,
|
|
39
|
+
gridRow: cell.rowIndex,
|
|
40
|
+
gridCol: cell.colIndex,
|
|
41
41
|
},
|
|
42
42
|
}));
|
|
43
43
|
this.cell = cell;
|
package/lib/cjs/beatview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatview.js","sourceRoot":"","sources":["../../src/beatview.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,qCAAgE;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jB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,MAAW;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CAIF;AA1CD,4BA0CC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomView, Embelishment, ElementShape } from \"./shapes\";\nimport { GridCell, GridCellView } from \"./grids\";\nimport { Cycle } from \"./cycle\";\nimport { Beat } from \"./beats\";\n\nexport abstract class BeatView extends ElementShape<SVGGElement> implements GridCellView {\n private _embelishments: Embelishment[];\n atomView: AtomView;\n needsLayout = true;\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly rootElement: SVGGraphicsElement,\n public readonly cycle: Cycle,\n config?: any,\n ) {\n super(\n TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"beatView\",\n beatId: \"\" + beat.uuid,\n id: \"\" + beat.uuid,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n }),\n );\n this.atomView = this.createAtomView();\n this.atomView.refreshLayout();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n setStyles(config: any): void {\n this.needsLayout = true;\n }\n\n protected abstract createEmbelishments(): Embelishment[];\n protected abstract createAtomView(): AtomView;\n}\n"]}
|
|
@@ -2,9 +2,9 @@ import * as TSU from "@panyam/tsutils";
|
|
|
2
2
|
import { LineView } from "./LineView";
|
|
3
3
|
import { Notation, RawBlock } from "../notation";
|
|
4
4
|
import { GlobalBeatLayout } from "../beats";
|
|
5
|
-
import { GridCell } from "../grids";
|
|
5
|
+
import { GridCell, GridCellView } from "../grids";
|
|
6
6
|
import { Line } from "../core";
|
|
7
|
-
import { BeatView } from "./beatviews";
|
|
7
|
+
import { BeatView, MarkerView } from "./beatviews";
|
|
8
8
|
export declare class NotationView {
|
|
9
9
|
readonly rootElement: HTMLElement;
|
|
10
10
|
readonly config?: any;
|
|
@@ -28,5 +28,6 @@ export declare class NotationView {
|
|
|
28
28
|
refreshLayout(): void;
|
|
29
29
|
renderBlock(raw: RawBlock): void;
|
|
30
30
|
beatViews: Map<number, BeatView>;
|
|
31
|
-
|
|
31
|
+
markerViews: Map<string, MarkerView>;
|
|
32
|
+
viewForBeat(cell: GridCell): GridCellView;
|
|
32
33
|
}
|
|
@@ -34,6 +34,7 @@ class NotationView {
|
|
|
34
34
|
this.lineViews = [];
|
|
35
35
|
this.currentSVGElement = null;
|
|
36
36
|
this.beatViews = new Map();
|
|
37
|
+
this.markerViews = new Map();
|
|
37
38
|
this.loadChildViews();
|
|
38
39
|
}
|
|
39
40
|
get beatLayout() {
|
|
@@ -161,16 +162,32 @@ class NotationView {
|
|
|
161
162
|
this.currentSVGElement = null;
|
|
162
163
|
}
|
|
163
164
|
viewForBeat(cell) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
if (cell.colIndex % 3 == 1) {
|
|
166
|
+
const beat = cell.value;
|
|
167
|
+
let curr = this.beatViews.get(beat.uuid) || null;
|
|
168
|
+
if (curr == null) {
|
|
169
|
+
const line = beat.role.line;
|
|
170
|
+
const lineView = this.ensureLineView(line);
|
|
171
|
+
const lp = line.layoutParams;
|
|
172
|
+
curr = new beatviews_1.BeatView(cell, beat, lineView.gElem, lp.cycle);
|
|
173
|
+
this.beatViews.set(beat.uuid, curr);
|
|
174
|
+
}
|
|
175
|
+
return curr;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const marker = cell.value;
|
|
179
|
+
const beat = marker.beat;
|
|
180
|
+
let curr = this.markerViews.get("pre:" + beat.uuid) || null;
|
|
181
|
+
if (curr == null) {
|
|
182
|
+
const line = beat.role.line;
|
|
183
|
+
const lineView = this.ensureLineView(line);
|
|
184
|
+
const lp = line.layoutParams;
|
|
185
|
+
const isPreMarker = cell.colIndex % 3 == 0;
|
|
186
|
+
curr = new beatviews_1.MarkerView(cell, beat, marker.markers, isPreMarker, lineView.gElem);
|
|
187
|
+
this.markerViews.set("pre:" + beat.uuid, curr);
|
|
188
|
+
}
|
|
189
|
+
return curr;
|
|
172
190
|
}
|
|
173
|
-
return curr;
|
|
174
191
|
}
|
|
175
192
|
}
|
|
176
193
|
exports.NotationView = NotationView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yCAAsC;AAKtC,2CAAuC;AAEvC,MAAa,YAAY;IAUvB,YAA4B,WAAwB,EAAkB,MAAY;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QAPlF,cAAS,GAAe,EAAE,CAAC;QAE3B,sBAAiB,GAAyB,IAAI,CAAC;QA+J/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QAzJtC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU,CAAC,UAA4B;QACzC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,UAAU,CAAC,eAAe,CAAC,WAAW,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,I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I,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;YAC7B,IAAI,GAAG,IAAI,oBAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;YAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlLD,oCAkLC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { GlobalBeatLayout } from \"../beats\";\nimport { GridCell } from \"../grids\";\nimport { Line } from \"../core\";\nimport { BeatView } from \"./beatviews\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n markdownParser: (contents: string) => string;\n _beatLayout: GlobalBeatLayout;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n get beatLayout(): GlobalBeatLayout {\n return this._beatLayout;\n }\n\n set beatLayout(beatLayout: GlobalBeatLayout) {\n this._beatLayout = beatLayout;\n beatLayout.gridLayoutGroup.getCellView = (cell) => this.viewForBeat(cell);\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = line.layoutParams || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n lineView.gridModel = this.beatLayout!.getGridModelForLine(line.uuid);\n }\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.type == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.ensureLineView(block as Line);\n lineViews.push(lineView);\n }\n }\n\n const now = performance.now();\n for (const lineView of lineViews) {\n lineView.gridModel.lastUpdatedAt = now;\n }\n\n this.beatLayout.gridLayoutGroup.refreshLayout();\n\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n\n // now that all spacing has been calculated\n // go through all\n // for (const beatView of this.beatViews.values()) { beatView.refreshLayout(); }\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n // For now ignore metadata with \":\" in the key\n if (meta.key.toLowerCase().indexOf(\":\") < 0) {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n }\n } else {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n\n beatViews = new Map<number, BeatView>();\n viewForBeat(cell: GridCell): BeatView {\n const beat = cell.value;\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n curr = new BeatView(cell, beat, lineView.gElem, lp.cycle);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yCAAsC;AAKtC,2CAAmD;AAEnD,MAAa,YAAY;IAUvB,YAA4B,WAAwB,EAAkB,MAA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M,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,GAAG,IAAI,sBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/E,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAChD;YACD,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AApMD,oCAoMC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, GlobalBeatLayout } from \"../beats\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { Line } from \"../core\";\nimport { BeatView, MarkerView } from \"./beatviews\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n markdownParser: (contents: string) => string;\n _beatLayout: GlobalBeatLayout;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n get beatLayout(): GlobalBeatLayout {\n return this._beatLayout;\n }\n\n set beatLayout(beatLayout: GlobalBeatLayout) {\n this._beatLayout = beatLayout;\n beatLayout.gridLayoutGroup.getCellView = (cell) => this.viewForBeat(cell);\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = line.layoutParams || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n lineView.gridModel = this.beatLayout!.getGridModelForLine(line.uuid);\n }\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.type == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.ensureLineView(block as Line);\n lineViews.push(lineView);\n }\n }\n\n const now = performance.now();\n for (const lineView of lineViews) {\n lineView.gridModel.lastUpdatedAt = now;\n }\n\n this.beatLayout.gridLayoutGroup.refreshLayout();\n\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n\n // now that all spacing has been calculated\n // go through all\n // for (const beatView of this.beatViews.values()) { beatView.refreshLayout(); }\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n // For now ignore metadata with \":\" in the key\n if (meta.key.toLowerCase().indexOf(\":\") < 0) {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n }\n } else {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n\n beatViews = new Map<number, BeatView>();\n markerViews = new Map<string, MarkerView>();\n viewForBeat(cell: GridCell): GridCellView {\n if (cell.colIndex % 3 == 1) {\n // beat view needed\n const beat = cell.value;\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n curr = new BeatView(cell, beat, lineView.gElem, lp.cycle);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n } else {\n // markers view\n const marker = cell.value;\n const beat = marker.beat as Beat;\n let curr = this.markerViews.get(\"pre:\" + beat.uuid) || null;\n if (curr == null) {\n const line = beat.role.line;\n const lineView = this.ensureLineView(line);\n const lp = line.layoutParams;\n const isPreMarker = cell.colIndex % 3 == 0;\n curr = new MarkerView(cell, beat, marker.markers, isPreMarker, lineView.gElem);\n this.markerViews.set(\"pre:\" + beat.uuid, curr);\n }\n return curr;\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
import * as TSU from "@panyam/tsutils";
|
|
1
2
|
import { Embelishment } from "../shapes";
|
|
3
|
+
import { GridCell, GridCellView } from "../grids";
|
|
4
|
+
import { ElementShape } from "../shapes";
|
|
5
|
+
import { Marker } from "../core";
|
|
6
|
+
import { Beat } from "../beats";
|
|
2
7
|
import { BeatView as BeatViewBase } from "../beatview";
|
|
8
|
+
export declare class MarkerView extends ElementShape<SVGGElement> implements GridCellView {
|
|
9
|
+
readonly cell: GridCell;
|
|
10
|
+
readonly beat: Beat;
|
|
11
|
+
readonly markers: Marker[];
|
|
12
|
+
readonly isPreMarker: boolean;
|
|
13
|
+
readonly rootElement: SVGGraphicsElement;
|
|
14
|
+
needsLayout: boolean;
|
|
15
|
+
rootGroup: SVGGElement;
|
|
16
|
+
textElement: SVGTextElement;
|
|
17
|
+
constructor(cell: GridCell, beat: Beat, markers: Marker[], isPreMarker: boolean, rootElement: SVGGraphicsElement, config?: any);
|
|
18
|
+
protected refreshMinSize(): TSU.Geom.Size;
|
|
19
|
+
refreshLayout(): void;
|
|
20
|
+
protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
|
|
21
|
+
}
|
|
3
22
|
export declare class BeatView extends BeatViewBase {
|
|
4
23
|
createAtomView(): import("../shapes").AtomView;
|
|
5
24
|
refreshLayout(): void;
|
|
@@ -1,9 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeatView = void 0;
|
|
26
|
+
exports.BeatView = exports.MarkerView = void 0;
|
|
27
|
+
const TSU = __importStar(require("@panyam/tsutils"));
|
|
28
|
+
const shapes_1 = require("../shapes");
|
|
4
29
|
const atomviews_1 = require("./atomviews");
|
|
5
30
|
const beatview_1 = require("../beatview");
|
|
6
31
|
const embelishments_1 = require("./embelishments");
|
|
32
|
+
class MarkerView extends shapes_1.ElementShape {
|
|
33
|
+
constructor(cell, beat, markers, isPreMarker, rootElement, config) {
|
|
34
|
+
const rootGroup = TSU.DOM.createSVGNode("g", {
|
|
35
|
+
parent: rootElement,
|
|
36
|
+
attrs: {
|
|
37
|
+
class: "markerView",
|
|
38
|
+
pre: isPreMarker,
|
|
39
|
+
roleName: beat.role.name,
|
|
40
|
+
beatIndex: "" + beat.index,
|
|
41
|
+
gridRow: cell.rowIndex,
|
|
42
|
+
gridCol: cell.colIndex,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
super(rootGroup);
|
|
46
|
+
this.cell = cell;
|
|
47
|
+
this.beat = beat;
|
|
48
|
+
this.markers = markers;
|
|
49
|
+
this.isPreMarker = isPreMarker;
|
|
50
|
+
this.rootElement = rootElement;
|
|
51
|
+
this.needsLayout = true;
|
|
52
|
+
this.rootGroup = rootGroup;
|
|
53
|
+
this.textElement = TSU.DOM.createSVGNode("text", {
|
|
54
|
+
parent: rootGroup,
|
|
55
|
+
attrs: {
|
|
56
|
+
class: "markerText",
|
|
57
|
+
pre: isPreMarker,
|
|
58
|
+
dx: isPreMarker ? 0 : 15,
|
|
59
|
+
},
|
|
60
|
+
text: this.markers[0].text,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
refreshMinSize() {
|
|
64
|
+
const ts = TSU.DOM.svgBBox(this.textElement);
|
|
65
|
+
const totalWidth = ts.width;
|
|
66
|
+
const maxHeight = ts.height;
|
|
67
|
+
return new TSU.Geom.Size(totalWidth + 5, maxHeight + 5);
|
|
68
|
+
}
|
|
69
|
+
refreshLayout() {
|
|
70
|
+
this.rootGroup.setAttribute("transform", "translate(" + this.x + "," + this.y + ")");
|
|
71
|
+
}
|
|
72
|
+
updateBounds(x, y, w, h) {
|
|
73
|
+
return [x, y, NaN, NaN];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.MarkerView = MarkerView;
|
|
7
77
|
class BeatView extends beatview_1.BeatView {
|
|
8
78
|
createAtomView() {
|
|
9
79
|
return (0, atomviews_1.createAtomView)(this.element, this.beat.atom, this.beat.role.defaultToNotes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":"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,GAAG,CAAC,GAAG,CAAC,CAAC;qBACvB;iBACF;aACF;SACF;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA7CD,4BA6CC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Embelishment } from \"../shapes\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { ElementShape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { Marker } from \"../core\";\nimport { Beat } from \"../beats\";\nimport { BeatView as BeatViewBase } from \"../beatview\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class MarkerView extends ElementShape<SVGGElement> implements GridCellView {\n needsLayout = true;\n rootGroup: SVGGElement;\n textElement: SVGTextElement;\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly markers: Marker[],\n public readonly isPreMarker: boolean,\n public readonly rootElement: SVGGraphicsElement,\n config?: any,\n ) {\n const rootGroup = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"markerView\",\n pre: isPreMarker,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n });\n super(rootGroup);\n this.rootGroup = rootGroup as SVGGElement;\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: rootGroup,\n attrs: {\n class: \"markerText\",\n pre: isPreMarker,\n dx: isPreMarker ? 0 : 15,\n },\n text: this.markers[0].text,\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const ts = TSU.DOM.svgBBox(this.textElement);\n const totalWidth = ts.width;\n const maxHeight = ts.height;\n return new TSU.Geom.Size(totalWidth + 5, maxHeight + 5);\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.rootGroup.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n}\n\nexport class BeatView extends BeatViewBase {\n createAtomView() {\n return createAtomView(this.element, this.beat.atom, this.beat.role.defaultToNotes);\n }\n\n refreshLayout(): void {\n const newX = this.hasX ? this._x : 0;\n const newY = this.hasY ? this._y : 0;\n this.element.setAttribute(\"transform\", \"translate(\" + newX + \",\" + newY + \")\");\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n protected createEmbelishments(): Embelishment[] {\n let embelishments: Embelishment[] = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.rootElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.instanceCount(beat.beatIndex) - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n embelishments = [emb];\n }\n }\n }\n }\n return embelishments;\n }\n}\n"]}
|
|
@@ -163,7 +163,7 @@ class BeatEndLines extends shapes_1.Embelishment {
|
|
|
163
163
|
this.source = source;
|
|
164
164
|
this.rootElement = rootElement;
|
|
165
165
|
this.lineSpacing = 2;
|
|
166
|
-
this.barSpacing =
|
|
166
|
+
this.barSpacing = 0;
|
|
167
167
|
this.lines = [];
|
|
168
168
|
for (let i = 0; i < nLines; i++) {
|
|
169
169
|
this.lines.push(TSU.DOM.createSVGNode("line", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embelishments.js","sourceRoot":"","sources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I,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;IAES,cAAc;QACtB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,WAAW;QACnB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,YAAY,CACpB,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB;QAEhB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAvDD,sBAuDC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beatview\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: LeafAtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: LeafAtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 15;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: LeafAtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAGvC,sCAAyC;AAOzC,MAAsB,wBAAyB,SAAQ,qBAAY;IACjE,YAA4B,QAAsB;QAChD,KAAK,EAAE,CAAC;QADkB,aAAQ,GAAR,QAAQ,CAAc;IAElD,CAAC;CACF;AAJD,4DAIC;AAED,MAAa,eAAgB,SAAQ,wBAAwB;IAK3D,YAA4B,QAAsB,EAAkB,IAAU;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QADU,aAAQ,GAAR,QAAQ,CAAc;QAAkB,SAAI,GAAJ,IAAI,CAAM;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AC,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAvDD,sBAuDC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beatview\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: LeafAtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: LeafAtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 0;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: LeafAtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
|