vibe-editor 0.0.4 → 0.0.6

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 (78) hide show
  1. package/package.json +66 -61
  2. package/src/scripts/js/Core.js +28 -9
  3. package/src/scripts/js/entry.js +6 -5
  4. package/src/scripts/js/gui/Annotations.js +27 -12
  5. package/src/scripts/js/gui/ScoreManipulator.js +6 -4
  6. package/src/scripts/js/gui/Tabbar.js +13 -4
  7. package/src/scripts/js/handlers/AnnotationChangeHandler.js +13 -1
  8. package/src/scripts/js/handlers/InsertModeHandler.js +3 -3
  9. package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
  10. package/src/scripts/js/handlers/WindowHandler.js +7 -7
  11. package/src/scripts/js/scripts/Core.js +932 -0
  12. package/src/scripts/js/scripts/MusicProcessor.js +810 -0
  13. package/src/scripts/js/scripts/VIBE.js +219 -0
  14. package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
  15. package/src/scripts/js/scripts/gui/Annotations.js +549 -0
  16. package/src/scripts/js/scripts/gui/Cursor.js +203 -0
  17. package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
  18. package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
  19. package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
  20. package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
  21. package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
  22. package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
  23. package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
  24. package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
  25. package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
  26. package/src/scripts/js/scripts/handlers/Handler.js +2 -0
  27. package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
  28. package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
  29. package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
  30. package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
  31. package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +161 -0
  32. package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
  33. package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
  34. package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
  35. package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
  36. package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
  37. package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
  38. package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
  39. package/src/scripts/js/scripts/utils/Types.js +2 -0
  40. package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +32 -18
  41. package/src/scripts/js/scripts/utils/coordinates.js +78 -0
  42. package/src/scripts/js/utils/Mouse2SVG.js +11 -4
  43. package/src/scripts/js/utils/VerovioWrapper.js +4 -4
  44. package/src/scripts/js/utils/coordinates.js +26 -2
  45. package/src/styles/vibe.css +32 -6
  46. package/src/scripts/js/.DS_Store +0 -0
  47. package/src/scripts/js/MusicPlayer.js +0 -572
  48. package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
  49. package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
  50. package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
  51. package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
  52. package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
  53. package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
  54. package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
  55. package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
  56. package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
  57. package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
  58. package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
  59. package/src/scripts/js/handlers/SelectionHandler.js +0 -262
  60. package/src/scripts/js/utils/RectWrapper.js +0 -10
  61. package/src/scripts/js/utils/SVGFiller.js +0 -245
  62. package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
  63. package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
  64. /package/src/scripts/js/{assets → scripts/assets}/mei_template.js +0 -0
  65. /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
  66. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
  67. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
  68. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
  69. /package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +0 -0
  70. /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
  71. /package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +0 -0
  72. /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
  73. /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
  74. /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
  75. /package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +0 -0
  76. /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
  77. /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
  78. /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const PhantomElement_1 = require("../gui/PhantomElement");
