Repository: godotengine/godot
File: editor/scene/sprite_frames_editor_plugin.cpp (C++)

Code before:
	anim_speed->update_minimum_size();
}

void SpriteFramesEditor::_animation_speed_changed(double p_value) {
	if (frames.is_null()) {
		return;
	}

	if (updating) {
		return;
	}

	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Change Animation FPS"), UndoRedo::MERGE_ENDS, frames.ptr());
	undo_redo->add_do_method(frames.ptr(), "set_animation_speed", edited_anim, p_value);
	undo_redo->add_undo_method(frames.ptr(), "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
	undo_redo->add_do_method(this, "_update_library", true);
	undo_redo->add_undo_method(this, "_update_library", true);
	undo_redo->commit_action();
}

void SpriteFramesEditor::_animation_remove_undo_redo(const StringName &p_action_name, const Vector<ClipboardSpriteFrames::Frame> *p_frames) {
	StringName new_edited = _find_next_animation();
	int frame_count = frames->get_frame_count(edited_anim);
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR(p_action_name), UndoRedo::MERGE_DISABLE, frames.ptr());
	_rename_node_animation(undo_redo, false, edited_anim, new_edited, "");
	undo_redo->add_do_method(frames.ptr(), "remove_animation", edited_anim);
	undo_redo->add_undo_method(frames.ptr(), "add_animation", edited_anim);
	_rename_node_animation(undo_redo, true, edited_anim, edited_anim, edited_anim);
	undo_redo->add_undo_method(frames.ptr(), "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
	undo_redo->add_undo_method(frames.ptr(), "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
	for (int i = 0; i < frame_count; i++) {
		Ref<Texture2D> texture;
		float duration;
		if (p_frames) {
			texture = (*p_frames)[i].texture;
			duration = (*p_frames)[i].duration;
		} else {
			texture = frames->get_frame_texture(edited_anim, i);
			duration = frames->get_frame_duration(edited_anim, i);
		}
		undo_redo->add_undo_method(frames.ptr(), "add_frame", edited_anim, texture, duration);
	}
	undo_redo->add_do_method(this, "_select_animation", new_edited);
	undo_redo->add_undo_method(this, "_select_animation", edited_anim);
	undo_redo->add_do_method(this, "_update_library");
	undo_redo->add_undo_method(this, "_update_library");
	undo_redo->commit_action();
}


Review comment (refactor):
This translation macro won't work afaik, or at least it won't make it extracted, it should be called for the argument to `_animation_remove_undo_redo` instead 
```suggestion
	undo_redo->create_action(p_action_name, UndoRedo::MERGE_DISABLE, frames.ptr());
```

Code after:
	undo_redo->add_do_method(frames.ptr(), "set_animation_loop", edited_anim, anim_loop->is_pressed());
	undo_redo->add_undo_method(frames.ptr(), "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
	undo_redo->add_do_method(this, "_update_library", true);
	undo_redo->add_undo_method(this, "_update_library", true);
	undo_redo->commit_action();
}

void SpriteFramesEditor::_animation_speed_resized() {
	anim_speed->update_minimum_size();
}

void SpriteFramesEditor::_animation_speed_changed(double p_value) {
	if (frames.is_null()) {
		return;
	}

	if (updating) {
		return;
	}

	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Change Animation FPS"), UndoRedo::MERGE_ENDS, frames.ptr());
	undo_redo->add_do_method(frames.ptr(), "set_animation_speed", edited_anim, p_value);
	undo_redo->add_undo_method(frames.ptr(), "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
	undo_redo->add_do_method(this, "_update_library", true);
	undo_redo->add_undo_method(this, "_update_library", true);
	undo_redo->commit_action();
}

void SpriteFramesEditor::_animation_remove_undo_redo(const StringName &p_action_name, const Vector<ClipboardSpriteFrames::Frame> *p_frames) {
	StringName new_edited = _find_next_animation();
	int frame_count = frames->get_frame_count(edited_anim);
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(p_action_name, UndoRedo::MERGE_DISABLE, frames.ptr());
	_rename_node_animation(undo_redo, false, edited_anim, new_edited, "");
	undo_redo->add_do_method(frames.ptr(), "remove_animation", edited_anim);
	undo_redo->add_undo_method(frames.ptr(), "add_animation", edited_anim);
	_rename_node_animation(undo_redo, true, edited_anim, edited_anim, edited_anim);
	undo_redo->add_undo_method(frames.ptr(), "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
	undo_redo->add_undo_method(frames.ptr(), "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
	for (int i = 0; i < frame_count; i++) {
		Ref<Texture2D> texture;
		float duration;
		if (p_frames) {
			texture = (*p_frames)[i].texture;
			duration = (*p_frames)[i].duration;
		} else {
			texture = frames->get_frame_texture(edited_anim, i);
			duration = frames->get_frame_duration(edited_anim, i);
		}
		undo_redo->add_undo_method(frames.ptr(), "add_frame", edited_anim, texture, duration);