Repository: godotengine/godot
File: editor/inspector/editor_inspector.cpp (C++)

Code before:
}

void EditorPaginator::update(int p_page, int p_max_page) {
	page = p_page;
	max_page = p_max_page;

	// Update buttons.
	first_page_button->set_disabled(page == 0);
	prev_page_button->set_disabled(page == 0);
	next_page_button->set_disabled(page == max_page);
	last_page_button->set_disabled(page == max_page);

	// Update page number and page count.
	page_line_edit->set_text(vformat("%d", page + 1));
	page_count_label->set_text(vformat("/ %d", max_page + 1));
}

void EditorPaginator::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_THEME_CHANGED: {
			first_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageFirst")));
			prev_page_button->set_button_icon(get_editor_theme_icon(SNAME("PagePrevious")));
			next_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageNext")));
			last_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageLast")));
		} break;
	}
}

void EditorPaginator::_bind_methods() {
	ADD_SIGNAL(MethodInfo("page_changed", PropertyInfo(Variant::INT, "page")));
}

EditorPaginator::EditorPaginator() {
	set_h_size_flags(SIZE_EXPAND_FILL);
	set_alignment(ALIGNMENT_CENTER);

	first_page_button = memnew(Button);
	first_page_button->set_accessibility_name(TTRC("First Page"));
	first_page_button->set_flat(true);
	first_page_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPaginator::_first_page_button_pressed));
	add_child(first_page_button);

	prev_page_button = memnew(Button);
	prev_page_button->set_accessibility_name(TTRC("Previous Page"));
	prev_page_button->set_flat(true);
	prev_page_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPaginator::_prev_page_button_pressed));
	add_child(prev_page_button);

	page_line_edit = memnew(LineEdit);
	page_line_edit->set_accessibility_name(TTRC("Page Number"));
	page_line_edit->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPaginator::_page_line_edit_text_submitted));

Review comment (performance):
```suggestion
		container = Object::cast_to<VBoxContainer>(last_child);
```
Should be equivalent and more efficient

Code after:

void EditorPaginator::update(int p_page, int p_max_page) {
	page = p_page;
	max_page = p_max_page;

	// Update buttons.
	first_page_button->set_disabled(page == 0);
	prev_page_button->set_disabled(page == 0);
	next_page_button->set_disabled(page == max_page);
	last_page_button->set_disabled(page == max_page);

	// Update page number and page count.
	page_line_edit->set_text(vformat("%d", page + 1));
	page_count_label->set_text(vformat("/ %d", max_page + 1));
}

void EditorPaginator::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_THEME_CHANGED: {
			first_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageFirst")));
			prev_page_button->set_button_icon(get_editor_theme_icon(SNAME("PagePrevious")));
			next_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageNext")));
			last_page_button->set_button_icon(get_editor_theme_icon(SNAME("PageLast")));
		} break;
	}
}

void EditorPaginator::_bind_methods() {
	ADD_SIGNAL(MethodInfo("page_changed", PropertyInfo(Variant::INT, "page")));
}

EditorPaginator::EditorPaginator() {
	set_h_size_flags(SIZE_EXPAND_FILL);
	set_alignment(ALIGNMENT_CENTER);

	first_page_button = memnew(Button);
	first_page_button->set_accessibility_name(TTRC("First Page"));
	first_page_button->set_flat(true);
	first_page_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPaginator::_first_page_button_pressed));
	add_child(first_page_button);

	prev_page_button = memnew(Button);
	prev_page_button->set_accessibility_name(TTRC("Previous Page"));
	prev_page_button->set_flat(true);
	prev_page_button->connect(SceneStringName(pressed), callable_mp(this, &EditorPaginator::_prev_page_button_pressed));
	add_child(prev_page_button);

	page_line_edit = memnew(LineEdit);
	page_line_edit->set_accessibility_name(TTRC("Page Number"));
	page_line_edit->connect(SceneStringName(text_submitted), callable_mp(this, &EditorPaginator::_page_line_edit_text_submitted));
	page_line_edit->add_theme_constant_override("minimum_character_width", 2);