Skip to content

Commit

Permalink
Merge pull request #88825 from adamscott/add-create-folder-icon
Browse files Browse the repository at this point in the history
Add create folder icon
  • Loading branch information
akien-mga committed Feb 27, 2024
2 parents bbe263d + fd36662 commit 4a49373
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doc/classes/FileDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
<theme_item name="back_folder" data_type="icon" type="Texture2D">
Custom icon for the back arrow.
</theme_item>
<theme_item name="create_folder" data_type="icon" type="Texture2D">
Custom icon for the create folder button.
</theme_item>
<theme_item name="file" data_type="icon" type="Texture2D">
Custom icon for files.
</theme_item>
Expand Down
7 changes: 6 additions & 1 deletion editor/gui/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions editor/gui/editor_file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class EditorFileDialog : public ConfirmationDialog {
Ref<Texture2D> favorite;
Ref<Texture2D> mode_thumbnails;
Ref<Texture2D> mode_list;
Ref<Texture2D> create_folder;
Ref<Texture2D> favorites_up;
Ref<Texture2D> favorites_down;

Expand Down
1 change: 1 addition & 0 deletions editor/icons/FolderCreate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &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));
Expand Down
12 changes: 11 additions & 1 deletion scene/gui/file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class FileDialog : public ConfirmationDialog {
Ref<Texture2D> toggle_hidden;
Ref<Texture2D> folder;
Ref<Texture2D> file;
Ref<Texture2D> create_folder;

Color folder_icon_color;
Color file_icon_color;
Expand Down
1 change: 1 addition & 0 deletions scene/theme/default_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &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));
Expand Down
1 change: 1 addition & 0 deletions scene/theme/icons/folder_create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4a49373

Please sign in to comment.