From dbfd4d84120731b5cfa1c95109ea9990799cac2c Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 9 Apr 2024 02:30:50 +0300 Subject: [PATCH] When merging layers, automatically make the bottom layer visible If the bottom layer is invisible, it becomes visible now. Consistent with behavior seen in Krita and Photopea. --- src/Classes/Layers/BaseLayer.gd | 6 +++++- src/UI/Timeline/AnimationTimeline.gd | 2 +- src/UI/Timeline/LayerButton.gd | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Classes/Layers/BaseLayer.gd b/src/Classes/Layers/BaseLayer.gd index b5431e58f..aa5898d07 100644 --- a/src/Classes/Layers/BaseLayer.gd +++ b/src/Classes/Layers/BaseLayer.gd @@ -3,6 +3,7 @@ extends RefCounted ## Base class for layer properties. Different layer types extend from this class. signal name_changed ## Emits when [member name] is changed. +signal visibility_changed ## Emits when [member visible] is changed. ## All currently supported layer blend modes between two layers. The upper layer ## is the blend layer, and the bottom layer is the base layer. @@ -37,7 +38,10 @@ var name := "": ## Name of the layer. var project: Project ## The project the layer belongs to. var index: int ## Index of layer in the timeline. var parent: BaseLayer ## Parent of the layer. -var visible := true ## Sets visibility of the layer. +var visible := true: ## Sets visibility of the layer. + set(value): + visible = value + visibility_changed.emit() var locked := false ## Images of a locked layer won't be overritten. var new_cels_linked := false ## Determines if new cel of the layer should be linked or not. var blend_mode := BlendModes.NORMAL ## Blend mode of the current layer. diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index ccc2466be..8c95c474a 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -948,7 +948,6 @@ func _on_MergeDownLayer_pressed() -> void: project.undos += 1 project.undo_redo.create_action("Merge Layer") - for frame in project.frames: var top_cel := frame.cels[top_layer.index] top_cels.append(top_cel) # Store for undo purposes @@ -1000,6 +999,7 @@ func _on_MergeDownLayer_pressed() -> void: project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true)) project.undo_redo.add_do_method(Global.undo_or_redo.bind(false)) project.undo_redo.commit_action() + bottom_layer.visible = true func _on_OpacitySlider_value_changed(value: float) -> void: diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index 3fd616860..2d7344803 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -34,6 +34,7 @@ func _ready() -> void: Global.cel_switched.connect(func(): z_index = 1 if button_pressed else 0) var layer := Global.current_project.layers[layer_index] layer.name_changed.connect(func(): label.text = layer.name) + layer.visibility_changed.connect(update_buttons) if layer is PixelLayer: linked_button.visible = true elif layer is GroupLayer: