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

Code before:
	shrink_pixels->set_min(0);
	shrink_pixels->set_max(10);
	shrink_pixels->set_step(1);
	shrink_pixels->set_value(0);
	shrink_pixels->set_accessibility_name(TTRC("Shrink"));
	hb->add_child(shrink_pixels);
	hb->add_spacer();
	hb->add_child(memnew(Label(TTR("Grow (Pixels):"))));
	grow_pixels = memnew(SpinBox);
	grow_pixels->set_min(0);
	grow_pixels->set_max(10);
	grow_pixels->set_step(1);
	grow_pixels->set_value(2);
	grow_pixels->set_accessibility_name(TTRC("Grow"));
	hb->add_child(grow_pixels);
	hb->add_spacer();
	update_preview = memnew(Button);
	update_preview->set_text(TTR("Update Preview"));
	update_preview->connect(SceneStringName(pressed), callable_mp(this, &Sprite2DEditor::_update_mesh_data));
	hb->add_child(update_preview);
	vb->add_margin_child(TTR("Settings:"), hb);

	add_child(debug_uv_dialog);
}

void Sprite2DEditorPlugin::_editor_theme_changed() {
	dragging_mode_hint->remove_theme_color_override(SceneStringName(font_color));
	dragging_mode_hint->add_theme_color_override(SceneStringName(font_color), Color(0.6f, 0.6f, 0.6f, 1));
	dragging_mode_hint->add_theme_color_override("font_shadow_color", Color(0.2f, 0.2f, 0.2f, 1));
	dragging_mode_hint->add_theme_constant_override("shadow_outline_size", 1 * EDSCALE);
	dragging_mode_hint->add_theme_constant_override("line_spacing", 0);
}

void Sprite2DEditorPlugin::edit(Object *p_object) {
	Sprite2D *spr = Object::cast_to<Sprite2D>(p_object);
	sprite_editor->edit(spr);
}

bool Sprite2DEditorPlugin::handles(Object *p_object) const {
	return p_object->is_class("Sprite2D");
}

void Sprite2DEditorPlugin::make_visible(bool p_visible) {
	if (p_visible) {
		sprite_editor->options->show();
		dragging_mode_hint->show();
	} else {
		sprite_editor->options->hide();
		dragging_mode_hint->hide();
		sprite_editor->edit(nullptr);
	}

Review comment (suggestion):
Looks like this method should be called somewhere? (other than constructor)
Sprite2DEditor is a Control, so you can just use NOTIFICATION_THEME_CHANGED.

Code after:
	shrink_pixels->set_min(0);
	shrink_pixels->set_max(10);
	shrink_pixels->set_step(1);
	shrink_pixels->set_value(0);
	shrink_pixels->set_accessibility_name(TTRC("Shrink"));
	hb->add_child(shrink_pixels);
	hb->add_spacer();
	hb->add_child(memnew(Label(TTR("Grow (Pixels):"))));
	grow_pixels = memnew(SpinBox);
	grow_pixels->set_min(0);
	grow_pixels->set_max(10);
	grow_pixels->set_step(1);
	grow_pixels->set_value(2);
	grow_pixels->set_accessibility_name(TTRC("Grow"));
	hb->add_child(grow_pixels);
	hb->add_spacer();
	update_preview = memnew(Button);
	update_preview->set_text(TTR("Update Preview"));
	update_preview->connect(SceneStringName(pressed), callable_mp(this, &Sprite2DEditor::_update_mesh_data));
	hb->add_child(update_preview);
	vb->add_margin_child(TTR("Settings:"), hb);

	add_child(debug_uv_dialog);
}

void Sprite2DEditorPlugin::_editor_theme_changed() {
	dragging_mode_hint->add_theme_color_override(SceneStringName(font_color), Color(0.6f, 0.6f, 0.6f, 1));
	dragging_mode_hint->add_theme_color_override("font_shadow_color", Color(0.2f, 0.2f, 0.2f, 1));
	dragging_mode_hint->add_theme_constant_override("shadow_outline_size", 1 * EDSCALE);
	dragging_mode_hint->add_theme_constant_override("line_spacing", 0);
}

void Sprite2DEditorPlugin::_update_dragging_mode_hint(bool p_region_enabled) {
	if (p_region_enabled) {
		dragging_mode_hint->show();
	} else {
		dragging_mode_hint->hide();
	}
}

void Sprite2DEditorPlugin::edit(Object *p_object) {
	Callable update_text = callable_mp(this, &Sprite2DEditorPlugin::_update_dragging_mode_hint);
	StringName update_signal = SNAME("_editor_region_rect_enabled");

	Sprite2D *spr = sprite_editor->node;
	if (spr != nullptr && spr->is_connected(update_signal, update_text)) {
		spr->disconnect(update_signal, update_text);
	}

	spr = Object::cast_to<Sprite2D>(p_object);
	sprite_editor->edit(spr);