Added layer focus when it's hovered in the menu

This commit is contained in:
unsettledgames 2020-09-18 10:18:27 +02:00
parent 8d033778a5
commit b6d4544cd8

View File

@ -57,6 +57,8 @@ class Layer {
if (menuEntry != null) { if (menuEntry != null) {
this.name = menuEntry.getElementsByTagName("p")[0].innerHTML; this.name = menuEntry.getElementsByTagName("p")[0].innerHTML;
menuEntry.id = "layer" + id; menuEntry.id = "layer" + id;
menuEntry.onmouseover = () => this.hover();
menuEntry.onmouseout = () => this.unhover();
menuEntry.onclick = () => this.selectLayer(); menuEntry.onclick = () => this.selectLayer();
menuEntry.getElementsByTagName("button")[0].onclick = () => this.toggleLock(); menuEntry.getElementsByTagName("button")[0].onclick = () => this.toggleLock();
menuEntry.getElementsByTagName("button")[1].onclick = () => this.toggleVisibility(); menuEntry.getElementsByTagName("button")[1].onclick = () => this.toggleVisibility();
@ -100,6 +102,24 @@ class Layer {
this.context.mozImageSmoothingEnabled = false; this.context.mozImageSmoothingEnabled = false;
} }
hover() {
// Hide all the layers but the current one
for (let i=1; i<layers.length - 2; i++) {
if (layers[i] !== this) {
layers[i].canvas.style.opacity = 0.3;
}
}
}
unhover() {
// Show all the layers again
for (let i=1; i<layers.length - 2; i++) {
if (layers[i] !== this) {
layers[i].canvas.style.opacity = 1;
}
}
}
setID(id) { setID(id) {
this.id = id; this.id = id;
if (this.menuEntry != null) { if (this.menuEntry != null) {