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_meshcache.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_meshcache.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshcache.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 2041b7a25db..456ece7704b 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -297,72 +297,69 @@ static void deformVertsEM(ModifierData *md, meshcache_do(mcmd, scene, ctx->object, vertexCos, numVerts); } -static void panel_draw(const bContext *C, Panel *panel) +static void panel_draw(const bContext *UNUSED(C), Panel *panel) { 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, "cache_format", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "filepath", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "cache_format", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "filepath", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "factor", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(layout, &ptr, "deform_mode", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "interpolation", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "factor", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "deform_mode", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "interpolation", 0, NULL, ICON_NONE); - modifier_panel_end(layout, &ptr); + modifier_panel_end(layout, ptr); } -static void time_remapping_panel_draw(const bContext *C, Panel *panel) +static void time_remapping_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA ptr; - modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); - uiItemR(layout, &ptr, "time_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "time_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiLayoutSetPropSep(layout, true); - uiItemR(layout, &ptr, "play_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "play_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - if (RNA_enum_get(&ptr, "play_mode") == MOD_MESHCACHE_PLAY_CFEA) { - uiItemR(layout, &ptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "frame_scale", 0, NULL, ICON_NONE); + if (RNA_enum_get(ptr, "play_mode") == MOD_MESHCACHE_PLAY_CFEA) { + uiItemR(layout, ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "frame_scale", 0, NULL, ICON_NONE); } else { /* play_mode == MOD_MESHCACHE_PLAY_EVAL */ - int time_mode = RNA_enum_get(&ptr, "time_mode"); + int time_mode = RNA_enum_get(ptr, "time_mode"); if (time_mode == MOD_MESHCACHE_TIME_FRAME) { - uiItemR(layout, &ptr, "eval_frame", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_frame", 0, NULL, ICON_NONE); } else if (time_mode == MOD_MESHCACHE_TIME_SECONDS) { - uiItemR(layout, &ptr, "eval_time", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_time", 0, NULL, ICON_NONE); } else { /* time_mode == MOD_MESHCACHE_TIME_FACTOR */ - uiItemR(layout, &ptr, "eval_factor", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "eval_factor", 0, NULL, ICON_NONE); } } } -static void axis_mapping_panel_draw(const bContext *C, Panel *panel) +static void axis_mapping_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, true); - uiLayoutSetRedAlert(col, RNA_enum_get(&ptr, "forward_axis") == RNA_enum_get(&ptr, "up_axis")); - uiItemR(col, &ptr, "forward_axis", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "up_axis", 0, NULL, ICON_NONE); + uiLayoutSetRedAlert(col, RNA_enum_get(ptr, "forward_axis") == RNA_enum_get(ptr, "up_axis")); + uiItemR(col, ptr, "forward_axis", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "up_axis", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } static void panelRegister(ARegionType *region_type) |