Repository: godotengine/godot
File: editor/scene/3d/node_3d_editor_plugin.cpp (C++)

Code before:
	selection_menu = memnew(PopupMenu);
	add_child(selection_menu);
	selection_menu->set_min_size(Size2(100, 0) * EDSCALE);
	selection_menu->connect(SceneStringName(id_pressed), callable_mp(this, &Node3DEditorViewport::_selection_result_pressed));
	selection_menu->connect("popup_hide", callable_mp(this, &Node3DEditorViewport::_selection_menu_hide));

	if (p_index == 0) {
		view_display_menu->get_popup()->set_item_checked(view_display_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true);
		viewport->set_as_audio_listener_3d(true);
	}

	ruler = memnew(Node);

	ruler_start_point = memnew(Node3D);
	ruler_start_point->set_visible(false);

	ruler_end_point = memnew(Node3D);
	ruler_end_point->set_visible(false);

	ruler_material.instantiate();
	ruler_material->set_albedo(Color(1.0, 0.9, 0.0, 1.0));
	ruler_material->set_flag(BaseMaterial3D::FLAG_DISABLE_FOG, true);
	ruler_material->set_shading_mode(BaseMaterial3D::SHADING_MODE_UNSHADED);
	ruler_material->set_depth_draw_mode(BaseMaterial3D::DEPTH_DRAW_DISABLED);

	ruler_material_xray.instantiate();
	ruler_material_xray->set_albedo(Color(1.0, 0.9, 0.0, 0.15));
	ruler_material_xray->set_flag(BaseMaterial3D::FLAG_DISABLE_FOG, true);
	ruler_material_xray->set_shading_mode(BaseMaterial3D::SHADING_MODE_UNSHADED);
	ruler_material_xray->set_flag(BaseMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
	ruler_material_xray->set_transparency(BaseMaterial3D::TRANSPARENCY_ALPHA);
	ruler_material_xray->set_render_priority(BaseMaterial3D::RENDER_PRIORITY_MAX);

	geometry.instantiate();

	ruler_line = memnew(MeshInstance3D);
	ruler_line->set_mesh(geometry);
	ruler_line->set_material_override(ruler_material);

	ruler_line_xray = memnew(MeshInstance3D);
	ruler_line_xray->set_mesh(geometry);
	ruler_line_xray->set_material_override(ruler_material_xray);

	ruler_label = memnew(Label);
	ruler_label->set_visible(false);

	ruler->add_child(ruler_start_point);
	ruler->add_child(ruler_end_point);
	ruler->add_child(ruler_line);
	ruler->add_child(ruler_line_xray);


Review comment (suggestion):
Personally I'm not sure if we should have this new signal, it should be possible to call `_load_viewport_inputs()` from `InputMap::load_from_project_settings()`, I think

Code after:
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_information", TTRC("View Information")), VIEW_INFORMATION);
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTRC("View Frame Time")), VIEW_FRAME_TIME);
	view_display_menu->get_popup()->set_item_checked(view_display_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true);
	view_display_menu->get_popup()->add_separator();
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_half_resolution", TTRC("Half Resolution")), VIEW_HALF_RESOLUTION);
	view_display_menu->get_popup()->add_separator();
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTRC("Audio Listener")), VIEW_AUDIO_LISTENER);
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_doppler", TTRC("Enable Doppler")), VIEW_AUDIO_DOPPLER);
	view_display_menu->get_popup()->set_item_checked(view_display_menu->get_popup()->get_item_index(VIEW_GIZMOS), true);
	view_display_menu->get_popup()->set_item_checked(view_display_menu->get_popup()->get_item_index(VIEW_TRANSFORM_GIZMO), true);
	view_display_menu->get_popup()->set_item_checked(view_display_menu->get_popup()->get_item_index(VIEW_GRID), true);

	view_display_menu->get_popup()->add_separator();
	view_display_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_cinematic_preview", TTRC("Cinematic Preview")), VIEW_CINEMATIC_PREVIEW);

	view_display_menu->get_popup()->add_separator();
	view_display_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_origin"), VIEW_CENTER_TO_ORIGIN);
	view_display_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
	view_display_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW);
	view_display_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW);
	view_display_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &Node3DEditorViewport::_menu_option));
	display_submenu->connect(SceneStringName(id_pressed), callable_mp(this, &Node3DEditorViewport::_menu_option));
	view_display_menu->set_disable_shortcuts(true);

	_load_viewport_inputs();
	InputMap::get_singleton()->connect("project_settings_loaded", callable_mp(this, &Node3DEditorViewport::_load_viewport_inputs));

	ED_SHORTCUT("spatial_editor/lock_transform_x", TTRC("Lock Transformation to X axis"), Key::X);
	ED_SHORTCUT("spatial_editor/lock_transform_y", TTRC("Lock Transformation to Y axis"), Key::Y);
	ED_SHORTCUT("spatial_editor/lock_transform_z", TTRC("Lock Transformation to Z axis"), Key::Z);
	ED_SHORTCUT("spatial_editor/lock_transform_yz", TTRC("Lock Transformation to YZ plane"), KeyModifierMask::SHIFT | Key::X);
	ED_SHORTCUT("spatial_editor/lock_transform_xz", TTRC("Lock Transformation to XZ plane"), KeyModifierMask::SHIFT | Key::Y);
	ED_SHORTCUT("spatial_editor/lock_transform_xy", TTRC("Lock Transformation to XY plane"), KeyModifierMask::SHIFT | Key::Z);
	ED_SHORTCUT("spatial_editor/cancel_transform", TTRC("Cancel Transformation"), Key::ESCAPE);
	ED_SHORTCUT("spatial_editor/instant_translate", TTRC("Begin Translate Transformation"));
	ED_SHORTCUT("spatial_editor/instant_rotate", TTRC("Begin Rotate Transformation"));
	ED_SHORTCUT("spatial_editor/instant_scale", TTRC("Begin Scale Transformation"));
	ED_SHORTCUT("spatial_editor/collision_reposition", TTRC("Reposition Using Collisions"), KeyModifierMask::SHIFT | Key::G);
	ED_SHORTCUT("spatial_editor/reset_transform_position", TTRC("Reset Position"), KeyModifierMask::ALT + Key::W);
	ED_SHORTCUT("spatial_editor/reset_transform_rotation", TTRC("Reset Rotation"), KeyModifierMask::ALT + Key::E);
	ED_SHORTCUT("spatial_editor/reset_transform_scale", TTRC("Reset Scale"), KeyModifierMask::ALT + Key::R);

	translation_preview_button = memnew(EditorTranslationPreviewButton);
	hbox->add_child(translation_preview_button);

	preview_camera = memnew(CheckBox);
	preview_camera->set_text(TTRC("Preview"));
	// Using Control even on macOS to avoid conflict with Quick Open shortcut.
	preview_camera->set_shortcut(ED_SHORTCUT("spatial_editor/toggle_camera_preview", TTRC("Toggle Camera Preview"), KeyModifierMask::CTRL | Key::P));
	vbox->add_child(preview_camera);
	preview_camera->set_h_size_flags(0);