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/shader_fx/intern/FX_shader_shadow.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/shader_fx/intern/FX_shader_shadow.c')
-rw-r--r-- | source/blender/shader_fx/intern/FX_shader_shadow.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/source/blender/shader_fx/intern/FX_shader_shadow.c b/source/blender/shader_fx/intern/FX_shader_shadow.c index 11690d2cca0..14fd2ed3d28 100644 --- a/source/blender/shader_fx/intern/FX_shader_shadow.c +++ b/source/blender/shader_fx/intern/FX_shader_shadow.c @@ -99,78 +99,74 @@ static void foreachObjectLink(ShaderFxData *fx, walk(userData, ob, &fxd->object, IDWALK_CB_NOP); } -static void panel_draw(const bContext *C, Panel *panel) +static void panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *row, *col; uiLayout *layout = panel->layout; - PointerRNA ptr; - shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, NULL); uiLayoutSetPropSep(layout, true); - uiItemR(layout, &ptr, "shadow_color", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "shadow_color", 0, NULL, ICON_NONE); /* Add the X, Y labels manually because size is a #PROP_PIXEL. */ col = uiLayoutColumn(layout, true); - PropertyRNA *prop = RNA_struct_find_property(&ptr, "offset"); - uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Offset X"), ICON_NONE); - uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE); + PropertyRNA *prop = RNA_struct_find_property(ptr, "offset"); + uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Offset X"), ICON_NONE); + uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE); - uiItemR(layout, &ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "rotation", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE); row = uiLayoutRowWithHeading(layout, true, IFACE_("Object Pivot")); - uiItemR(row, &ptr, "use_object", 0, "", ICON_NONE); - uiItemR(row, &ptr, "object", 0, "", ICON_NONE); + uiItemR(row, ptr, "use_object", 0, "", ICON_NONE); + uiItemR(row, ptr, "object", 0, "", ICON_NONE); - shaderfx_panel_end(layout, &ptr); + shaderfx_panel_end(layout, ptr); } -static void blur_panel_draw(const bContext *C, Panel *panel) +static void blur_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA ptr; - shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, NULL); uiLayoutSetPropSep(layout, true); /* Add the X, Y labels manually because size is a #PROP_PIXEL. */ col = uiLayoutColumn(layout, true); - PropertyRNA *prop = RNA_struct_find_property(&ptr, "blur"); - uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Blur X"), ICON_NONE); - uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE); + PropertyRNA *prop = RNA_struct_find_property(ptr, "blur"); + uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Blur X"), ICON_NONE); + uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE); - uiItemR(layout, &ptr, "samples", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "samples", 0, NULL, ICON_NONE); } -static void wave_header_draw(const bContext *C, Panel *panel) +static void wave_header_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA ptr; - shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, NULL); - uiItemR(layout, &ptr, "use_wave", 0, IFACE_("Wave Effect"), ICON_NONE); + uiItemR(layout, ptr, "use_wave", 0, IFACE_("Wave Effect"), ICON_NONE); } -static void wave_panel_draw(const bContext *C, Panel *panel) +static void wave_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA ptr; - shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); + PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, NULL); uiLayoutSetPropSep(layout, true); - uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_wave")); + uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_wave")); - uiItemR(layout, &ptr, "orientation", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(layout, &ptr, "amplitude", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "period", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "phase", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "orientation", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "amplitude", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "period", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "phase", 0, NULL, ICON_NONE); } static void panelRegister(ARegionType *region_type) |