diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 214d77b84..cde038f23 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -389,14 +389,8 @@ func _on_MoveRight_pressed() -> void: Global.frame_hbox.get_child(frame).change_frame_order(1) -func reverse_frames() -> void: +func reverse_frames(indices := []) -> void: var project = Global.current_project - 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() project.undo_redo.create_action("Change Frame Order") project.undo_redo.add_do_method(project, "reverse_frames", indices) project.undo_redo.add_undo_method(project, "reverse_frames", indices) diff --git a/src/UI/Timeline/FrameButton.gd b/src/UI/Timeline/FrameButton.gd index 49e071ab4..3d46f86c0 100644 --- a/src/UI/Timeline/FrameButton.gd +++ b/src/UI/Timeline/FrameButton.gd @@ -70,28 +70,28 @@ func _button_pressed() -> void: pressed = !pressed elif Input.is_action_just_released("middle_mouse"): pressed = !pressed - Global.animation_timeline.delete_frames() + Global.animation_timeline.delete_frames(_get_frame_indices()) else: # An example of this would be Space pressed = !pressed func _on_PopupMenu_id_pressed(id: int) -> void: + var indices := _get_frame_indices() match id: REMOVE: - Global.animation_timeline.delete_frames() + Global.animation_timeline.delete_frames(indices) CLONE: - Global.animation_timeline.copy_frames() + Global.animation_timeline.copy_frames(indices) MOVE_LEFT: change_frame_order(-1) MOVE_RIGHT: change_frame_order(1) PROPERTIES: + frame_properties.frame_indices = indices frame_properties.popup_centered() Global.dialog_open(true) - frame_properties.set_frame_label(frame) - frame_properties.set_frame_dur(Global.current_project.frames[frame].duration) REVERSE: - Global.animation_timeline.reverse_frames() + Global.animation_timeline.reverse_frames(indices) func change_frame_order(rate: int) -> void: @@ -178,3 +178,15 @@ func _get_region_rect(x_begin: float, x_end: float) -> Rect2: rect.position.x += rect.size.x * x_begin rect.size.x *= x_end - x_begin return rect + + +func _get_frame_indices() -> Array: + 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() + if not frame in indices: + indices = [frame] + return indices diff --git a/src/UI/Timeline/FrameProperties.gd b/src/UI/Timeline/FrameProperties.gd index e2cfc67af..f5687e69d 100644 --- a/src/UI/Timeline/FrameProperties.gd +++ b/src/UI/Timeline/FrameProperties.gd @@ -1,14 +1,19 @@ extends ConfirmationDialog +var frame_indices := [] onready var frame_num = $VBoxContainer/GridContainer/FrameNum onready var frame_dur = $VBoxContainer/GridContainer/FrameTime -func set_frame_label(frame: int) -> void: - frame_num.set_text(str(frame + 1)) - - -func set_frame_dur(duration: float) -> void: +func _on_FrameProperties_about_to_show() -> void: + if frame_indices.size() == 0: + frame_num.set_text("") + return + if frame_indices.size() == 1: + frame_num.set_text(str(frame_indices[0] + 1)) + else: + frame_num.set_text("[%s...%s]" % [frame_indices[0] + 1, frame_indices[-1] + 1]) + var duration: float = Global.current_project.frames[frame_indices[0]].duration frame_dur.set_value(duration) @@ -16,24 +21,16 @@ func _on_FrameProperties_popup_hide() -> void: Global.dialog_open(false) -func _on_FrameProperties_confirmed(): - var frame: int = int(frame_num.get_text()) - 1 - var duration: float = frame_dur.get_value() - var new_duration = Global.current_project.frames[frame].duration - new_duration = duration - - Global.current_project.undos += 1 - Global.current_project.undo_redo.create_action("Change frame duration") - - Global.current_project.undo_redo.add_do_property( - Global.current_project.frames[frame], "duration", new_duration - ) - Global.current_project.undo_redo.add_undo_property( - Global.current_project.frames[frame], - "duration", - Global.current_project.frames[frame].duration - ) - - Global.current_project.undo_redo.add_do_method(Global, "undo_or_redo", false) - Global.current_project.undo_redo.add_undo_method(Global, "undo_or_redo", true) - Global.current_project.undo_redo.commit_action() +func _on_FrameProperties_confirmed() -> void: + var project: Project = Global.current_project + var new_duration: float = frame_dur.get_value() + project.undos += 1 + project.undo_redo.create_action("Change frame duration") + for frame in frame_indices: + project.undo_redo.add_do_property(project.frames[frame], "duration", new_duration) + project.undo_redo.add_undo_property( + project.frames[frame], "duration", project.frames[frame].duration + ) + project.undo_redo.add_do_method(Global, "undo_or_redo", false) + project.undo_redo.add_undo_method(Global, "undo_or_redo", true) + project.undo_redo.commit_action() diff --git a/src/UI/Timeline/FrameProperties.tscn b/src/UI/Timeline/FrameProperties.tscn index f80ad452a..4ab3face8 100644 --- a/src/UI/Timeline/FrameProperties.tscn +++ b/src/UI/Timeline/FrameProperties.tscn @@ -65,5 +65,6 @@ value = 2.0 allow_greater = true suffix = "x" +[connection signal="about_to_show" from="." to="." method="_on_FrameProperties_about_to_show"] [connection signal="confirmed" from="." to="." method="_on_FrameProperties_confirmed"] [connection signal="popup_hide" from="." to="." method="_on_FrameProperties_popup_hide"]