[Bf-blender-cvs] [170a40c338b] property-search-ui: Property Search: Sort filtered panels properly

Hans Goudey noreply at git.blender.org
Thu Jun 25 22:53:26 CEST 2020


Commit: 170a40c338bd5b6c12d87e1f58cde81922e10b8c
Author: Hans Goudey
Date:   Thu Jun 25 16:53:18 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rB170a40c338bd5b6c12d87e1f58cde81922e10b8c

Property Search: Sort filtered panels properly

Instead of just putting the filtered panels at the bottom, or not updating
their search order, we stop increasing the offset while the current panel
is invisible. This way the order is not completely broken if you drag to
reorder a panel while some have been filtered out.

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

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

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

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index eee7ae73047..855bb9f777d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1391,17 +1391,17 @@ static int find_highest_panel(const void *a1, const void *a2)
 {
   const PanelSort *ps1 = a1, *ps2 = a2;
 
-  /* Sort search-filtered panels to the bottom */
-  if (ps1->panel->runtime_flag & PNL_SEARCH_FILTERED &&
-      ps2->panel->runtime_flag & PNL_SEARCH_FILTERED) {
-    /* Skip and check for offset and sort order below. */
-  }
-  else if (ps2->panel->runtime_flag & PNL_SEARCH_FILTERED) {
-    return -1;
-  }
-  else if (ps1->panel->runtime_flag & PNL_SEARCH_FILTERED) {
-    return 1;
-  }
+  // /* Sort search-filtered panels to the bottom */
+  // if (ps1->panel->runtime_flag & PNL_SEARCH_FILTERED &&
+  //     ps2->panel->runtime_flag & PNL_SEARCH_FILTERED) {
+  //   /* Skip and check for offset and sort order below. */
+  // }
+  // else if (ps2->panel->runtime_flag & PNL_SEARCH_FILTERED) {
+  //   return -1;
+  // }
+  // else if (ps1->panel->runtime_flag & PNL_SEARCH_FILTERED) {
+  //   return 1;
+  // }
 
   /* stick uppermost header-less panels to the top of the region -
    * prevent them from being sorted (multiple header-less panels have to be sorted though) */
@@ -1532,14 +1532,19 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
   ps->panel->ofsy = -get_panel_size_y(ps->panel);
   ps->panel->ofsx += ps->panel->runtime.region_ofsx;
 
+  PanelSort *ps_last_visible = ps;
+
   for (a = 0; a < tot - 1; a++, ps++) {
     psnext = ps + 1;
 
     if (align == BUT_VERTICAL) {
-      bool use_box = ps->panel->type && ps->panel->type->flag & PNL_DRAW_BOX;
+      bool use_box = ps_last_visible->panel->type &&
+                     ps_last_visible->panel->type->flag & PNL_DRAW_BOX;
       bool use_box_next = psnext->panel->type && psnext->panel->type->flag & PNL_DRAW_BOX;
-      psnext->panel->ofsx = ps->panel->ofsx;
-      psnext->panel->ofsy = get_panel_real_ofsy(ps->panel) - get_panel_size_y(psnext->panel);
+
+      psnext->panel->ofsx = ps_last_visible->panel->ofsx;
+      psnext->panel->ofsy = get_panel_real_ofsy(ps_last_visible->panel) -
+                            get_panel_size_y(psnext->panel);
 
       /* Extra margin for box style panels. */
       ps->panel->ofsx += (use_box) ? UI_PANEL_BOX_STYLE_MARGIN : 0.0f;
@@ -1552,6 +1557,10 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
       psnext->panel->ofsy = ps->panel->ofsy + get_panel_size_y(ps->panel) -
                             get_panel_size_y(psnext->panel);
     }
+
+    if (!UI_panel_is_search_filtered(psnext->panel)) {
+      ps_last_visible = psnext;
+    }
   }
   /* Extra margin for the last panel if it's a box-style panel. */
   if (panelsort[tot - 1].panel->type && panelsort[tot - 1].panel->type->flag & PNL_DRAW_BOX) {
@@ -1575,7 +1584,7 @@ static bool uiAlignPanelStep(ScrArea *area, ARegion *region, const float fac, co
 
   /* set locations for tabbed and sub panels */
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
-    if (panel->runtime_flag & PNL_ACTIVE) {
+    if ((panel->runtime_flag & PNL_ACTIVE) && !UI_panel_is_search_filtered(panel)) {
       if (panel->children.first) {
         align_sub_panels(panel);
       }



More information about the Bf-blender-cvs mailing list