diff options
author | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-08-16 13:25:42 -0300 |
---|---|---|
committer | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-08-16 15:27:00 -0300 |
commit | f6b39827b1f68aef52fd87723f0225946eff1551 (patch) | |
tree | af2e8f28df3c8b337f4260d505667d44b004ae75 | |
parent | 91ba00b4163ceec83211b9445dd1a0900d71efe4 (diff) |
Better editor settings for the FileSystem dock
* Save the current display mode when changing it from the dock
-rw-r--r-- | tools/editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | tools/editor/editor_settings.cpp | 5 | ||||
-rw-r--r-- | tools/editor/filesystem_dock.cpp | 46 | ||||
-rw-r--r-- | tools/editor/filesystem_dock.h | 11 |
4 files changed, 46 insertions, 18 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 85c560bf9d..b224cac7be 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -6180,7 +6180,7 @@ EditorNode::EditorNode() { scenes_dock = memnew( FileSystemDock(this) ); scenes_dock->set_name(TTR("FileSystem")); - scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS); + scenes_dock->set_display_mode(int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode"))); dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock); //prop_pallete->add_child(scenes_dock); scenes_dock->connect("open",this,"open_request"); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 582462aa19..f973d97ef1 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -622,6 +622,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("file_dialog/thumbnail_size", 64); hints["file_dialog/thumbnail_size"]=PropertyInfo(Variant::INT,"file_dialog/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16"); + set("filesystem_dock/display_mode", 0); + hints["filesystem_dock/display_mode"]=PropertyInfo(Variant::INT,"filesystem_dock/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List"); + set("filesystem_dock/thumbnail_size", 64); + hints["filesystem_dock/thumbnail_size"]=PropertyInfo(Variant::INT,"filesystem_dock/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16"); + set("animation/autorename_animation_tracks",true); set("animation/confirm_insert_track",true); diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp index 378edd6667..8a94c6e340 100644 --- a/tools/editor/filesystem_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -146,8 +146,12 @@ void FileSystemDock::_notification(int p_what) { //button_instance->set_icon( get_icon("Add","EditorIcons")); //button_open->set_icon( get_icon("Folder","EditorIcons")); button_back->set_icon( get_icon("Filesystem","EditorIcons")); - display_mode->set_icon( get_icon("FileList","EditorIcons")); - display_mode->connect("pressed",this,"_change_file_display"); + if (display_mode == DISPLAY_THUMBNAILS) { + button_display_mode->set_icon(get_icon("FileList","EditorIcons")); + } else { + button_display_mode->set_icon(get_icon("FileThumbnail","EditorIcons")); + } + button_display_mode->connect("pressed",this,"_change_file_display"); //file_options->set_icon( get_icon("Tools","EditorIcons")); files->connect("item_activated",this,"_select_file"); button_hist_next->connect("pressed",this,"_fw_history"); @@ -197,9 +201,13 @@ void FileSystemDock::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST); + int new_mode = int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode")); - _change_file_display(); + if (new_mode != display_mode) { + set_display_mode(new_mode); + } else { + _update_files(true); + } } break; } @@ -314,13 +322,16 @@ void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_ void FileSystemDock::_change_file_display() { - if (display_mode->is_pressed()) { - display_mode->set_icon( get_icon("FileThumbnail","EditorIcons")); - + if (button_display_mode->is_pressed()) { + display_mode = DISPLAY_LIST; + button_display_mode->set_icon( get_icon("FileThumbnail","EditorIcons")); } else { - display_mode->set_icon( get_icon("FileList","EditorIcons")); + display_mode = DISPLAY_THUMBNAILS; + button_display_mode->set_icon( get_icon("FileList","EditorIcons")); } + EditorSettings::get_singleton()->set("filesystem_dock/display_mode", display_mode); + _update_files(true); } @@ -393,12 +404,12 @@ void FileSystemDock::_update_files(bool p_keep_selection) { if (!efd) return; - int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); + int thumbnail_size = EditorSettings::get_singleton()->get("filesystem_dock/thumbnail_size"); thumbnail_size*=EDSCALE; Ref<Texture> folder_thumbnail; Ref<Texture> file_thumbnail; - bool use_thumbnails=!display_mode->is_pressed(); + bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS); bool use_folders = search_box->get_text().length()==0 && split_mode; if (use_thumbnails) { //thumbnails @@ -1147,9 +1158,13 @@ void FileSystemDock::focus_on_filter() { } -void FileSystemDock::set_use_thumbnails(bool p_use) { +void FileSystemDock::set_display_mode(int p_mode) { + + if (p_mode == display_mode) + return; - display_mode->set_pressed(!p_use); + button_display_mode->set_pressed(p_mode == DISPLAY_LIST); + _change_file_display(); } @@ -1721,9 +1736,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { search_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED); path_hb->add_child(search_icon); - display_mode = memnew( ToolButton ); - path_hb->add_child(display_mode); - display_mode->set_toggle_mode(true); + button_display_mode = memnew( ToolButton ); + path_hb->add_child(button_display_mode); + button_display_mode->set_toggle_mode(true); file_list_vb->add_child(files); @@ -1766,6 +1781,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { history_pos=0; split_mode=false; + display_mode = DISPLAY_THUMBNAILS; path="res://"; diff --git a/tools/editor/filesystem_dock.h b/tools/editor/filesystem_dock.h index 171dbd16e9..f5b96760fc 100644 --- a/tools/editor/filesystem_dock.h +++ b/tools/editor/filesystem_dock.h @@ -54,6 +54,12 @@ class EditorNode; class FileSystemDock : public VBoxContainer { OBJ_TYPE( FileSystemDock, VBoxContainer ); +public: + enum DisplayMode { + DISPLAY_THUMBNAILS, + DISPLAY_LIST + }; +private: enum FileMenu { FILE_OPEN, FILE_INSTANCE, @@ -79,7 +85,7 @@ class FileSystemDock : public VBoxContainer { Button *button_reload; Button *button_favorite; Button *button_back; - Button *display_mode; + Button *button_display_mode; Button *button_hist_next; Button *button_hist_prev; LineEdit *current_path; @@ -88,6 +94,7 @@ class FileSystemDock : public VBoxContainer { HBoxContainer *path_hb; bool split_mode; + DisplayMode display_mode; PopupMenu *file_options; @@ -182,7 +189,7 @@ public: void fix_dependencies(const String& p_for_file); - void set_use_thumbnails(bool p_use); + void set_display_mode(int p_mode); FileSystemDock(EditorNode *p_editor); ~FileSystemDock(); |