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/gpencil_modifiers/intern/MOD_gpencilhook.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/gpencil_modifiers/intern/MOD_gpencilhook.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index 1608d7a2d4c..83c65e2d3a2 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -359,69 +359,67 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); } -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; - gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); + PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr); - PointerRNA hook_object_ptr = RNA_pointer_get(&ptr, "object"); - bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0; + PointerRNA hook_object_ptr = RNA_pointer_get(ptr, "object"); + bool has_vertex_group = RNA_string_length(ptr, "vertex_group") != 0; uiLayoutSetPropSep(layout, true); col = uiLayoutColumn(layout, false); - uiItemR(col, &ptr, "object", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); if (!RNA_pointer_is_null(&hook_object_ptr) && RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) { PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data"); uiItemPointerR( - col, &ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); + col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); } row = uiLayoutRow(layout, true); - uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE); + uiItemPointerR(row, ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE); sub = uiLayoutRow(row, true); uiLayoutSetActive(sub, has_vertex_group); uiLayoutSetPropSep(sub, false); - uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT); + uiItemR(sub, ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT); - uiItemR(layout, &ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - gpencil_modifier_panel_end(layout, &ptr); + gpencil_modifier_panel_end(layout, ptr); } -static void falloff_panel_draw(const bContext *C, Panel *panel) +static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *row; uiLayout *layout = panel->layout; - PointerRNA ptr; - gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL); - bool use_falloff = RNA_enum_get(&ptr, "falloff_type") != eWarp_Falloff_None; + bool use_falloff = RNA_enum_get(ptr, "falloff_type") != eWarp_Falloff_None; uiLayoutSetPropSep(layout, true); - uiItemR(layout, &ptr, "falloff_type", 0, IFACE_("Type"), ICON_NONE); + uiItemR(layout, ptr, "falloff_type", 0, IFACE_("Type"), ICON_NONE); row = uiLayoutRow(layout, false); uiLayoutSetActive(row, use_falloff); - uiItemR(row, &ptr, "falloff_radius", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "falloff_radius", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "use_falloff_uniform", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_falloff_uniform", 0, NULL, ICON_NONE); - if (RNA_enum_get(&ptr, "falloff_type") == eWarp_Falloff_Curve) { - uiTemplateCurveMapping(layout, &ptr, "falloff_curve", 0, false, false, false, false); + if (RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) { + uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false); } } -static void mask_panel_draw(const bContext *C, Panel *panel) +static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel) { - gpencil_modifier_masking_panel_draw(C, panel, true, false); + gpencil_modifier_masking_panel_draw(panel, true, false); } static void panelRegister(ARegionType *region_type) |