[Bf-blender-cvs] [1da053956a9] master: UI: Category support for instanced panels

Hans Goudey noreply at git.blender.org
Wed Aug 12 18:56:24 CEST 2020


Commit: 1da053956a920c34324917becbfe1455b929c824
Author: Hans Goudey
Date:   Wed Aug 12 12:56:10 2020 -0400
Branches: master
https://developer.blender.org/rB1da053956a920c34324917becbfe1455b929c824

UI: Category support for instanced panels

This adds support for panel categories to the instanced panel system
used for modifiers and others. The change is pulled from D7997 where
it is needed for FCurve modifiers, but it is unused now.

The change is simple and basically amounts to checking the panel
category where it was overlooked before.

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

M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c

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

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 799a3b7fd5e..1b48ed8a7a1 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -117,7 +117,9 @@ typedef struct PanelSort {
 static int get_panel_real_size_y(const Panel *panel);
 static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state);
 static int compare_panel(const void *a1, const void *a2);
-static bool panel_type_context_poll(PanelType *panel_type, const char *context);
+static bool panel_type_context_poll(ARegion *region,
+                                    const PanelType *panel_type,
+                                    const char *context);
 
 static void panel_title_color_get(bool show_background, uchar color[4])
 {
@@ -460,14 +462,17 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
     return;
   }
 
-  char *context = drag_panel->type->context;
+  char *context = NULL;
+  if (!UI_panel_category_is_visible(region)) {
+    context = drag_panel->type->context;
+  }
 
   /* Find how many instanced panels with this context string. */
   int list_panels_len = 0;
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
     if (panel->type) {
-      if (panel_type_context_poll(panel->type, context)) {
-        if (panel->type->flag & PNL_INSTANCED) {
+      if (panel->type->flag & PNL_INSTANCED) {
+        if (panel_type_context_poll(region, panel->type, context)) {
           list_panels_len++;
         }
       }
@@ -479,8 +484,8 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
   PanelSort *sort_index = panel_sort;
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
     if (panel->type) {
-      if (panel_type_context_poll(panel->type, context)) {
-        if (panel->type->flag & PNL_INSTANCED) {
+      if (panel->type->flag & PNL_INSTANCED) {
+        if (panel_type_context_poll(region, panel->type, context)) {
           sort_index->panel = MEM_dupallocN(panel);
           sort_index->orig = panel;
           sort_index++;
@@ -657,11 +662,18 @@ static void panels_collapse_all(const bContext *C,
   set_panels_list_data_expand_flag(C, region);
 }
 
-static bool panel_type_context_poll(PanelType *panel_type, const char *context)
+static bool panel_type_context_poll(ARegion *region,
+                                    const PanelType *panel_type,
+                                    const char *context)
 {
+  if (UI_panel_category_is_visible(region)) {
+    return STREQ(panel_type->category, UI_panel_category_active_get(region, false));
+  }
+
   if (panel_type->context[0] && STREQ(panel_type->context, context)) {
     return true;
   }
+
   return false;
 }
 
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 58fb934ebf0..38bac3afef6 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2658,29 +2658,35 @@ void ED_region_panels_layout_ex(const bContext *C,
   if (has_instanced_panel) {
     LISTBASE_FOREACH (Panel *, panel, &region->panels) {
       if (panel->type == NULL) {
-        continue; /* Some panels don't have a type.. */
+        continue; /* Some panels don't have a type. */
       }
-      if (panel->type->flag & PNL_INSTANCED) {
-        if (panel && UI_panel_is_dragging(panel)) {
-          /* Prevent View2d.tot rectangle size changes while dragging panels. */
-          update_tot_size = false;
-        }
-
-        /* Use a unique identifier for instanced panels, otherwise an old block for a different
-         * panel of the same type might be found. */
-        char unique_panel_str[8];
-        UI_list_panel_unique_str(panel, unique_panel_str);
-        ed_panel_draw(C,
-                      area,
-                      region,
-                      &region->panels,
-                      panel->type,
-                      panel,
-                      (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w,
-                      em,
-                      vertical,
-                      unique_panel_str);
+      if (!(panel->type->flag & PNL_INSTANCED)) {
+        continue;
       }
+      if (use_category_tabs && panel->type->category[0] &&
+          !STREQ(category, panel->type->category)) {
+        continue;
+      }
+
+      if (panel && UI_panel_is_dragging(panel)) {
+        /* Prevent View2d.tot rectangle size changes while dragging panels. */
+        update_tot_size = false;
+      }
+
+      /* Use a unique identifier for instanced panels, otherwise an old block for a different
+       * panel of the same type might be found. */
+      char unique_panel_str[8];
+      UI_list_panel_unique_str(panel, unique_panel_str);
+      ed_panel_draw(C,
+                    area,
+                    region,
+                    &region->panels,
+                    panel->type,
+                    panel,
+                    (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w,
+                    em,
+                    vertical,
+                    unique_panel_str);
     }
   }



More information about the Bf-blender-cvs mailing list