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

Code before:
	}

	zoom_widget->set_zoom(zoom);
	update_viewport();
}

void CanvasItemEditor::_update_zoom(real_t p_zoom) {
	_zoom_on_position(p_zoom, viewport_scrollable->get_size() / 2.0);
}

void CanvasItemEditor::_shortcut_zoom_set(real_t p_zoom) {
	_zoom_on_position(p_zoom * MAX(1, EDSCALE), viewport->get_local_mouse_position());
}

void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) {
	smart_snap_active = p_status;
	viewport->queue_redraw();
}

void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
	grid_snap_active = p_status;
	viewport->queue_redraw();
}

void CanvasItemEditor::_button_tool_select(int p_index) {
	_commit_drag();

	Button *tb[TOOL_MAX] = { select_button, list_select_button, move_button, scale_button, rotate_button, pivot_button, pan_button, ruler_button };
	for (int i = 0; i < TOOL_MAX; i++) {
		tb[i]->set_pressed(i == p_index);
	}

	tool = (Tool)p_index;

	if (p_index == TOOL_EDIT_PIVOT && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
		// Special action that places temporary rotation pivot in the middle of the selection.
		List<CanvasItem *> selection = _get_edited_canvas_items();
		if (!selection.is_empty()) {
			Vector2 center;
			for (const CanvasItem *ci : selection) {
				center += ci->get_viewport()->get_popup_base_transform().xform(ci->_edit_get_position());
			}
			temp_pivot = center / selection.size();
		}
	}

	viewport->queue_redraw();
	_update_cursor();
}

void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) {

Review comment (suggestion):
You could check if `drag_type` isn't `DRAG_NONE`. While calling the method unnecessarily has no adverse effects, it's better to avoid it.

Code after:
	}

	zoom_widget->set_zoom(zoom);
	update_viewport();
}

void CanvasItemEditor::_update_zoom(real_t p_zoom) {
	_zoom_on_position(p_zoom, viewport_scrollable->get_size() / 2.0);
}

void CanvasItemEditor::_shortcut_zoom_set(real_t p_zoom) {
	_zoom_on_position(p_zoom * MAX(1, EDSCALE), viewport->get_local_mouse_position());
}

void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) {
	smart_snap_active = p_status;
	viewport->queue_redraw();
}

void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
	grid_snap_active = p_status;
	viewport->queue_redraw();
}

void CanvasItemEditor::_button_tool_select(int p_index) {
	if (drag_type != DRAG_NONE) {
		_commit_drag();
	}

	Button *tb[TOOL_MAX] = { select_button, list_select_button, move_button, scale_button, rotate_button, pivot_button, pan_button, ruler_button };
	for (int i = 0; i < TOOL_MAX; i++) {
		tb[i]->set_pressed(i == p_index);
	}

	tool = (Tool)p_index;

	if (p_index == TOOL_EDIT_PIVOT && Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
		// Special action that places temporary rotation pivot in the middle of the selection.
		List<CanvasItem *> selection = _get_edited_canvas_items();
		if (!selection.is_empty()) {
			Vector2 center;
			for (const CanvasItem *ci : selection) {
				center += ci->get_viewport()->get_popup_base_transform().xform(ci->_edit_get_position());
			}
			temp_pivot = center / selection.size();
		}
	}

	viewport->queue_redraw();
	_update_cursor();
}