mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Implemented Remove Layer - Doesn't work properly yet
This commit is contained in:
parent
bb6e2cbf16
commit
2bfae68755
3 changed files with 24 additions and 6 deletions
|
@ -182,15 +182,23 @@ func add_layer(is_new := true) -> void:
|
|||
Global.undo_redo.commit_action()
|
||||
|
||||
func _on_RemoveLayer_pressed() -> void:
|
||||
var new_layers : Array = Global.canvas.layers.duplicate()
|
||||
new_layers.remove(Global.canvas.current_layer_index)
|
||||
var new_layers : Array = Global.layers.duplicate()
|
||||
new_layers.remove(Global.current_layer)
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Remove Layer")
|
||||
Global.undo_redo.add_do_property(Global.canvas, "layers", new_layers)
|
||||
Global.undo_redo.add_undo_property(Global.canvas, "layers", Global.canvas.layers)
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas], Global.current_layer)
|
||||
Global.undo_redo.add_do_property(Global, "current_layer", Global.current_layer - 1)
|
||||
Global.undo_redo.add_do_property(Global, "layers", new_layers)
|
||||
|
||||
for c in Global.canvases:
|
||||
var new_canvas_layers : Array = c.layers.duplicate()
|
||||
new_canvas_layers.remove(Global.current_layer)
|
||||
Global.undo_redo.add_do_property(c, "layers", new_canvas_layers)
|
||||
Global.undo_redo.add_undo_property(c, "layers", c.layers)
|
||||
|
||||
Global.undo_redo.add_undo_property(Global, "current_layer", Global.current_layer)
|
||||
Global.undo_redo.add_undo_property(Global, "layers", Global.canvas.layers)
|
||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
||||
Global.undo_redo.commit_action()
|
||||
|
||||
func change_layer_order(rate : int) -> void:
|
||||
|
|
|
@ -30,7 +30,7 @@ func _on_FrameButton_pressed() -> void:
|
|||
|
||||
func _on_PopupMenu_id_pressed(ID : int) -> void:
|
||||
match ID:
|
||||
0: #Remove Frame
|
||||
0: # Remove Frame
|
||||
remove_frame()
|
||||
|
||||
1: # Clone Layer
|
||||
|
|
|
@ -474,6 +474,16 @@ func redo(_canvases : Array, layer_index : int = -1) -> void:
|
|||
|
||||
layers[current_layer][2].add_child(frame_button)
|
||||
|
||||
remove_layer_button.disabled = false
|
||||
remove_layer_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
|
||||
if action_name == "Remove Layer":
|
||||
var layer_container_child_index = (layers_container.get_child_count() - 1) - layer_index
|
||||
layers_container.remove_child(layers_container.get_child(layer_container_child_index))
|
||||
frames_container.remove_child(layers[layer_index][2])
|
||||
if layers.size() == 2: # Actually 1, but it hasn't been updated yet
|
||||
remove_layer_button.disabled = true
|
||||
remove_layer_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
||||
|
||||
# if action_name == "Change Layer Order":
|
||||
# var current_layer_index : int = _canvases[0].current_layer_index
|
||||
|
|
Loading…
Add table
Reference in a new issue