From fd3666298c4f60c62e9b3552772c01f4dbce65a9 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Sun, 25 Feb 2024 11:51:50 -0500 Subject: [PATCH] Add create folder icon --- doc/classes/FileDialog.xml | 3 +++ editor/gui/editor_file_dialog.cpp | 7 ++++++- editor/gui/editor_file_dialog.h | 1 + editor/icons/FolderCreate.svg | 1 + editor/themes/editor_theme_manager.cpp | 1 + scene/gui/file_dialog.cpp | 12 +++++++++++- scene/gui/file_dialog.h | 1 + scene/theme/default_theme.cpp | 1 + scene/theme/icons/folder_create.svg | 1 + 9 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 editor/icons/FolderCreate.svg create mode 100644 scene/theme/icons/folder_create.svg diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 47a1801f58a..7c8910d0605 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -210,6 +210,9 @@ Custom icon for the back arrow. + + Custom icon for the create folder button. + Custom icon for files. diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index 2dada257280..7d6cd545650 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -86,6 +86,7 @@ void EditorFileDialog::_update_theme_item_cache() { theme_cache.mode_list = get_editor_theme_icon(SNAME("FileList")); theme_cache.favorites_up = get_editor_theme_icon(SNAME("MoveUp")); theme_cache.favorites_down = get_editor_theme_icon(SNAME("MoveDown")); + theme_cache.create_folder = get_editor_theme_icon(SNAME("FolderCreate")); theme_cache.folder = get_editor_theme_icon(SNAME("Folder")); theme_cache.folder_icon_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); @@ -1328,6 +1329,7 @@ void EditorFileDialog::_update_icons() { refresh->set_icon(theme_cache.reload); favorite->set_icon(theme_cache.favorite); show_hidden->set_icon(theme_cache.toggle_hidden); + makedir->set_icon(theme_cache.create_folder); fav_up->set_icon(theme_cache.favorites_up); fav_down->set_icon(theme_cache.favorites_down); @@ -1875,8 +1877,11 @@ EditorFileDialog::EditorFileDialog() { drives->connect("item_selected", callable_mp(this, &EditorFileDialog::_select_drive)); pathhb->add_child(drives); + pathhb->add_child(memnew(VSeparator)); + makedir = memnew(Button); - makedir->set_text(TTR("Create Folder")); + makedir->set_theme_type_variation("FlatButton"); + makedir->set_tooltip_text(TTR("Create a new folder.")); makedir->connect("pressed", callable_mp(this, &EditorFileDialog::_make_dir)); pathhb->add_child(makedir); diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index e0f53ace969..6514781e2c4 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -155,6 +155,7 @@ private: Ref favorite; Ref mode_thumbnails; Ref mode_list; + Ref create_folder; Ref favorites_up; Ref favorites_down; diff --git a/editor/icons/FolderCreate.svg b/editor/icons/FolderCreate.svg new file mode 100644 index 00000000000..80a3f90e2aa --- /dev/null +++ b/editor/icons/FolderCreate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index 4a67bd6b31d..d645405a44e 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -1279,6 +1279,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref &p_the p_theme->set_icon("forward_folder", "FileDialog", p_theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons))); p_theme->set_icon("reload", "FileDialog", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons))); p_theme->set_icon("toggle_hidden", "FileDialog", p_theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons))); + p_theme->set_icon("create_folder", "FileDialog", p_theme->get_icon(SNAME("FolderCreate"), EditorStringName(EditorIcons))); // Use a different color for folder icons to make them easier to distinguish from files. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color. p_theme->set_color("folder_icon_color", "FileDialog", (p_config.dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(p_config.accent_color, 0.7)); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 8f58c1e6f52..178af01a3e9 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -187,6 +187,7 @@ void FileDialog::_notification(int p_what) { } refresh->set_icon(theme_cache.reload); show_hidden->set_icon(theme_cache.toggle_hidden); + makedir->set_icon(theme_cache.create_folder); dir_up->begin_bulk_theme_override(); dir_up->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); @@ -223,6 +224,13 @@ void FileDialog::_notification(int p_what) { show_hidden->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); show_hidden->end_bulk_theme_override(); + makedir->begin_bulk_theme_override(); + makedir->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); + makedir->add_theme_color_override("icon_hover_color", theme_cache.icon_hover_color); + makedir->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); + makedir->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); + makedir->end_bulk_theme_override(); + invalidate(); } break; @@ -1331,6 +1339,7 @@ void FileDialog::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, toggle_hidden); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, folder); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, file); + BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, FileDialog, create_folder); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, FileDialog, folder_icon_color); BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, FileDialog, file_icon_color); @@ -1426,7 +1435,8 @@ FileDialog::FileDialog() { hbc->add_child(shortcuts_container); makedir = memnew(Button); - makedir->set_text(RTR("Create Folder")); + makedir->set_theme_type_variation("FlatButton"); + makedir->set_tooltip_text(RTR("Create a new folder.")); makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); hbc->add_child(makedir); vbox->add_child(hbc); diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 7356e1c9e3c..1b53c7e05e3 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -120,6 +120,7 @@ private: Ref toggle_hidden; Ref folder; Ref file; + Ref create_folder; Color folder_icon_color; Color file_icon_color; diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index fa83e06315a..634b32c9f61 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -651,6 +651,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_icon("toggle_hidden", "FileDialog", icons["visibility_visible"]); theme->set_icon("folder", "FileDialog", icons["folder"]); theme->set_icon("file", "FileDialog", icons["file"]); + theme->set_icon("create_folder", "FileDialog", icons["folder_create"]); theme->set_color("folder_icon_color", "FileDialog", Color(1, 1, 1)); theme->set_color("file_icon_color", "FileDialog", Color(1, 1, 1)); theme->set_color("file_disabled_color", "FileDialog", Color(1, 1, 1, 0.25)); diff --git a/scene/theme/icons/folder_create.svg b/scene/theme/icons/folder_create.svg new file mode 100644 index 00000000000..d11d0715a12 --- /dev/null +++ b/scene/theme/icons/folder_create.svg @@ -0,0 +1 @@ + \ No newline at end of file