Indicate project folders with special icon in File Browser

Using the dev-fund heart icon temporarily :)
This commit is contained in:
Julian Eisel 2022-10-07 15:58:14 +02:00
parent c8daddf7db
commit 9dc2bcf166
4 changed files with 24 additions and 1 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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)) {

View File

@ -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),