[Bf-blender-cvs] [9dc2bcf1662] blender-projects-basics: Indicate project folders with special icon in File Browser
Julian Eisel
noreply at git.blender.org
Fri Oct 7 16:06:20 CEST 2022
Commit: 9dc2bcf16627279429381c1f07f9cfe82995851d
Author: Julian Eisel
Date: Fri Oct 7 15:58:14 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB9dc2bcf16627279429381c1f07f9cfe82995851d
Indicate project folders with special icon in File Browser
Using the dev-fund heart icon temporarily :)
===================================================================
M source/blender/blenkernel/BKE_blender_project.h
M source/blender/blenkernel/intern/blender_project.cc
M source/blender/editors/space_file/filelist.cc
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_blender_project.h b/source/blender/blenkernel/BKE_blender_project.h
index 0646e017d1f..2127e837d8d 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -29,7 +29,12 @@ BlenderProject *BKE_project_active_get(void) ATTR_WARN_UNUSED_RESULT;
*/
void BKE_project_active_unset(void);
/**
- * Check if \a path points into the project root path (i.e. if one of the ancestors of the
+ * Check if \a path references a project root directory. Will return false for paths pointing into
+ * the project root directory.
+ */
+bool BKE_project_is_path_project_root(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+/**
+ * Check if \a path points to or into a project root path (i.e. if one of the ancestors of the
* referenced file/directory is a project root directory).
*/
bool BKE_project_contains_path(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenkernel/intern/blender_project.cc b/source/blender/blenkernel/intern/blender_project.cc
index 7b5027bb487..990649008d9 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -318,6 +318,11 @@ void BKE_project_active_unset(void)
bke::BlenderProject::set_active_from_settings(nullptr);
}
+bool BKE_project_is_path_project_root(const char *path)
+{
+ return bke::path_contains_project_settings(path);
+}
+
bool BKE_project_contains_path(const char *path)
{
const StringRef found_root_path = bke::BlenderProject::project_root_path_find_from_path(path);
diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index c2dc8e9196d..4ab69eb82c2 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -42,6 +42,7 @@
#include "BKE_asset.h"
#include "BKE_asset_library.h"
+#include "BKE_blender_project.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_icons.h"
@@ -1171,6 +1172,10 @@ static int filelist_geticon_ex(const FileDirEntry *file,
{
const eFileSel_File_Types typeflag = (eFileSel_File_Types)file->typeflag;
+ if ((typeflag & FILE_TYPE_DIR) && (typeflag & FILE_TYPE_BLENDER_PROJECT)) {
+ return ICON_FUND;
+ }
+
if ((typeflag & FILE_TYPE_DIR) &&
!(ignore_libdir && (typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER)))) {
if (FILENAME_IS_PARENT(file->relpath)) {
@@ -2941,6 +2946,12 @@ static int filelist_readjob_list_dir(const char *root,
}
}
+ if ((entry->typeflag & FILE_TYPE_DIR) && !(entry->typeflag & FILE_TYPE_BLENDER)) {
+ if (BKE_project_is_path_project_root(target)) {
+ entry->typeflag |= FILE_TYPE_BLENDER_PROJECT;
+ }
+ }
+
#ifndef WIN32
/* Set linux-style dot files hidden too. */
if (is_hidden_dot_filename(entry->relpath, entry)) {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 0413fe36ec0..aab24d22a6c 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1083,6 +1083,8 @@ typedef enum eFileSel_File_Types {
FILE_TYPE_VOLUME = (1 << 19),
FILE_TYPE_ASSET = (1 << 28),
+ /** Directory is a Blender project root directory. */
+ FILE_TYPE_BLENDER_PROJECT = (1 << 29),
/** An FS directory (i.e. S_ISDIR on its path is true). */
FILE_TYPE_DIR = (1 << 30),
FILE_TYPE_BLENDERLIB = (1u << 31),
More information about the Bf-blender-cvs
mailing list