From 180aab6360583112aefbae01aa6df8a375896e5a Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Fri, 16 Jun 2023 16:18:57 +0300 Subject: [PATCH] Remove and copy frame options on the right click menu of the frames now affect all of the selected frames This behavior is consistent with the clone and remove texture buttons --- src/UI/Timeline/AnimationTimeline.gd | 31 +++++++++++++--------------- src/UI/Timeline/FrameButton.gd | 14 ++++++------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 70a10d4a2..ee67ee7c1 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -198,13 +198,7 @@ func add_frame() -> void: func _on_DeleteFrame_pressed() -> void: - var indices := [] - for cel in Global.current_project.selected_cels: - var f: int = cel[0] - if not f in indices: - indices.append(f) - indices.sort() - delete_frames(indices) + delete_frames() func delete_frames(indices := []) -> void: @@ -212,10 +206,15 @@ func delete_frames(indices := []) -> void: if project.frames.size() == 1: return + if indices.size() == 0: + for cel in Global.current_project.selected_cels: + var f: int = cel[0] + if not f in indices: + indices.append(f) + indices.sort() + if indices.size() == project.frames.size(): indices.remove(indices.size() - 1) # Ensure the project has at least 1 frame - elif indices.size() == 0: - indices.append(project.current_frame) var current_frame: int = min(project.current_frame, project.frames.size() - indices.size() - 1) var frames := [] @@ -269,20 +268,18 @@ func delete_frames(indices := []) -> void: func _on_CopyFrame_pressed() -> void: - var indices := [] - for cel in Global.current_project.selected_cels: - var f: int = cel[0] - if not f in indices: - indices.append(f) - indices.sort() - copy_frames(indices) + copy_frames() func copy_frames(indices := [], destination := -1) -> void: var project: Project = Global.current_project if indices.size() == 0: - indices.append(project.current_frame) + for cel in Global.current_project.selected_cels: + var f: int = cel[0] + if not f in indices: + indices.append(f) + indices.sort() var copied_frames := [] var copied_indices := [] # the indices of newly copied frames diff --git a/src/UI/Timeline/FrameButton.gd b/src/UI/Timeline/FrameButton.gd index 6f6a7872c..27b03a986 100644 --- a/src/UI/Timeline/FrameButton.gd +++ b/src/UI/Timeline/FrameButton.gd @@ -63,7 +63,7 @@ func _button_pressed() -> void: pressed = !pressed elif Input.is_action_just_released("middle_mouse"): pressed = !pressed - Global.animation_timeline.delete_frames([frame]) + Global.animation_timeline.delete_frames() else: # An example of this would be Space pressed = !pressed @@ -71,9 +71,9 @@ func _button_pressed() -> void: func _on_PopupMenu_id_pressed(id: int) -> void: match id: 0: # Remove Frame - Global.animation_timeline.delete_frames([frame]) + Global.animation_timeline.delete_frames() 1: # Clone Frame - Global.animation_timeline.copy_frames([frame]) + Global.animation_timeline.copy_frames() 2: # Move Left change_frame_order(-1) 3: # Move Right @@ -86,7 +86,7 @@ func _on_PopupMenu_id_pressed(id: int) -> void: func change_frame_order(rate: int) -> void: - var change = frame + rate + var change := frame + rate var project = Global.current_project project.undo_redo.create_action("Change Frame Order") @@ -104,7 +104,7 @@ func change_frame_order(rate: int) -> void: project.undo_redo.commit_action() -func get_drag_data(_position) -> Array: +func get_drag_data(_position: Vector2) -> Array: var button := Button.new() button.rect_size = rect_size button.theme = Global.control.theme @@ -114,7 +114,7 @@ func get_drag_data(_position) -> Array: return ["Frame", frame] -func can_drop_data(_pos, data) -> bool: +func can_drop_data(_pos: Vector2, data) -> bool: if typeof(data) == TYPE_ARRAY: if data[0] == "Frame": if data[1] != frame: # Can't move to same frame @@ -136,7 +136,7 @@ func can_drop_data(_pos, data) -> bool: return false -func drop_data(_pos, data) -> void: +func drop_data(_pos: Vector2, data) -> void: var drop_frame = data[1] var project = Global.current_project project.undo_redo.create_action("Change Frame Order")