[Bf-blender-cvs] [3d0c5455edf] master: Cleanup: Store "is_active" instead of pointer property in panel type

Hans Goudey noreply at git.blender.org
Wed Dec 2 16:46:38 CET 2020


Commit: 3d0c5455edf4e32e6e8120b280710cb4b531e38a
Author: Hans Goudey
Date:   Mon Nov 30 17:43:14 2020 -0500
Branches: master
https://developer.blender.org/rB3d0c5455edf4e32e6e8120b280710cb4b531e38a

Cleanup: Store "is_active" instead of pointer property in panel type

This is consistent with the way other panel type fields are stored.

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

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/modifiers/intern/MOD_ui_common.c

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

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index dea9884f508..473a684eaba 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -234,6 +234,8 @@ typedef struct PanelType {
   char category[BKE_ST_MAXNAME];  /* for category tabs */
   char owner_id[BKE_ST_MAXNAME];  /* for work-spaces to selectively show. */
   char parent_id[BKE_ST_MAXNAME]; /* parent idname for sub-panels */
+  /** Boolean property identifier of the panel custom data. Used to draw a highlighted border. */
+  char active_property[BKE_ST_MAXNAME];
   short space_type;
   short region_type;
   /* For popovers, 0 for default. */
@@ -251,11 +253,6 @@ typedef struct PanelType {
   /* draw entirely, view changes should be handled here */
   void (*draw)(const struct bContext *C, struct Panel *panel);
 
-  /**
-   * Identifier of a boolean property of the panel custom data. Used to draw a highlighted border.
-   */
-  const char *active_property;
-
   /* For instanced panels corresponding to a list: */
 
   /** Reorder function, called when drag and drop finishes. */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index d1e5bbcb536..b60fa40f39a 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -589,7 +589,7 @@ static bool panel_use_active_highlight(const Panel *panel)
   BLI_assert(UI_panel_is_active(panel));
   BLI_assert(panel->type != NULL);
 
-  if (panel->type->active_property) {
+  if (panel->type->active_property[0] != '\0') {
     PointerRNA *ptr = UI_panel_custom_data_get(panel);
     if (ptr != NULL && !RNA_pointer_is_null(ptr)) {
       return RNA_boolean_get(ptr, panel->type->active_property);
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c
index 166d77624e8..fa5243c548f 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -409,6 +409,7 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type,
   BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME);
+  BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME);
 
   panel_type->draw_header = modifier_panel_header;
   panel_type->draw = draw;
@@ -417,7 +418,6 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type,
   /* Give the panel the special flag that says it was built here and corresponds to a
    * modifier rather than a #PanelType. */
   panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED;
-  panel_type->active_property = "is_active";
   panel_type->reorder = modifier_reorder;
   panel_type->get_list_data_expand_flag = get_modifier_expand_flag;
   panel_type->set_list_data_expand_flag = set_modifier_expand_flag;



More information about the Bf-blender-cvs mailing list