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

Code before:

	selection = frame_list->get_selected_items();
	if (selection.is_empty() || !p_selected) {
		return;
	}

	updating = true;
	frame_duration->set_value(frames->get_frame_duration(edited_anim, selection[0]));
	updating = false;
}

void SpriteFramesEditor::_frame_duration_changed(double p_value) {
	if (updating) {
		return;
	}

	int nb_selected_items = selection.size();
	if (nb_selected_items == 0) {
		return;
	}

	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Set Frame Duration"), UndoRedo::MERGE_ENDS, EditorNode::get_singleton()->get_edited_scene());

	for (int selected_index = 0; selected_index < nb_selected_items; selected_index++) {
		int index = selection[selected_index];

		Ref<Texture2D> texture = frames->get_frame_texture(edited_anim, index);
		float old_duration = frames->get_frame_duration(edited_anim, index);

		undo_redo->add_do_method(frames.ptr(), "set_frame", edited_anim, index, texture, p_value);
		undo_redo->add_undo_method(frames.ptr(), "set_frame", edited_anim, index, texture, old_duration);
	}

	undo_redo->add_do_method(this, "_update_library");
	undo_redo->add_undo_method(this, "_update_library");
	undo_redo->commit_action();
}

void SpriteFramesEditor::_zoom_in() {
	// Do not zoom in or out with no visible frames
	if (frames->get_frame_count(edited_anim) <= 0) {
		return;
	}
	if (thumbnail_zoom < max_thumbnail_zoom) {
		thumbnail_zoom *= scale_ratio;
		int thumbnail_size = (int)(thumbnail_default_size * thumbnail_zoom);
		frame_list->set_fixed_column_width(thumbnail_size * 3 / 2);
		frame_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
	}
}

Review comment (suggestion):
```suggestion
	for (const int &index  : selection) {
```

Code after:
		return;
	}

	updating = true;
	frame_duration->set_value(frames->get_frame_duration(edited_anim, selection[0]));
	updating = false;
}

void SpriteFramesEditor::_frame_duration_changed(double p_value) {
	if (updating) {
		return;
	}

	if (selection.is_empty()) {
		return;
	}

	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Set Frame Duration"), UndoRedo::MERGE_ENDS, frames.ptr());

	for (const int &index : selection) {
		Ref<Texture2D> texture = frames->get_frame_texture(edited_anim, index);
		float old_duration = frames->get_frame_duration(edited_anim, index);

		undo_redo->add_do_method(frames.ptr(), "set_frame", edited_anim, index, texture, p_value);
		undo_redo->add_undo_method(frames.ptr(), "set_frame", edited_anim, index, texture, old_duration);
	}

	undo_redo->add_do_method(this, "_update_library");
	undo_redo->add_undo_method(this, "_update_library");
	undo_redo->commit_action();
}

void SpriteFramesEditor::_zoom_in() {
	// Do not zoom in or out with no visible frames
	if (frames->get_frame_count(edited_anim) <= 0) {
		return;
	}
	if (thumbnail_zoom < max_thumbnail_zoom) {
		thumbnail_zoom *= scale_ratio;
		int thumbnail_size = (int)(thumbnail_default_size * thumbnail_zoom);
		frame_list->set_fixed_column_width(thumbnail_size * 3 / 2);
		frame_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
	}
}

void SpriteFramesEditor::_zoom_out() {
	// Do not zoom in or out with no visible frames
	if (frames->get_frame_count(edited_anim) <= 0) {
		return;
	}