This commit is contained in:
Nicola
2021-12-11 10:48:14 +01:00
parent dfa9810a75
commit a238fb1b47
7 changed files with 117 additions and 65 deletions

View File

@@ -50,6 +50,7 @@ class Layer {
if (this.menuEntry !== undefined) {
this.name = this.menuEntry.getElementsByTagName("p")[0].innerHTML;
this.menuEntry.id = "layer" + id;
this.menuEntry.onmouseover = () => this.hover();
this.menuEntry.onmouseout = () => this.unhover();
this.menuEntry.onclick = () => this.selectLayer();
@@ -63,6 +64,8 @@ class Layer {
this.menuEntry.addEventListener("dragleave", this.layerDragLeave, false);
this.menuEntry.addEventListener("dragend", this.layerDragEnd, false);
Events.onCustom("del", this.tryDelete.bind(this));
this.menuEntry.getElementsByTagName("canvas")[0].getContext('2d').imageSmoothingEnabled = false;
}
@@ -73,6 +76,12 @@ class Layer {
return this.menuEntry != null;
}
tryDelete() {
if (Input.getLastTarget() != this.menuEntry && Input.getLastTarget().parentElement != this.menuEntry)
return;
LayerList.deleteLayer();
}
// Initializes the canvas
initialize() {
//resize canvas