[Bf-blender-cvs] [ce6cf2b4756] property-search-ui: Property Search: Various cleanups and comment changes

Hans Goudey noreply at git.blender.org
Tue Jul 28 23:12:10 CEST 2020


Commit: ce6cf2b4756b808fd4a5bc62ea8ab7df3f39d953
Author: Hans Goudey
Date:   Tue Jul 28 17:12:09 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rBce6cf2b4756b808fd4a5bc62ea8ab7df3f39d953

Property Search: Various cleanups and comment changes

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

M	release/scripts/startup/bl_ui/space_properties.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/buttons_ops.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index a6cff0b2787..ead39c7b6fa 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -33,7 +33,6 @@ class PROPERTIES_HT_header(Header):
         layout.prop(view, "filter_text", icon='VIEWZOOM', text="")
         layout.separator_spacer()
         
-        # Note: pin ID doesn't properly work with this simple button in python yet.
         row = layout.row()
         row.emboss = 'NONE'
         row.operator("buttons.toggle_pin", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="")
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 1d56cbb782d..a3fc66484d0 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -159,6 +159,9 @@ enum {
   UI_BLOCK_SHOW_SHORTCUT_ALWAYS = 1 << 23,
   /** All items have been removed from the block by the search filter. */
   UI_BLOCK_FILTERED_EMPTY = 1 << 24,
+  /** The block is only used during the layout process and will not be drawn,
+   * for the case of a subpanel of a closed panel. */
+  UI_BLOCK_SEARCH_ONLY = 1 << 25,
 };
 
 /** #uiPopupBlockHandle.menuretval */
