diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-02 22:13:26 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-02 22:13:26 +0300 |
commit | ba4a2a4c8b827201b18e97d9dd025ef93a4db754 (patch) | |
tree | a71d6b72aaf0616ebda671bf4b011880b49bb280 /source/blender/modifiers/intern/MOD_displace.c | |
parent | ff7d74235023d0c927c0ad3f4d72d1c5dd41b240 (diff) |
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
Diffstat (limited to 'source/blender/modifiers/intern/MOD_displace.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 191623112bb..caee077c475 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -435,31 +435,30 @@ static void 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); PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data"); - PointerRNA texture_ptr = RNA_pointer_get(&ptr, "texture"); + PointerRNA texture_ptr = RNA_pointer_get(ptr, "texture"); bool has_texture = !RNA_pointer_is_null(&texture_ptr); - int texture_coords = RNA_enum_get(&ptr, "texture_coords"); + int texture_coords = RNA_enum_get(ptr, "texture_coords"); uiLayoutSetPropSep(layout, true); - 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); col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, has_texture); - 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", @@ -468,30 +467,30 @@ static void panel_draw(const bContext *C, Panel *panel) } } else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) { - 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); } uiItemS(layout); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "direction", 0, 0, ICON_NONE); - if (ELEM(RNA_enum_get(&ptr, "direction"), + uiItemR(col, ptr, "direction", 0, 0, ICON_NONE); + if (ELEM(RNA_enum_get(ptr, "direction"), MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ)) { - uiItemR(col, &ptr, "space", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "space", 0, NULL, ICON_NONE); } uiItemS(layout); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "mid_level", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "strength", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "mid_level", 0, NULL, ICON_NONE); - modifier_vgroup_ui(col, &ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); + modifier_vgroup_ui(col, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); - modifier_panel_end(layout, &ptr); + modifier_panel_end(layout, ptr); } static void panelRegister(ARegionType *region_type) |