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

This is consistent with the way other panel type fields are stored.
This commit is contained in:
Hans Goudey 2020-11-30 17:43:14 -05:00 committed by Jacques Lucke
parent 9281a1f4eb
commit 3d0c5455ed
3 changed files with 4 additions and 7 deletions

View File

@ -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. */

View File

@ -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);

View File

@ -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;