5
+ const coordinates = require("../utils/coordinates");
6
+ const cq = require("../utils/convenienceQueries");
7
+ class PhantomElementHandler {
8
+ constructor(containerId) {
9
+ this.trackMouseHandler = (function handler(e) {
10
+ var that = this;
11
+ that.trackMouse(e);
12
+ }).bind(this);
13
+ this.timeMarkerHandler = (function timeMarkerHandler(e) {
14
+ this.drawMarkers(e);
15
+ }).bind(this);
16
+ this.setContainerId(containerId);
17
+ this.addCanvas();
18
+ this.phantom = new PhantomElement_1.default("note", containerId);
19
+ this.isTrackingMouse = false;
20
+ }
21
+ addCanvas() {
22
+ if (cq.getInteractOverlay(this.containerId).querySelector("#phantomCanvas") !== null)
23
+ return;
24
+ this.rootBBox = this.vrvSVG.getBoundingClientRect();
25
+ var rootWidth = this.rootBBox.width.toString();
26
+ var rootHeigth = this.rootBBox.height.toString();
27
+ if (this.phantomCanvas == undefined) {
28
+ this.phantomCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
29
+ this.phantomCanvas.setAttribute("id", "phantomCanvas");
30
+ }
31
+ this.interactionOverlay.insertBefore(this.phantomCanvas, this.interactionOverlay.firstChild);
32
+ }
33
+ setListeners() {
34
+ this.interactionOverlay.addEventListener("mousemove", this.trackMouseHandler);
35
+ this.interactionOverlay.querySelectorAll(".notehead rect").forEach(n => n.addEventListener("draggingNote", this.trackMouseHandler));
36
+ // Listener just for staves
37
+ this.interactionOverlay.querySelectorAll(".staffLine").forEach(element => {
38
+ element.addEventListener('click', this.trackMouseHandler);
39
+ });
40
+ this.interactionOverlay.querySelectorAll(".staff").forEach(s => {
41
+ s.addEventListener("currStaffChanged", this.timeMarkerHandler);
42
+ });
43
+ return this;
44
+ }
45
+ setPhantomLineListeners() {
46
+ this.interactionOverlay.querySelectorAll(".phantomLine").forEach(element => {
47
+ element.addEventListener('click', this.trackMouseHandler);
48
+ });
49
+ }
50
+ removeListeners() {
51
+ this.interactionOverlay.removeEventListener("mousemove", this.trackMouseHandler);
52
+ this.interactionOverlay.querySelectorAll(".notehead rect").forEach(n => n.removeEventListener("draggingNote", this.trackMouseHandler));
53
+ this.interactionOverlay.querySelectorAll(".staff").forEach(s => {
54
+ s.removeEventListener("currStaffChanged", this.timeMarkerHandler);
55
+ });
56
+ this.interactionOverlay.querySelectorAll(".staffLine").forEach(element => {
57
+ element.removeEventListener('click', this.trackMouseHandler);
58
+ clearInterval(this.trackMouseHandler);
59
+ });
60
+ if (this.phantom) {
61
+ this.phantom.removePhantomNote();
62
+ this.phantom = undefined;
63
+ }
64
+ return this;
65
+ }
66
+ removePhantomLineListeners() {
67
+ this.interactionOverlay.querySelectorAll(".phantomLine").forEach(element => {
68
+ element.removeEventListener('click', this.trackMouseHandler);
69
+ });
70
+ }
71
+ /**
72
+ * Draw circle under mouse cursor
73
+ * @param e
74
+ */
75
+ trackMouse(e) {
76
+ var _a, _b, _c, _d, _e;
77
+ if (this.m2s.getLastMouseEnter().staff === null)
78
+ return;
79
+ var definitionScale = (_b = cq.getVrvSVG(this.containerId).querySelector("#" + ((_a = this.m2s.getLastMouseEnter().staff) === null || _a === void 0 ? void 0 : _a.getAttribute("refId")))) === null || _b === void 0 ? void 0 : _b.closest(".definition-scale");
80
+ if (!definitionScale)
81
+ return;
82
+ var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, cq.getInteractOverlay(this.containerId));
83
+ var relX = pt.x;
84
+ var relY = pt.y;
85
+ var dsCoords = coordinates.getDOMMatrixCoordinates(definitionScale, cq.getInteractOverlay(this.containerId));
86
+ if (relX < dsCoords.left || relX > dsCoords.right) {
87
+ this.isTrackingMouse = false;
88
+ return;
89
+ }
90
+ this.isTrackingMouse = true;
91
+ var target = e.target;
92
+ target = target.closest("g");
93
+ var options = {};
94
+ if (target === null || target === void 0 ? void 0 : target.classList.contains("staffLine")) {
95
+ options["staffLineId"] = target.id;
96
+ }
97
+ var phantomNoteElement = this.phantom.getNoteElement();
98
+ if (phantomNoteElement == undefined) {
99
+ return;
100
+ }
101
+ phantomNoteElement.setAttribute("cx", relX.toString());
102
+ phantomNoteElement.setAttribute("cy", relY.toString());
103
+ phantomNoteElement.setAttribute("r", ((_d = (_c = this.m2s) === null || _c === void 0 ? void 0 : _c.getLineDist()) === null || _d === void 0 ? void 0 : _d.toString()) || "0");
104
+ phantomNoteElement.setAttribute("visibility", phantomNoteElement.getAttribute("visibility") || "visible");
105
+ this.m2s.defineNote(relX, relY, options);
106
+ var newCY = (_e = (this.m2s.getNewNoteY())) === null || _e === void 0 ? void 0 : _e.toString();
107
+ phantomNoteElement.setAttribute("cy", (newCY || "0"));
108
+ this.removeLines();
109
+ if (this.m2s.getPhantomLines() != undefined) {
110
+ this.phantomLines = new Array();
111
+ this.m2s.getPhantomLines().forEach(pl => {
112
+ this.phantomLines.push(new PhantomElement_1.default("line", this.containerId, { lineX: relX, lineY: pl }, this.phantomCanvas));
113
+ });
114
+ this.setPhantomLineListeners();
115
+ }
116
+ }
117
+ removeLines() {
118
+ var lines = this.interactionOverlay.querySelectorAll(".phantomLine");
119
+ this.removePhantomLineListeners();
120
+ if (lines.length > 0) {
121
+ lines.forEach(l => {
122
+ l.remove();
123
+ });
124
+ }
125
+ return this;
126
+ }
127
+ drawMarkers(e) {
128
+ this.container.querySelectorAll(".phantomMarker").forEach(pm => pm.remove());
129
+ var pm = new PhantomElement_1.default("timeMarkers", this.containerId, { lastStaffEnteredId: e.target.getAttribute("refId"),
130
+ measureMatrix: this.m2s.getMeasureMatrix() });
131
+ }
132
+ resetCanvas() {
133
+ this.setContainerId(this.containerId);
134
+ this.rootBBox = this.vrvSVG.getBoundingClientRect();
135
+ this.phantomCanvas = this.interactionOverlay.querySelector("#phantomCanvas");
136
+ this.removeListeners();
137
+ this.removePhantomLineListeners();
138
+ this.phantom = new PhantomElement_1.default("note", this.containerId);
139
+ this.setListeners();
140
+ this.setPhantomLineListeners();
141
+ }
142
+ setm2s(m2s) {
143
+ this.m2s = m2s;
144
+ return this;
145
+ }
146
+ setContainerId(id) {
147
+ this.containerId = id;
148
+ this.vrvSVG = cq.getVrvSVG(id);
149
+ this.interactionOverlay = cq.getInteractOverlay(id);
150
+ this.container = document.getElementById(id);
151
+ return this;
152
+ }
153
+ setPhantomNote(note = undefined) {
154
+ this.phantom = note || new PhantomElement_1.default("note", this.containerId);
155
+ return this;
156
+ }
157
+ getIsTrackingMouse() {
158
+ return this.isTrackingMouse;
159
+ }
160
+ }
161
+ exports.default = PhantomElementHandler;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ScoreManipulator_1 = require("../gui/ScoreManipulator");
4
+ const constants_1 = require("../constants");
5
+ const meiOperation = require("../utils/MEIOperations");
6
+ const meiConverter = require("../utils/MEIConverter");
7
+ const cq = require("../utils/convenienceQueries");
8
+ const mei_template_1 = require("../assets/mei_template");
9
+ const manipSelector = ".manipulator";
10
+ const canvasId = "manipulatorCanvas";
11
+ /**
12
+ * Handler for all options which could change the given score with methods which are not bound to the toolsbars.
13
+ * These functions are related to all elements seen inside a score. (Adding Staves, Measures and Layers)
14
+ */
15
+ class ScoreManipulatorHandler {
16
+ constructor() {
17
+ this.cacheLayers = {};
18
+ this.addMeasure = (function addMeasure(e) {
19
+ e.target.dispatchEvent(this.manipulateEvent);
20
+ e.preventDefault();
21
+ e.stopPropagation();
22
+ meiOperation.addMeasure(this.currentMEI);
23
+ var that = this;
24
+ this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
25
+ that.setActiveLayers();
26
+ });
27
+ }).bind(this);
28
+ this.removeMeasure = (function removeMeasure(e) {
29
+ e.target.dispatchEvent(this.manipulateEvent);
30
+ e.preventDefault();
31
+ e.stopPropagation();
32
+ meiOperation.removeMeasure(this.currentMEI);
33
+ this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false);
34
+ }).bind(this);
35
+ this.addStaff = (function addStaff(e) {
36
+ var target = e.target.closest(".manipulator");
37
+ target.dispatchEvent(this.manipulateEvent);
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ var relpos = target.classList.contains("below") ? "below" : "above";
41
+ meiOperation.addStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
42
+ this.musicPlayer.resetMidiInstruments();
43
+ var that = this;
44
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
45
+ that.setActiveLayers();
46
+ });
47
+ }).bind(this);
48
+ this.removeStaff = (function removeStaff(e) {
49
+ var target = e.target.closest(".manipulator");
50
+ target.dispatchEvent(this.manipulateEvent);
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ var relpos = target.classList.contains("below") ? "below" : "above";
54
+ meiOperation.removeStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
55
+ this.musicPlayer.resetMidiInstruments();
56
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false);
57
+ e.target.dispatchEvent(this.manipulateEvent);
58
+ }).bind(this);
59
+ this.removeFunction = (function removeElementsFunction() {
60
+ this.removeElements();
61
+ }).bind(this);
62
+ this.selectVoiceHandler = (function selectVoiceHandler(e) {
63
+ this.selectVoice(e);
64
+ }).bind(this);
65
+ this.sm = new ScoreManipulator_1.default();
66
+ this.manipulateEvent = new Event("manipulated");
67
+ }
68
+ addCanvas() {
69
+ var _a;
70
+ var rootBBox = cq.getVrvSVG(this.containerId).firstElementChild.getBoundingClientRect();
71
+ var rootWidth = rootBBox.width.toString();
72
+ var rootHeigth = rootBBox.height.toString();
73
+ this.manipulatorCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
74
+ this.manipulatorCanvas.setAttribute("id", canvasId);
75
+ this.manipulatorCanvas.classList.add("canvas");
76
+ //this.manipulatorCanvas.setAttribute("preserveAspectRatio", "xMinYMin meet")
77
+ //this.manipulatorCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "))
78
+ (_a = this.interactionOverlay.querySelector("#" + canvasId)) === null || _a === void 0 ? void 0 : _a.remove();
79
+ this.manipulatorCanvas.insertAdjacentElement("beforebegin", this.interactionOverlay.querySelector("#scoreRects"));
80
+ this.interactionOverlay.append(this.manipulatorCanvas);
81
+ }
82
+ drawElements() {
83
+ this.addCanvas();
84
+ this.sm.drawMeasureManipulators();
85
+ this.sm.drawStaffManipulators();
86
+ this.sm.drawVoiceSelectors();
87
+ this.setListeners();
88
+ return this;
89
+ }
90
+ removeElements() {
91
+ //this.removeListeners()
92
+ this.interactionOverlay.querySelectorAll(manipSelector).forEach(m => {
93
+ m.remove();
94
+ });
95
+ }
96
+ setListeners() {
97
+ var that = this;
98
+ this.removeListeners();
99
+ this.interactionOverlay.querySelector("#measureAdder").addEventListener("click", this.addMeasure, true);
100
+ this.interactionOverlay.querySelector("#measureRemover").addEventListener("click", this.removeMeasure, true);
101
+ this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
102
+ as.addEventListener("click", that.addStaff, true);
103
+ });
104
+ this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
105
+ as.addEventListener("click", that.removeStaff, true);
106
+ });
107
+ this.interactionOverlay.querySelectorAll(".voiceBtn").forEach(vb => {
108
+ vb.addEventListener("click", that.selectVoiceHandler, true);
109
+ });
110
+ // if(!this.interactionOverlay.querySelector(".voiceBtn.selected")){
111
+ // (this.interactionOverlay.querySelector(".voiceBtn") as HTMLElement).click()
112
+ // }
113
+ }
114
+ removeListeners() {
115
+ var _a, _b;
116
+ var that = this;
117
+ (_a = this.interactionOverlay.querySelector("#measureAdder")) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this.addMeasure);
118
+ (_b = this.interactionOverlay.querySelector("#measureRemover")) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this.removeMeasure);
119
+ this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
120
+ as.removeEventListener("click", that.addStaff);
121
+ });
122
+ this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
123
+ as.removeEventListener("click", that.removeStaff);
124
+ });
125
+ this.interactionOverlay.querySelectorAll(".voiceBtn").forEach(vb => {
126
+ vb.removeEventListener("click", that.selectVoiceHandler);
127
+ });
128
+ }
129
+ /**
130
+ * Logic for behaviour if when a voice btn is selected:
131
+ * Creating new layer, deactivating and reactivating layers.
132
+ * Afterwards the MEI will be rendered anew.
133
+ * @param e
134
+ */
135
+ selectVoice(e) {
136
+ var t = e.target.closest(".voiceBtn");
137
+ var staffN = t.getAttribute("staffN");
138
+ var btnN = t.getAttribute("btnN");
139
+ // change between selected and inactive button
140
+ if (t.classList.contains("selected")) {
141
+ t.classList.remove("selected");
142
+ t.classList.add("inactive");
143
+ }
144
+ else if (t.classList.contains("inactive")) {
145
+ t.classList.remove("inactive");
146
+ t.classList.add("selected");
147
+ }
148
+ var that = this;
149
+ //In this case there is no existing layer for the selected voice
150
+ if (!this.currentMEI.querySelector(`staff[n='${staffN}'] layer[n='${btnN}']`) && !this.cacheLayers[staffN + btnN]) {
151
+ meiOperation.addLayerForStaff(this.currentMEI, staffN, btnN);
152
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
153
+ that.setActiveLayerClass(staffN, btnN);
154
+ });
155
+ }
156
+ else {
157
+ // if the button is really inactive, cache the layer for this layer and staff
158
+ if (t.classList.contains("inactive")) {
159
+ this.cacheLayers[staffN + btnN] = this.currentMEI.querySelectorAll(`staff[n='${staffN}'] layer[n='${btnN}']`);
160
+ console.log(this.cacheLayers);
161
+ this.currentMEI.querySelectorAll(`staff[n='${staffN}'] layer[n='${btnN}']`).forEach(el => el.remove());
162
+ }
163
+ else if (this.cacheLayers[staffN + btnN]) { // bring the layers back to life
164
+ this.currentMEI.querySelectorAll(`staff[n='${staffN}']`).forEach((staff, i) => {
165
+ if (this.cacheLayers[staffN + btnN][i]) {
166
+ staff.insertBefore(this.cacheLayers[staffN + btnN][i], staff.querySelector(`layer[n='${(parseInt(btnN) + 1).toString()}']`));
167
+ }
168
+ else {
169
+ staff.append(new mei_template_1.default().createLayer(btnN));
170
+ }
171
+ });
172
+ delete this.cacheLayers[staffN + btnN];
173
+ }
174
+ this.loadDataCallback("", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
175
+ that.setActiveLayerClass(staffN, btnN);
176
+ });
177
+ }
178
+ }
179
+ setActiveLayerClass(staffN, btnN) {
180
+ this.interactionOverlay.querySelectorAll(`.voiceBtn[staffN='${staffN}'].selected`).forEach(vb => vb.classList.remove("selected"));
181
+ this.interactionOverlay.querySelectorAll(`.voiceBtn:not(.inactive)[staffN='${staffN}'][btnN='${btnN}']`).forEach(vb => vb.classList.add("selected"));
182
+ cq.getContainer(this.containerId).querySelectorAll(`.staff[n='${staffN}'] > .activeLayer`).forEach(layer => layer.classList.remove("activeLayer"));
183
+ cq.getContainer(this.containerId).querySelectorAll(`.staff[n='${staffN}'] > .layer[n='${btnN}']`).forEach(layer => {
184
+ layer.classList.add("activeLayer");
185
+ });
186
+ return this;
187
+ }
188
+ setActiveLayers() {
189
+ cq.getContainer(this.containerId).querySelectorAll(".activeLayer").forEach(al => {
190
+ var staffN = al.closest(".staff").getAttribute("n");
191
+ this.setActiveLayerClass(staffN, al.getAttribute("n"));
192
+ });
193
+ cq.getContainer(this.containerId).querySelectorAll("#vrvSVG .staff:not(:has(.activeLayer))").forEach(staff => {
194
+ this.setActiveLayerClass(staff.getAttribute("n"), "1");
195
+ });
196
+ var activeNotes = Array.from(cq.getContainer(this.containerId).querySelectorAll(".activeLayer > .note")).reverse();
197
+ var hasNotes = activeNotes.length > 0;
198
+ var lastNode = cq.getContainer(this.containerId).querySelector(".activeLayer > :is(.rest, .mRest");
199
+ if (hasNotes) {
200
+ lastNode = activeNotes[0];
201
+ }
202
+ this.scoreGraph.setCurrentNodeById(lastNode.id);
203
+ }
204
+ //SETTER////
205
+ setMEI(mei) {
206
+ this.currentMEI = mei;
207
+ this.sm.setMEI(mei);
208
+ return this;
209
+ }
210
+ setm2s(m2s) {
211
+ this.m2s = m2s;
212
+ return this;
213
+ }
214
+ setMusicProcessor(mp) {
215
+ this.musicPlayer = mp;
216
+ return this;
217
+ }
218
+ setScoreGraph(sg) {
219
+ this.scoreGraph = sg;
220
+ return this;
221
+ }
222
+ setLoadDataCallback(loadDataCallback) {
223
+ this.loadDataCallback = loadDataCallback;
224
+ return this;
225
+ }
226
+ setContainerId(containerId) {
227
+ this.containerId = containerId;
228
+ this.interactionOverlay = cq.getInteractOverlay(containerId);
229
+ this.sm.setContainerId(this.containerId);
230
+ return this;
231
+ }
232
+ }
233
+ exports.default = ScoreManipulatorHandler;