Merge pull request #73 from zero01101/testing

Fix layer hide/delete/undo
This commit is contained in:
Victor Seiji Hariki 2022-12-06 22:52:04 -03:00 committed by GitHub
commit 77ea8d7554
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ const uil = {
layers: [], layers: [],
_active: null, _active: null,
set active(v) { set active(v) {
console.debug(v);
Array.from(this._ui_layer_list.children).forEach((child) => { Array.from(this._ui_layer_list.children).forEach((child) => {
child.classList.remove("active"); child.classList.remove("active");
}); });
@ -104,6 +105,7 @@ const uil = {
deleteButton.addEventListener( deleteButton.addEventListener(
"click", "click",
(evn) => { (evn) => {
evn.stopPropagation();
commands.runCommand("deleteLayer", "Deleted Layer", { commands.runCommand("deleteLayer", "Deleted Layer", {
layer: uiLayer, layer: uiLayer,
}); });
@ -131,9 +133,6 @@ const uil = {
(evn) => { (evn) => {
evn.stopPropagation(); evn.stopPropagation();
uiLayer.hidden = !uiLayer.hidden; uiLayer.hidden = !uiLayer.hidden;
if (uiLayer.hidden) {
uiLayer.entry.classList.add("hidden");
} else uiLayer.entry.classList.remove("hidden");
}, },
{passive: false} {passive: false}
); );
@ -204,9 +203,11 @@ const uil = {
if (v) { if (v) {
this._hidden = true; this._hidden = true;
this.layer.hide(v); this.layer.hide(v);
this.entry && this.entry.classList.add("hidden");
} else { } else {
this._hidden = false; this._hidden = false;
this.layer.unhide(v); this.layer.unhide(v);
this.entry && this.entry.classList.remove("hidden");
} }
}, },
get hidden() { get hidden() {
@ -351,9 +352,11 @@ commands.createCommand(
if (v) { if (v) {
this._hidden = true; this._hidden = true;
this.layer.hide(v); this.layer.hide(v);
this.entry && this.entry.classList.add("hidden");
} else { } else {
this._hidden = false; this._hidden = false;
this.layer.unhide(v); this.layer.unhide(v);
this.entry && this.entry.classList.remove("hidden");
} }
}, },
get hidden() { get hidden() {
@ -448,12 +451,14 @@ commands.createCommand(
state.position = index; state.position = index;
} }
if (uil.active === state.layer)
uil.active =
uil.layers[state.position - 1] || uil.layers[state.position + 1];
uil.layers.splice(state.position, 1); uil.layers.splice(state.position, 1);
uil.active = uil.layers[state.position - 1] || uil.layers[state.position];
uil._syncLayers(); uil._syncLayers();
state.layer.layer.hide(); state.layer.hidden = true;
}, },
(title, state) => { (title, state) => {
uil.layers.splice(state.position, 0, state.layer); uil.layers.splice(state.position, 0, state.layer);
@ -461,7 +466,7 @@ commands.createCommand(
uil._syncLayers(); uil._syncLayers();
state.layer.layer.unhide(); state.layer.hidden = false;
} }
); );