Skip to content

Commit

Permalink
Preserve focus during rescans in FileSystem dock
Browse files Browse the repository at this point in the history
  • Loading branch information
VedatGunel committed Feb 4, 2024
1 parent b4e2a24 commit 96cdafc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
27 changes: 19 additions & 8 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include "scene/gui/item_list.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/texture_rect.h"
#include "scene/main/window.h"
Expand Down Expand Up @@ -595,6 +597,7 @@ void FileSystemDock::_notification(int p_what) {
}

overwrite_dialog_scroll->add_theme_style_override("panel", get_theme_stylebox("panel", "Tree"));
scanning_panel->add_theme_style_override("panel", get_theme_stylebox("PanelForeground", EditorStringName(EditorStyles)));
} break;

case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
Expand Down Expand Up @@ -1248,8 +1251,8 @@ void FileSystemDock::_preview_invalidated(const String &p_path) {
void FileSystemDock::_fs_changed() {
button_hist_prev->set_disabled(history_pos == 0);
button_hist_next->set_disabled(history_pos == history.size() - 1);
scanning_vb->hide();
split_box->show();
scanning_panel->hide();
split_box->set_process_mode(PROCESS_MODE_INHERIT);

if (tree->is_visible()) {
_update_tree(get_uncollapsed_paths());
Expand All @@ -1272,9 +1275,10 @@ void FileSystemDock::_fs_changed() {
void FileSystemDock::_set_scanning_mode() {
button_hist_prev->set_disabled(true);
button_hist_next->set_disabled(true);
split_box->hide();
scanning_vb->show();
split_box->set_process_mode(PROCESS_MODE_DISABLED);
scanning_panel->show();
set_process(true);

if (EditorFileSystem::get_singleton()->is_scanning()) {
scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
} else {
Expand Down Expand Up @@ -3843,11 +3847,15 @@ FileSystemDock::FileSystemDock() {

add_child(tree_popup);

MarginContainer *mc = memnew(MarginContainer);
mc->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(mc);

split_box = memnew(SplitContainer);
split_box->set_v_size_flags(SIZE_EXPAND_FILL);
split_box->connect("dragged", callable_mp(this, &FileSystemDock::_split_dragged));
split_box_offset_h = 240 * EDSCALE;
add_child(split_box);
mc->add_child(split_box);

tree = memnew(FileSystemTree);

Expand Down Expand Up @@ -3902,9 +3910,12 @@ FileSystemDock::FileSystemDock() {
files->set_allow_rmb_select(true);
file_list_vb->add_child(files);

scanning_vb = memnew(VBoxContainer);
scanning_vb->hide();
add_child(scanning_vb);
scanning_panel = memnew(PanelContainer);
scanning_panel->hide();
mc->add_child(scanning_panel);

VBoxContainer *scanning_vb = memnew(VBoxContainer);
scanning_panel->add_child(scanning_vb);

Label *slabel = memnew(Label);
slabel->set_text(TTR("Scanning Files,\nPlease Wait..."));
Expand Down
3 changes: 2 additions & 1 deletion editor/filesystem_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CreateDialog;
class EditorDirDialog;
class ItemList;
class LineEdit;
class PanelContainer;
class ProgressBar;
class SceneCreateDialog;
class ShaderCreateDialog;
Expand Down Expand Up @@ -144,7 +145,7 @@ class FileSystemDock : public VBoxContainer {

FileSortOption file_sort = FILE_SORT_NAME;

VBoxContainer *scanning_vb = nullptr;
PanelContainer *scanning_panel = nullptr;
ProgressBar *scanning_progress = nullptr;
SplitContainer *split_box = nullptr;
VBoxContainer *file_list_vb = nullptr;
Expand Down

0 comments on commit 96cdafc

Please sign in to comment.