notations 0.0.44 → 0.0.45

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.
Files changed (109) hide show
  1. package/README.md +38 -0
  2. package/lib/cjs/beats.d.ts +111 -0
  3. package/lib/cjs/beats.js +523 -0
  4. package/lib/cjs/beats.js.map +1 -0
  5. package/lib/cjs/carnatic/LineView.d.ts +20 -0
  6. package/lib/cjs/carnatic/LineView.js +69 -0
  7. package/lib/cjs/carnatic/LineView.js.map +1 -0
  8. package/lib/cjs/carnatic/NotationView.d.ts +31 -0
  9. package/lib/cjs/carnatic/NotationView.js +250 -0
  10. package/lib/cjs/carnatic/NotationView.js.map +1 -0
  11. package/lib/cjs/carnatic/atomviews.d.ts +14 -7
  12. package/lib/cjs/carnatic/atomviews.js +170 -137
  13. package/lib/cjs/carnatic/atomviews.js.map +1 -1
  14. package/lib/cjs/carnatic/beatviews.d.ts +10 -14
  15. package/lib/cjs/carnatic/beatviews.js +53 -110
  16. package/lib/cjs/carnatic/beatviews.js.map +1 -1
  17. package/lib/cjs/carnatic/embelishments.d.ts +38 -32
  18. package/lib/cjs/carnatic/embelishments.js +34 -19
  19. package/lib/cjs/carnatic/embelishments.js.map +1 -1
  20. package/lib/cjs/carnatic/index.d.ts +2 -0
  21. package/lib/cjs/carnatic/index.js +2 -0
  22. package/lib/cjs/carnatic/index.js.map +1 -1
  23. package/lib/cjs/core.d.ts +15 -73
  24. package/lib/cjs/core.js +196 -564
  25. package/lib/cjs/core.js.map +1 -1
  26. package/lib/cjs/cycle.d.ts +47 -0
  27. package/lib/cjs/cycle.js +492 -0
  28. package/lib/cjs/cycle.js.map +1 -0
  29. package/lib/cjs/entity.d.ts +24 -0
  30. package/lib/cjs/entity.js +135 -0
  31. package/lib/cjs/entity.js.map +1 -0
  32. package/lib/cjs/index.d.ts +3 -0
  33. package/lib/cjs/index.js +3 -0
  34. package/lib/cjs/index.js.map +1 -1
  35. package/lib/cjs/iterators.d.ts +14 -2
  36. package/lib/cjs/iterators.js +77 -5
  37. package/lib/cjs/iterators.js.map +1 -1
  38. package/lib/cjs/layouts.d.ts +7 -106
  39. package/lib/cjs/layouts.js +4 -478
  40. package/lib/cjs/layouts.js.map +1 -1
  41. package/lib/cjs/loader.d.ts +2 -1
  42. package/lib/cjs/loader.js +31 -26
  43. package/lib/cjs/loader.js.map +1 -1
  44. package/lib/cjs/notation.d.ts +3 -1
  45. package/lib/cjs/notation.js +6 -4
  46. package/lib/cjs/notation.js.map +1 -1
  47. package/lib/cjs/parser.js +5 -4
  48. package/lib/cjs/parser.js.map +1 -1
  49. package/lib/cjs/shapes.d.ts +35 -14
  50. package/lib/cjs/shapes.js +153 -43
  51. package/lib/cjs/shapes.js.map +1 -1
  52. package/lib/cjs/utils.d.ts +2 -1
  53. package/lib/cjs/utils.js +4 -3
  54. package/lib/cjs/utils.js.map +1 -1
  55. package/lib/esm/beats.d.ts +111 -0
  56. package/lib/esm/beats.js +501 -0
  57. package/lib/esm/beats.js.map +1 -0
  58. package/lib/esm/carnatic/LineView.d.ts +20 -0
  59. package/lib/esm/carnatic/LineView.js +47 -0
  60. package/lib/esm/carnatic/LineView.js.map +1 -0
  61. package/lib/esm/carnatic/NotationView.d.ts +31 -0
  62. package/lib/esm/carnatic/NotationView.js +228 -0
  63. package/lib/esm/carnatic/NotationView.js.map +1 -0
  64. package/lib/esm/carnatic/atomviews.d.ts +14 -7
  65. package/lib/esm/carnatic/atomviews.js +170 -137
  66. package/lib/esm/carnatic/atomviews.js.map +1 -1
  67. package/lib/esm/carnatic/beatviews.d.ts +10 -14
  68. package/lib/esm/carnatic/beatviews.js +54 -111
  69. package/lib/esm/carnatic/beatviews.js.map +1 -1
  70. package/lib/esm/carnatic/embelishments.d.ts +38 -32
  71. package/lib/esm/carnatic/embelishments.js +33 -18
  72. package/lib/esm/carnatic/embelishments.js.map +1 -1
  73. package/lib/esm/carnatic/index.d.ts +2 -0
  74. package/lib/esm/carnatic/index.js +2 -0
  75. package/lib/esm/carnatic/index.js.map +1 -1
  76. package/lib/esm/core.d.ts +15 -73
  77. package/lib/esm/core.js +192 -560
  78. package/lib/esm/core.js.map +1 -1
  79. package/lib/esm/cycle.d.ts +47 -0
  80. package/lib/esm/cycle.js +470 -0
  81. package/lib/esm/cycle.js.map +1 -0
  82. package/lib/esm/entity.d.ts +24 -0
  83. package/lib/esm/entity.js +132 -0
  84. package/lib/esm/entity.js.map +1 -0
  85. package/lib/esm/index.d.ts +3 -0
  86. package/lib/esm/index.js +3 -0
  87. package/lib/esm/index.js.map +1 -1
  88. package/lib/esm/iterators.d.ts +14 -2
  89. package/lib/esm/iterators.js +73 -1
  90. package/lib/esm/iterators.js.map +1 -1
  91. package/lib/esm/layouts.d.ts +7 -106
  92. package/lib/esm/layouts.js +1 -475
  93. package/lib/esm/layouts.js.map +1 -1
  94. package/lib/esm/loader.d.ts +2 -1
  95. package/lib/esm/loader.js +27 -23
  96. package/lib/esm/loader.js.map +1 -1
  97. package/lib/esm/notation.d.ts +3 -1
  98. package/lib/esm/notation.js +3 -1
  99. package/lib/esm/notation.js.map +1 -1
  100. package/lib/esm/parser.js +5 -4
  101. package/lib/esm/parser.js.map +1 -1
  102. package/lib/esm/shapes.d.ts +35 -14
  103. package/lib/esm/shapes.js +152 -42
  104. package/lib/esm/shapes.js.map +1 -1
  105. package/lib/esm/utils.d.ts +2 -1
  106. package/lib/esm/utils.js +3 -2
  107. package/lib/esm/utils.js.map +1 -1
  108. package/package.json +30 -25
  109. package/styles/NotationView.scss +35 -0
