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

Code before:
	_sheet_zoom_on_position(scale_ratio, Vector2());
}

void SpriteFramesEditor::_sheet_zoom_out() {
	_sheet_zoom_on_position(1 / scale_ratio, Vector2());
}

void SpriteFramesEditor::_sheet_zoom_reset() {
	// Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad.
	sheet_zoom = MAX(1.0f, EDSCALE);
	Size2 texture_size = split_sheet_preview->get_texture()->get_size();
	split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);

	_sheet_update_zoom_label();
}

void SpriteFramesEditor::_sheet_zoom_fit() {
	const float margin_percentage = 0.1f;
	const float max_margin = 64.0f;
	const Size2 margin = (margin_percentage * split_sheet_scroll->get_size()).minf(max_margin);
	const Size2 display_area_size = split_sheet_scroll->get_size() - margin;
	const Size2 texture_size = split_sheet_preview->get_texture()->get_size();
	const Vector2 texture_ratio = display_area_size / texture_size;
	float texture_fit_zoom = MIN(texture_ratio.x, texture_ratio.y);

	// quantize the zoom level to avoid subpixel rendering
	if (texture_fit_zoom > 1.0) {
		texture_fit_zoom = Math::floor(texture_fit_zoom);
	} else if (!Math::is_zero_approx(texture_fit_zoom)) {
		texture_fit_zoom = 1.0f / Math::ceil(1.0f / texture_fit_zoom);
	}

	sheet_zoom = texture_fit_zoom;
	split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);

	_sheet_update_zoom_label();
}

void SpriteFramesEditor::_sheet_order_selected(int p_option) {
	frames_need_sort = true;
	split_sheet_preview->queue_redraw();
}

void SpriteFramesEditor::_sheet_select_all_frames() {
	for (int i = 0; i < split_sheet_h->get_value() * split_sheet_v->get_value(); i++) {
		if (!frames_selected.has(i)) {
			frames_selected.insert(i, selected_count);
			selected_count++;
			frames_need_sort = true;
		}
	}

Review comment (suggestion):
```suggestion
	// Quantize the zoom level to avoid subpixel rendering.
```

Code after:
	_sheet_zoom_on_position(scale_ratio, Vector2());
}

void SpriteFramesEditor::_sheet_zoom_out() {
	_sheet_zoom_on_position(1 / scale_ratio, Vector2());
}

void SpriteFramesEditor::_sheet_zoom_reset() {
	// Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad.
	sheet_zoom = MAX(1.0f, EDSCALE);
	Size2 texture_size = split_sheet_preview->get_texture()->get_size();
	split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);

	_sheet_update_zoom_label();
}

void SpriteFramesEditor::_sheet_zoom_fit() {
	const float margin_percentage = 0.1f;
	const float max_margin = 64.0f;
	const Size2 margin = (margin_percentage * split_sheet_scroll->get_size()).minf(max_margin);
	const Size2 display_area_size = split_sheet_scroll->get_size() - margin;
	const Size2 texture_size = split_sheet_preview->get_texture()->get_size();
	const Vector2 texture_ratio = display_area_size / texture_size;
	float texture_fit_zoom = MIN(texture_ratio.x, texture_ratio.y);

	// Quantize the zoom level to avoid subpixel rendering
	if (texture_fit_zoom > 1.0) {
		texture_fit_zoom = Math::floor(texture_fit_zoom);
	} else if (!Math::is_zero_approx(texture_fit_zoom)) {
		texture_fit_zoom = 1.0f / Math::ceil(1.0f / texture_fit_zoom);
	}

	sheet_zoom = CLAMP(texture_fit_zoom, min_sheet_zoom, max_sheet_zoom);
	split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);

	_sheet_update_zoom_label();
}

void SpriteFramesEditor::_sheet_order_selected(int p_option) {
	frames_need_sort = true;
	split_sheet_preview->queue_redraw();
}

void SpriteFramesEditor::_sheet_select_all_frames() {
	for (int i = 0; i < split_sheet_h->get_value() * split_sheet_v->get_value(); i++) {
		if (!frames_selected.has(i)) {
			frames_selected.insert(i, selected_count);
			selected_count++;
			frames_need_sort = true;
		}
	}