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

Code before:
	shrink_pixels->set_max(10);
	shrink_pixels->set_step(1);
	shrink_pixels->set_value(0);
	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);
	hb->add_child(grow_pixels);
	hb->add_spacer();
	update_preview = memnew(Button);
	update_preview->set_text(TTR("Update Preview"));
	update_preview->connect("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::edit(Object *p_object) {
	sprite_editor->edit(Object::cast_to<Sprite2D>(p_object));
}

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();
	} else {
		sprite_editor->options->hide();
		sprite_editor->edit(nullptr);
	}
}

Sprite2DEditorPlugin::Sprite2DEditorPlugin() {
	sprite_editor = memnew(Sprite2DEditor);
	EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor);
	make_visible(false);

	//sprite_editor->options->hide();
}

Sprite2DEditorPlugin::~Sprite2DEditorPlugin() {
}


Review comment (suggestion):
This code still falls into THEME_CHANGED from editor settings. How about this?
```suggestion
			[[fallthrough]];
		}
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
			panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
		} break;
		case NOTIFICATION_ENTER_TREE:
```
The panner can be initialized in READY too.

Code after:
	h_scroll->set_page(page_size.x);
	h_scroll->set_value(draw_offset.x);
	h_scroll->set_block_signals(false);

	v_scroll->set_block_signals(true);
	v_scroll->set_min(min_corner.y);
	v_scroll->set_max(max_corner.y);
	v_scroll->set_page(page_size.y);
	v_scroll->set_value(draw_offset.y);
	v_scroll->set_block_signals(false);

	debug_uv->queue_redraw();
}

void Sprite2DEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_READY: {
			v_scroll->set_anchors_and_offsets_preset(Control::PRESET_RIGHT_WIDE);
			h_scroll->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_WIDE);
			// Avoid scrollbar overlapping.
			Size2 hmin = h_scroll->get_combined_minimum_size();
			Size2 vmin = v_scroll->get_combined_minimum_size();
			h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -vmin.width);
			v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -hmin.height);
			[[fallthrough]];
		}
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
			panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
		} break;
		case NOTIFICATION_ENTER_TREE:
		case NOTIFICATION_THEME_CHANGED: {
			options->set_icon(get_editor_theme_icon(SNAME("Sprite2D")));

			options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_MESH_2D, get_editor_theme_icon(SNAME("MeshInstance2D")));
			options->get_popup()->set_item_icon(MENU_OPTION_CONVERT_TO_POLYGON_2D, get_editor_theme_icon(SNAME("Polygon2D")));
			options->get_popup()->set_item_icon(MENU_OPTION_CREATE_COLLISION_POLY_2D, get_editor_theme_icon(SNAME("CollisionPolygon2D")));
			options->get_popup()->set_item_icon(MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D, get_editor_theme_icon(SNAME("LightOccluder2D")));
		} break;
	}
}

void Sprite2DEditor::_bind_methods() {
	ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child);
}

Sprite2DEditor::Sprite2DEditor() {
	options = memnew(MenuButton);

	CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);

	options->set_text(TTR("Sprite2D"));