@@ -56,12 +56,23 @@ var __values = (this && this.__values) || function(o) {
56
56
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
57
57
  };
58
58
  Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.createAtomView = exports.LeafAtomView = void 0;
59
+ exports.createAtomView = exports.LeafAtomView = exports.GroupView = void 0;
60
60
  var TSU = __importStar(require("@panyam/tsutils"));
61
61
  var core_1 = require("../core");
62
62
  var shapes_1 = require("../shapes");
63
63
  var embelishments_1 = require("./embelishments");
64
64
  var gamakas_1 = require("./gamakas");
65
+ var GroupView = (function (_super) {
66
+ __extends(GroupView, _super);
67
+ function GroupView() {
68
+ return _super !== null && _super.apply(this, arguments) || this;
69
+ }
70
+ GroupView.prototype.createAtomView = function (atom) {
71
+ return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);
72
+ };
73
+ return GroupView;
74
+ }(shapes_1.GroupView));
75
+ exports.GroupView = GroupView;
65
76
  var LeafAtomView = (function (_super) {
66
77
  __extends(LeafAtomView, _super);
67
78
  function LeafAtomView() {
@@ -72,8 +83,11 @@ var LeafAtomView = (function (_super) {
72
83
  _this.bottomSlot = [];
73
84
  return _this;
74
85
  }
86
+ LeafAtomView.prototype.refreshBBox = function () {
87
+ return TSU.DOM.svgBBox(this.rootGroup.element);
88
+ };
75
89
  LeafAtomView.prototype.refreshMinSize = function () {
76
- var out = __assign({}, (this.rootShape || this.glyph).minSize);
90
+ var out = __assign({}, this.rootText.minSize);
77
91
  var totalWidth = this.leftSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
78
92
  this.rightSlot.reduce(function (a, b) { return a + b.minSize.width; }, 0) +
79
93
  this.leftSlot.length +
@@ -87,95 +101,92 @@ var LeafAtomView = (function (_super) {
87
101
  LeafAtomView.prototype.updateBounds = function (x, y, w, h) {
88
102
  return [x, y, NaN, NaN];
89
103
  };
90
- LeafAtomView.prototype.refreshLayout = function () {
104
+ LeafAtomView.prototype.layoutElements = function () {
91
105
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
92
- var x = this.x;
93
- var y = this.y;
94
- this.glyph.setBounds(null, y, null, null, true);
95
- var currX = x;
96
- var currY = y;
97
- if (currX != null) {
106
+ var textSize = this.rootText.minSize;
107
+ var currX = 0;
108
+ var currY = this.hasY ? this.y : 0;
109
+ try {
110
+ for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
111
+ var emb = _f.value;
112
+ emb.x = currX;
113
+ emb.refreshLayout();
114
+ currX += emb.minSize.width + 1;
115
+ }
116
+ }
117
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
118
+ finally {
98
119
  try {
99
- for (var _e = __values(this.leftSlot), _f = _e.next(); !_f.done; _f = _e.next()) {
100
- var emb = _f.value;
101
- emb.x = currX;
102
- emb.refreshLayout();
103
- currX += emb.minSize.width + 1;
104
- }
120
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
105
121
  }
106
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
107
- finally {
108
- try {
109
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
110
- }
111
- finally { if (e_1) throw e_1.error; }
122
+ finally { if (e_1) throw e_1.error; }
123
+ }
124
+ var textX = currX;
125
+ this.rootText.x = currX;
126
+ this.rootText.refreshLayout();
127
+ currX += this.rootText.minSize.width;
128
+ try {
129
+ for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
130
+ var emb = _h.value;
131
+ emb.x = currX;
132
+ emb.refreshLayout();
133
+ currX += emb.minSize.width + 1;
112
134
  }
113
- var glyphRoot = this.rootShape || this.glyph;
114
- glyphRoot.x = currX;
115
- glyphRoot.refreshLayout();
116
- currX += glyphRoot.minSize.width;
135
+ }
136
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
137
+ finally {
117
138
  try {
118
- for (var _g = __values(this.rightSlot), _h = _g.next(); !_h.done; _h = _g.next()) {
119
- var emb = _h.value;
120
- emb.x = currX;
121
- emb.refreshLayout();
122
- currX += emb.minSize.width + 1;
123
- }
139
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
124
140
  }
125
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
126
- finally {
127
- try {
128
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
129
- }
130
- finally { if (e_2) throw e_2.error; }
141
+ finally { if (e_2) throw e_2.error; }
142
+ }
143
+ var gminSize = this.glyph.minSize;
144
+ var glyphX = textX + this.glyph.x;
145
+ var glyphY = this.glyph.y;
146
+ currY = glyphY - this.glyph.minSize.height + 5;
147
+ try {
148
+ for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
149
+ var emb = _k.value;
150
+ var bb = emb.minSize;
151
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
152
+ currY = emb.y;
131
153
  }
132
154
  }
133
- if (currX != null || currY != null) {
134
- var gminSize = this.glyph.minSize;
135
- var glyphX = this.glyph.x;
136
- var glyphY = this.glyph.y;
137
- currY = glyphY - 1;
155
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
156
+ finally {
138
157
  try {
139
- for (var _j = __values(this.topSlot), _k = _j.next(); !_k.done; _k = _j.next()) {
140
- var emb = _k.value;
141
- var bb = emb.minSize;
142
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);
143
- currY = emb.y;
144
- }
158
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
145
159
  }
146
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
147
- finally {
148
- try {
149
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
150
- }
151
- finally { if (e_3) throw e_3.error; }
160
+ finally { if (e_3) throw e_3.error; }
161
+ }
162
+ currY = glyphY + 7;
163
+ try {
164
+ for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
165
+ var emb = _m.value;
166
+ var bb = emb.minSize;
167
+ emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
168
+ currY = emb.y + bb.height;
152
169
  }
153
- currY = glyphY + gminSize.height + 2;
170
+ }
171
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
172
+ finally {
154
173
  try {
155
- for (var _l = __values(this.bottomSlot), _m = _l.next(); !_m.done; _m = _l.next()) {
156
- var emb = _m.value;
157
- var bb = emb.minSize;
158
- emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);
159
- currY = emb.y + bb.height;
160
- }
161
- }
162
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
163
- finally {
164
- try {
165
- if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
166
- }
167
- finally { if (e_4) throw e_4.error; }
174
+ if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
168
175
  }
176
+ finally { if (e_4) throw e_4.error; }
169
177
  }
170
- this.resetMinSize();
178
+ this.invalidateBounds();
179
+ };
180
+ LeafAtomView.prototype.refreshLayout = function () {
181
+ this.layoutElements();
182
+ this.rootGroup.element.setAttribute("transform", "translate(" + this.x + "," + this.y + ")");
171
183
  };
172
184
  LeafAtomView.prototype.addEmbelishment = function (slot, emb) {
173
185
  slot.push(emb);
174
- this.addShape(emb);
175
186
  };
176
187
  LeafAtomView.prototype.orderEmbelishments = function () {
177
188
  var e_5, _a;
178
- var atom = this.flatAtom.atom;
189
+ var atom = this.leafAtom;
179
190
  if (atom.type != core_1.AtomType.SYLLABLE && atom.type != core_1.AtomType.NOTE) {
180
191
  return;
181
192
  }
@@ -228,86 +239,67 @@ var LeafAtomView = (function (_super) {
228
239
  finally { if (e_5) throw e_5.error; }
229
240
  }
230
241
  };
242
+ LeafAtomView.prototype.embRoot = function () {
243
+ return this.rootGroup.element;
244
+ };
231
245
  LeafAtomView.prototype.needsRootElement = function () {
232
- return this.rightSlot.length > 0 || this.flatAtom.atom.beforeRest;
246
+ return true;
233
247
  };
234
248
  LeafAtomView.prototype.createElements = function (parent) {
235
- var _a;
236
- if (this.needsRootElement()) {
237
- this.createGlyphRoot(parent);
238
- }
239
- this.createGlyphElement(((_a = this.rootShape) === null || _a === void 0 ? void 0 : _a.element) || parent);
249
+ this.createGlyphRoot(parent);
250
+ this.createGlyphElement();
240
251
  this.orderEmbelishments();
241
- if (this.needsRootElement()) {
242
- if (!this.rootShape) {
243
- this.createGlyphRoot(parent);
244
- this.moveGlyphToRoot();
245
- }
246
- this.createPostSpacingElement();
247
- }
248
- this.resetMinSize();
252
+ this.createPostSpacingElement();
253
+ this.invalidateBounds();
249
254
  };
250
255
  LeafAtomView.prototype.createGlyphRoot = function (parent) {
251
- this.rootShape = new shapes_1.ElementShape(TSU.DOM.createSVGNode("tspan", {
256
+ this.rootGroup = new shapes_1.ElementShape(TSU.DOM.createSVGNode("g", {
252
257
  doc: document,
253
258
  parent: parent,
254
259
  attrs: {
255
- depth: this.flatAtom.depth || 0,
256
- atomid: this.flatAtom.atom.uuid,
257
- id: "atomViewRoot" + this.flatAtom.atom.uuid,
260
+ atomid: this.leafAtom.uuid,
261
+ class: "atomViewRootGroup",
262
+ id: "atomViewRootGroup" + this.leafAtom.uuid,
258
263
  },
259
264
  }));
260
- };
261
- LeafAtomView.prototype.createPostSpacingElement = function () {
262
- this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
265
+ this.rootText = new shapes_1.ElementShape(TSU.DOM.createSVGNode("text", {
263
266
  doc: document,
264
- parent: this.rootShape.element,
267
+ parent: this.rootGroup.element,
265
268
  attrs: {
266
- depth: this.flatAtom.depth || 0,
267
- atomid: this.flatAtom.atom.uuid,
268
- id: "postSpacing" + this.flatAtom.atom.uuid,
269
+ atomid: this.leafAtom.uuid,
270
+ class: "atomViewTextRoot",
271
+ id: "atomViewTextRoot" + this.leafAtom.uuid,
269
272
  },
270
- text: this.flatAtom.atom.beforeRest ? " - " : " ",
271
- });
272
- };
273
- LeafAtomView.prototype.moveGlyphToRoot = function () {
274
- this.rootShape.element.appendChild(this.glyph.element);
273
+ }));
275
274
  };
276
- LeafAtomView.prototype.createGlyphElement = function (parent) {
277
- var atom = this.flatAtom.atom;
275
+ LeafAtomView.prototype.createGlyphElement = function () {
276
+ var atom = this.leafAtom;
278
277
  this.glyph = new shapes_1.ElementShape(TSU.DOM.createSVGNode("tspan", {
279
278
  doc: document,
280
- parent: parent,
279
+ parent: this.rootText.element,
281
280
  attrs: {
282
- depth: this.flatAtom.depth || 0,
283
281
  atomid: atom.uuid,
284
- id: "atom" + atom.uuid,
282
+ id: "atomGlyph" + atom.uuid,
285
283
  },
286
284
  text: this.glyphLabel,
287
285
  }));
288
286
  };
287
+ LeafAtomView.prototype.createPostSpacingElement = function () {
288
+ if (this.leafAtom.beforeRest) {
289
+ this.postSpacingSpan = TSU.DOM.createSVGNode("tspan", {
290
+ doc: document,
291
+ parent: this.rootText.element,
292
+ attrs: {
293
+ atomid: this.leafAtom.uuid,
294
+ id: "postSpacing" + this.leafAtom.uuid,
295
+ },
296
+ text: this.leafAtom.beforeRest ? " - " : " ",
297
+ });
298
+ }
299
+ };
289
300
  return LeafAtomView;
290
- }(shapes_1.AtomView));
301
+ }(shapes_1.LeafAtomView));
291
302
  exports.LeafAtomView = LeafAtomView;
292
- function createAtomView(parent, atom) {
293
- var out;
294
- switch (atom.atom.type) {
295
- case core_1.AtomType.SPACE:
296
- out = new SpaceView(atom);
297
- break;
298
- case core_1.AtomType.SYLLABLE:
299
- out = new SyllableView(atom);
300
- break;
301
- case core_1.AtomType.NOTE:
302
- out = new NoteView(atom);
303
- break;
304
- default:
305
- throw new Error("Invalid atom type: " + atom.atom.type);
306
- }
307
- out.createElements(parent);
308
- return out;
309
- }
310
- exports.createAtomView = createAtomView;
311
303
  var SpaceView = (function (_super) {
312
304
  __extends(SpaceView, _super);
313
305
  function SpaceView() {
@@ -315,14 +307,20 @@ var SpaceView = (function (_super) {
315
307
  }
316
308
  Object.defineProperty(SpaceView.prototype, "glyphLabel", {
317
309
  get: function () {
318
- return this.space.isSilent ? " " : ",";
310
+ if (this.space.isSilent)
311
+ return " ";
312
+ if (this.space.duration.isOne)
313
+ return ",";
314
+ if (this.space.duration.cmpNum(2) == 0)
315
+ return ";";
316
+ return "_";
319
317
  },
320
318
  enumerable: false,
321
319
  configurable: true
322
320
  });
323
321
  Object.defineProperty(SpaceView.prototype, "space", {
324
322
  get: function () {
325
- return this.flatAtom.atom;
323
+ return this.leafAtom;
326
324
  },
327
325
  enumerable: false,
328
326
  configurable: true
@@ -342,17 +340,17 @@ var NoteView = (function (_super) {
342
340
  configurable: true
343
341
  });
344
342
  NoteView.prototype.needsRootElement = function () {
345
- return this.note.shift == true || this.note.shift != 0 || _super.prototype.needsRootElement.call(this);
343
+ return true;
346
344
  };
347
- NoteView.prototype.createGlyphElement = function (parent) {
348
- _super.prototype.createGlyphElement.call(this, parent);
345
+ NoteView.prototype.createGlyphElement = function () {
346
+ _super.prototype.createGlyphElement.call(this);
349
347
  if (this.note.shift == true || this.note.shift != 0) {
350
348
  this.shiftElement = TSU.DOM.createSVGNode("tspan", {
351
349
  doc: document,
352
- parent: this.rootShape.element,
350
+ parent: this.rootText.element,
353
351
  attrs: {
354
- depth: this.flatAtom.depth || 0,
355
352
  atomid: this.note.uuid,
353
+ class: "noteShiftTSpan",
356
354
  id: "noteShift" + this.note.uuid,
357
355
  "baseline-shift": "sub",
358
356
  },
@@ -361,9 +359,8 @@ var NoteView = (function (_super) {
361
359
  }
362
360
  };
363
361
  NoteView.prototype.moveGlyphToRoot = function () {
364
- _super.prototype.moveGlyphToRoot.call(this);
365
362
  if (this.shiftElement) {
366
- this.rootShape.element.appendChild(this.shiftElement);
363
+ this.rootGroup.element.appendChild(this.shiftElement);
367
364
  }
368
365
  };
369
366
  NoteView.prototype.orderEmbelishments = function () {
@@ -378,7 +375,7 @@ var NoteView = (function (_super) {
378
375
  };
379
376
  Object.defineProperty(NoteView.prototype, "note", {
380
377
  get: function () {
381
- return this.flatAtom.atom;
378
+ return this.leafAtom;
382
379
  },
383
380
  enumerable: false,
384
381
  configurable: true
@@ -399,11 +396,47 @@ var SyllableView = (function (_super) {
399
396
  });
400
397
  Object.defineProperty(SyllableView.prototype, "syllable", {
401
398
  get: function () {
402
- return this.flatAtom.atom;
399
+ return this.leafAtom;
403
400
  },
404
401
  enumerable: false,
405
402
  configurable: true
406
403
  });
407
404
  return SyllableView;
408
405
  }(LeafAtomView));
406
+ function createAtomView(parent, atom, litDefaultsToNote, groupViewScale) {
407
+ if (litDefaultsToNote === void 0) { litDefaultsToNote = false; }
408
+ if (groupViewScale === void 0) { groupViewScale = 1.0; }
409
+ var out;
410
+ switch (atom.type) {
411
+ case core_1.AtomType.SPACE:
412
+ out = new SpaceView(atom);
413
+ break;
414
+ case core_1.AtomType.SYLLABLE:
415
+ out = new SyllableView(atom);
416
+ break;
417
+ case core_1.AtomType.NOTE:
418
+ out = new NoteView(atom);
419
+ break;
420
+ case core_1.AtomType.LITERAL:
421
+ if (litDefaultsToNote) {
422
+ var lit = core_1.Note.fromLit(atom);
423
+ out = new NoteView(lit);
424
+ }
425
+ else {
426
+ var lit = core_1.Syllable.fromLit(atom);
427
+ out = new SyllableView(lit);
428
+ }
429
+ break;
430
+ case core_1.AtomType.GROUP:
431
+ out = new GroupView(atom);
432
+ out.defaultToNotes = litDefaultsToNote;
433
+ out.scaleFactor = groupViewScale;
434
+ break;
435
+ default:
436
+ throw new Error("Invalid atom type: " + atom.type);
437
+ }
438
+ out.createElements(parent);
439
+ return out;
440
+ }
441
+ exports.createAtomView = createAtomView;
409
442
  //# sourceMappingURL=atomviews.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,gCAAmE;AACnE,oCAAiE;AAEjE,iDAYyB;AACzB,qCAAuC;AAEvC;IAA2C,gCAAQ;IAAnD;QAAA,qEA6NC;QA5NC,cAAQ,GAAmB,EAAE,CAAC;QAC9B,aAAO,GAAmB,EAAE,CAAC;QAC7B,eAAS,GAAmB,EAAE,CAAC;QAC/B,gBAAU,GAAmB,EAAE,CAAC;;IAyNlC,CAAC;IA/MW,qCAAc,GAAxB;QACE,IAAM,GAAG,gBAAQ,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAE,CAAC;QAC1D,IAAM,UAAU,GAC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AC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACvD;IACH,CAAC;IAED,qCAAkB,GAAlB;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,+BAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACpD;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,+BAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACvD;QACD,iBAAM,kBAAkB,WAAE,CAAC;IAC7B,CAAC;IAED,sBAAI,0BAAI;aAAR;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAY,CAAC;QACpC,CAAC;;;OAAA;IACH,eAAC;AAAD,CAAC,AAhDD,CAAuB,YAAY,GAgDlC;AAED;IAA2B,gCAAY;IAAvC;;IAQA,CAAC;IAPC,sBAAI,oCAAU;aAAd;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,CAAC;;;OAAA;IAED,sBAAI,kCAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAgB,CAAC;QACxC,CAAC;;;OAAA;IACH,mBAAC;AAAD,CAAC,AARD,CAA2B,YAAY,GAQtC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport { AtomView, Embelishment, ElementShape } from \"../shapes\";\nimport { FlatAtom } from \"../iterators\";\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 abstract class LeafAtomView extends AtomView {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\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 rootShape: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...(this.rootShape || this.glyph).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 refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n const x = this.x;\n const y = this.y;\n this.glyph.setBounds(null, y, null, null, true);\n\n // now layout leftSlots\n let currX = x;\n let currY = y;\n if (currX != null) {\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 glyph\n const glyphRoot = this.rootShape || this.glyph;\n glyphRoot.x = currX;\n glyphRoot.refreshLayout();\n currX += glyphRoot.minSize.width;\n\n // And right embelishments\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n }\n\n // layout top and bottom if x or y has changed\n if (currX != null || currY != null) {\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - 1;\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 + gminSize.height + 2;\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 }\n this.resetMinSize();\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.flatAtom.atom;\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 needsRootElement(): boolean {\n return this.rightSlot.length > 0 || this.flatAtom.atom.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 if (this.needsRootElement()) {\n this.createGlyphRoot(parent);\n }\n this.createGlyphElement(this.rootShape?.element || parent);\n\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n if (this.needsRootElement()) {\n // create as 2 sub span elements\n if (!this.rootShape) {\n this.createGlyphRoot(parent);\n // move the element into the parent\n this.moveGlyphToRoot();\n }\n\n this.createPostSpacingElement();\n }\n this.resetMinSize();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootShape = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: parent,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.flatAtom.atom.uuid,\n id: \"atomViewRoot\" + this.flatAtom.atom.uuid,\n },\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootShape.element,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.flatAtom.atom.uuid,\n id: \"postSpacing\" + this.flatAtom.atom.uuid,\n },\n text: this.flatAtom.atom.beforeRest ? \" - \" : \" \",\n });\n }\n\n protected moveGlyphToRoot(): void {\n this.rootShape.element.appendChild(this.glyph.element);\n }\n\n protected createGlyphElement(parent: SVGGraphicsElement): void {\n const atom = this.flatAtom.atom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: parent,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: atom.uuid,\n id: \"atom\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n}\n\nexport function createAtomView(parent: SVGGraphicsElement, atom: FlatAtom): AtomView {\n let out: AtomView;\n switch (atom.atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom);\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.atom.type);\n }\n out.createElements(parent);\n return out;\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n return this.space.isSilent ? \" \" : \",\";\n }\n\n get space(): Space {\n return this.flatAtom.atom 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 this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(parent: SVGGraphicsElement): void {\n super.createGlyphElement(parent);\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootShape.element,\n attrs: {\n depth: this.flatAtom.depth || 0,\n atomid: this.note.uuid,\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.rootShape.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.flatAtom.atom 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.flatAtom.atom as Syllable;\n }\n}\n"]}
1
+ {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":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YACpB,GAAG,GAAG,IAAI,YAAY,CAAC,IAAgB,CAAC,CAAC;YACzC,MAAM;QACR,KAAK,eAAQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,eAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE;gBACrB,IAAM,GAAG,GAAG,WAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;aACzB;iBAAM;gBACL,IAAM,GAAG,GAAG,eAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,eAAQ,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;AAvCD,wCAuCC","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,20 +1,16 @@
1
- import * as TSU from "@panyam/tsutils";
2
- import { Cycle } from "../core";
3
- import { BeatView as BeatViewBase, Beat } from "../layouts";
4
- import { Embelishment, Shape } from "../shapes";
5
- export declare class BeatView extends Shape implements BeatViewBase {
1
+ import { Cycle } from "../cycle";
2
+ import { BeatView as BeatViewBase, Beat } from "../beats";
3
+ import { AtomView, Embelishment, ElementShape } from "../shapes";
4
+ export declare class BeatView extends ElementShape<SVGGElement> implements BeatViewBase {
6
5
  readonly beat: Beat;
6
+ readonly rootElement: SVGGraphicsElement;
7
7
  readonly cycle: Cycle;
8
- protected atomSpacing: number;
9
- needsLayout: boolean;
10
8
  private _embelishments;
11
- private atomViews;
12
- groupElement: SVGGElement;
13
- textElement: SVGTextElement;
14
- constructor(beat: Beat, rootElement: Element, cycle: Cycle, config?: any);
15
- protected refreshMinSize(): TSU.Geom.Size;
16
- protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
17
- setStyles(config: any): void;
9
+ atomView: AtomView;
10
+ needsLayout: boolean;
11
+ constructor(beat: Beat, rootElement: SVGGraphicsElement, cycle: Cycle, config?: any);
18
12
  refreshLayout(): void;
19
13
  get embelishments(): Embelishment[];
14
+ protected createEmbelishments(): Embelishment[];
15
+ setStyles(config: any): void;
20
16
  }