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_wave.c | 74 ++++++++++++++---------------- 1 file changed, 35 insertions(+), 39 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_wave.c') diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 26f1bf2d69a..ae0c59ed9ef 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -377,74 +377,71 @@ static void deformVertsEM(ModifierData *md, } } -static void panel_draw(const bContext *C, Panel *panel) +static void panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *sub, *row, *col; uiLayout *layout = panel->layout; - 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); uiLayoutSetPropSep(layout, true); row = uiLayoutRowWithHeading(layout, true, IFACE_("Motion")); - uiItemR(row, &ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); - uiItemR(row, &ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); + uiItemR(row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); + uiItemR(row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE); - uiItemR(layout, &ptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_cyclic", 0, NULL, ICON_NONE); row = uiLayoutRowWithHeading(layout, true, IFACE_("Along Normals")); - uiItemR(row, &ptr, "use_normal", 0, "", ICON_NONE); + uiItemR(row, ptr, "use_normal", 0, "", ICON_NONE); sub = uiLayoutRow(row, true); - uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_normal")); - uiItemR(sub, &ptr, "use_normal_x", UI_ITEM_R_TOGGLE, "X", ICON_NONE); - uiItemR(sub, &ptr, "use_normal_y", UI_ITEM_R_TOGGLE, "Y", ICON_NONE); - uiItemR(sub, &ptr, "use_normal_z", UI_ITEM_R_TOGGLE, "Z", ICON_NONE); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_normal")); + uiItemR(sub, ptr, "use_normal_x", UI_ITEM_R_TOGGLE, "X", ICON_NONE); + uiItemR(sub, ptr, "use_normal_y", UI_ITEM_R_TOGGLE, "Y", ICON_NONE); + uiItemR(sub, ptr, "use_normal_z", UI_ITEM_R_TOGGLE, "Z", ICON_NONE); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "falloff_radius", 0, "Falloff", ICON_NONE); - uiItemR(col, &ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, &ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, &ptr, "narrowness", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "falloff_radius", 0, "Falloff", ICON_NONE); + uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - modifier_vgroup_ui(layout, &ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); - modifier_panel_end(layout, &ptr); + modifier_panel_end(layout, ptr); } -static void position_panel_draw(const bContext *C, Panel *panel) +static void position_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA ptr; - modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); uiLayoutSetPropSep(layout, true); - uiItemR(layout, &ptr, "start_position_object", 0, IFACE_("Object"), ICON_NONE); + uiItemR(layout, ptr, "start_position_object", 0, IFACE_("Object"), ICON_NONE); col = uiLayoutColumn(layout, true); - uiItemR(col, &ptr, "start_position_x", 0, "Start Position X", ICON_NONE); - uiItemR(col, &ptr, "start_position_y", 0, "Y", ICON_NONE); + uiItemR(col, ptr, "start_position_x", 0, "Start Position X", ICON_NONE); + uiItemR(col, ptr, "start_position_y", 0, "Y", ICON_NONE); } -static void time_panel_draw(const bContext *C, Panel *panel) +static void time_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA ptr; - modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "time_offset", 0, "Offset", ICON_NONE); - uiItemR(col, &ptr, "lifetime", 0, "Life", ICON_NONE); - uiItemR(col, &ptr, "damping_time", 0, "Damping", ICON_NONE); - uiItemR(col, &ptr, "speed", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "time_offset", 0, "Offset", ICON_NONE); + uiItemR(col, ptr, "lifetime", 0, "Life", ICON_NONE); + uiItemR(col, ptr, "damping_time", 0, "Damping", ICON_NONE); + uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } static void texture_panel_draw(const bContext *C, Panel *panel) @@ -452,26 +449,25 @@ static void texture_panel_draw(const bContext *C, Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - 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 texture_coords = RNA_enum_get(&ptr, "texture_coords"); + int texture_coords = RNA_enum_get(ptr, "texture_coords"); - uiTemplateID(layout, C, &ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); + uiTemplateID(layout, C, ptr, "texture", "texture.new", NULL, NULL, 0, ICON_NONE, NULL); uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "texture_coords", 0, IFACE_("Coordinates"), ICON_NONE); + uiItemR(col, ptr, "texture_coords", 0, IFACE_("Coordinates"), ICON_NONE); if (texture_coords == MOD_DISP_MAP_OBJECT) { - uiItemR(col, &ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); - PointerRNA texture_coords_obj_ptr = RNA_pointer_get(&ptr, "texture_coords_object"); + uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); + PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); uiItemPointerR(col, - &ptr, + ptr, "texture_coords_bone", &texture_coords_obj_data_ptr, "bones", @@ -481,7 +477,7 @@ static void texture_panel_draw(const bContext *C, Panel *panel) } else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); - uiItemPointerR(col, &ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); + uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE); } } -- cgit v1.2.3