notations 0.0.48 → 0.0.49
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 +34 -69
- package/lib/cjs/beats.js +178 -439
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/beatutils.d.ts +3 -0
- package/lib/cjs/beatutils.js +64 -0
- package/lib/cjs/beatutils.js.map +1 -0
- package/lib/cjs/beatview.d.ts +18 -0
- package/lib/cjs/beatview.js +62 -0
- package/lib/cjs/beatview.js.map +1 -0
- package/lib/cjs/carnatic/LineView.d.ts +2 -7
- package/lib/cjs/carnatic/LineView.js +13 -31
- package/lib/cjs/carnatic/LineView.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.d.ts +8 -7
- package/lib/cjs/carnatic/NotationView.js +73 -153
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +149 -287
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.d.ts +4 -13
- package/lib/cjs/carnatic/beatviews.js +23 -118
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.d.ts +1 -1
- package/lib/cjs/carnatic/embelishments.js +189 -283
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/gamakas.js +15 -47
- package/lib/cjs/carnatic/gamakas.js.map +1 -1
- package/lib/cjs/commands.js +111 -271
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.d.ts +6 -1
- package/lib/cjs/core.js +288 -493
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js +175 -367
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/entity.js +48 -102
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/grids.d.ts +124 -1
- package/lib/cjs/grids.js +546 -6
- package/lib/cjs/grids.js.map +1 -1
- package/lib/cjs/iterators.js +96 -234
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.d.ts +1 -1
- package/lib/cjs/layouts.js +62 -98
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.d.ts +2 -2
- package/lib/cjs/loader.js +23 -123
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.d.ts +0 -3
- package/lib/cjs/notation.js +139 -241
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/parser.d.ts +2 -0
- package/lib/cjs/parser.js +217 -219
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js +149 -283
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.d.ts +8 -0
- package/lib/cjs/utils.js +60 -55
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.d.ts +34 -69
- package/lib/esm/beats.js +172 -438
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatutils.d.ts +3 -0
- package/lib/esm/beatutils.js +37 -0
- package/lib/esm/beatutils.js.map +1 -0
- package/lib/esm/beatview.d.ts +18 -0
- package/lib/esm/beatview.js +35 -0
- package/lib/esm/beatview.js.map +1 -0
- package/lib/esm/carnatic/LineView.d.ts +2 -7
- package/lib/esm/carnatic/LineView.js +12 -31
- package/lib/esm/carnatic/LineView.js.map +1 -1
- package/lib/esm/carnatic/NotationView.d.ts +8 -7
- package/lib/esm/carnatic/NotationView.js +71 -152
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/carnatic/atomviews.js +144 -284
- package/lib/esm/carnatic/atomviews.js.map +1 -1
- package/lib/esm/carnatic/beatviews.d.ts +4 -13
- package/lib/esm/carnatic/beatviews.js +21 -94
- package/lib/esm/carnatic/beatviews.js.map +1 -1
- package/lib/esm/carnatic/embelishments.d.ts +1 -1
- package/lib/esm/carnatic/embelishments.js +187 -296
- package/lib/esm/carnatic/embelishments.js.map +1 -1
- package/lib/esm/carnatic/gamakas.js +14 -48
- package/lib/esm/carnatic/gamakas.js.map +1 -1
- package/lib/esm/commands.js +100 -271
- package/lib/esm/commands.js.map +1 -1
- package/lib/esm/core.d.ts +6 -1
- package/lib/esm/core.js +286 -502
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.js +172 -367
- package/lib/esm/cycle.js.map +1 -1
- package/lib/esm/entity.js +48 -104
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/grids.d.ts +124 -1
- package/lib/esm/grids.js +515 -5
- package/lib/esm/grids.js.map +1 -1
- package/lib/esm/iterators.js +93 -235
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.d.ts +1 -1
- package/lib/esm/layouts.js +60 -97
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.d.ts +2 -2
- package/lib/esm/loader.js +20 -120
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.d.ts +0 -3
- package/lib/esm/notation.js +135 -242
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/parser.d.ts +2 -0
- package/lib/esm/parser.js +211 -214
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.js +148 -288
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.d.ts +8 -0
- package/lib/esm/utils.js +55 -51
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,236 +1,139 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
1
|
import * as TSU from "@panyam/tsutils";
|
|
39
2
|
import { AtomType, Note, Syllable } from "../core";
|
|
40
3
|
import { LeafAtomView as LeafAtomViewBase, GroupView as GroupViewBase, ElementShape, } from "../shapes";
|
|
41
4
|
import { OctaveIndicator, Kampitham, Nokku, Spuritham, Prathyagatham, Orikkai, Odukkal, Raavi, Kandippu, Vaali, Jaaru, } from "./embelishments";
|
|
42
5
|
import { GamakaType } from "./gamakas";
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function GroupView() {
|
|
46
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
47
|
-
}
|
|
48
|
-
GroupView.prototype.createAtomView = function (atom) {
|
|
6
|
+
export class GroupView extends GroupViewBase {
|
|
7
|
+
createAtomView(atom) {
|
|
49
8
|
return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);
|
|
50
|
-
};
|
|
51
|
-
return GroupView;
|
|
52
|
-
}(GroupViewBase));
|
|
53
|
-
export { GroupView };
|
|
54
|
-
var LeafAtomView = (function (_super) {
|
|
55
|
-
__extends(LeafAtomView, _super);
|
|
56
|
-
function LeafAtomView() {
|
|
57
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
58
|
-
_this.leftSlot = [];
|
|
59
|
-
_this.topSlot = [];
|
|
60
|
-
_this.rightSlot = [];
|
|
61
|
-
_this.bottomSlot = [];
|
|
62
|
-
return _this;
|
|
63
9
|
}
|
|
64
|
-
|
|
10
|
+
}
|
|
11
|
+
export class LeafAtomView extends LeafAtomViewBase {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.leftSlot = [];
|
|
15
|
+
this.topSlot = [];
|
|
16
|
+
this.rightSlot = [];
|
|
17
|
+
this.bottomSlot = [];
|
|
18
|
+
}
|
|
19
|
+
refreshBBox() {
|
|
65
20
|
return TSU.DOM.svgBBox(this.rootGroup.element);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.rightSlot.reduce(
|
|
21
|
+
}
|
|
22
|
+
refreshMinSize() {
|
|
23
|
+
const out = Object.assign({}, this.rootText.minSize);
|
|
24
|
+
const totalWidth = this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +
|
|
25
|
+
this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +
|
|
71
26
|
this.leftSlot.length +
|
|
72
27
|
this.rightSlot.length;
|
|
73
|
-
|
|
74
|
-
this.bottomSlot.reduce(
|
|
28
|
+
const totalHeight = this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +
|
|
29
|
+
this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);
|
|
75
30
|
out.width += totalWidth;
|
|
76
31
|
out.height += totalHeight;
|
|
77
32
|
return out;
|
|
78
|
-
}
|
|
79
|
-
|
|
33
|
+
}
|
|
34
|
+
updateBounds(x, y, w, h) {
|
|
80
35
|
return [x, y, NaN, NaN];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
emb.x = currX;
|
|
91
|
-
emb.refreshLayout();
|
|
92
|
-
currX += emb.minSize.width + 1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
96
|
-
finally {
|
|
97
|
-
try {
|
|
98
|
-
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
99
|
-
}
|
|
100
|
-
finally { if (e_1) throw e_1.error; }
|
|
36
|
+
}
|
|
37
|
+
layoutElements() {
|
|
38
|
+
const textSize = this.rootText.minSize;
|
|
39
|
+
let currX = 0;
|
|
40
|
+
let currY = this.hasY ? this.y : 0;
|
|
41
|
+
for (const emb of this.leftSlot) {
|
|
42
|
+
emb.x = currX;
|
|
43
|
+
emb.refreshLayout();
|
|
44
|
+
currX += emb.minSize.width + 1;
|
|
101
45
|
}
|
|
102
|
-
|
|
46
|
+
const textX = currX;
|
|
103
47
|
this.rootText.x = currX;
|
|
104
48
|
this.rootText.refreshLayout();
|
|
105
49
|
currX += this.rootText.minSize.width;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
emb.refreshLayout();
|
|
111
|
-
currX += emb.minSize.width + 1;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
115
|
-
finally {
|
|
116
|
-
try {
|
|
117
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
118
|
-
}
|
|
119
|
-
finally { if (e_2) throw e_2.error; }
|
|
50
|
+
for (const emb of this.rightSlot) {
|
|
51
|
+
emb.x = currX;
|
|
52
|
+
emb.refreshLayout();
|
|
53
|
+
currX += emb.minSize.width + 1;
|
|
120
54
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
55
|
+
const gminSize = this.glyph.minSize;
|
|
56
|
+
const glyphX = textX + this.glyph.x;
|
|
57
|
+
const glyphY = this.glyph.y;
|
|
124
58
|
currY = glyphY - this.glyph.minSize.height + 5;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
|
|
130
|
-
currY = emb.y;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
134
|
-
finally {
|
|
135
|
-
try {
|
|
136
|
-
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
137
|
-
}
|
|
138
|
-
finally { if (e_3) throw e_3.error; }
|
|
59
|
+
for (const emb of this.topSlot) {
|
|
60
|
+
const bb = emb.minSize;
|
|
61
|
+
emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
|
|
62
|
+
currY = emb.y;
|
|
139
63
|
}
|
|
140
64
|
currY = glyphY + 7;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
|
|
146
|
-
currY = emb.y + bb.height;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
150
|
-
finally {
|
|
151
|
-
try {
|
|
152
|
-
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
153
|
-
}
|
|
154
|
-
finally { if (e_4) throw e_4.error; }
|
|
65
|
+
for (const emb of this.bottomSlot) {
|
|
66
|
+
const bb = emb.minSize;
|
|
67
|
+
emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
|
|
68
|
+
currY = emb.y + bb.height;
|
|
155
69
|
}
|
|
156
70
|
this.invalidateBounds();
|
|
157
|
-
}
|
|
158
|
-
|
|
71
|
+
}
|
|
72
|
+
refreshLayout() {
|
|
159
73
|
this.layoutElements();
|
|
160
74
|
this.rootGroup.element.setAttribute("transform", "translate(" + this.x + "," + this.y + ")");
|
|
161
|
-
}
|
|
162
|
-
|
|
75
|
+
}
|
|
76
|
+
addEmbelishment(slot, emb) {
|
|
163
77
|
slot.push(emb);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var atom = this.leafAtom;
|
|
78
|
+
}
|
|
79
|
+
orderEmbelishments() {
|
|
80
|
+
const atom = this.leafAtom;
|
|
168
81
|
if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {
|
|
169
82
|
return;
|
|
170
83
|
}
|
|
171
|
-
|
|
84
|
+
const lit = atom;
|
|
172
85
|
if (lit.embelishments.length == 0)
|
|
173
86
|
return;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
213
|
-
finally {
|
|
214
|
-
try {
|
|
215
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
87
|
+
for (const emb of lit.embelishments) {
|
|
88
|
+
switch (emb.type) {
|
|
89
|
+
case GamakaType.Kampitham:
|
|
90
|
+
this.addEmbelishment(this.topSlot, new Kampitham(this));
|
|
91
|
+
break;
|
|
92
|
+
case GamakaType.Nokku:
|
|
93
|
+
this.addEmbelishment(this.topSlot, new Nokku(this));
|
|
94
|
+
break;
|
|
95
|
+
case GamakaType.Spuritham:
|
|
96
|
+
this.addEmbelishment(this.topSlot, new Spuritham(this));
|
|
97
|
+
break;
|
|
98
|
+
case GamakaType.Prathyagatham:
|
|
99
|
+
this.addEmbelishment(this.topSlot, new Prathyagatham(this));
|
|
100
|
+
break;
|
|
101
|
+
case GamakaType.Orikkai:
|
|
102
|
+
this.addEmbelishment(this.topSlot, new Orikkai(this));
|
|
103
|
+
break;
|
|
104
|
+
case GamakaType.Odukkal:
|
|
105
|
+
this.addEmbelishment(this.topSlot, new Odukkal(this));
|
|
106
|
+
break;
|
|
107
|
+
case GamakaType.Aahaatam_Raavi:
|
|
108
|
+
this.addEmbelishment(this.topSlot, new Raavi(this));
|
|
109
|
+
break;
|
|
110
|
+
case GamakaType.Aahaatam_Kandippu:
|
|
111
|
+
this.addEmbelishment(this.topSlot, new Kandippu(this));
|
|
112
|
+
break;
|
|
113
|
+
case GamakaType.Vaali:
|
|
114
|
+
this.addEmbelishment(this.topSlot, new Vaali(this));
|
|
115
|
+
break;
|
|
116
|
+
case GamakaType.Jaaru_Eetra:
|
|
117
|
+
case GamakaType.Jaaru_Irakka:
|
|
118
|
+
this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));
|
|
119
|
+
break;
|
|
216
120
|
}
|
|
217
|
-
finally { if (e_5) throw e_5.error; }
|
|
218
121
|
}
|
|
219
|
-
}
|
|
220
|
-
|
|
122
|
+
}
|
|
123
|
+
embRoot() {
|
|
221
124
|
return this.rootGroup.element;
|
|
222
|
-
}
|
|
223
|
-
|
|
125
|
+
}
|
|
126
|
+
needsRootElement() {
|
|
224
127
|
return true;
|
|
225
|
-
}
|
|
226
|
-
|
|
128
|
+
}
|
|
129
|
+
createElements(parent) {
|
|
227
130
|
this.createGlyphRoot(parent);
|
|
228
131
|
this.createGlyphElement();
|
|
229
132
|
this.orderEmbelishments();
|
|
230
133
|
this.createPostSpacingElement();
|
|
231
134
|
this.invalidateBounds();
|
|
232
|
-
}
|
|
233
|
-
|
|
135
|
+
}
|
|
136
|
+
createGlyphRoot(parent) {
|
|
234
137
|
this.rootGroup = new ElementShape(TSU.DOM.createSVGNode("g", {
|
|
235
138
|
doc: document,
|
|
236
139
|
parent: parent,
|
|
@@ -249,9 +152,9 @@ var LeafAtomView = (function (_super) {
|
|
|
249
152
|
id: "atomViewTextRoot" + this.leafAtom.uuid,
|
|
250
153
|
},
|
|
251
154
|
}));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
155
|
+
}
|
|
156
|
+
createGlyphElement() {
|
|
157
|
+
const atom = this.leafAtom;
|
|
255
158
|
this.glyph = new ElementShape(TSU.DOM.createSVGNode("tspan", {
|
|
256
159
|
doc: document,
|
|
257
160
|
parent: this.rootText.element,
|
|
@@ -261,8 +164,8 @@ var LeafAtomView = (function (_super) {
|
|
|
261
164
|
},
|
|
262
165
|
text: this.glyphLabel,
|
|
263
166
|
}));
|
|
264
|
-
}
|
|
265
|
-
|
|
167
|
+
}
|
|
168
|
+
createPostSpacingElement() {
|
|
266
169
|
if (this.leafAtom.beforeRest) {
|
|
267
170
|
this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
|
|
268
171
|
doc: document,
|
|
@@ -274,54 +177,31 @@ var LeafAtomView = (function (_super) {
|
|
|
274
177
|
text: this.leafAtom.beforeRest ? " - " : " ",
|
|
275
178
|
});
|
|
276
179
|
}
|
|
277
|
-
};
|
|
278
|
-
return LeafAtomView;
|
|
279
|
-
}(LeafAtomViewBase));
|
|
280
|
-
export { LeafAtomView };
|
|
281
|
-
var SpaceView = (function (_super) {
|
|
282
|
-
__extends(SpaceView, _super);
|
|
283
|
-
function SpaceView() {
|
|
284
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
285
180
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return "
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
Object.defineProperty(SpaceView.prototype, "space", {
|
|
300
|
-
get: function () {
|
|
301
|
-
return this.leafAtom;
|
|
302
|
-
},
|
|
303
|
-
enumerable: false,
|
|
304
|
-
configurable: true
|
|
305
|
-
});
|
|
306
|
-
return SpaceView;
|
|
307
|
-
}(LeafAtomView));
|
|
308
|
-
var NoteView = (function (_super) {
|
|
309
|
-
__extends(NoteView, _super);
|
|
310
|
-
function NoteView() {
|
|
311
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
181
|
+
}
|
|
182
|
+
class SpaceView extends LeafAtomView {
|
|
183
|
+
get glyphLabel() {
|
|
184
|
+
if (this.space.isSilent)
|
|
185
|
+
return " ";
|
|
186
|
+
if (this.space.duration.isOne)
|
|
187
|
+
return ",";
|
|
188
|
+
if (this.space.duration.cmpNum(2) == 0)
|
|
189
|
+
return ";";
|
|
190
|
+
return "_";
|
|
191
|
+
}
|
|
192
|
+
get space() {
|
|
193
|
+
return this.leafAtom;
|
|
312
194
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
});
|
|
320
|
-
NoteView.prototype.needsRootElement = function () {
|
|
195
|
+
}
|
|
196
|
+
class NoteView extends LeafAtomView {
|
|
197
|
+
get glyphLabel() {
|
|
198
|
+
return this.note.value;
|
|
199
|
+
}
|
|
200
|
+
needsRootElement() {
|
|
321
201
|
return true;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
202
|
+
}
|
|
203
|
+
createGlyphElement() {
|
|
204
|
+
super.createGlyphElement();
|
|
325
205
|
if (this.note.shift == true || this.note.shift != 0) {
|
|
326
206
|
this.shiftElement = TSU.DOM.createSVGNode("tspan", {
|
|
327
207
|
doc: document,
|
|
@@ -335,56 +215,36 @@ var NoteView = (function (_super) {
|
|
|
335
215
|
text: (this.note.shift == true ? "*" : this.note.shift) + " ",
|
|
336
216
|
});
|
|
337
217
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
218
|
+
}
|
|
219
|
+
moveGlyphToRoot() {
|
|
340
220
|
if (this.shiftElement) {
|
|
341
221
|
this.rootGroup.element.appendChild(this.shiftElement);
|
|
342
222
|
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
223
|
+
}
|
|
224
|
+
orderEmbelishments() {
|
|
225
|
+
const note = this.note;
|
|
346
226
|
if (note.octave > 0) {
|
|
347
227
|
this.topSlot.push(new OctaveIndicator(this, note));
|
|
348
228
|
}
|
|
349
229
|
else if (this.note.octave < 0) {
|
|
350
230
|
this.bottomSlot.push(new OctaveIndicator(this, note));
|
|
351
231
|
}
|
|
352
|
-
|
|
353
|
-
};
|
|
354
|
-
Object.defineProperty(NoteView.prototype, "note", {
|
|
355
|
-
get: function () {
|
|
356
|
-
return this.leafAtom;
|
|
357
|
-
},
|
|
358
|
-
enumerable: false,
|
|
359
|
-
configurable: true
|
|
360
|
-
});
|
|
361
|
-
return NoteView;
|
|
362
|
-
}(LeafAtomView));
|
|
363
|
-
var SyllableView = (function (_super) {
|
|
364
|
-
__extends(SyllableView, _super);
|
|
365
|
-
function SyllableView() {
|
|
366
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
232
|
+
super.orderEmbelishments();
|
|
367
233
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return SyllableView;
|
|
383
|
-
}(LeafAtomView));
|
|
384
|
-
export function createAtomView(parent, atom, litDefaultsToNote, groupViewScale) {
|
|
385
|
-
if (litDefaultsToNote === void 0) { litDefaultsToNote = false; }
|
|
386
|
-
if (groupViewScale === void 0) { groupViewScale = 1.0; }
|
|
387
|
-
var out;
|
|
234
|
+
get note() {
|
|
235
|
+
return this.leafAtom;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
class SyllableView extends LeafAtomView {
|
|
239
|
+
get glyphLabel() {
|
|
240
|
+
return this.syllable.value;
|
|
241
|
+
}
|
|
242
|
+
get syllable() {
|
|
243
|
+
return this.leafAtom;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
export function createAtomView(parent, atom, litDefaultsToNote = false, groupViewScale = 1.0) {
|
|
247
|
+
let out;
|
|
388
248
|
switch (atom.type) {
|
|
389
249
|
case AtomType.SPACE:
|
|
390
250
|
out = new SpaceView(atom);
|
|
@@ -397,11 +257,11 @@ export function createAtomView(parent, atom, litDefaultsToNote, groupViewScale)
|
|
|
397
257
|
break;
|
|
398
258
|
case AtomType.LITERAL:
|
|
399
259
|
if (litDefaultsToNote) {
|
|
400
|
-
|
|
260
|
+
const lit = Note.fromLit(atom);
|
|
401
261
|
out = new NoteView(lit);
|
|
402
262
|
}
|
|
403
263
|
else {
|
|
404
|
-
|
|
264
|
+
const lit = Syllable.fromLit(atom);
|
|
405
265
|
out = new SyllableView(lit);
|
|
406
266
|
}
|
|
407
267
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAwB,QAAQ,EAAE,IAAI,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,SAAS,IAAI,aAAa,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ACR,KAAK,QAAQ,CAAC,QAAQ;YACpB,GAAG,GAAG,IAAI,YAAY,CAAC,IAAgB,CAAC,CAAC;YACzC,MAAM;QACR,KAAK,QAAQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,QAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE;gBACrB,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;aACzB;iBAAM;gBACL,IAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,QAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\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 protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\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.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.type);\n }\n out.createElements(parent);\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAwB,QAAQ,EAAE,IAAI,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,SAAS,IAAI,aAAa,EAG1B,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,cAAc,CAAC,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IAA3D;;QACE,aAAQ,GAAmB,EAAE,CAAC;QAC9B,Y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AQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,QAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE;gBACrB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;aACzB;iBAAM;gBACL,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,QAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\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 protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\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.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.type);\n }\n out.createElements(parent);\n return out;\n}\n"]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BeatView as BeatViewBase
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly beat: Beat;
|
|
6
|
-
readonly rootElement: SVGGraphicsElement;
|
|
7
|
-
readonly cycle: Cycle;
|
|
8
|
-
private _embelishments;
|
|
9
|
-
atomView: AtomView;
|
|
10
|
-
needsLayout: boolean;
|
|
11
|
-
constructor(beat: Beat, rootElement: SVGGraphicsElement, cycle: Cycle, config?: any);
|
|
1
|
+
import { Embelishment } from "../shapes";
|
|
2
|
+
import { BeatView as BeatViewBase } from "../beatview";
|
|
3
|
+
export declare class BeatView extends BeatViewBase {
|
|
4
|
+
createAtomView(): import("../shapes").AtomView;
|
|
12
5
|
refreshLayout(): void;
|
|
13
|
-
get embelishments(): Embelishment[];
|
|
14
6
|
protected createEmbelishments(): Embelishment[];
|
|
15
|
-
setStyles(config: any): void;
|
|
16
7
|
}
|