summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_node.cpp16
-rw-r--r--editor/editor_settings.cpp4
-rw-r--r--editor/filesystem_dock.cpp58
-rw-r--r--editor/filesystem_dock.h18
4 files changed, 43 insertions, 53 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9d9c5b6cc8..e23afec5b8 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3632,6 +3632,8 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p
}
p_layout->set_value(p_section, "dock_filesystem_split", filesystem_dock->get_split_offset());
+ p_layout->set_value(p_section, "dock_filesystem_display_mode", filesystem_dock->get_display_mode());
+ p_layout->set_value(p_section, "dock_filesystem_file_list_display_mode", filesystem_dock->get_file_list_display_mode());
for (int i = 0; i < vsplits.size(); i++) {
@@ -3819,6 +3821,17 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
int fs_split_ofs = 0;
if (p_layout->has_section_key(p_section, "dock_filesystem_split")) {
fs_split_ofs = p_layout->get_value(p_section, "dock_filesystem_split");
+ filesystem_dock->set_split_offset(fs_split_ofs);
+ }
+
+ if (p_layout->has_section_key(p_section, "dock_filesystem_display_mode")) {
+ FileSystemDock::DisplayMode dock_filesystem_display_mode = FileSystemDock::DisplayMode(int(p_layout->get_value(p_section, "dock_filesystem_display_mode")));
+ filesystem_dock->set_display_mode(dock_filesystem_display_mode);
+ }
+
+ if (p_layout->has_section_key(p_section, "dock_filesystem_file_list_display_mode")) {
+ FileSystemDock::FileListDisplayMode dock_filesystem_file_list_display_mode = FileSystemDock::FileListDisplayMode(int(p_layout->get_value(p_section, "dock_filesystem_file_list_display_mode")));
+ filesystem_dock->set_file_list_display_mode(dock_filesystem_file_list_display_mode);
}
filesystem_dock->set_split_offset(fs_split_ofs);
@@ -5580,9 +5593,10 @@ EditorNode::EditorNode() {
node_dock = memnew(NodeDock);
filesystem_dock = memnew(FileSystemDock(this));
- filesystem_dock->set_file_list_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/files_display_mode")));
filesystem_dock->connect("open", this, "open_request");
+ filesystem_dock->set_file_list_display_mode(FileSystemDock::FILE_LIST_DISPLAY_LIST);
filesystem_dock->connect("instance", this, "_instance_request");
+ filesystem_dock->connect("display_mode_changed", this, "_save_docks");
// Scene: Top left
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scene_tree_dock);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index cbd8df315a..741a210950 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -389,12 +389,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("docks/scene_tree/relationship_line_color", Color::html("464646"));
// FileSystem
- _initial_set("docks/filesystem/display_mode", 0);
- hints["docks/filesystem/display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/display_mode", PROPERTY_HINT_ENUM, "Tree only, Split");
_initial_set("docks/filesystem/thumbnail_size", 64);
hints["docks/filesystem/thumbnail_size"] = PropertyInfo(Variant::INT, "docks/filesystem/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
- _initial_set("docks/filesystem/files_display_mode", 0);
- hints["docks/filesystem/files_display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/files_display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
_initial_set("docks/filesystem/always_show_folders", true);
// Property editor
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index b1aa75e124..0c3c222085 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -66,7 +66,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
subdirectory_item->set_selectable(0, true);
String lpath = p_dir->get_path();
subdirectory_item->set_metadata(0, lpath);
- if (!p_select_in_favorites && (path == lpath || ((display_mode_setting == DISPLAY_MODE_SETTING_SPLIT) && path.get_base_dir() == lpath))) {
+ if (!p_select_in_favorites && (path == lpath || ((display_mode == DISPLAY_MODE_SPLIT) && path.get_base_dir() == lpath))) {
subdirectory_item->select(0);
}
@@ -84,7 +84,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
parent_should_expand = (_create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths, p_select_in_favorites) || parent_should_expand);
// Create all items for the files in the subdirectory
- if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) {
+ if (display_mode == DISPLAY_MODE_TREE_ONLY) {
for (int i = 0; i < p_dir->get_file_count(); i++) {
String file_name = p_dir->get_file(i);
@@ -229,19 +229,21 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool
updating_tree = false;
}
+void FileSystemDock::set_display_mode(DisplayMode p_display_mode) {
+ display_mode = p_display_mode;
+ emit_signal("display_mode_changed");
+ _update_display_mode(false);
+}
+
void FileSystemDock::_update_display_mode(bool p_force) {
// Compute the new display mode
- 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;
- old_display_mode_setting = display_mode_setting;
- button_toggle_display_mode->set_pressed(display_mode_setting == DISPLAY_MODE_SETTING_SPLIT ? true : false);
+ if (p_force || old_display_mode != display_mode) {
+ button_toggle_display_mode->set_pressed(display_mode == DISPLAY_MODE_SPLIT ? true : false);
switch (display_mode) {
case DISPLAY_MODE_TREE_ONLY:
tree->show();
tree->set_v_size_flags(SIZE_EXPAND_FILL);
- if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) {
+ if (display_mode == DISPLAY_MODE_TREE_ONLY) {
tree_search_box->show();
} else {
tree_search_box->hide();
@@ -262,6 +264,7 @@ void FileSystemDock::_update_display_mode(bool p_force) {
_update_file_list(true);
break;
}
+ old_display_mode = display_mode;
}
}
@@ -269,9 +272,6 @@ void FileSystemDock::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_RESIZED: {
- _update_display_mode();
- } break;
case NOTIFICATION_ENTER_TREE: {
if (initialized)
@@ -302,7 +302,6 @@ void FileSystemDock::_notification(int p_what) {
current_path->connect("text_entered", this, "_navigate_to_path");
- display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders"));
_update_display_mode();
@@ -362,27 +361,10 @@ void FileSystemDock::_notification(int p_what) {
file_list_search_box->set_right_icon(get_icon("Search", ei));
file_list_search_box->set_clear_button_enabled(true);
- bool should_update_files = false;
-
- // Update file list display mode
- int new_file_list_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/files_display_mode"));
- if (new_file_list_mode != file_list_display_mode) {
- set_file_list_display_mode(new_file_list_mode);
- _update_file_list_display_mode_button();
- should_update_files = true;
- }
-
- // Update display of files in tree
- display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
-
// Update always showfolders
bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders"));
if (new_always_show_folders != always_show_folders) {
always_show_folders = new_always_show_folders;
- should_update_files = true;
- }
-
- if (should_update_files) {
_update_file_list(true);
}
@@ -530,6 +512,7 @@ void FileSystemDock::_update_file_list_display_mode_button() {
button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
button_file_list_display_mode->set_tooltip(TTR("View items as a list."));
}
+ emit_signal("display_mode_changed");
}
void FileSystemDock::_change_file_display() {
@@ -1695,9 +1678,7 @@ void FileSystemDock::_rescan() {
}
void FileSystemDock::_toggle_split_mode(bool p_active) {
- display_mode_setting = p_active ? DISPLAY_MODE_SETTING_SPLIT : DISPLAY_MODE_SETTING_TREE_ONLY;
- EditorSettings::get_singleton()->set("docks/filesystem/display_mode", int(display_mode_setting));
- _update_display_mode();
+ set_display_mode(p_active ? DISPLAY_MODE_SPLIT : DISPLAY_MODE_TREE_ONLY);
}
void FileSystemDock::fix_dependencies(const String &p_for_file) {
@@ -1709,7 +1690,7 @@ void FileSystemDock::focus_on_filter() {
file_list_search_box->grab_focus();
}
-void FileSystemDock::set_file_list_display_mode(int p_mode) {
+void FileSystemDock::set_file_list_display_mode(FileListDisplayMode p_mode) {
if (p_mode == file_list_display_mode)
return;
@@ -2219,7 +2200,7 @@ void FileSystemDock::_update_import_dock() {
// List selected
Vector<String> selected;
- if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) {
+ if (display_mode == DISPLAY_MODE_TREE_ONLY) {
// Use the tree
selected = _tree_get_selected();
@@ -2334,6 +2315,8 @@ void FileSystemDock::_bind_methods() {
ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder")));
ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_file")));
+
+ ADD_SIGNAL(MethodInfo("display_mode_changed"));
}
FileSystemDock::FileSystemDock(EditorNode *p_editor) {
@@ -2564,11 +2547,10 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
history_max_size = 20;
history.push_back("res://");
- display_mode = DISPLAY_MODE_SPLIT;
+ display_mode = DISPLAY_MODE_TREE_ONLY;
+ old_display_mode = DISPLAY_MODE_TREE_ONLY;
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
- display_mode_setting = DISPLAY_MODE_SETTING_TREE_ONLY;
- old_display_mode_setting = DISPLAY_MODE_SETTING_TREE_ONLY;
always_show_folders = false;
}
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 237413acc4..e31afee23e 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -65,17 +65,12 @@ public:
FILE_LIST_DISPLAY_LIST
};
-private:
- enum DisplayModeSetting {
- DISPLAY_MODE_SETTING_TREE_ONLY,
- DISPLAY_MODE_SETTING_SPLIT,
- };
-
enum DisplayMode {
DISPLAY_MODE_TREE_ONLY,
DISPLAY_MODE_SPLIT,
};
+private:
enum FileMenu {
FILE_OPEN,
FILE_INSTANCE,
@@ -123,8 +118,7 @@ private:
FileListDisplayMode file_list_display_mode;
DisplayMode display_mode;
- DisplayModeSetting display_mode_setting;
- DisplayModeSetting old_display_mode_setting;
+ DisplayMode old_display_mode;
PopupMenu *file_list_popup;
PopupMenu *tree_popup;
@@ -287,12 +281,16 @@ public:
void fix_dependencies(const String &p_for_file);
- void set_file_list_display_mode(int p_mode);
-
int get_split_offset() { return split_box->get_split_offset(); }
void set_split_offset(int p_offset) { split_box->set_split_offset(p_offset); }
void select_file(const String &p_file);
+ void set_display_mode(DisplayMode p_display_mode);
+ DisplayMode get_display_mode() { return display_mode; }
+
+ void set_file_list_display_mode(FileListDisplayMode p_mode);
+ FileListDisplayMode get_file_list_display_mode() { return file_list_display_mode; };
+
FileSystemDock(EditorNode *p_editor);
~FileSystemDock();
};