[Bf-blender-cvs] [a5c580c] asset-experiments: Some tweaking to UI, try to make filebrowser header a bit more compact...

Bastien Montagne noreply at git.blender.org
Thu May 21 15:21:22 CEST 2015


Commit: a5c580c9e49a4ad96af4fce7d82f4fa262e5fddb
Author: Bastien Montagne
Date:   Thu May 21 15:20:53 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rBa5c580c9e49a4ad96af4fce7d82f4fa262e5fddb

Some tweaking to UI, try to make filebrowser header a bit more compact...

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

M	release/scripts/startup/bl_ui/space_filebrowser.py
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 29345b1..7637ddb 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -40,12 +40,10 @@ class FILEBROWSER_HT_header(Header):
         row.operator("file.parent", text="", icon='FILE_PARENT')
         row.operator("file.refresh", text="", icon='FILE_REFRESH')
 
-        row = layout.row()
-        row.separator()
-
-        row = layout.row(align=True)
+        layout.separator()
         layout.operator_context = 'EXEC_DEFAULT'
-        row.operator("file.directory_new", icon='NEWFOLDER')
+        layout.operator("file.directory_new", icon='NEWFOLDER', text="")
+        layout.separator()
 
         layout.operator_context = 'INVOKE_DEFAULT'
         params = st.params
@@ -54,13 +52,14 @@ class FILEBROWSER_HT_header(Header):
         if params:
             is_lib_browser = params.use_library_browsing
 
+            layout.prop(params, "recursion_level", text="")
+
             layout.prop(params, "display_type", expand=True, text="")
 
             layout.prop(params, "thumbnail_size", text="")
 
             layout.prop(params, "sort_method", expand=True, text="")
 
-            layout.prop(params, "recursion_level")
             layout.prop(params, "show_hidden", text="", icon='FILE_HIDDEN')
             layout.prop(params, "use_filter", text="", icon='FILTER')
 
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 4fcae18..6981914 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -222,6 +222,16 @@ static EnumPropertyItem buttons_texture_context_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
+
+static EnumPropertyItem fileselectparams_recursion_level_items[] = {
+	{0, "NONE",  0, "None", "Only list current directory's content, with no recursion"},
+	{1, "BLEND", 0, "Blend File", "List .blend files' content"},
+	{2, "ALL_1", 0, "One Level", "List all sub-directories' content, one level of recursion"},
+	{3, "ALL_2", 0, "Two Levels", "List all sub-directories' content, two levels of recursion"},
+	{4, "ALL_3", 0, "Three Levels", "List all sub-directories' content, three levels of recursion"},
+	{0, NULL, 0, NULL, NULL}
+};
+
 #ifdef RNA_RUNTIME
 
 #include "DNA_anim_types.h"
@@ -1531,6 +1541,30 @@ static int rna_FileSelectParams_use_lib_get(PointerRNA *ptr)
 	return params && (params->type == FILE_LOADLIB);
 }
 
+static EnumPropertyItem *rna_FileSelectParams_recursion_level_itemf(
+        bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
+{
+	FileSelectParams *params = ptr->data;
+
+	if (params && params->type != FILE_LOADLIB) {
+		EnumPropertyItem *item = NULL;
+		int totitem = 0;
+
+		RNA_enum_items_add_value(&item, &totitem, fileselectparams_recursion_level_items, 0);
+		RNA_enum_items_add_value(&item, &totitem, fileselectparams_recursion_level_items, 2);
+		RNA_enum_items_add_value(&item, &totitem, fileselectparams_recursion_level_items, 3);
+		RNA_enum_items_add_value(&item, &totitem, fileselectparams_recursion_level_items, 4);
+
+		RNA_enum_item_end(&item, &totitem);
+		*r_free = true;
+
+		return item;
+	}
+
+	*r_free = false;
+	return fileselectparams_recursion_level_items;
+}
+
 static void rna_FileBrowser_FSMenuEntry_path_get(PointerRNA *ptr, char *value)
 {
 	char *path = ED_fsmenu_entry_get_path(ptr->data);
@@ -3778,13 +3812,10 @@ 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, "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)");
+	prop = RNA_def_property(srna, "recursion_level", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, fileselectparams_recursion_level_items);
+	RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_FileSelectParams_recursion_level_itemf");
+	RNA_def_property_ui_text(prop, "Recursion", "Numbers of dirtree levels to show simultaneously");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
 
 	prop = RNA_def_property(srna, "use_filter", PROP_BOOLEAN, PROP_NONE);




More information about the Bf-blender-cvs mailing list