Commit: 17922955e71b819e8a08fc3fed351ad08c34025e
Author: Julian Eisel
Date:   Mon Aug 24 19:13:24 2020 +0200
Branches: asset-browser
https://developer.blender.org/rB17922955e71b819e8a08fc3fed351ad08c34025e

Add Asset Browser as sub-editor for the File Browser

This is the code design we agreed on to go with for now. See T73366.

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

M       source/blender/editors/space_file/space_file.c
M       source/blender/makesdna/DNA_space_types.h
M       source/blender/makesrna/RNA_enum_types.h
M       source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index 25658d5b7f9..04a0d341987 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -35,6 +35,8 @@
 #include "BKE_screen.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_message.h"
@@ -682,6 +684,25 @@ static void file_dropboxes(void)
   WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, 
filepath_drop_copy);
 }
 
+static int file_space_subtype_get(ScrArea *area)
+{
+  SpaceFile *sfile = area->spacedata.first;
+  return sfile->mode;
+}
+
+static void file_space_subtype_set(ScrArea *area, int value)
+{
+  SpaceFile *sfile = area->spacedata.first;
+  sfile->mode = value;
+}
+
+static void file_space_subtype_item_extend(bContext *UNUSED(C),
+                                           EnumPropertyItem **item,
+                                           int *totitem)
+{
+  RNA_enum_items_add(item, totitem, rna_enum_space_file_mode_items);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_file(void)
 {
@@ -701,6 +722,9 @@ void ED_spacetype_file(void)
   st->operatortypes = file_operatortypes;
   st->keymap = file_keymap;
   st->dropboxes = file_dropboxes;
+  st->space_subtype_item_extend = file_space_subtype_item_extend;
+  st->space_subtype_get = file_space_subtype_get;
+  st->space_subtype_set = file_space_subtype_set;
 
   /* regions: main window */
   art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 776d1f32043..31d0988e0f7 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -725,7 +725,9 @@ typedef struct SpaceFile {
   char _pad0[6];
   /* End 'SpaceLink' header. */
 
-  char _pad1[4];
+  char mode; /* eFileBrowse_Mode */
+
+  char _pad1[3];
   int scroll_offset;
 
   /** Config and input for file select. */
@@ -755,6 +757,14 @@ typedef struct SpaceFile {
   short systemnr, system_bookmarknr;
 } SpaceFile;
 
+/* SpaceFile.mode (File Space Browsing Mode) */
+typedef enum eFileBrowse_Mode {
+  /* Regular Blender File Browser */
+  FILE_BROWSE_MODE_REGULAR = 0,
+  /* Asset Browser */
+  FILE_BROWSE_MODE_ASSETS = 0,
+} eFileBrowse_Mode;
+
 /* FileSelectParams.display */
 enum eFileDisplayType {
   FILE_DEFAULTDISPLAY = 0,
diff --git a/source/blender/makesrna/RNA_enum_types.h 
b/source/blender/makesrna/RNA_enum_types.h
index fb9b62e729a..acaa4a05336 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -55,6 +55,7 @@ extern const EnumPropertyItem 
rna_enum_mesh_select_mode_items[];
 extern const EnumPropertyItem rna_enum_mesh_select_mode_uv_items[];
 extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[];
 extern const EnumPropertyItem rna_enum_space_graph_mode_items[];
+extern const EnumPropertyItem rna_enum_space_file_mode_items[];
 extern const EnumPropertyItem rna_enum_space_sequencer_view_type_items[];
 extern const EnumPropertyItem rna_enum_space_type_items[];
 extern const EnumPropertyItem rna_enum_space_image_mode_items[];
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index adfdd294d49..1753a1bf7ec 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -170,6 +170,12 @@ const EnumPropertyItem 
rna_enum_space_sequencer_view_type_items[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
+const EnumPropertyItem rna_enum_space_file_mode_items[] = {
+    {FILE_BROWSE_MODE_REGULAR, "REGULAR", ICON_FILEBROWSER, "File Browser", 
""},
+    {FILE_BROWSE_MODE_ASSETS, "ASSETS", ICON_BLANK1, "Asset Browser", ""},
+    {0, NULL, 0, NULL, NULL},
+};
+
 #define SACT_ITEM_DOPESHEET \
   { \
     SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all 
keyframes in scene" \
@@ -5856,6 +5862,14 @@ static void rna_def_space_filebrowser(BlenderRNA *brna)
 
   rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_TOOLS) | (1 
<< RGN_TYPE_UI));
 
+  prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, rna_enum_space_file_mode_items);
+  RNA_def_property_ui_text(
+      prop,
+      "Browsing Mode",
+      "Type of the File Editor view (regular file browsing or asset 
browsing)");
+  // RNA_def_property_update(prop, 0, "rna_SpaceFileBrowser_mode_update");
+
   prop = RNA_def_property(srna, "params", PROP_POINTER, PROP_NONE);
   RNA_def_property_pointer_sdna(prop, NULL, "params");
   RNA_def_property_ui_text(

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

Reply via email to