Layer ordering fixes

This commit is contained in:
luboslenco
2021-01-31 17:02:00 +01:00
parent b1ad1c6a4f
commit 78d2de076f
2 changed files with 25 additions and 10 deletions
+13 -4
View File
@@ -467,7 +467,7 @@ class LayerSlot {
public function move(to: Int) {
var i = Project.layers.indexOf(this);
var delta = to - i;
if (i + delta < 0 || i + delta > Project.layers.length - 1) return;
if (i + delta < 0 || i + delta > Project.layers.length - 1 || delta == 0) return;
var pointers = TabLayers.initLayerMap();
var isGroup = this.getChildren() != null;
@@ -479,10 +479,14 @@ class LayerSlot {
var kLayer = k < Project.layers.length ? Project.layers[k] : null;
// Prevent group nesting for now
if (isGroup && jParent != null) {
if (isGroup && jParent != null && jParent.show_panel) {
return;
}
if (kGroup && !kLayer.show_panel) {
delta -= Project.layers[k].getChildren().length;
}
Context.setLayer(this);
History.orderLayers(i + delta);
UISidebar.inst.hwnd0.redraws = 2;
@@ -500,7 +504,7 @@ class LayerSlot {
}
else {
// Moved to group
if (this.parent == null && jParent != null) {
if (this.parent == null && jParent != null && jParent.show_panel) {
this.parent = jParent;
}
// Moved out of group
@@ -513,8 +517,13 @@ class LayerSlot {
}
}
// Moved to different group
if (this.parent != null && (kParent != null || kGroup)) {
if (this.parent != null && ((kParent != null && kParent.show_panel) || kGroup)) {
var parent = this.parent;
this.parent = kGroup ? kLayer : kParent;
// Remove empty group
if (parent.getChildren() == null) {
parent.delete();
}
}
}
+12 -6
View File
@@ -110,13 +110,19 @@ class TabLayers {
var my = mouse.y;
var inLayers = mx > UISidebar.inst.tabx && my < Config.raw.layout[LayoutSidebarH0];
if (App.isDragging && App.dragLayer != null && inLayers) {
if (my > ui._y - step && my < ui._y + step) {
ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
Context.dragDestination = Project.layers.indexOf(App.dragLayer) < i ? i : i + 1;
if (my > ui._y + step && my < ui._y + step * 3) {
var down = Project.layers.indexOf(App.dragLayer) >= i;
Context.dragDestination = down ? i : i - 1;
var ls = Project.layers;
var dest = Context.dragDestination;
var toGroup = down ? dest > 0 && ls[dest - 1].parent != null && ls[dest - 1].parent.show_panel : dest < ls.length && ls[dest].parent != null && ls[dest].parent.show_panel;
var nestedGroup = App.dragLayer.getChildren() != null && toGroup;
if (!nestedGroup) ui.fill(checkw, step * 2, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
}
else if (i == 0 && my > ui._y + step) {
ui.fill(checkw, step * 2, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
Context.dragDestination = 0;
else if (i == Project.layers.length - 1 && my < ui._y + step) {
Context.dragDestination = Project.layers.length - 1;
ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL);
}
}