@@ -674,7 +677,8 @@ enum {
 void UI_block_theme_style_set(uiBlock *block, char theme_style);
 char UI_block_emboss_get(uiBlock *block);
 void UI_block_emboss_set(uiBlock *block, char dt);
-bool UI_block_has_search_filter(uiBlock *block);
+bool UI_block_has_search_filter(const uiBlock *block);
+bool UI_block_is_search_only(const uiBlock *block);
 void UI_block_set_search_only(uiBlock *block, bool search_only);
 
 void UI_block_free(const struct bContext *C, uiBlock *block);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 0401e493f98..b8c0199cd28 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3369,7 +3369,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh
   block->dt = dt;
   block->evil_C = (void *)C; /* XXX */
 
-  /* Set the search filter in the properties editor. */
+  /* Set the search filter for the properties editor. */
   if ((region && region->regiontype == RGN_TYPE_WINDOW) &&
       (area && area->spacetype == SPACE_PROPERTIES)) {
     SpaceProperties *sbuts = CTX_wm_space_properties(C);
@@ -3425,14 +3425,19 @@ void UI_block_theme_style_set(uiBlock *block, char theme_style)
   block->theme_style = theme_style;
 }
 
-bool UI_block_has_search_filter(uiBlock *block)
+bool UI_block_has_search_filter(const uiBlock *block)
 {
   return block->search_filter != NULL && block->search_filter[0] != '\0';
 }
 
+bool UI_block_is_search_only(const uiBlock *block)
+{
+  return block->flag & UI_BLOCK_SEARCH_ONLY;
+}
+
 void UI_block_set_search_only(uiBlock *block, bool search_only)
 {
-  block->search_only = search_only;
+  SET_FLAG_FROM_TEST(block->flag, search_only, UI_BLOCK_SEARCH_ONLY);
 }
 
 static void ui_but_build_drawstr_float(uiBut *but, double value)
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index c080bea9a29..582be87a36b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -465,7 +465,6 @@ struct uiBlock {
   char display_device[64];
 
   char *search_filter;
-  bool search_only;
 
   struct PieMenuData pie_data;
 };
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 3ac38a4465e..37d45d6283b 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -85,6 +85,9 @@ typedef struct uiLayoutRoot {
   int type;
   int opcontext;
 
+  /** If true, the root will be removed as part of the property search process.
+   * Necessary for cases like searching the contents of closed panels, where the
+   * block-level tag isn't enough because there might be buttons in the header. */
   bool search_only;
 
   int emw, emh;
@@ -828,7 +831,8 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
    *   this doubles the icon_only parameter.
    * - we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
    *
-   * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
+   * Unfortunately, fixing this implies an API "soft break", so better to defer it for later...
+   * :/
    * - mont29
    */
 
@@ -1990,8 +1994,8 @@ static uiBut *ui_layout_heading_label_add(uiLayout *layout,
  */
 static uiLayout *ui_item_prop_split_layout_hack(uiLayout *layout_parent, uiLayout *layout_split)
 {
-  /* Tag item as using property split layout, this is inherited to children so they can get special
-   * treatment if needed. */
+  /* Tag item as using property split layout, this is inherited to children so they can get
+   * special treatment if needed. */
   layout_parent->item.flag |= UI_ITEM_INSIDE_PROP_SEP;
 
   if (layout_parent->item.type == ITEM_LAYOUT_ROW) {
@@ -2017,9 +2021,9 @@ void uiItemFullR(uiLayout *layout,
   char namestr[UI_MAX_NAME_STR];
   const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
   const bool inside_prop_sep = ((layout->item.flag & UI_ITEM_INSIDE_PROP_SEP) != 0);
-  /* Columns can define a heading to insert. If the first item added to a split layout doesn't have
-   * a label to display in the first column, the heading is inserted there. Otherwise it's inserted
-   * as a new row before the first item. */
+  /* Columns can define a heading to insert. If the first item added to a split layout doesn't
+   * have a label to display in the first column, the heading is inserted there. Otherwise it's
+   * inserted as a new row before the first item. */
   uiLayout *heading_layout = ui_layout_heading_find(layout);
   /* Although checkboxes use the split layout, they are an exception and should only place their
    * label in the second column, to not make that almost empty.
@@ -3277,7 +3281,8 @@ uiBut *uiItemL_respect_property_split(uiLayout *layout,
   if (layout->item.flag & UI_ITEM_PROP_SEP) {
     uiBlock *block = uiLayoutGetBlock(layout);
     uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout);
-    /* Further items added to 'layout' will automatically be added to split_wrapper.property_row */
+    /* Further items added to 'layout' will automatically be added to split_wrapper.property_row
+     */
 
     label_but = uiItemL_(split_wrapper.label_column, text, icon);
     UI_block_layout_set_current(block, split_wrapper.property_row);
@@ -5167,6 +5172,7 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only)
  * \{ */
 
 // #define PROPERTY_SEARCH_USE_TOOLTIPS
+// #define PROPERTY_SEARCH_USE_PANEL_LABELS
 #define DEBUG_LAYOUT_ROOTS
 
 static void ui_layout_free(uiLayout *layout);
@@ -5527,11 +5533,13 @@ static bool ui_block_search_layout(uiBlock *block)
 
   /* Also search based on panel labels. */
   bool panel_label_matches = false;
-  // if ((block->panel != NULL) && (block->panel->type != NULL)) {
-  //   if (BLI_strcasestr(block->panel->type->label, block->search_filter)) {
-  //     panel_label_matches = true;
-  //   }
-  // }
+#ifdef PROPERTY_SEARCH_USE_PANEL_LABELS
+  if ((block->panel != NULL) && (block->panel->type != NULL)) {
+    if (BLI_strcasestr(block->panel->type->label, block->search_filter)) {
+      panel_label_matches = true;
+    }
+  }
+#endif
 
   /* Apply search filter. */
   if (!panel_label_matches) {
@@ -5550,20 +5558,21 @@ static bool ui_block_search_layout(uiBlock *block)
     }
   }
 
-  /* Change layouts to the single column search layout. */
-  if (!all_roots_empty && !block->search_only) {
+  /* Replace label button strings with RNA property names. */
+  if (!all_roots_empty && !UI_block_is_search_only(block)) {
     ui_block_replace_labels(block);
   }
 
   /* Set empty flags. */
-  if (block->search_only) {
+  if (UI_block_is_search_only(block)) {
     /* Make sure all of the block's buttons are hidden. They might not have
      * been hidden if a layout wasn't searched. */
     LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
       but->flag |= UI_HIDDEN;
     }
   }
-  SET_FLAG_FROM_TEST(block->flag, all_roots_empty || block->search_only, UI_BLOCK_FILTERED_EMPTY);
+  SET_FLAG_FROM_TEST(
+      block->flag, all_roots_empty || UI_block_is_search_only(block), UI_BLOCK_FILTERED_EMPTY);
   if (block->panel != NULL) {
     ui_panel_set_search_filtered(block->panel, all_roots_empty);
   }
@@ -5577,7 +5586,7 @@ static bool ui_block_search_layout(uiBlock *block)
   }
 #endif
 
-  return all_roots_empty || block->search_only;
+  return all_roots_empty || UI_block_is_search_only(block);
 }
 
 /** \} */
@@ -6118,9 +6127,9 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout,
       panel->layout = NULL;
     }
 
-    /* draw_header() is often used to add a checkbox to the header. If we add the label like below
-     * the label is disconnected from the checkbox, adding a weird looking gap. As workaround, let
-     * the checkbox add the label instead. */
+    /* draw_header() is often used to add a checkbox to the header. If we add the label like
+     * below the label is disconnected from the checkbox, adding a weird looking gap. As
+     * workaround, let the checkbox add the label instead. */
     if (!ui_layout_has_panel_label(row, pt)) {
       uiItemL(row, CTX_IFACE_(pt->translation_context, pt->label), ICON_NONE);
     }
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index bbe3668e756..bde7fc47ff7 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1689,14 +1689,14 @@ void UI_panels_draw(const bContext *C, ARegion *region)
    * and we need child panels to draw on top. */
   LISTBASE_FOREACH_BACKWARD (uiBlock *, block, &region->uiblocks) {
     if (block->acti

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list