From ba4a2a4c8b827201b18e97d9dd025ef93a4db754 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 2 Sep 2020 14:13:26 -0500 Subject: UI: Use instanced panel custom data instead of list index For modifier shortcuts we added a "custom_data" field to panels. This commit uses the same system for accessing the list data that corresponds to each panel. This way the context is only used once and the modifier for each panel can be accessed more easily later. This ends up being mostly a cleanup commit with a few small changes in interface_panel.c. The large changes in the UI functions are due to the fact that the panel custom data is now passed around as a single pointer instead of being created again for every panel. The list_index variable in Panel.runtime is removed as it's now unnecessary. Differential Revision: https://developer.blender.org/D8559 --- source/blender/modifiers/intern/MOD_remesh.c | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_remesh.c') diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 197d759c352..2c554a6b1a0 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -237,47 +237,45 @@ static Mesh *modifyMesh(ModifierData *UNUSED(md), #endif /* !WITH_MOD_REMESH */ -static void panel_draw(const bContext *C, Panel *panel) +static void panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; #ifdef WITH_MOD_REMESH uiLayout *row, *col; - PointerRNA ptr; PointerRNA ob_ptr; - modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - int mode = RNA_enum_get(&ptr, "mode"); + int mode = RNA_enum_get(ptr, "mode"); - uiItemR(layout, &ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); if (mode == MOD_REMESH_VOXEL) { - uiItemR(col, &ptr, "voxel_size", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "adaptivity", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "voxel_size", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "adaptivity", 0, NULL, ICON_NONE); } else { - uiItemR(col, &ptr, "octree_depth", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "octree_depth", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "scale", 0, NULL, ICON_NONE); if (mode == MOD_REMESH_SHARP_FEATURES) { - uiItemR(col, &ptr, "sharpness", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "sharpness", 0, NULL, ICON_NONE); } - uiItemR(layout, &ptr, "use_remove_disconnected", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_remove_disconnected", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, false); - uiLayoutSetActive(row, RNA_boolean_get(&ptr, "use_remove_disconnected")); - uiItemR(layout, &ptr, "threshold", 0, NULL, ICON_NONE); + uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_remove_disconnected")); + uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); } - uiItemR(layout, &ptr, "use_smooth_shade", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_smooth_shade", 0, NULL, ICON_NONE); - modifier_panel_end(layout, &ptr); + modifier_panel_end(layout, ptr); #else /* WITH_MOD_REMESH */ uiItemL(layout, IFACE_("Built without Remesh modifier"), ICON_NONE); - UNUSED_VARS(C); #endif /* WITH_MOD_REMESH */ } -- cgit v1.2.3