Skip to content

Commit

Permalink
Merge pull request #23061 from groud/remove_thumbnail_view
Browse files Browse the repository at this point in the history
Remove the thumnail-only view from the filesystem dock
  • Loading branch information
reduz authored Nov 2, 2018
2 parents 08612e1 + 8f3beca commit 03563c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 75 deletions.
77 changes: 7 additions & 70 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,7 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool

void FileSystemDock::_update_display_mode(bool p_force) {
// Compute the new display mode
DisplayMode new_display_mode;
if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) {
new_display_mode = file_list_view ? DISPLAY_MODE_FILE_LIST_ONLY : DISPLAY_MODE_TREE_ONLY;
} else {
new_display_mode = DISPLAY_MODE_SPLIT;
}
DisplayMode new_display_mode = (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) ? DISPLAY_MODE_TREE_ONLY : DISPLAY_MODE_SPLIT;

if (p_force || new_display_mode != display_mode || old_display_mode_setting != display_mode_setting) {
display_mode = new_display_mode;
Expand All @@ -252,19 +247,9 @@ void FileSystemDock::_update_display_mode(bool p_force) {
file_list_vb->hide();
break;

case DISPLAY_MODE_FILE_LIST_ONLY:
tree->hide();
tree_search_box->hide();
button_tree->show();

file_list_vb->show();
_update_file_list(true);
break;

case DISPLAY_MODE_SPLIT:
tree->show();
tree->set_v_size_flags(SIZE_EXPAND_FILL);
button_tree->hide();
tree->ensure_cursor_is_visible();
tree_search_box->hide();
_update_tree(_compute_uncollapsed_paths());
Expand Down Expand Up @@ -295,7 +280,6 @@ void FileSystemDock::_notification(int p_what) {
String ei = "EditorIcons";
button_reload->set_icon(get_icon("Reload", ei));
button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
_update_file_list_display_mode_button();
button_file_list_display_mode->connect("pressed", this, "_change_file_display");

Expand All @@ -312,7 +296,6 @@ void FileSystemDock::_notification(int p_what) {
file_list_popup->connect("id_pressed", this, "_file_list_rmb_option");
tree_popup->connect("id_pressed", this, "_tree_rmb_option");

button_tree->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
current_path->connect("text_entered", this, "navigate_to_path");

display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
Expand Down Expand Up @@ -362,7 +345,6 @@ void FileSystemDock::_notification(int p_what) {
String ei = "EditorIcons";
button_reload->set_icon(get_icon("Reload", ei));
button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
button_hist_next->set_icon(get_icon("Forward", ei));
button_hist_prev->set_icon(get_icon("Back", ei));
if (button_file_list_display_mode->is_pressed()) {
Expand Down Expand Up @@ -484,20 +466,9 @@ void FileSystemDock::navigate_to_path(const String &p_path) {
_set_current_path_text(path);
_push_to_history();

_update_tree(_compute_uncollapsed_paths());
if (display_mode == DISPLAY_MODE_SPLIT) {
if (path.ends_with("/") || path == "Favorites") {
_go_to_file_list();
}
_update_tree(_compute_uncollapsed_paths());
_update_file_list(false);
} else if (display_mode == DISPLAY_MODE_TREE_ONLY) {
if (path.ends_with("/") || path == "Favorites") {
_go_to_file_list();
} else {
_update_tree(_compute_uncollapsed_paths());
}
} else { // DISPLAY_MODE_FILE_LIST_ONLY
_update_file_list(true);
}

String file_name = p_path.get_file();
Expand Down Expand Up @@ -711,7 +682,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
_search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
} else {

if ((display_mode == DISPLAY_MODE_FILE_LIST_ONLY || display_mode == DISPLAY_MODE_TREE_ONLY) || always_show_folders) {
if (display_mode == DISPLAY_MODE_TREE_ONLY || always_show_folders) {
// Display folders in the list

if (directory != "res://") {
Expand Down Expand Up @@ -839,35 +810,16 @@ void FileSystemDock::_tree_activate_file() {
TreeItem *selected = tree->get_selected();
if (selected) {
call_deferred("_select_file", selected->get_metadata(0));
}
}

void FileSystemDock::_file_list_activate_file(int p_idx) {
_select_file(files->get_item_metadata(p_idx));
}

void FileSystemDock::_go_to_file_list() {

if (display_mode == DISPLAY_MODE_TREE_ONLY) {

file_list_view = true;
_update_display_mode();
} else {
TreeItem *selected = tree->get_selected();
if (selected) {
if (path.ends_with("/") || path == "Favorites") {
bool collapsed = selected->is_collapsed();
selected->set_collapsed(!collapsed);
}
_update_file_list(false);
}
}

void FileSystemDock::_go_to_tree() {

file_list_view = false;
tree->grab_focus();
_update_display_mode();
tree->ensure_cursor_is_visible();
void FileSystemDock::_file_list_activate_file(int p_idx) {
_select_file(files->get_item_metadata(p_idx));
}

void FileSystemDock::_preview_invalidated(const String &p_path) {
Expand Down Expand Up @@ -1704,9 +1656,6 @@ void FileSystemDock::_search_changed(const String &p_text, const Control *p_from
tree_search_box->set_text(searched_string);

switch (display_mode) {
case DISPLAY_MODE_FILE_LIST_ONLY: {
_update_file_list(false);
} break;
case DISPLAY_MODE_TREE_ONLY: {
_update_tree(searched_string.length() == 0 ? uncollapsed_paths_before_search : Vector<String>());
} break;
Expand Down Expand Up @@ -1735,12 +1684,6 @@ void FileSystemDock::fix_dependencies(const String &p_for_file) {

void FileSystemDock::focus_on_filter() {

if (display_mode == DISPLAY_MODE_FILE_LIST_ONLY && tree->is_visible()) {
// Tree mode, switch to files list with search box
tree->hide();
file_list_vb->show();
}

file_list_search_box->grab_focus();
}

Expand Down Expand Up @@ -2330,7 +2273,6 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_file_list_activate_file"), &FileSystemDock::_file_list_activate_file);
ClassDB::bind_method(D_METHOD("_tree_activate_file"), &FileSystemDock::_tree_activate_file);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
Expand Down Expand Up @@ -2426,7 +2368,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
/*
button_open = memnew( Button );
button_open->set_flat(true);
button_open->connect("pressed",this,"_go_to_file_list");
button_open->connect("pressed",this,"_tree_toggle_collapsed");
toolbar_hbc->add_child(button_open);
button_open->hide();
button_open->set_focus_mode(FOCUS_NONE);
Expand Down Expand Up @@ -2476,11 +2418,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
path_hb = memnew(HBoxContainer);
file_list_vb->add_child(path_hb);

button_tree = memnew(ToolButton);
button_tree->set_tooltip(TTR("Enter tree-view."));
button_tree->hide();
path_hb->add_child(button_tree);

file_list_search_box = memnew(LineEdit);
file_list_search_box->set_h_size_flags(SIZE_EXPAND_FILL);
file_list_search_box->set_placeholder(TTR("Search files"));
Expand Down
6 changes: 1 addition & 5 deletions editor/filesystem_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class FileSystemDock : public VBoxContainer {

enum DisplayMode {
DISPLAY_MODE_TREE_ONLY,
DISPLAY_MODE_FILE_LIST_ONLY,
DISPLAY_MODE_SPLIT,
};

Expand Down Expand Up @@ -109,7 +108,6 @@ class FileSystemDock : public VBoxContainer {

Button *button_toggle_display_mode;
Button *button_reload;
Button *button_tree;
Button *button_file_list_display_mode;
Button *button_hist_next;
Button *button_hist_prev;
Expand All @@ -127,7 +125,6 @@ class FileSystemDock : public VBoxContainer {
DisplayMode display_mode;
DisplayModeSetting display_mode_setting;
DisplayModeSetting old_display_mode_setting;
bool file_list_view;

PopupMenu *file_list_popup;
PopupMenu *tree_popup;
Expand Down Expand Up @@ -193,8 +190,7 @@ class FileSystemDock : public VBoxContainer {
void _change_file_display();
void _fs_changed();

void _go_to_tree();
void _go_to_file_list();
void _tree_toggle_collapsed();

void _select_file(const String p_path);
void _tree_activate_file();
Expand Down

0 comments on commit 03563c8

Please sign in to comment.