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

Code before:
		p_own_node->get_parent()->add_child(p_new_node, true);
		Object::cast_to<Node2D>(p_new_node)->set_transform(Object::cast_to<Node2D>(p_own_node)->get_transform());
	} else {
		p_own_node->add_child(p_new_node, true);
	}

	p_new_node->set_owner(get_tree()->get_edited_scene_root());
}

void Sprite2DEditor::_sync_sprite_resize_mode() {
	if (node != nullptr) {
		node->_editor_set_dragging_to_resize_rect(resize_region_rect->is_pressed());
	}
}

void Sprite2DEditor::_update_sprite_resize_mode_button() {
	if (node == nullptr) {
		return;
	}
	resize_region_rect->set_disabled(!node->is_region_enabled());
	resize_region_rect->set_pressed(node->_editor_is_dragging_to_resiz_rect());
}

void Sprite2DEditor::_update_sprite_resize_mode_tooltip() {
	if (node != nullptr && !node->is_region_enabled()) {
		resize_region_rect->set_tooltip_text("\n" + TTR("Sprite's region needs to be enabled in the inspector."));
		;
	}
}

void Sprite2DEditor::_debug_uv_input(const Ref<InputEvent> &p_input) {
	if (panner->gui_input(p_input, debug_uv->get_global_rect())) {
		accept_event();
	}
}

void Sprite2DEditor::_debug_uv_draw() {
	debug_uv->draw_set_transform(-draw_offset * draw_zoom, 0, Vector2(draw_zoom, draw_zoom));

	Ref<Texture2D> tex = node->get_texture();
	ERR_FAIL_COND(tex.is_null());

	debug_uv->draw_texture(tex, Point2());

	Color color = Color(1.0, 0.8, 0.7);

	if (selected_menu_item == MENU_OPTION_CONVERT_TO_MESH_2D && uv_lines.size() > 0) {
		debug_uv->draw_multiline(uv_lines, color);

	} else if ((selected_menu_item == MENU_OPTION_CONVERT_TO_POLYGON_2D || selected_menu_item == MENU_OPTION_CREATE_COLLISION_POLY_2D || selected_menu_item == MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D) && outline_lines.size() > 0) {
		for (int i = 0; i < outline_lines.size(); i++) {

Review comment (suggestion):
```suggestion
		resize_region_rect->set_tooltip_text(TTRC("Sprite's region needs to be enabled in the inspector."));
```
This seems to work correctly.

Code after:
		p_own_node->get_parent()->add_child(p_new_node, true);
		Object::cast_to<Node2D>(p_new_node)->set_transform(Object::cast_to<Node2D>(p_own_node)->get_transform());
	} else {
		p_own_node->add_child(p_new_node, true);
	}

	p_new_node->set_owner(get_tree()->get_edited_scene_root());
}

void Sprite2DEditor::_sync_sprite_resize_mode() {
	if (node != nullptr) {
		node->_editor_set_dragging_to_resize_rect(resize_region_rect->is_pressed());
	}
}

void Sprite2DEditor::_update_sprite_resize_mode_button() {
	if (node == nullptr) {
		return;
	}
	resize_region_rect->set_disabled(!node->is_region_enabled());
	resize_region_rect->set_pressed(node->_editor_is_dragging_to_resiz_rect());
	resize_region_rect->set_tooltip_text(node->is_region_enabled() ? "" : TTRC("Sprite's region needs to be enabled in the inspector."));
}

void Sprite2DEditor::_debug_uv_input(const Ref<InputEvent> &p_input) {
	if (panner->gui_input(p_input, debug_uv->get_global_rect())) {
		accept_event();
	}
}

void Sprite2DEditor::_debug_uv_draw() {
	debug_uv->draw_set_transform(-draw_offset * draw_zoom, 0, Vector2(draw_zoom, draw_zoom));

	Ref<Texture2D> tex = node->get_texture();
	ERR_FAIL_COND(tex.is_null());

	debug_uv->draw_texture(tex, Point2());

	Color color = Color(1.0, 0.8, 0.7);

	if (selected_menu_item == MENU_OPTION_CONVERT_TO_MESH_2D && uv_lines.size() > 0) {
		debug_uv->draw_multiline(uv_lines, color);

	} else if ((selected_menu_item == MENU_OPTION_CONVERT_TO_POLYGON_2D || selected_menu_item == MENU_OPTION_CREATE_COLLISION_POLY_2D || selected_menu_item == MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D) && outline_lines.size() > 0) {
		for (int i = 0; i < outline_lines.size(); i++) {
			Vector<Vector2> outline = outline_lines[i];

			debug_uv->draw_polyline(outline, color);
			debug_uv->draw_line(outline[0], outline[outline.size() - 1], color);
		}
	}