[Bf-blender-cvs] [f9fbe4efd67] master: Cleanup: Improve property search related comments panel code

Hans Goudey noreply at git.blender.org
Wed Nov 4 22:31:03 CET 2020


Commit: f9fbe4efd67e364940c5813d4201dcf1a26c65af
Author: Hans Goudey
Date:   Wed Nov 4 15:30:56 2020 -0600
Branches: master
https://developer.blender.org/rBf9fbe4efd67e364940c5813d4201dcf1a26c65af

Cleanup: Improve property search related comments panel code

The comments related to property search changes should be generally
more correct and more helpful.

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

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 de281724afe..af7b674df7f 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -259,7 +259,7 @@ static Panel *panel_add_instanced(ARegion *region,
                                   PanelType *panel_type,
                                   PointerRNA *custom_data)
 {
-  Panel *panel = MEM_callocN(sizeof(Panel), "instanced panel");
+  Panel *panel = MEM_callocN(sizeof(Panel), __func__);
   panel->type = panel_type;
   BLI_strncpy(panel->panelname, panel_type->idname, sizeof(panel->panelname));
 
@@ -466,7 +466,7 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
   }
 
   /* Sort the matching instanced panels by their display order. */
-  PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), "instancedpanelsort");
+  PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), __func__);
   PanelSort *sort_index = panel_sort;
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
     if (panel->type) {
@@ -571,8 +571,8 @@ static void get_panel_expand_flag(Panel *panel, short *flag, short *flag_index)
  * Call the callback to store the panel and sub-panel expansion settings in the list item that
  * corresponds to each instanced panel.
  *
- * \note This needs to iterate through all of the regions panels because the panel with changed
- * expansion could have been the sub-panel of a instanced panel, meaning it might not know
+ * \note This needs to iterate through all of the region's panels because the panel with changed
+ * expansion might have been the sub-panel of an instanced panel, meaning it might not know
  * which list item it corresponds to.
  */
 static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *region)
@@ -681,7 +681,7 @@ Panel *UI_panel_begin(
   const bool newpanel = (panel == NULL);
 
   if (newpanel) {
-    panel = MEM_callocN(sizeof(Panel), "new panel");
+    panel = MEM_callocN(sizeof(Panel), __func__);
     panel->type = pt;
     BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname));
 
@@ -753,8 +753,8 @@ Panel *UI_panel_begin(
 
 /**
  * Create the panel header button group, used to mark which buttons are part of
- * panel headers for later panel search handling. Should be called before adding
- * buttons for the panel's header layout.
+ * panel headers for the panel search process that happens later. This Should be
+ * called before adding buttons for the panel's header layout.
  */
 void UI_panel_header_buttons_begin(Panel *panel)
 {
@@ -764,20 +764,20 @@ void UI_panel_header_buttons_begin(Panel *panel)
 }
 
 /**
- * Allow new button groups to be created after the header group.
+ * Finish the button group for the panel header to avoid putting panel body buttons in it.
  */
 void UI_panel_header_buttons_end(Panel *panel)
 {
   uiBlock *block = panel->runtime.block;
 
-  /* There should always be the button group created in #UI_panel_header_buttons_begin. */
+  /* A button group should always be created in #UI_panel_header_buttons_begin. */
   BLI_assert(!BLI_listbase_is_empty(&block->button_groups));
 
   uiButtonGroup *button_group = block->button_groups.last;
 
   button_group->flag &= ~UI_BUTTON_GROUP_LOCK;
 
-  /* Repurpose the first "header" button group if it is empty, in case the first button added to
+  /* Repurpose the first header button group if it is empty, in case the first button added to
    * the panel doesn't add a new group (if the button is created directly rather than through an
    * interface layout call). */
   if (BLI_listbase_is_single(&block->button_groups) &&
@@ -785,9 +785,9 @@ void UI_panel_header_buttons_end(Panel *panel)
     button_group->flag &= ~UI_BUTTON_GROUP_PANEL_HEADER;
   }
   else {
-    /* We should still always add a new button group. Although this results in many empty groups,
-     * without it, new buttons not protected with a #ui_block_new_button_group call would end up
-     * in the panel header group. */
+    /* Always add a new button group. Although this may result in many empty groups, without it,
+     * new buttons in the panel body not protected with a #ui_block_new_button_group call would
+     * end up in the panel header group. */
     ui_block_new_button_group(block, 0);
   }
 }
@@ -934,14 +934,16 @@ static void region_panels_set_expansion_from_seach_filter(const bContext *C,
                                                           const bool use_search_closed)
 {
   LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+    /* Don't check if the panel is active, otherwise the expansion won't
+     * be correct when switching back to tab after exiting search. */
     panel_set_expansion_from_seach_filter_recursive(C, panel, use_search_closed);
   }
   set_panels_list_data_expand_flag(C, region);
 }
 
 /**
- * Hide buttons in invisible layouts, which are created because in order to search,
- * buttons must be added for all panels, even panels that will end up closed.
+ * Hide buttons in invisible layouts, which are created because buttons must be
+ * added for all panels in order to search, even panels that will end up closed.
  */
 static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *parent_panel)
 {



More information about the Bf-blender-cvs mailing list