[Bf-blender-cvs] [52e857b129a] asset-browser: Some (partial dummy) additions to the Asset Browser UI

Julian Eisel noreply at git.blender.org
Tue Aug 25 03:02:19 CEST 2020


Commit: 52e857b129a28a6f626de78dc9ae6933a75a81b0
Author: Julian Eisel
Date:   Tue Aug 25 02:58:43 2020 +0200
Branches: asset-browser
https://developer.blender.org/rB52e857b129a28a6f626de78dc9ae6933a75a81b0

Some (partial dummy) additions to the Asset Browser UI

* Add search button
* Add filter and display options popups from the File Browser. These might have
  to be tweaked for the Asset Browser, but adding the buttons as a first step
  to fill the space.
* Add properties sidebar toggle button (gear icon, like in the File Browser)
* Add dummy repository selector
* Use placeholder icon for Asset Browser editor

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

M	release/scripts/startup/bl_ui/space_filebrowser.py
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 f8ff44fbb90..c102e921d46 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -28,16 +28,47 @@ class FILEBROWSER_HT_header(Header):
         layout = self.layout
 
         st = context.space_data
+        params = st.params
 
         if st.active_operator is None:
             layout.template_header()
 
         FILEBROWSER_MT_editor_menus.draw_collapsible(context, layout)
 
+        if panel_poll_is_asset_browsing(context):
+            layout.prop(params, "asset_repository", text="")
+
         # can be None when save/reload with a file selector open
 
         layout.separator_spacer()
 
+        if panel_poll_is_asset_browsing(context):
+            # Uses prop_with_popover() as popover() only adds the triangle icon in headers.
+            layout.prop_with_popover(
+                params,
+                "display_type",
+                panel="FILEBROWSER_PT_display",
+                text="",
+                icon_only=True,
+            )
+            layout.prop_with_popover(
+                params,
+                "display_type",
+                panel="FILEBROWSER_PT_filter",
+                text="",
+                icon='FILTER',
+                icon_only=True,
+            )
+
+            layout.prop(params, "filter_search", text="", icon='VIEWZOOM')
+
+            layout.operator(
+                "screen.region_toggle",
+                text="",
+                icon='PREFERENCES',
+                depress=is_option_region_visible(context, st)
+            ).region_type = 'TOOL_PROPS'
+
         if not context.screen.show_statusbar:
             layout.template_running_jobs()
 
@@ -361,6 +392,17 @@ class FILEBROWSER_PT_advanced_filter(Panel):
                         col.prop(filter_id, identifier, toggle=True)
 
 
+def is_option_region_visible(context, space):
+    if not space.active_operator:
+        return False
+
+    for region in context.area.regions:
+        if region.type == 'TOOL_PROPS' and region.width <= 1:
+            return False
+
+    return True
+
+
 class FILEBROWSER_PT_directory_path(Panel):
     bl_space_type = 'FILE_BROWSER'
     bl_region_type = 'UI'
@@ -375,16 +417,6 @@ class FILEBROWSER_PT_directory_path(Panel):
 
         return True
 
-    def is_option_region_visible(self, context, space):
-        if not space.active_operator:
-            return False
-
-        for region in context.area.regions:
-            if region.type == 'TOOL_PROPS' and region.width <= 1:
-                return False
-
-        return True
-
     def draw(self, context):
         layout = self.layout
         space = context.space_data
@@ -438,7 +470,7 @@ class FILEBROWSER_PT_directory_path(Panel):
                 "screen.region_toggle",
                 text="",
                 icon='PREFERENCES',
-                depress=self.is_option_region_visible(context, space)
+                depress=is_option_region_visible(context, space)
             ).region_type = 'TOOL_PROPS'
 
 
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index e62fadad07b..7e087e67367 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -260,8 +260,9 @@ static void file_ensure_valid_region_state(bContext *C,
     ARegion *region_execute = file_execute_region_ensure(area, region_tools);
     ARegion *region_props = file_tool_props_region_ensure(area, region_execute);
 
-    /* Properties are hidden by default. */
+    /* Hide specific regions by default. */
     region_props->flag |= RGN_FLAG_HIDDEN;
+    region_execute->flag |= RGN_FLAG_HIDDEN;
 
     ARegion *region_ui = BKE_area_find_region_type(area, RGN_TYPE_UI);
     if (region_ui) {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index cd5020d2edd..f79c49ee532 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -702,7 +702,8 @@ typedef struct FileSelectParams {
   short display;
   /** Details toggles (file size, creation date, etc.) */
   char details_flags;
-  char _pad2[3];
+  char _pad2[1];
+  short asset_repository;
   /** Filter when (flags & FILE_FILTER) is true. */
   int filter;
 
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 1ba902415a4..e15e86f57c0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -172,7 +172,7 @@ const EnumPropertyItem rna_enum_space_sequencer_view_type_items[] = {
 
 const EnumPropertyItem rna_enum_space_file_browse_mode_items[] = {
     {FILE_BROWSE_MODE_FILES, "FILES", ICON_FILEBROWSER, "File Browser", ""},
-    {FILE_BROWSE_MODE_ASSETS, "ASSETS", ICON_BLANK1, "Asset Browser", ""},
+    {FILE_BROWSE_MODE_ASSETS, "ASSETS", ICON_FUND, "Asset Browser", ""},
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -5690,6 +5690,11 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem asset_repository_dummy_items[] = {
+      {0, "BUNDLED", 0, "Bundled", "Show the default user assets"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "FileSelectParams", NULL);
   RNA_def_struct_path_func(srna, "rna_FileSelectParams_path");
   RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters");
@@ -5861,6 +5866,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
   RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
 
+  /* XXX dummy */
+  prop = RNA_def_property(srna, "asset_repository", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, asset_repository_dummy_items);
+  RNA_def_property_ui_text(prop, "Asset Repository", "");
+  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+
   prop = RNA_def_property(srna, "asset_category", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(prop, asset_category_items);
   RNA_def_property_enum_funcs(prop,



More information about the Bf-blender-cvs mailing list