#61 - layers fixes

This commit is contained in:
Vilius 2017-08-14 23:16:11 +03:00
parent d44a996c39
commit f3d7d61e95
2 changed files with 8 additions and 6 deletions

View File

@ -90,7 +90,7 @@ function EDIT_CLASS() {
}
return false;
}
LAYER.layer_max_index++;
tmp = new Array();
var new_name = LAYER.generate_layer_name();
LAYER.create_canvas(new_name);
@ -150,6 +150,7 @@ function EDIT_CLASS() {
return false;
}
EDIT.edit_clear();
LAYER.remove_all_layers();
if (WIDTH != layers_archive[j].width || HEIGHT != layers_archive[j].height) {

View File

@ -23,7 +23,7 @@ function LAYER_CLASS() {
/**
* latest layer index
*/
var layer_max_index = 0;
this.layer_max_index = 0;
//new layer
this.layer_new = function () {
@ -56,7 +56,7 @@ function LAYER_CLASS() {
for (var i = LAYER.layers.length-1; i >= 0; i--) {
LAYER.layer_remove(i, true);
}
layer_max_index = 0;
this.layer_max_index = 0;
this.layer_renew();
};
@ -65,12 +65,12 @@ function LAYER_CLASS() {
if(prefix == undefined)
prefix = 'Layer';
return prefix + ' #' + (layer_max_index);
return prefix + ' #' + (this.layer_max_index);
};
//create layer
this.layer_add = function (name, data, layer_type, layer_extra_info) {
layer_max_index++;
this.layer_max_index++;
if(layer_type == undefined)
layer_type = 'default';
@ -182,6 +182,7 @@ function LAYER_CLASS() {
if (this.layers.length == 1 && force == undefined){
//only 1 layer left
canvas_active().clearRect(0, 0, WIDTH, HEIGHT);
GUI.redraw_preview();
return false;
}
element = document.getElementById(this.layers[i].name);
@ -208,7 +209,7 @@ function LAYER_CLASS() {
LAYER.layer_renew();
}
else {
layer_max_index++;
this.layer_max_index++;
//copy all layer
tmp_data = document.createElement("canvas");
tmp_data.width = WIDTH;