Commit: 0715b73e185ce483a245bd428b2dc86625deb7cd
Author: Bastien Montagne
Date:   Tue Jan 13 15:41:10 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB0715b73e185ce483a245bd428b2dc86625deb7cd

Recursive listdir: let user set level of recursion...

===================================================================

M       release/scripts/startup/bl_ui/space_filebrowser.py
M       source/blender/editors/space_file/file_ops.c
M       source/blender/editors/space_file/filelist.c
M       source/blender/editors/space_file/filelist.h
M       source/blender/editors/space_file/space_file.c
M       source/blender/makesdna/DNA_space_types.h
M       source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py 
b/release/scripts/startup/bl_ui/space_filebrowser.py
index 0af5d10..c99d00b 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -57,8 +57,8 @@ class FILEBROWSER_HT_header(Header):
             layout.prop(params, "display_type", expand=True, text="")
             layout.prop(params, "sort_method", expand=True, text="")
 
+            layout.prop(params, "recursion_level", slider=True)
             layout.prop(params, "show_hidden")
-            layout.prop(params, "use_flat_view")
             layout.prop(params, "use_filter", text="", icon='FILTER')
 
             row = layout.row(align=True)
diff --git a/source/blender/editors/space_file/file_ops.c 
b/source/blender/editors/space_file/file_ops.c
index c72810b..93f52cd 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -193,10 +193,10 @@ static FileSelect file_select_do(bContext *C, int 
selected_idx, bool do_diropen)
                                        /* avoids /../../ */
                                        BLI_parent_dir(params->dir);
 
-                                       if (params->flag & FILE_SHOWFLAT) {
-                                               /* Disable 'show flat' when 
going up in tree! */
-                                               params->flag &= ~FILE_SHOWFLAT;
-                                               
filelist_setrecursive(sfile->files, false);
+                                       if (params->recursion_level > 1) {
+                                               /* Disable 'dirtree' recursion 
when going up in tree! */
+                                               params->recursion_level = 1;
+                                               
filelist_setrecursion(sfile->files, params->recursion_level);
                                        }
                                }
                                else {
@@ -1046,10 +1046,10 @@ int file_parent_exec(bContext *C, wmOperator 
*UNUSED(unused))
                        else {
                                file_change_dir(C, 1);
                        }
-                       if (sfile->params->flag & FILE_SHOWFLAT) {
-                               /* Disable 'show flat' when going up in tree! */
-                               sfile->params->flag &= ~FILE_SHOWFLAT;
-                               filelist_setrecursive(sfile->files, false);
+                       if (sfile->params->recursion_level > 1) {
+                               /* Disable 'dirtree' recursion when going up in 
tree! */
+                               sfile->params->recursion_level = 1;
+                               filelist_setrecursion(sfile->files, 
sfile->params->recursion_level);
                        }
                        WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, 
NULL);
                }
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index 011a536..1fcb66f 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -244,7 +244,7 @@ typedef struct FileList {
 
        bool need_thumbnails;
 
-       bool use_recursion;
+       short max_recursion;
        short recursion_level;
 
        struct BlendHandle *libfiledata;
@@ -259,8 +259,6 @@ typedef struct FileList {
        bool (*filterf)(struct direntry *, const char *, FileListFilter *);
 } FileList;
 
-#define FILELIST_MAX_RECURSION 3
-
 #define FILENAME_IS_BREADCRUMBS(_n) \
        ((_n)[0] == '.' && ((_n)[1] == '\0' || ((_n)[1] == '.' && (_n)[2] == 
'\0')))
 
@@ -1029,10 +1027,10 @@ void filelist_setdir(struct FileList *filelist, char 
*r_dir)
        }
 }
 
