[Bf-blender-cvs] [ce6e34e1318] filebrowser_redesign: Move filter settings into popup

Julian Eisel noreply at git.blender.org
Mon Jul 22 19:36:51 CEST 2019


Commit: ce6e34e131840c99b25c2ca98a532ea7ec73f510
Author: Julian Eisel
Date:   Sat Jul 20 17:28:38 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rBce6e34e131840c99b25c2ca98a532ea7ec73f510

Move filter settings into popup

Saves space, hides complexity and is more consistent to other editors
(e.g. viewport and outliner). The search button is in the popup too for
now, we may want to move that later.
Note the filter popup is not located in the header, but in the directory
path (`UI`) region.

Had to do two additional changes:
* Allow registering a panel without drawing it in the default location.
  Required so we can register the popup panel in the `UI` region without
  it drawing there. For other places that's no issue because they are
  registered for headers - which don't draw panels anyway.
* `UI` regions are used for category tabs by default. Added a flag to
  allow region types to disable categories entirely.

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

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/makesrna/intern/rna_ui.c

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

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index af8a6ec424a..5f7023d5a25 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -49,35 +49,73 @@ class FILEBROWSER_HT_header(Header):
 
         layout.template_running_jobs()
 
-        if params:
-            layout.prop(params, "use_filter", text="", icon='FILTER')
 
