[Bf-blender-cvs] [aed5b88ec1a] master: Asset System: Disable Asset Browser as experimental feature

Julian Eisel noreply at git.blender.org
Wed Jan 13 11:10:39 CET 2021


Commit: aed5b88ec1a651faad5f4a95828e1b9d907f0af4
Author: Julian Eisel
Date:   Wed Jan 13 00:52:10 2021 +0100
Branches: master
https://developer.blender.org/rBaed5b88ec1a651faad5f4a95828e1b9d907f0af4

Asset System: Disable Asset Browser as experimental feature

The Asset Browser will be disabled and not available for the 2.92 release. In
alpha/beta builds, there will be an "Asset Browser" option under Preferences >
Experimental, if the developer extras are enabled.
Note that this also disables related UI elements (e.g. "Mark Asset" buttons,
Preferences settings for asset libraries, etc.).

The code is still in master of course, development and testing will continue
there. But there simply needs to be too much polishing and fixing before the
2.92 release, plus there are some design decisions to be reevaluated.

Check the milestone 1 project to follow ongoing work:
https://developer.blender.org/project/view/124/

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

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/asset/asset_ops.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 73a12e5d1c7..ef4f47c9399 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -197,7 +197,8 @@ class FILEBROWSER_PT_filter(Panel):
 
                 sub = row.column(align=True)
 
-                sub.prop(params, "use_filter_asset_only")
+                if context.preferences.experimental.use_asset_browser:
+                    sub.prop(params, "use_filter_asset_only")
 
                 filter_id = params.filter_id
                 for identifier in dir(filter_id):
@@ -390,7 +391,8 @@ class FILEBROWSER_PT_advanced_filter(Panel):
                 layout.separator()
                 col = layout.column(align=True)
 
-                col.prop(params, "use_filter_asset_only")
+                if context.preferences.experimental.use_asset_browser:
+                    col.prop(params, "use_filter_asset_only")
 
                 filter_id = params.filter_id
                 for identifier in dir(filter_id):
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 0b77d8a2538..22c0ce7f56b 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1342,6 +1342,11 @@ class USERPREF_PT_saveload_autorun(FilePathsPanel, Panel):
 class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel):
     bl_label = "Asset Libraries"
 
+    @classmethod
+    def poll(cls, context):
+        prefs = context.preferences
+        return prefs.experimental.use_asset_browser
+
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = False
@@ -2188,14 +2193,21 @@ class ExperimentalPanel:
         layout.use_property_split = False
         layout.use_property_decorate = False
 
-        for prop_keywords, task in items:
+        for prop_keywords, reference in items:
             split = layout.split(factor=0.66)
             col = split.split()
             col.prop(experimental, **prop_keywords)
 
-            if task:
+            if reference:
+                if type(reference) is tuple:
+                    url_ext = reference[0]
+                    text = reference[1]
+                else:
+                    url_ext = reference
+                    text = reference
+
                 col = split.split()
-                col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task
+                col.operator("wm.url_open", text=text, icon='URL').url = self.url_prefix + url_ext
 
 
 """
@@ -2225,6 +2237,7 @@ class USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel):
                 ({"property": "use_switch_object_operator"}, "T80402"),
                 ({"property": "use_sculpt_tools_tilt"}, "T82877"),
                 ({"property": "use_object_add_tool"}, "T57210"),
+                ({"property": "use_asset_browser"}, ("project/profile/124/", "Milestone 1")),
             ),
         )
 
diff --git a/source/blender/editors/asset/asset_ops.c b/source/blender/editors/asset/asset_ops.c
index 929d49e19fa..29c3174f051 100644
--- a/source/blender/editors/asset/asset_ops.c
+++ b/source/blender/editors/asset/asset_ops.c
@@ -26,8 +26,10 @@
 
 #include "BLI_listbase.h"
 #include "BLI_string_utils.h"
+#include "BLI_utildefines.h"
 
 #include "DNA_asset_types.h"
+#include "DNA_userdef_types.h"
 
 #include "ED_asset.h"
 
@@ -47,6 +49,11 @@ struct AssetMarkResultStats {
   ID *last_id;
 };
 
+static bool asset_ops_poll(bContext *UNUSED(C))
+{
+  return U.experimental.use_asset_browser;
+}
+
 /**
  * Return the IDs to operate on as list of #CollectionPointerLink links. Needs freeing.
  */
@@ -146,6 +153,7 @@ static void ASSET_OT_mark(wmOperatorType *ot)
   ot->idname = "ASSET_OT_mark";
 
   ot->exec = asset_mark_exec;
+  ot->poll = asset_ops_poll;
 
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
@@ -225,6 +233,7 @@ static void ASSET_OT_clear(wmOperatorType *ot)
   ot->idname = "ASSET_OT_clear";
 
   ot->exec = asset_clear_exec;
+  ot->poll = asset_ops_poll;
 
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 09e3d39c603..24a9558d095 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -954,7 +954,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
   }
 
   /* If the button reprents an id, it can set the "id" context pointer. */
-  if (ED_asset_can_make_single_from_context(C)) {
+  if (U.experimental.use_asset_browser && ED_asset_can_make_single_from_context(C)) {
     ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data;
 
     /* Gray out items depending on if data-block is an asset. Preferably this could be done via
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 774dc54700c..aedc6228355 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -776,7 +776,13 @@ static void file_space_subtype_item_extend(bContext *UNUSED(C),
                                            EnumPropertyItem **item,
                                            int *totitem)
 {
-  RNA_enum_items_add(item, totitem, rna_enum_space_file_browse_mode_items);
+  if (U.experimental.use_asset_browser) {
+    RNA_enum_items_add(item, totitem, rna_enum_space_file_browse_mode_items);
+  }
+  else {
+    RNA_enum_items_add_value(
+        item, totitem, rna_enum_space_file_browse_mode_items, FILE_BROWSE_MODE_FILES);
+  }
 }
 
 static const char *file_context_dir[] = {"active_file", "active_id", NULL};
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index f6d6e771801..2a2803c58dd 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -1791,6 +1791,9 @@ static bool outliner_id_operation_item_poll(bContext *C,
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
 
   switch (enum_value) {
+    case OUTLINER_IDOP_MARK_ASSET:
+    case OUTLINER_IDOP_CLEAR_ASSET:
+      return U.experimental.use_asset_browser;
     case OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE:
     case OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE_HIERARCHY:
       return true;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index d9ee9a27294..51699dae641 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -644,7 +644,8 @@ typedef struct UserDef_Experimental {
   char use_switch_object_operator;
   char use_sculpt_tools_tilt;
   char use_object_add_tool;
-  char _pad[7];
+  char use_asset_browser;
+  char _pad[6];
   /** `makesdna` does not allow empty structs. */
 } UserDef_Experimental;
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index f5a11719912..3a4e395c914 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6229,6 +6229,13 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "use_object_add_tool", 1);
   RNA_def_property_ui_text(
       prop, "Add Object Tool", "Show add object tool in the toolbar in Object Mode and Edit Mode");
+
+  prop = RNA_def_property(srna, "use_asset_browser", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "use_asset_browser", 1);
+  RNA_def_property_ui_text(
+      prop,
+      "Asset Browser",
+      "Enable Asset Browser editor and operators to manage data-blocks as asset");
 }
 
 static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)



More information about the Bf-blender-cvs mailing list