vibe-editor 0.0.0
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/LICENSE +21 -0
- package/README.md +51 -0
- package/package.json +56 -0
- package/src/fonts/bravura/FONTLOG.txt +243 -0
- package/src/fonts/bravura/OFL-FAQ.txt +369 -0
- package/src/fonts/bravura/OFL.txt +94 -0
- package/src/fonts/bravura/bravura-text.md +153 -0
- package/src/fonts/bravura/bravura_metadata.json +34718 -0
- package/src/fonts/bravura/eot/Bravura.eot +0 -0
- package/src/fonts/bravura/eot/BravuraText.eot +0 -0
- package/src/fonts/bravura/otf/Bravura.otf +0 -0
- package/src/fonts/bravura/otf/BravuraText.otf +0 -0
- package/src/fonts/bravura/svg/Bravura.svg +3517 -0
- package/src/fonts/bravura/svg/BravuraText.svg +18879 -0
- package/src/fonts/bravura/woff/Bravura.woff +0 -0
- package/src/fonts/bravura/woff/BravuraText.woff +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabBol-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabLig-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabMed-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabReg-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.svg +970 -0
- package/src/fonts/colaborate/ColabThi-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.woff +0 -0
- package/src/images/GUI/.DS_Store +0 -0
- package/src/images/GUI/backward-fast-solid.svg +1 -0
- package/src/images/GUI/bars-solid.svg +1 -0
- package/src/images/GUI/caret-left-solid.svg +1 -0
- package/src/images/GUI/caret-right-solid.svg +1 -0
- package/src/images/GUI/edit-solid.svg +1 -0
- package/src/images/GUI/pause-solid.svg +1 -0
- package/src/images/GUI/play-solid.svg +1 -0
- package/src/images/GUI/triplet.svg +21 -0
- package/src/images/GUI/zoomin.svg +1 -0
- package/src/images/GUI/zoomout.svg +1 -0
- package/src/images/bravura_notes/.DS_Store +0 -0
- package/src/images/bravura_notes/16th.svg +1 -0
- package/src/images/bravura_notes/32th.svg +1 -0
- package/src/images/bravura_notes/alterDDown.svg +1 -0
- package/src/images/bravura_notes/alterDUp.svg +1 -0
- package/src/images/bravura_notes/alterDown.svg +1 -0
- package/src/images/bravura_notes/alterNeutral.svg +1 -0
- package/src/images/bravura_notes/alterUp.svg +1 -0
- package/src/images/bravura_notes/beams.svg +1 -0
- package/src/images/bravura_notes/eigth.svg +1 -0
- package/src/images/bravura_notes/full.svg +1 -0
- package/src/images/bravura_notes/half.svg +1 -0
- package/src/images/bravura_notes/oneDot.svg +1 -0
- package/src/images/bravura_notes/pauseNote.svg +1 -0
- package/src/images/bravura_notes/quarter.svg +1 -0
- package/src/images/bravura_notes/tie.svg +1 -0
- package/src/images/bravura_notes/twoDot.svg +1 -0
- package/src/scripts/js/.DS_Store +0 -0
- package/src/scripts/js/Core.js +887 -0
- package/src/scripts/js/MusicPlayer.js +572 -0
- package/src/scripts/js/MusicProcessor.js +652 -0
- package/src/scripts/js/VerovioScoreEditor.js +183 -0
- package/src/scripts/js/assets/mei_template.js +161 -0
- package/src/scripts/js/constants.js +20 -0
- package/src/scripts/js/datastructures/MeasureMatrix.js +235 -0
- package/src/scripts/js/datastructures/ScoreGraph.js +432 -0
- package/src/scripts/js/datastructures/ScoreNode.js +78 -0
- package/src/scripts/js/entry.js +4 -0
- package/src/scripts/js/gui/Annotations.js +456 -0
- package/src/scripts/js/gui/Cursor.js +203 -0
- package/src/scripts/js/gui/CustomAnnotationDrawer.js +114 -0
- package/src/scripts/js/gui/CustomAnnotationShapeDrawer.js +114 -0
- package/src/scripts/js/gui/HarmonyLabel.js +104 -0
- package/src/scripts/js/gui/Label.js +2 -0
- package/src/scripts/js/gui/PhantomElement.js +132 -0
- package/src/scripts/js/gui/ScoreManipulator.js +156 -0
- package/src/scripts/js/gui/Tabbar.js +675 -0
- package/src/scripts/js/gui/TempoLabel.js +60 -0
- package/src/scripts/js/gui/Toolbar copy.js +614 -0
- package/src/scripts/js/gui/Toolbar.js +618 -0
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +567 -0
- package/src/scripts/js/handlers/AnnotationDragHandler.js +113 -0
- package/src/scripts/js/handlers/AnnotationLineHandler.js +113 -0
- package/src/scripts/js/handlers/ArticulationHandler.js +20 -0
- package/src/scripts/js/handlers/ClickModeHandler.js +265 -0
- package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +131 -0
- package/src/scripts/js/handlers/CustomToolbarHandler.js +297 -0
- package/src/scripts/js/handlers/DeleteHandler.js +102 -0
- package/src/scripts/js/handlers/GlobalKeyboardHandler.js +367 -0
- package/src/scripts/js/handlers/Handler.js +2 -0
- package/src/scripts/js/handlers/HarmonyHandler.js +282 -0
- package/src/scripts/js/handlers/InsertModeHandler copy.js +423 -0
- package/src/scripts/js/handlers/InsertModeHandler.js +380 -0
- package/src/scripts/js/handlers/InsertModeHandler_deprecated.js +424 -0
- package/src/scripts/js/handlers/KeyModeHandler copy.js +407 -0
- package/src/scripts/js/handlers/KeyModeHandler.js +456 -0
- package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +411 -0
- package/src/scripts/js/handlers/LabelHandler.js +461 -0
- package/src/scripts/js/handlers/ModHandler.js +311 -0
- package/src/scripts/js/handlers/NoteDragHandler copy.js +148 -0
- package/src/scripts/js/handlers/NoteDragHandler.js +97 -0
- package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +150 -0
- package/src/scripts/js/handlers/PhantomElementHandler.js +168 -0
- package/src/scripts/js/handlers/ScoreManipulatorHandler.js +135 -0
- package/src/scripts/js/handlers/SelectionHandler.js +218 -0
- package/src/scripts/js/handlers/SideBarHandler.js +499 -0
- package/src/scripts/js/handlers/TooltipHandler.js +132 -0
- package/src/scripts/js/handlers/WindowHandler.js +257 -0
- package/src/scripts/js/utils/DOMCreator.js +174 -0
- package/src/scripts/js/utils/MEIConverter.js +64 -0
- package/src/scripts/js/utils/MEIOperations.js +2112 -0
- package/src/scripts/js/utils/Mouse2MEI.js +735 -0
- package/src/scripts/js/utils/Mouse2SVG.js +737 -0
- package/src/scripts/js/utils/SVGEditor.js +352 -0
- package/src/scripts/js/utils/SVGFiller.js +245 -0
- package/src/scripts/js/utils/Types.js +2 -0
- package/src/scripts/js/utils/VerovioWrapper copy.js +156 -0
- package/src/scripts/js/utils/VerovioWrapper.js +165 -0
- package/src/scripts/js/utils/VerovioWrapperLocal.js +156 -0
- package/src/scripts/js/utils/convenienceQueries.js +37 -0
- package/src/scripts/js/utils/coordinates.js +54 -0
- package/src/scripts/js/utils/firefoxBBoxes.js +143 -0
- package/src/scripts/js/utils/mappings.js +332 -0
- package/src/scripts/js/utils/random.js +45 -0
- package/src/styles/VerovioScoreEditor.css +694 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const MeasureMatrix_1 = require("../datastructures/MeasureMatrix");
|
4
|
+
const d3 = require("d3");
|
5
|
+
const coordinates = require("../utils/coordinates");
|
6
|
+
const cq = require("../utils/convenienceQueries");
|
7
|
+
//@ts-ignore
|
8
|
+
//const $ = H5P.jQuery;
|
9
|
+
/**
|
10
|
+
* @deprecated
|
11
|
+
* Class that handles insert mode, events, and actions.
|
12
|
+
*/
|
13
|
+
class NoteDragHandler {
|
14
|
+
constructor(containerId) {
|
15
|
+
this.wasDragged = false;
|
16
|
+
this.setContainerId(containerId);
|
17
|
+
this.dragInit();
|
18
|
+
this.noteDraggedEvent = new Event("noteDragged");
|
19
|
+
}
|
20
|
+
setListeners() {
|
21
|
+
}
|
22
|
+
removeListeners() {
|
23
|
+
}
|
24
|
+
resetListeners() {
|
25
|
+
this.removeListeners();
|
26
|
+
this.setListeners();
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Initialize the dragging action and handler for selected elements.
|
30
|
+
*/
|
31
|
+
dragInit() {
|
32
|
+
// Adding listeners
|
33
|
+
const dragBehaviour = d3.drag()
|
34
|
+
.on('start', dragStarted.bind(this))
|
35
|
+
.on('drag', this.dragging.bind(this))
|
36
|
+
.on('end', this.dragEnded.bind(this));
|
37
|
+
this.notes = document.querySelectorAll(".note, .notehead"); //d3.select("#" + this.containerId).selectAll(".note, .notehead");
|
38
|
+
this.draggedOverlayElement = null;
|
39
|
+
this.notes.call(dragBehaviour);
|
40
|
+
// Drag effects
|
41
|
+
function dragStarted() {
|
42
|
+
var _a;
|
43
|
+
this.draggedOverlayElement = d3.event.sourceEvent.currentTarget;
|
44
|
+
this.draggedRootSVGElement = (_a = this.rootSVG.querySelector("#" + this.draggedOverlayElement.getAttribute("refId"))) === null || _a === void 0 ? void 0 : _a.closest(".note");
|
45
|
+
this.dragStartCoords = [d3.event.x, d3.event.y]; //coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, document.getElementById(c._ROOTSVGID_))
|
46
|
+
this.dx = 0; //this.dragStartCoords[0]
|
47
|
+
this.dy = 0; //this.dragStartCoords[1]
|
48
|
+
}
|
49
|
+
}
|
50
|
+
dragging() {
|
51
|
+
if (this.draggedOverlayElement === null || this.draggedRootSVGElement === null)
|
52
|
+
return;
|
53
|
+
this.dx = d3.event.x;
|
54
|
+
this.dy = d3.event.y;
|
55
|
+
var overlayCoords = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, this.interactionOverlay);
|
56
|
+
var diffY = Math.abs(this.dy - this.dragStartCoords[1]);
|
57
|
+
if (diffY > 15) {
|
58
|
+
this.wasDragged = true;
|
59
|
+
}
|
60
|
+
//snap while dragging
|
61
|
+
this.m2m.defineNote(overlayCoords.x, overlayCoords.y, {});
|
62
|
+
var newNote = [this.m2m.getNewNote().pname, this.m2m.getNewNote().oct];
|
63
|
+
if (this.oldNote == undefined) {
|
64
|
+
this.oldNote = newNote;
|
65
|
+
}
|
66
|
+
const relativeY = d3.event.y - this.dragStartCoords[1]; //d3.event.y - this.dragStartCoords[1]
|
67
|
+
const relativeX = 0; //d3.event.x - this.dragStartCoords[0];
|
68
|
+
//overlay and defscale have completely different viewbox dimensions
|
69
|
+
var defScaleVBox = this.rootSVG.querySelector(".definition-scale").viewBox.baseVal;
|
70
|
+
var overlayVBox = this.interactionOverlay.viewBox.baseVal;
|
71
|
+
this.scaleX = defScaleVBox.width / overlayVBox.width;
|
72
|
+
this.scaleY = defScaleVBox.height / overlayVBox.height;
|
73
|
+
var shiftY = 10;
|
74
|
+
shiftY = relativeY < 0 ? -shiftY : shiftY;
|
75
|
+
if (!this.oldNote.every((v, i) => v === newNote[i])) {
|
76
|
+
this.draggedOverlayElement.setAttribute('transform', 'translate(' + [relativeX, relativeY + shiftY] + ')');
|
77
|
+
this.draggedRootSVGElement.setAttribute('transform', 'translate(' + [relativeX * this.scaleX, (relativeY + shiftY) * this.scaleY] + ')');
|
78
|
+
this.oldNote = newNote;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
dragEnded() {
|
82
|
+
if (this.draggedOverlayElement === null || this.draggedRootSVGElement === null)
|
83
|
+
return;
|
84
|
+
if (this.wasDragged) {
|
85
|
+
this.notes.on("drag", null);
|
86
|
+
this.wasDragged = false;
|
87
|
+
this.draggedOverlayElement.dispatchEvent(this.noteDraggedEvent);
|
88
|
+
this.container.querySelector("#" + this.draggedRootSVGElement.id).classList.remove(this.deleteHandler.getDeleteFlag()); //remove flag to delete after dragging
|
89
|
+
const action = {
|
90
|
+
action: "drag",
|
91
|
+
param: { elementId: this.draggedRootSVGElement.id,
|
92
|
+
//x: this.dx,
|
93
|
+
//y: this.dy
|
94
|
+
}
|
95
|
+
};
|
96
|
+
this.editCallback(action).then(() => {
|
97
|
+
var attr = this.elementAttrCallback(this.draggedRootSVGElement.id);
|
98
|
+
var mm = new MeasureMatrix_1.default();
|
99
|
+
//mm.populateFromSVG(svg)
|
100
|
+
mm.populateFromMEI(this.currentMEI);
|
101
|
+
var staff = this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("staff");
|
102
|
+
var measure = staff.closest("measure");
|
103
|
+
var staffIdx = parseInt(staff.getAttribute("n")) - 1;
|
104
|
+
var measureIdx = parseInt(measure.getAttribute("n")) - 1;
|
105
|
+
var dur = this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("chord") !== null ? this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("chord").getAttribute("dur") : attr.dur;
|
106
|
+
let newNote = {
|
107
|
+
pname: attr.pname,
|
108
|
+
oct: attr.oct.toString(),
|
109
|
+
dur: dur,
|
110
|
+
keysig: mm.get(measureIdx, staffIdx).keysig,
|
111
|
+
rest: false,
|
112
|
+
};
|
113
|
+
this.musicPlayer.generateTone(newNote);
|
114
|
+
});
|
115
|
+
}
|
116
|
+
}
|
117
|
+
//////////////// GETTER/ SETTER ////////////
|
118
|
+
setMusicPlayer(musicPlayer) {
|
119
|
+
this.musicPlayer = musicPlayer;
|
120
|
+
return this;
|
121
|
+
}
|
122
|
+
setCurrentMEI(xmlDoc) {
|
123
|
+
this.currentMEI = xmlDoc;
|
124
|
+
return this;
|
125
|
+
}
|
126
|
+
setM2M(m2m) {
|
127
|
+
this.m2m = m2m;
|
128
|
+
return this;
|
129
|
+
}
|
130
|
+
setDeleteHandler(deleteHandler) {
|
131
|
+
this.deleteHandler = deleteHandler;
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
setEditCallback(editCallback) {
|
135
|
+
this.editCallback = editCallback;
|
136
|
+
return this;
|
137
|
+
}
|
138
|
+
setElementAttrCallback(elementAttrCallback) {
|
139
|
+
this.elementAttrCallback = elementAttrCallback;
|
140
|
+
return this;
|
141
|
+
}
|
142
|
+
setContainerId(id) {
|
143
|
+
this.containerId = id;
|
144
|
+
this.container = document.getElementById(id);
|
145
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
146
|
+
this.rootSVG = cq.getRootSVG(id);
|
147
|
+
return this;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
exports.default = NoteDragHandler;
|
@@ -0,0 +1,168 @@
|
|
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 != undefined) {
|
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 pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay)
|
80
|
+
// var relX = pt.x
|
81
|
+
// var relY = pt.y
|
82
|
+
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");
|
83
|
+
if (definitionScale == undefined || definitionScale == null)
|
84
|
+
return;
|
85
|
+
var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay);
|
86
|
+
var relX = pt.x;
|
87
|
+
var relY = pt.y;
|
88
|
+
var dsCoords = coordinates.getDOMMatrixCoordinates(definitionScale, definitionScale.closest(".page"));
|
89
|
+
//console.log(relX, dsCoords, definitionScale.getBoundingClientRect())
|
90
|
+
if (relX < dsCoords.left || relX > dsCoords.right) {
|
91
|
+
this.isTrackingMouse = false;
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
this.isTrackingMouse = true;
|
95
|
+
var target = e.target;
|
96
|
+
target = target.closest("g");
|
97
|
+
var options = {};
|
98
|
+
if (target === null || target === void 0 ? void 0 : target.classList.contains("staffLine")) {
|
99
|
+
options["staffLineId"] = target.id;
|
100
|
+
}
|
101
|
+
var phantomNoteElement = this.phantom.getNoteElement();
|
102
|
+
if (phantomNoteElement == undefined) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
phantomNoteElement.setAttribute("cx", relX.toString());
|
106
|
+
phantomNoteElement.setAttribute("cy", relY.toString());
|
107
|
+
phantomNoteElement.setAttribute("r", ((_d = (_c = this.m2s) === null || _c === void 0 ? void 0 : _c.getLineDist()) === null || _d === void 0 ? void 0 : _d.toString()) || "0");
|
108
|
+
phantomNoteElement.setAttribute("visibility", phantomNoteElement.getAttribute("visibility") || "visible");
|
109
|
+
this.m2s.defineNote(relX, relY, options);
|
110
|
+
var newCY = (_e = (this.m2s.getNewNoteY())) === null || _e === void 0 ? void 0 : _e.toString();
|
111
|
+
phantomNoteElement.setAttribute("cy", (newCY || "0"));
|
112
|
+
this.removeLines();
|
113
|
+
if (this.m2s.getPhantomLines() != undefined) {
|
114
|
+
this.phantomLines = new Array();
|
115
|
+
this.m2s.getPhantomLines().forEach(pl => {
|
116
|
+
this.phantomLines.push(new PhantomElement_1.default("line", this.containerId, { lineX: relX, lineY: pl }, this.phantomCanvas));
|
117
|
+
});
|
118
|
+
this.setPhantomLineListeners();
|
119
|
+
}
|
120
|
+
// if(e.type === "draggingNote"){
|
121
|
+
// console.log(phantomNoteElement, this.phantomLines)
|
122
|
+
// }
|
123
|
+
}
|
124
|
+
removeLines() {
|
125
|
+
var lines = this.interactionOverlay.querySelectorAll(".phantomLine");
|
126
|
+
this.removePhantomLineListeners();
|
127
|
+
if (lines.length > 0) {
|
128
|
+
lines.forEach(l => {
|
129
|
+
l.remove();
|
130
|
+
});
|
131
|
+
}
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
drawMarkers(e) {
|
135
|
+
this.container.querySelectorAll(".phantomMarker").forEach(pm => pm.remove());
|
136
|
+
var pm = new PhantomElement_1.default("timeMarkers", this.containerId, { lastStaffEnteredId: e.target.getAttribute("refId"),
|
137
|
+
measureMatrix: this.m2s.getMeasureMatrix() });
|
138
|
+
}
|
139
|
+
resetCanvas() {
|
140
|
+
this.setContainerId(this.containerId);
|
141
|
+
this.rootBBox = this.vrvSVG.getBoundingClientRect();
|
142
|
+
this.phantomCanvas = this.interactionOverlay.querySelector("#phantomCanvas");
|
143
|
+
this.removeListeners();
|
144
|
+
this.removePhantomLineListeners();
|
145
|
+
this.phantom = new PhantomElement_1.default("note", this.containerId);
|
146
|
+
this.setListeners();
|
147
|
+
this.setPhantomLineListeners();
|
148
|
+
}
|
149
|
+
setm2s(m2s) {
|
150
|
+
this.m2s = m2s;
|
151
|
+
return this;
|
152
|
+
}
|
153
|
+
setContainerId(id) {
|
154
|
+
this.containerId = id;
|
155
|
+
this.vrvSVG = cq.getVrvSVG(id);
|
156
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
157
|
+
this.container = document.getElementById(id);
|
158
|
+
return this;
|
159
|
+
}
|
160
|
+
setPhantomNote(note = undefined) {
|
161
|
+
this.phantom = note || new PhantomElement_1.default("note", this.containerId);
|
162
|
+
return this;
|
163
|
+
}
|
164
|
+
getIsTrackingMouse() {
|
165
|
+
return this.isTrackingMouse;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
exports.default = PhantomElementHandler;
|
@@ -0,0 +1,135 @@
|
|
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 manipSelector = ".manipulator";
|
9
|
+
const canvasId = "manipulatorCanvas";
|
10
|
+
/**
|
11
|
+
* Handler for all options which could modulate the given score from within the score. These functions are related to all elements seen inside a score
|
12
|
+
*/
|
13
|
+
class ScoreManipulatorHandler {
|
14
|
+
constructor() {
|
15
|
+
this.addMeasure = (function addMeasure(e) {
|
16
|
+
e.target.dispatchEvent(this.manipulateEvent);
|
17
|
+
e.preventDefault();
|
18
|
+
e.stopPropagation();
|
19
|
+
meiOperation.addMeasure(this.currentMEI);
|
20
|
+
this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false);
|
21
|
+
}).bind(this);
|
22
|
+
this.removeMeasure = (function removeMeasure(e) {
|
23
|
+
e.target.dispatchEvent(this.manipulateEvent);
|
24
|
+
e.preventDefault();
|
25
|
+
e.stopPropagation();
|
26
|
+
meiOperation.removeMeasure(this.currentMEI);
|
27
|
+
this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false);
|
28
|
+
}).bind(this);
|
29
|
+
this.addStaff = (function addStaff(e) {
|
30
|
+
var target = e.target.closest(".manipulator");
|
31
|
+
target.dispatchEvent(this.manipulateEvent);
|
32
|
+
e.preventDefault();
|
33
|
+
e.stopPropagation();
|
34
|
+
var relpos = target.classList.contains("below") ? "below" : "above";
|
35
|
+
meiOperation.addStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
|
36
|
+
this.musicPlayer.resetMidiInstruments();
|
37
|
+
this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false);
|
38
|
+
}).bind(this);
|
39
|
+
this.removeStaff = (function removeStaff(e) {
|
40
|
+
var target = e.target.closest(".manipulator");
|
41
|
+
target.dispatchEvent(this.manipulateEvent);
|
42
|
+
e.preventDefault();
|
43
|
+
e.stopPropagation();
|
44
|
+
var relpos = target.classList.contains("below") ? "below" : "above";
|
45
|
+
meiOperation.removeStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
|
46
|
+
this.musicPlayer.resetMidiInstruments();
|
47
|
+
this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false);
|
48
|
+
e.target.dispatchEvent(this.manipulateEvent);
|
49
|
+
}).bind(this);
|
50
|
+
this.removeFunction = (function removeElementsFunction() {
|
51
|
+
this.removeElements();
|
52
|
+
}).bind(this);
|
53
|
+
this.sm = new ScoreManipulator_1.default();
|
54
|
+
this.manipulateEvent = new Event("manipulated");
|
55
|
+
}
|
56
|
+
addCanvas() {
|
57
|
+
var _a;
|
58
|
+
var rootBBox = cq.getVrvSVG(this.containerId).firstElementChild.getBoundingClientRect();
|
59
|
+
var rootWidth = rootBBox.width.toString();
|
60
|
+
var rootHeigth = rootBBox.height.toString();
|
61
|
+
this.manipulatorCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
62
|
+
this.manipulatorCanvas.setAttribute("id", canvasId);
|
63
|
+
this.manipulatorCanvas.classList.add("canvas");
|
64
|
+
this.manipulatorCanvas.setAttribute("preserveAspectRatio", "xMinYMin meet");
|
65
|
+
this.manipulatorCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "));
|
66
|
+
(_a = this.interactionOverlay.querySelector("#" + canvasId)) === null || _a === void 0 ? void 0 : _a.remove();
|
67
|
+
this.manipulatorCanvas.insertAdjacentElement("beforebegin", this.interactionOverlay.querySelector("#scoreRects"));
|
68
|
+
this.interactionOverlay.append(this.manipulatorCanvas);
|
69
|
+
}
|
70
|
+
drawElements() {
|
71
|
+
this.addCanvas();
|
72
|
+
this.sm.drawMeasureAdder();
|
73
|
+
this.sm.drawMeasureRemover();
|
74
|
+
this.sm.drawStaffManipulators();
|
75
|
+
this.setListeners();
|
76
|
+
}
|
77
|
+
removeElements() {
|
78
|
+
//this.removeListeners()
|
79
|
+
this.interactionOverlay.querySelectorAll(manipSelector).forEach(m => {
|
80
|
+
m.remove();
|
81
|
+
});
|
82
|
+
}
|
83
|
+
setListeners() {
|
84
|
+
var that = this;
|
85
|
+
this.removeListeners();
|
86
|
+
this.interactionOverlay.querySelector("#measureAdder").addEventListener("click", this.addMeasure, true);
|
87
|
+
this.interactionOverlay.querySelector("#measureRemover").addEventListener("click", this.removeMeasure, true);
|
88
|
+
this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
|
89
|
+
as.addEventListener("click", that.addStaff, true);
|
90
|
+
});
|
91
|
+
this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
|
92
|
+
as.addEventListener("click", that.removeStaff, true);
|
93
|
+
});
|
94
|
+
}
|
95
|
+
removeListeners() {
|
96
|
+
var _a, _b;
|
97
|
+
var that = this;
|
98
|
+
(_a = this.interactionOverlay.querySelector("#measureAdder")) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this.addMeasure);
|
99
|
+
(_b = this.interactionOverlay.querySelector("#measureRemover")) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this.removeMeasure);
|
100
|
+
this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
|
101
|
+
as.removeEventListener("click", that.addStaff);
|
102
|
+
});
|
103
|
+
this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
|
104
|
+
as.removeEventListener("click", that.removeStaff);
|
105
|
+
});
|
106
|
+
}
|
107
|
+
// drawFunction = (function drawFunction(e: TransitionEvent) {
|
108
|
+
// var that = this
|
109
|
+
// setTimeout(function () {
|
110
|
+
// that.drawElements()
|
111
|
+
// }, 500)
|
112
|
+
// //this.drawElements()
|
113
|
+
// }).bind(this)
|
114
|
+
//SETTER////
|
115
|
+
setMEI(mei) {
|
116
|
+
this.currentMEI = mei;
|
117
|
+
this.sm.setMEI(mei);
|
118
|
+
return this;
|
119
|
+
}
|
120
|
+
setMusicProcessor(mp) {
|
121
|
+
this.musicPlayer = mp;
|
122
|
+
return this;
|
123
|
+
}
|
124
|
+
setLoadDataCallback(loadDataCallback) {
|
125
|
+
this.loadDataCallback = loadDataCallback;
|
126
|
+
return this;
|
127
|
+
}
|
128
|
+
setContainerId(containerId) {
|
129
|
+
this.containerId = containerId;
|
130
|
+
this.interactionOverlay = cq.getInteractOverlay(containerId);
|
131
|
+
this.sm.setContainerId(this.containerId);
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
exports.default = ScoreManipulatorHandler;
|
@@ -0,0 +1,218 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
const mappings_1 = require("../utils/mappings");
|
5
|
+
const coordinates = require("../utils/coordinates");
|
6
|
+
const cq = require("../utils/convenienceQueries");
|
7
|
+
const marked = "marked";
|
8
|
+
class SelectionHandler {
|
9
|
+
constructor(containerId) {
|
10
|
+
/**
|
11
|
+
* Mark clicked element
|
12
|
+
*/
|
13
|
+
this.markedHandler = (function markedHandler(e) {
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
15
|
+
if (!this.shiftPressed) {
|
16
|
+
Array.from(this.container.querySelectorAll("." + marked)).forEach(n => {
|
17
|
+
n.classList.remove(marked);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
e.preventDefault();
|
21
|
+
var target = e.target;
|
22
|
+
if (target.getAttribute("refId") === null) {
|
23
|
+
target = target.closest("[refId]");
|
24
|
+
target = this.vrvSVG.querySelector("#" + target.getAttribute("refId"));
|
25
|
+
}
|
26
|
+
target = target.closest(".note, .rest, .mRest, .chord") || target;
|
27
|
+
target.classList.add(marked);
|
28
|
+
this.scoreGraph.setCurrentNodeById(target.id);
|
29
|
+
// change the selected durations in the toolbar
|
30
|
+
var firstMarkedNote = (_a = this.vrvSVG.querySelector(".chord.marked, .note.marked, .rest.marked")) === null || _a === void 0 ? void 0 : _a.id;
|
31
|
+
var meiNote = this.m2s.getCurrentMei().getElementById(firstMarkedNote);
|
32
|
+
if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
|
33
|
+
meiNote = meiNote.closest("chord");
|
34
|
+
}
|
35
|
+
if ((firstMarkedNote === null || firstMarkedNote === void 0 ? void 0 : firstMarkedNote.length) > 0) {
|
36
|
+
(_b = document.getElementById(this.containerId)) === null || _b === void 0 ? void 0 : _b.querySelectorAll("#noteGroup *, #dotGroup *, #modGroup *, #articGroup *").forEach(b => b.classList.remove("selected"));
|
37
|
+
(_d = (_c = document.getElementById(this.containerId)) === null || _c === void 0 ? void 0 : _c.querySelectorAll(".lastAdded")) === null || _d === void 0 ? void 0 : _d.forEach(la => la.classList.remove("lastAdded"));
|
38
|
+
//select buttons for given note state
|
39
|
+
var modBtnId = cq.getContainer(this.containerId).querySelector("#customToolbar #articGroup") !== null ? "artic" : "accid";
|
40
|
+
(_f = (_e = document.getElementById(this.containerId)) === null || _e === void 0 ? void 0 : _e.querySelector("#" + mappings_1.attrToModButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute(modBtnId)))) === null || _f === void 0 ? void 0 : _f.classList.add("selected");
|
41
|
+
if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
|
42
|
+
meiNote = meiNote.closest("chord");
|
43
|
+
}
|
44
|
+
(_h = (_g = document.getElementById(this.containerId)) === null || _g === void 0 ? void 0 : _g.querySelector("#" + mappings_1.numToNoteButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dur")))) === null || _h === void 0 ? void 0 : _h.classList.add("selected");
|
45
|
+
(_k = (_j = document.getElementById(this.containerId)) === null || _j === void 0 ? void 0 : _j.querySelector("#" + mappings_1.numToDotButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dots")))) === null || _k === void 0 ? void 0 : _k.classList.add("selected");
|
46
|
+
}
|
47
|
+
}).bind(this);
|
48
|
+
this.shiftKeyHandler = (function shiftKeyHandler(e) {
|
49
|
+
if (e.key === "Shift") {
|
50
|
+
if (e.type === "keydown") {
|
51
|
+
this.shiftPressed = true;
|
52
|
+
}
|
53
|
+
else if (e.type === "keyup") {
|
54
|
+
this.shiftPressed = false;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
console.log("shiftPressed ", this.shiftPressed);
|
58
|
+
}).bind(this);
|
59
|
+
this.setContainerId(containerId);
|
60
|
+
this.selectStartEvent = new Event("selectStart");
|
61
|
+
this.selectEndEvent = new Event("selectEnd");
|
62
|
+
this.shiftPressed = false;
|
63
|
+
this.setKeyListeners();
|
64
|
+
this.canvas = d3.select("#" + this.containerId + " #interactionOverlay"); // draw directly in svg
|
65
|
+
var dragSelectAction = d3.drag()
|
66
|
+
.on('start', selStart)
|
67
|
+
.on('drag', selecting)
|
68
|
+
.on('end', selEnd);
|
69
|
+
var that = this;
|
70
|
+
function selStart() {
|
71
|
+
if (document.getElementById(that.containerId).classList.contains("annotMode"))
|
72
|
+
return; // prevent selecting when resizing annotation objects
|
73
|
+
var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId));
|
74
|
+
that.initialX = pt.x; //d3.event.x
|
75
|
+
that.initialY = pt.y; //d3.event.y
|
76
|
+
if (!document.getElementById(that.containerId).classList.contains("harmonyMode") && !that.shiftPressed) { //!that.harmonyHandler.getGlobal()){
|
77
|
+
that.m2s.getNoteBBoxes().forEach(bb => {
|
78
|
+
let note = that.vrvSVG.querySelector("#" + bb.id);
|
79
|
+
note.classList.remove(marked);
|
80
|
+
});
|
81
|
+
}
|
82
|
+
that.initRect(that.initialX, that.initialY);
|
83
|
+
}
|
84
|
+
function selecting() {
|
85
|
+
if (document.getElementById(that.containerId).classList.contains("annotMode"))
|
86
|
+
return; // prevent selecting when resizing annotation objects
|
87
|
+
var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId));
|
88
|
+
const curX = pt.x; //d3.event.x + container.scrollLeft
|
89
|
+
const curY = pt.y; //d3.event.y + container.scrollTop
|
90
|
+
const newX = curX < that.initialX ? curX : that.initialX;
|
91
|
+
const newY = curY < that.initialY ? curY : that.initialY;
|
92
|
+
const width = curX < that.initialX ? that.initialX - curX : curX - that.initialX;
|
93
|
+
const height = curY < that.initialY ? that.initialY - curY : curY - that.initialY;
|
94
|
+
that.updateRect(newX, newY, width, height);
|
95
|
+
var rect = that.interactionOverlay.querySelector("#selectRect");
|
96
|
+
var rectpt = coordinates.getDOMMatrixCoordinates(rect, that.vrvSVG);
|
97
|
+
var rectHeightpt = rectpt.height; //Math.abs(rectpt.y - ptBottom.matrixTransform(rootMatrix.getScreenCTM().inverse()).y)
|
98
|
+
var rectWidthpt = rectpt.width; //Math.abs(rectpt.x - ptRight.matrixTransform(rootMatrix.getScreenCTM().inverse()).x)
|
99
|
+
var rx = rectpt.x;
|
100
|
+
var ry = rectpt.y;
|
101
|
+
var noteBBoxes = that.m2s.getNoteBBoxes();
|
102
|
+
noteBBoxes.forEach(bb => {
|
103
|
+
var note = cq.getVrvSVG(that.containerId).querySelector("#" + bb.id);
|
104
|
+
let stem = note.querySelector(".stem");
|
105
|
+
let accid = note.querySelector(".accid");
|
106
|
+
if (bb.x >= rx &&
|
107
|
+
//bb.x <= rx + rectBBox.width &&
|
108
|
+
bb.x <= rx + rectWidthpt &&
|
109
|
+
bb.y >= ry &&
|
110
|
+
//bb.y <= ry + rectBBox.height
|
111
|
+
bb.y <= ry + rectHeightpt) {
|
112
|
+
note.classList.add(marked);
|
113
|
+
if (stem !== null)
|
114
|
+
stem.classList.add(marked);
|
115
|
+
var chord = note.closest(".chord");
|
116
|
+
if (chord !== null) {
|
117
|
+
//if(!chord.classList.contains(marked))
|
118
|
+
let noteArr = Array.from(chord.querySelectorAll(".note"));
|
119
|
+
if (noteArr.every(c => c.classList.contains(marked)) && noteArr.length > 0) {
|
120
|
+
chord.classList.add(marked);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
else if (!that.shiftPressed) {
|
125
|
+
note.classList.remove(marked);
|
126
|
+
stem === null || stem === void 0 ? void 0 : stem.classList.remove(marked);
|
127
|
+
accid === null || accid === void 0 ? void 0 : accid.classList.remove(marked);
|
128
|
+
var chord = note.closest(".chord");
|
129
|
+
chord === null || chord === void 0 ? void 0 : chord.classList.remove(marked);
|
130
|
+
}
|
131
|
+
});
|
132
|
+
}
|
133
|
+
function selEnd() {
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
135
|
+
if (document.getElementById(that.containerId).classList.contains("annotMode"))
|
136
|
+
return; // prevent selecting when resizing annotation objects
|
137
|
+
var selectRect = that.interactionOverlay.querySelector("#selectRect");
|
138
|
+
if (selectRect !== null && (selectRect === null || selectRect === void 0 ? void 0 : selectRect.getAttribute("width")) !== "0" && (selectRect === null || selectRect === void 0 ? void 0 : selectRect.getAttribute("height")) !== "0") {
|
139
|
+
document.dispatchEvent(that.selectEndEvent);
|
140
|
+
}
|
141
|
+
selectRect === null || selectRect === void 0 ? void 0 : selectRect.remove();
|
142
|
+
var firstMarkedNote = (_a = that.vrvSVG.querySelector(".chord.marked, .note.marked, .rest.marked")) === null || _a === void 0 ? void 0 : _a.id;
|
143
|
+
var meiNote = that.m2s.getCurrentMei().getElementById(firstMarkedNote);
|
144
|
+
(_c = (_b = document.getElementById(that.containerId)) === null || _b === void 0 ? void 0 : _b.querySelectorAll(".lastAdded")) === null || _c === void 0 ? void 0 : _c.forEach(la => la.classList.remove("lastAdded"));
|
145
|
+
if ((firstMarkedNote === null || firstMarkedNote === void 0 ? void 0 : firstMarkedNote.length) > 0) {
|
146
|
+
(_d = document.getElementById(that.containerId)) === null || _d === void 0 ? void 0 : _d.querySelectorAll("#noteGroup *, #dotGroup *, #modGroup *, #articGroup *").forEach(b => b.classList.remove("selected"));
|
147
|
+
//select buttons for given note state
|
148
|
+
var modBtnId = that.container.querySelector("#customToolbar #articGroup") !== null ? "artic" : "accid";
|
149
|
+
(_f = (_e = document.getElementById(that.containerId)) === null || _e === void 0 ? void 0 : _e.querySelector("#" + mappings_1.attrToModButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute(modBtnId)))) === null || _f === void 0 ? void 0 : _f.classList.add("selected");
|
150
|
+
if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
|
151
|
+
meiNote = meiNote.closest("chord");
|
152
|
+
}
|
153
|
+
(_h = (_g = document.getElementById(that.containerId)) === null || _g === void 0 ? void 0 : _g.querySelector("#" + mappings_1.numToNoteButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dur")))) === null || _h === void 0 ? void 0 : _h.classList.add("selected");
|
154
|
+
(_k = (_j = document.getElementById(that.containerId)) === null || _j === void 0 ? void 0 : _j.querySelector("#" + mappings_1.numToDotButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dots")))) === null || _k === void 0 ? void 0 : _k.classList.add("selected");
|
155
|
+
}
|
156
|
+
}
|
157
|
+
this.dsa = dragSelectAction;
|
158
|
+
this.setListeners();
|
159
|
+
//this.canvas.call(dragSelectAction);
|
160
|
+
}
|
161
|
+
initRect(ulx, uly) {
|
162
|
+
this.canvas.append('rect')
|
163
|
+
.attr('x', ulx)
|
164
|
+
.attr('y', uly)
|
165
|
+
.attr('width', 0)
|
166
|
+
.attr('height', 0)
|
167
|
+
.attr('id', 'selectRect')
|
168
|
+
.attr('stroke', 'black')
|
169
|
+
.attr('stroke-width', "1px")
|
170
|
+
.attr('fill', 'none');
|
171
|
+
}
|
172
|
+
updateRect(newX, newY, currentWidth, currentHeight) {
|
173
|
+
d3.select('#selectRect')
|
174
|
+
.attr('x', newX)
|
175
|
+
.attr('y', newY)
|
176
|
+
.attr('width', currentWidth)
|
177
|
+
.attr('height', currentHeight);
|
178
|
+
}
|
179
|
+
removeListeners() {
|
180
|
+
d3.select("#" + this.containerId + " #interactionOverlay").on('mousedown.drag', null);
|
181
|
+
this.interactionOverlay.querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
|
182
|
+
el.removeEventListener("click", this.markedHandler);
|
183
|
+
});
|
184
|
+
this.interactionOverlay.removeEventListener("keydown", this.shiftKeyHandler);
|
185
|
+
this.interactionOverlay.removeEventListener("keyup", this.shiftKeyHandler);
|
186
|
+
}
|
187
|
+
setListeners() {
|
188
|
+
this.canvas.call(this.dsa);
|
189
|
+
cq.getInteractOverlay(this.containerId).querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
|
190
|
+
el.addEventListener("click", this.markedHandler);
|
191
|
+
});
|
192
|
+
}
|
193
|
+
setKeyListeners() {
|
194
|
+
this.interactionOverlay.addEventListener("keydown", this.shiftKeyHandler);
|
195
|
+
this.interactionOverlay.addEventListener("keyup", this.shiftKeyHandler);
|
196
|
+
}
|
197
|
+
resetListeners() {
|
198
|
+
this.removeListeners();
|
199
|
+
this.setListeners();
|
200
|
+
}
|
201
|
+
///////// GETTER/ SETTER ////////
|
202
|
+
setm2s(m2s) {
|
203
|
+
this.m2s = m2s;
|
204
|
+
return this;
|
205
|
+
}
|
206
|
+
setScoreGraph(sg) {
|
207
|
+
this.scoreGraph = sg;
|
208
|
+
return this;
|
209
|
+
}
|
210
|
+
setContainerId(id) {
|
211
|
+
this.containerId = id;
|
212
|
+
this.container = document.getElementById(id);
|
213
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
214
|
+
this.vrvSVG = cq.getVrvSVG(id);
|
215
|
+
return this;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
exports.default = SelectionHandler;
|