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

Code before:
	// Can't make sibling if own node is scene root
	if (p_own_node != get_tree()->get_edited_scene_root()) {
		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) {
		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) {

Review comment (suggestion):
I don't know how, but the tooltip and disabled state can still get desynced.
![image](https://github.com/user-attachments/assets/f2f71757-8c20-4ad0-94ed-eaa314666b0b)
Though as I mentioned, you can update them together. I don't see why there are 2 separate methods if they are called together and button's tooltip and disabled state basically depend on each other.

Code after:
	// Can't make sibling if own node is scene root
	if (p_own_node != get_tree()->get_edited_scene_root()) {
		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);