-void filelist_setrecursive(struct FileList *filelist, const bool use_recursion)
+void filelist_setrecursion(struct FileList *filelist, const int 
recursion_level)
 {
-       if (filelist->use_recursion != use_recursion) {
-               filelist->use_recursion = use_recursion;
+       if (filelist->max_recursion != recursion_level) {
+               filelist->max_recursion = recursion_level;
                filelist->force_reset = true;
        }
 }
@@ -1684,7 +1682,7 @@ static void filelist_readjob_dir_lib_rec(
        *do_update = true;
 
        /* in case it's a lib we don't care anymore about max recursion 
level... */
-       if (!*stop && filelist->use_recursion && ((do_lib && is_lib) || 
(recursion_level < FILELIST_MAX_RECURSION))) {
+       if (!*stop && filelist->max_recursion && ((do_lib && is_lib) || 
(recursion_level < filelist->max_recursion))) {
                for (i = 0, file = files; i < num_files && !*stop; i++, file++) 
{
                        char subdir[FILE_MAX];
 
diff --git a/source/blender/editors/space_file/filelist.h 
b/source/blender/editors/space_file/filelist.h
index 04af8b5..de9ddb4 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -107,7 +107,7 @@ void                filelist_select(struct FileList 
*filelist, FileSelection *se
 void                filelist_select_file(struct FileList *filelist, int index, 
FileSelType select, unsigned int flag, FileCheckType check);
 bool                filelist_is_selected(struct FileList *filelist, int index, 
FileCheckType check);
 
-void                filelist_setrecursive(struct FileList *filelist, const 
bool use_recursion);
+void                filelist_setrecursion(struct FileList *filelist, const int 
recursion_level);
 
 struct BlendHandle *filelist_lib(struct FileList *filelist);
 bool                filelist_islibrary(struct FileList *filelist, char *dir, 
char **group);
diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index d1c0049..02e3dd2 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -202,7 +202,7 @@ static void file_refresh(const bContext *C, ScrArea 
*UNUSED(sa))
                params->active_file = -1; /* added this so it opens nicer (ton) 
*/
        }
        filelist_setdir(sfile->files, params->dir);
-       filelist_setrecursive(sfile->files, (params->flag & FILE_SHOWFLAT) != 
0);
+       filelist_setrecursion(sfile->files, params->recursion_level);
        filelist_setsorting(sfile->files, params->sort);
        filelist_setfilter_options(sfile->files, params->flag & FILE_HIDE_DOT,
                                                 false, /* TODO hide_parent, 
should be controllable? */
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 67056e5..13bc3cf 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -599,9 +599,10 @@ typedef struct FileSelectParams {
        short display; /* display mode flag */
        int filter; /* filter when (flags & FILE_FILTER) is true */
 
+       short recursion_level;  /* max number of levels in dirtree to show at 
once, 0 to disable recursion. */
+
        /* XXX --- still unused -- */
        short f_fp; /* show font preview */
-       short pad_s1;
        char fp_str[8]; /* string to use for font preview */
 
        /* XXX --- end unused -- */
@@ -700,7 +701,6 @@ typedef enum eFileSel_Params_Flag {
        FILE_FILTER         = (1 << 8),
        FILE_BOOKMARKS      = (1 << 9),
        FILE_GROUP_INSTANCE = (1 << 10),
-       FILE_SHOWFLAT       = (1 << 11),
 } eFileSel_Params_Flag;
 
 
@@ -732,6 +732,8 @@ typedef enum eDirEntry_SelectFlag {
        FILE_SEL_EDITING        = (1 << 4),
 } eDirEntry_SelectFlag;
 
+#define FILE_LIST_MAX_RECURSION 4
+
 /* Image/UV Editor ======================================== */
 
 /* Image/UV Editor */
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 9068f54..343e48c 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3512,9 +3512,13 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Display Mode", "Display mode for the 
file list");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
 
-       prop = RNA_def_property(srna, "use_flat_view", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_SHOWFLAT);
-       RNA_def_property_ui_text(prop, "Use Flat View", "Display all items 
found recursively from current position");
+       prop = RNA_def_property(srna, "recursion_level", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "recursion_level");
+       RNA_def_property_range(prop, 0, FILE_LIST_MAX_RECURSION);
+       RNA_def_property_ui_range(prop, 0, 3, 1, 1);
+       RNA_def_property_ui_text(prop, "Recursion Level",
+                                "Numbers of dirtree levels to show 
simultaneously "
+                                "(use '1' to only show .blend content flat, 
and '0' to disable completely)");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
 
        prop = RNA_def_property(srna, "use_filter", PROP_BOOLEAN, PROP_NONE);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to