Add browse folder and browse file icons

This commit is contained in:
Adam Scott 2024-02-25 13:10:29 -05:00
parent 22c20cea6e
commit 44d3ce2c11
No known key found for this signature in database
GPG key ID: 1352C2919D96DDDF
9 changed files with 39 additions and 3 deletions

View file

@ -534,7 +534,11 @@ void EditorPropertyPath::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
path_edit->set_icon(get_editor_theme_icon(SNAME("Folder")));
if (folder) {
path_edit->set_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
} else {
path_edit->set_icon(get_editor_theme_icon(SNAME("FileBrowse")));
}
} break;
}
}

View file

@ -39,6 +39,10 @@
void FBXImporterManager::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
fbx_path_browse->set_icon(get_editor_theme_icon(SNAME("FileBrowse")));
} break;
case NOTIFICATION_READY: {
connect("confirmed", callable_mp(this, &FBXImporterManager::_path_confirmed));
} break;
@ -148,9 +152,9 @@ FBXImporterManager::FBXImporterManager() {
fbx_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(fbx_path);
fbx_path_browse = memnew(Button);
hb->add_child(fbx_path_browse);
fbx_path_browse->set_text(TTR("Browse"));
fbx_path_browse->connect("pressed", callable_mp(this, &FBXImporterManager::_browse_install));
hb->add_child(fbx_path_browse);
hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->set_custom_minimum_size(Size2(400 * EDSCALE, 0));

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M2 1v14h2.707a2.501 2.501 0 0 1-.207-1A2.49 2.49 0 0 1 7 11.5c.565 0 1.083.188 1.5.5.417-.312.935-.5 1.5-.5s1.083.188 1.5.5a2.51 2.51 0 0 1 2.5-.293V6H9V1Zm8 0v4h4z" style="fill:#e0e0e0;fill-opacity:1"/><path d="M6.609 10.405a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" style="fill:#e0e0e0;stroke-width:20.4397;stroke-linecap:round" transform="translate(1.391 3.595)"/></svg>

After

Width:  |  Height:  |  Size: 499 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="16" height="16"><path d="M2 2a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3.738a2.505 2.505 0 0 1-.238-1.074 2.49 2.49 0 0 1 2.5-2.5c.565 0 1.083.187 1.5.5.417-.313.935-.5 1.5-.5s1.083.187 1.5.5a2.504 2.504 0 0 1 2.5-.295V6a1 1 0 0 0-1-1h-4a1 1 0 0 1-1-1V3a1 1 0 0 0-1-1Zm3.8 12.121zm.126.205zm9.293-3.586zm.187.115zm.42.36zm.123.14zm.125.17zm.135.227zm.25.719zM6.084 14.537zm.348.34zm.17.125zm.203.123zm.603.23.074.018c-.025-.005-.05-.012-.074-.018zm.35.06z" style="fill:#e0e0e0;fill-opacity:1"/><path d="M6.336 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" style="fill:#e0e0e0;stroke-width:20.4397;stroke-linecap:round" transform="translate(2.664 1)"/></svg>

After

Width:  |  Height:  |  Size: 768 B

View file

@ -778,6 +778,16 @@ void ProjectDialog::show_dialog() {
popup_centered(Size2(500, 0) * EDSCALE);
}
void ProjectDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
create_dir->set_icon(get_editor_theme_icon(SNAME("FolderCreate")));
project_browse->set_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
install_browse->set_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
} break;
}
}
void ProjectDialog::_bind_methods() {
ADD_SIGNAL(MethodInfo("project_created"));
ADD_SIGNAL(MethodInfo("projects_updated"));

View file

@ -129,6 +129,7 @@ private:
protected:
static void _bind_methods();
void _notification(int p_what);
public:
void set_mode(Mode p_mode);

View file

@ -1659,6 +1659,8 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
{
p_theme->set_stylebox("project_list", "ProjectManager", p_config.tree_panel_style);
p_theme->set_constant("sidebar_button_icon_separation", "ProjectManager", int(6 * EDSCALE));
p_theme->set_icon("browse_folder", "ProjectManager", p_theme->get_icon(SNAME("FolderBrowse"), EditorStringName(EditorIcons)));
p_theme->set_icon("browse_file", "ProjectManager", p_theme->get_icon(SNAME("FileBrowse"), EditorStringName(EditorIcons)));
// ProjectTag.
{

View file

@ -471,6 +471,10 @@ void EditorFileSystemImportFormatSupportQueryBlend::_browse_install() {
browse_dialog->popup_centered_ratio();
}
void EditorFileSystemImportFormatSupportQueryBlend::_update_icons() {
blender_path_browse->set_icon(blender_path_browse->get_editor_theme_icon(SNAME("FolderBrowse")));
}
bool EditorFileSystemImportFormatSupportQueryBlend::query() {
if (!configure_blender_dialog) {
configure_blender_dialog = memnew(ConfirmationDialog);
@ -486,10 +490,12 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
blender_path = memnew(LineEdit);
blender_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(blender_path);
blender_path_browse = memnew(Button);
hb->add_child(blender_path_browse);
blender_path_browse->set_text(TTR("Browse"));
blender_path_browse->connect("pressed", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_browse_install));
hb->add_child(blender_path_browse);
hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->set_custom_minimum_size(Size2(400 * EDSCALE, 0));
@ -515,6 +521,11 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
browse_dialog->connect("dir_selected", callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_select_install));
EditorNode::get_singleton()->get_gui_base()->add_child(browse_dialog);
// Update icons.
// This is a hack because we can't rely on notifications here as we don't receive them.
// Usually, we only have to wait for `NOTIFICATION_THEME_CHANGED` to update the icons.
callable_mp(this, &EditorFileSystemImportFormatSupportQueryBlend::_update_icons).call_deferred();
}
String path = EDITOR_GET("filesystem/import/blender/blender_path");

View file

@ -102,6 +102,8 @@ class EditorFileSystemImportFormatSupportQueryBlend : public EditorFileSystemImp
void _select_install(String p_path);
void _browse_install();
void _update_icons();
public:
virtual bool is_active() const override;
virtual Vector<String> get_file_extensions() const override;