From 71200309f206e01eb5d494392e2be20c3669b471 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 23 Jan 2025 00:04:17 +0200 Subject: [PATCH] Add an icon in the layer buttons for layers that contain effects --- .../graphics/layers/layer_active_effect.png | Bin 0 -> 124 bytes .../layers/layer_active_effect.png.import | 34 ++++++++++++++++++ src/Classes/Layers/BaseLayer.gd | 5 +++ src/UI/Timeline/LayerButton.gd | 5 +++ src/UI/Timeline/LayerButton.tscn | 11 +++++- .../LayerEffects/LayerEffectsSettings.gd | 4 +++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 assets/graphics/layers/layer_active_effect.png create mode 100644 assets/graphics/layers/layer_active_effect.png.import diff --git a/assets/graphics/layers/layer_active_effect.png b/assets/graphics/layers/layer_active_effect.png new file mode 100644 index 0000000000000000000000000000000000000000..666fef3c769ab6e51995b162449342ce94407a85 GIT binary patch literal 124 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{VjKx9jP7LeL$-D$|%sgEjLnNk7 z?Q`T}FyJ`+=HLJ4Z&W-Y4?Yd*3|V8uaA)q8ieF;$vQ4BXv0V6Bn)&~-NM>K_Gp6U~ W?a%1m Image: return image +func emit_effects_added_removed() -> void: + effects_added_removed.emit() + + # Methods to Override: diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index b76699efa..7afdf65ad 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -33,6 +33,7 @@ var audio_player: AudioStreamPlayer @onready var label := %LayerNameLabel as Label @onready var line_edit := %LayerNameLineEdit as LineEdit @onready var hierarchy_spacer := %HierarchySpacer as Control +@onready var layer_fx_texture_rect := %LayerFXTextureRect as TextureRect @onready var layer_type_texture_rect := %LayerTypeTextureRect as TextureRect @onready var linked_button := %LinkButton as BaseButton @onready var clipping_mask_icon := %ClippingMask as TextureRect @@ -61,7 +62,11 @@ func _ready() -> void: custom_minimum_size.y = Global.animation_timeline.cel_size label.text = layer.name line_edit.text = layer.name + layer_fx_texture_rect.visible = layer.effects.size() > 0 layer_type_texture_rect.texture = ARRAY_TEXTURE_TYPES[layer.get_layer_type()] + layer.effects_added_removed.connect( + func(): layer_fx_texture_rect.visible = layer.effects.size() > 0 + ) for child in $HBoxContainer.get_children(): if not child is Button: continue diff --git a/src/UI/Timeline/LayerButton.tscn b/src/UI/Timeline/LayerButton.tscn index edefd1a3d..bac0ea281 100644 --- a/src/UI/Timeline/LayerButton.tscn +++ b/src/UI/Timeline/LayerButton.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://bai814sqvk68f"] +[gd_scene load_steps=10 format=3 uid="uid://bai814sqvk68f"] [ext_resource type="Script" path="res://src/UI/Timeline/LayerButton.gd" id="1_6hlpe"] [ext_resource type="Texture2D" uid="uid://c2b3htff5yox8" path="res://assets/graphics/layers/layer_visible.png" id="2_ef6fb"] @@ -7,6 +7,7 @@ [ext_resource type="Texture2D" uid="uid://cofw1x6chh4i" path="res://assets/graphics/layers/unlinked_layer.png" id="4_058qm"] [ext_resource type="Texture2D" uid="uid://ieo8fsapcgsy" path="res://assets/graphics/layers/clipping_mask.png" id="6_73j5q"] [ext_resource type="Script" path="res://src/UI/Timeline/LayerMainButton.gd" id="6_n8q6b"] +[ext_resource type="Texture2D" uid="uid://dv5y24sb8lxg2" path="res://assets/graphics/layers/layer_active_effect.png" id="8_7wf6f"] [ext_resource type="Texture2D" uid="uid://cjvk47bd56156" path="res://assets/graphics/layers/type_icons/layer_pixel.png" id="8_ce16y"] [node name="LayerButton" type="HBoxContainer"] @@ -166,6 +167,14 @@ editable = false caret_blink = true caret_blink_interval = 0.5 +[node name="LayerFXTextureRect" type="TextureRect" parent="LayerMainButton/LayerName" groups=["UIButtons"]] +unique_name_in_owner = true +visible = false +layout_mode = 2 +texture = ExtResource("8_7wf6f") +stretch_mode = 3 +flip_v = true + [node name="LayerTypeTextureRect" type="TextureRect" parent="LayerMainButton/LayerName" groups=["UIButtons"]] unique_name_in_owner = true modulate = Color(1, 1, 1, 0.498039) diff --git a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd index ce1b96bdc..c6fd70555 100644 --- a/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd +++ b/src/UI/Timeline/LayerEffects/LayerEffectsSettings.gd @@ -79,9 +79,11 @@ func _on_effect_list_id_pressed(index: int) -> void: Global.current_project.undos += 1 Global.current_project.undo_redo.create_action("Add layer effect") Global.current_project.undo_redo.add_do_method(func(): layer.effects.append(effect)) + Global.current_project.undo_redo.add_do_method(layer.emit_effects_added_removed) Global.current_project.undo_redo.add_do_method(Global.canvas.queue_redraw) Global.current_project.undo_redo.add_do_method(Global.undo_or_redo.bind(false)) Global.current_project.undo_redo.add_undo_method(func(): layer.effects.erase(effect)) + Global.current_project.undo_redo.add_undo_method(layer.emit_effects_added_removed) Global.current_project.undo_redo.add_undo_method(Global.canvas.queue_redraw) Global.current_project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true)) Global.current_project.undo_redo.commit_action() @@ -154,9 +156,11 @@ func _delete_effect(effect: LayerEffect) -> void: Global.current_project.undos += 1 Global.current_project.undo_redo.create_action("Delete layer effect") Global.current_project.undo_redo.add_do_method(func(): layer.effects.erase(effect)) + Global.current_project.undo_redo.add_do_method(layer.emit_effects_added_removed) Global.current_project.undo_redo.add_do_method(Global.canvas.queue_redraw) Global.current_project.undo_redo.add_do_method(Global.undo_or_redo.bind(false)) Global.current_project.undo_redo.add_undo_method(func(): layer.effects.insert(index, effect)) + Global.current_project.undo_redo.add_undo_method(layer.emit_effects_added_removed) Global.current_project.undo_redo.add_undo_method(Global.canvas.queue_redraw) Global.current_project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true)) Global.current_project.undo_redo.commit_action()