Repository: godotengine/godot
File: editor/docks/filesystem_dock.cpp (C++)

Code before:
	button->set_flat(false);
	button->set_theme_type_variation("FlatMenuButton");
	button->set_tooltip_text(TTRC("Sort Files"));
	button->set_accessibility_name(TTRC("Sort Files"));

	PopupMenu *p = button->get_popup();
	p->connect(SceneStringName(id_pressed), callable_mp(this, &FileSystemDock::_file_sort_popup));
	p->add_radio_check_item(TTRC("Sort by Name (Ascending)"), (int)FileSortOption::FILE_SORT_NAME);
	p->add_radio_check_item(TTRC("Sort by Name (Descending)"), (int)FileSortOption::FILE_SORT_NAME_REVERSE);
	p->add_radio_check_item(TTRC("Sort by Type (Ascending)"), (int)FileSortOption::FILE_SORT_TYPE);
	p->add_radio_check_item(TTRC("Sort by Type (Descending)"), (int)FileSortOption::FILE_SORT_TYPE_REVERSE);
	p->add_radio_check_item(TTRC("Sort by Last Modified"), (int)FileSortOption::FILE_SORT_MODIFIED_TIME);
	p->add_radio_check_item(TTRC("Sort by First Modified"), (int)FileSortOption::FILE_SORT_MODIFIED_TIME_REVERSE);
	p->set_item_checked((int)file_sort, true);
	return button;
}

void FileSystemDock::update_layout(EditorDock::DockLayout p_layout) {
	bool horizontal = p_layout == EditorDock::DOCK_LAYOUT_HORIZONTAL;
	if (button_dock_placement->is_visible() == horizontal) {
		return;
	}

	if (horizontal) {
    path_hb->reparent(toolbar_hbc, false);
		toolbar_hbc->move_child(path_hb, 2);
		set_meta("_dock_display_mode", get_display_mode());
		set_meta("_dock_file_display_mode", get_file_list_display_mode());

		FileSystemDock::DisplayMode new_display_mode = FileSystemDock::DisplayMode(int(get_meta("_bottom_display_mode", int(FileSystemDock::DISPLAY_MODE_HSPLIT))));
		FileSystemDock::FileListDisplayMode new_file_display_mode = FileSystemDock::FileListDisplayMode(int(get_meta("_bottom_file_display_mode", int(FileSystemDock::FILE_LIST_DISPLAY_THUMBNAILS))));

		set_display_mode(new_display_mode);
		set_file_list_display_mode(new_file_display_mode);
		set_custom_minimum_size(Size2(0, 200) * EDSCALE);
	} else {
		path_hb->reparent(file_list_vb);
		file_list_vb->move_child(path_hb, 0);
		set_meta("_bottom_display_mode", get_display_mode());
		set_meta("_bottom_file_display_mode", get_file_list_display_mode());

		FileSystemDock::DisplayMode new_display_mode = FileSystemDock::DISPLAY_MODE_TREE_ONLY;
		FileSystemDock::FileListDisplayMode new_file_display_mode = FileSystemDock::FILE_LIST_DISPLAY_LIST;

		new_display_mode = FileSystemDock::DisplayMode(int(get_meta("_dock_display_mode", new_display_mode)));
		new_file_display_mode = FileSystemDock::FileListDisplayMode(int(get_meta("_dock_file_display_mode", new_file_display_mode)));

		set_display_mode(new_display_mode);
		set_file_list_display_mode(new_file_display_mode);
		set_custom_minimum_size(Size2(0, 0));
	}

Review comment (suggestion):
```suggestion
		path_hb->reparent(toolbar_hbc, false);
		toolbar_hbc->move_child(path_hb, 2);
```

Code after:
	return assigned_folder_colors;
}

MenuButton *FileSystemDock::_create_file_menu_button() {
	MenuButton *button = memnew(MenuButton);
	button->set_flat(false);
	button->set_theme_type_variation("FlatMenuButton");
	button->set_tooltip_text(TTRC("Sort Files"));
	button->set_accessibility_name(TTRC("Sort Files"));

	PopupMenu *p = button->get_popup();
	p->connect(SceneStringName(id_pressed), callable_mp(this, &FileSystemDock::_file_sort_popup));
	p->add_radio_check_item(TTRC("Sort by Name (Ascending)"), (int)FileSortOption::FILE_SORT_NAME);
	p->add_radio_check_item(TTRC("Sort by Name (Descending)"), (int)FileSortOption::FILE_SORT_NAME_REVERSE);
	p->add_radio_check_item(TTRC("Sort by Type (Ascending)"), (int)FileSortOption::FILE_SORT_TYPE);
	p->add_radio_check_item(TTRC("Sort by Type (Descending)"), (int)FileSortOption::FILE_SORT_TYPE_REVERSE);
	p->add_radio_check_item(TTRC("Sort by Last Modified"), (int)FileSortOption::FILE_SORT_MODIFIED_TIME);
	p->add_radio_check_item(TTRC("Sort by First Modified"), (int)FileSortOption::FILE_SORT_MODIFIED_TIME_REVERSE);
	p->set_item_checked((int)file_sort, true);
	return button;
}

void FileSystemDock::update_layout(EditorDock::DockLayout p_layout) {
	horizontal = p_layout == EditorDock::DOCK_LAYOUT_HORIZONTAL;
	if (button_dock_placement->is_visible() == horizontal) {
		return;
	}

	if (horizontal) {
		path_hb->reparent(toolbar_hbc, false);
		toolbar_hbc->move_child(path_hb, 2);
		set_meta("_dock_display_mode", get_display_mode());
		set_meta("_dock_file_display_mode", get_file_list_display_mode());

		FileSystemDock::DisplayMode new_display_mode = FileSystemDock::DisplayMode(int(get_meta("_bottom_display_mode", int(FileSystemDock::DISPLAY_MODE_HSPLIT))));
		FileSystemDock::FileListDisplayMode new_file_display_mode = FileSystemDock::FileListDisplayMode(int(get_meta("_bottom_file_display_mode", int(FileSystemDock::FILE_LIST_DISPLAY_THUMBNAILS))));

		set_display_mode(new_display_mode);
		set_file_list_display_mode(new_file_display_mode);
		set_custom_minimum_size(Size2(0, 200) * EDSCALE);
	} else {
		path_hb->reparent(file_list_vb);
		file_list_vb->move_child(path_hb, 0);
		set_meta("_bottom_display_mode", get_display_mode());
		set_meta("_bottom_file_display_mode", get_file_list_display_mode());

		FileSystemDock::DisplayMode new_display_mode = FileSystemDock::DISPLAY_MODE_TREE_ONLY;
		FileSystemDock::FileListDisplayMode new_file_display_mode = FileSystemDock::FILE_LIST_DISPLAY_LIST;

		new_display_mode = FileSystemDock::DisplayMode(int(get_meta("_dock_display_mode", new_display_mode)));
		new_file_display_mode = FileSystemDock::FileListDisplayMode(int(get_meta("_dock_file_display_mode", new_file_display_mode)));