-            row = layout.row(align=True)
-            row.active = params.use_filter
-            row.prop(params, "use_filter_folder", text="")
+class FILEBROWSER_PT_filter(Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'UI'
+    bl_label = "Filter"
+    bl_options = {'HIDDEN'}
 
-            if params.filter_glob:
-                # if st.active_operator and hasattr(st.active_operator, "filter_glob"):
-                #     row.prop(params, "filter_glob", text="")
-                row.label(text=params.filter_glob)
-            else:
-                row.prop(params, "use_filter_blender", text="")
-                row.prop(params, "use_filter_backup", text="")
-                row.prop(params, "use_filter_image", text="")
-                row.prop(params, "use_filter_movie", text="")
-                row.prop(params, "use_filter_script", text="")
-                row.prop(params, "use_filter_font", text="")
-                row.prop(params, "use_filter_sound", text="")
-                row.prop(params, "use_filter_text", text="")
+    def draw(self, context):
+        layout = self.layout
+
+        space = context.space_data
+        params = space.params
+        is_lib_browser = params.use_library_browsing
 
-            if is_lib_browser:
-                row.prop(params, "use_filter_blendid", text="")
-                if params.use_filter_blendid:
-                    row.separator()
-                    row.prop(params, "filter_id_category", text="")
+        row = layout.row(align=True)
+        row.prop(params, "use_filter", text="", toggle=0)
+        row.label(text="Filter:")
 
-            row.separator()
-            row.prop(params, "filter_search", text="", icon='VIEWZOOM')
+        col = layout.column()
+        col.active = params.use_filter
+
+        row = col.row()
+        row.label(icon='FILE_FOLDER')
+        row.prop(params, "use_filter_folder", text="Folders", toggle=0)
+
+        if params.filter_glob:
+            col.label(text=params.filter_glob)
+        else:
+            row = col.row()
+            row.label(icon='FILE_BLEND')
+            row.prop(params, "use_filter_blender", text=".blend Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_BACKUP')
+            row.prop(params, "use_filter_backup", text="Backup .blend Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_IMAGE')
+            row.prop(params, "use_filter_image", text="Image Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_MOVIE')
+            row.prop(params, "use_filter_movie", text="Movie Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_SCRIPT')
+            row.prop(params, "use_filter_script", text="Script Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_FONT')
+            row.prop(params, "use_filter_font", text="Font Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_SOUND')
+            row.prop(params, "use_filter_sound", text="Sound Files", toggle=0)
+            row = col.row()
+            row.label(icon='FILE_TEXT')
+            row.prop(params, "use_filter_text", text="Text Files", toggle=0)
+
+        col.separator()
+
+        if is_lib_browser:
+            row = col.row()
+            row.label(icon='BLANK1')  # Indentation
+            row.prop(params, "use_filter_blendid", text="Blender IDs", toggle=0)
+            if params.use_filter_blendid:
+                row = col.row()
+                row.label(icon='BLANK1')  # Indentation
+                row.prop(params, "filter_id_category", text="")
+
+                col.separator()
+
+        col.prop(params, "filter_search", text="", icon='VIEWZOOM')
 
 
 class FILEBROWSER_UL_dir(UIList):
@@ -238,7 +276,6 @@ class FILEBROWSER_PT_directory_path(Panel):
     bl_space_type = 'FILE_BROWSER'
     bl_region_type = 'UI'
     bl_label = "Directory Path"
-    bl_category = "Directory Path"
     bl_options = {'HIDE_HEADER'}
 
     def draw(self, context):
@@ -264,6 +301,13 @@ class FILEBROWSER_PT_directory_path(Panel):
         subrow = row.row(align=True)
         subrow.prop(params, "display_type", expand=True, text="")
 
+        # TODO down triangle only created for UI_LAYOUT_HEADER
+        row.popover(
+            panel="FILEBROWSER_PT_filter",
+            text="",
+            icon='FILTER',
+        )
+
         subrow = row.row(align=True)
         subrow.operator("file.directory_new", icon='NEWFOLDER', text="")
 
@@ -315,6 +359,7 @@ class FILEBROWSER_MT_view(Menu):
 
 classes = (
     FILEBROWSER_HT_header,
+    FILEBROWSER_PT_filter,
     FILEBROWSER_UL_dir,
     FILEBROWSER_PT_bookmarks_volumes,
     FILEBROWSER_PT_bookmarks_system,
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index dcf6d6c3907..02763b593fe 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -179,6 +179,8 @@ typedef struct ARegionType {
   /* header type definitions */
   ListBase headertypes;
 
+  int flag;
+
   /* hardcoded constraints, smaller than these values region is not visible */
   int minsizex, minsizey;
   /* when new region opens (region prefsizex/y are zero then */
@@ -192,6 +194,12 @@ typedef struct ARegionType {
   short event_cursor;
 } ARegionType;
 
+/* ARegionType.flag */
+enum {
+  /** Never show category tabs in this region type. */
+  RGN_TYPE_FLAG_NO_CATEGORIES = (1 << 8),
+};
+
 /* panel types */
 
 typedef struct PanelType {
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 9c5ce0c9d2c..a9d44f87004 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -245,6 +245,10 @@ static void panels_collapse_all(ScrArea *sa, ARegion *ar, const Panel *from_pa)
   for (pa = ar->panels.first; pa; pa = pa->next) {
     PanelType *pt = pa->type;
 
+    if (pt->flag & PNL_HIDDEN) {
+      continue;
+    }
+
     /* close panels with headers in the same context */
     if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) {
       if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) {
@@ -1977,6 +1981,9 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
   interp_v3_v3v3_uchar(
       theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f);
 
+  /* Should be handled on registration (don't register category if not supported in region). */
+  BLI_assert((ar->type->flag & RGN_TYPE_FLAG_NO_CATEGORIES) == 0);
+
   is_alpha = (ar->overlap && (theme_col_back[3] != 255));
 
   if (fstyle->kerning == 1) {
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index aeec2528b9d..9f0d0ddc71c 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2423,6 +2423,10 @@ void ED_region_panels_layout_ex(const bContext *C,
     PanelType *pt = pt_link->link;
     Panel *panel = UI_panel_find_by_type(&ar->panels, pt);
 
+    if (pt->flag & PNL_HIDDEN) {
+      continue;
+    }
+
     if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) {
       if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) {
         continue;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 59b22aa262f..5ffd42da39b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -689,6 +689,7 @@ void ED_spacetype_file(void)
   /* regions: ui */
   art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
   art->regionid = RGN_TYPE_UI;
+  art->flag = RGN_TYPE_FLAG_NO_CATEGORIES;
   art->keymapflag = ED_KEYMAP_UI;
   art->listener = file_ui_region_listener;
   art->init = file_ui_region_init;
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 0319993631c..e37d72ff8af 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -523,6 +523,7 @@ enum {
 #define PNL_DEFAULT_CLOSED 1
 #define PNL_NO_HEADER 2
 #define PNL_LAYOUT_VERT_BAR 4
+#define PNL_HIDDEN 8
 
 /* Fallback panel category (only for old scripts which need updating) */
 #define PNL_CATEGORY_FALLBACK "Misc"
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 82315605ee5..f037205ea3c 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -249,7 +249,20 @@ static StructRNA *rna_Panel_register(Main *bmain,
     return NULL;
   }
 
-  if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) {
+  if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type))) {
+    return NULL;
+  }
+
+  if (art->flag & RGN_TYPE_FLAG_NO_CATEGORIES) {
+    /* Skip category registration if region doesn't allow categories. */
+#  ifndef NDEBUG
+    if (dummypt.category[0] != '\0') {
+      printf("Category '%s' can't be registered, category tabs are disabled for this region.",
+             dummypt.category);
+    }
+#  endif
+  }
+  else if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) {
     if (dummypt.category[0] == '\0') {
       /* Use a fallback, otherwise an empty value will draw the panel in every category. */
       strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
@@ -272,10 +285,6 @@ static StructRNA *rna_Panel_register(Main *bmain,
     }
   }
 
-  if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type))) {
-    return NULL;
-  }
-
   /* check if we have

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list