Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-09-02 22:13:26 +0300
committerHans Goudey <h.goudey@me.com>2020-09-02 22:13:26 +0300
commitba4a2a4c8b827201b18e97d9dd025ef93a4db754 (patch)
treea71d6b72aaf0616ebda671bf4b011880b49bb280 /source/blender/modifiers/intern/MOD_array.c
parentff7d74235023d0c927c0ad3f4d72d1c5dd41b240 (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_array.c')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c101
1 files changed, 45 insertions, 56 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 1c98cec915e..60e1a3de67e 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -835,163 +835,152 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return false;
}
-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;
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);
- uiItemR(layout, &ptr, "fit_type", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "fit_type", 0, NULL, ICON_NONE);
- int fit_type = RNA_enum_get(&ptr, "fit_type");
+ int fit_type = RNA_enum_get(ptr, "fit_type");
if (fit_type == MOD_ARR_FIXEDCOUNT) {
- uiItemR(layout, &ptr, "count", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "count", 0, NULL, ICON_NONE);
}
else if (fit_type == MOD_ARR_FITLENGTH) {
- uiItemR(layout, &ptr, "fit_length", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "fit_length", 0, NULL, ICON_NONE);
}
else if (fit_type == MOD_ARR_FITCURVE) {
- uiItemR(layout, &ptr, "curve", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "curve", 0, NULL, ICON_NONE);
}
- modifier_panel_end(layout, &ptr);
+ modifier_panel_end(layout, ptr);
}
-static void relative_offset_header_draw(const bContext *C, Panel *panel)
+static void relative_offset_header_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, "use_relative_offset", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_relative_offset", 0, NULL, ICON_NONE);
}
-static void relative_offset_draw(const bContext *C, Panel *panel)
+static void relative_offset_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);
uiLayout *col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_relative_offset"));
- uiItemR(col, &ptr, "relative_offset_displace", 0, IFACE_("Factor"), ICON_NONE);
+ uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_relative_offset"));
+ uiItemR(col, ptr, "relative_offset_displace", 0, IFACE_("Factor"), ICON_NONE);
}
-static void constant_offset_header_draw(const bContext *C, Panel *panel)
+static void constant_offset_header_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, "use_constant_offset", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_constant_offset", 0, NULL, ICON_NONE);
}
-static void constant_offset_draw(const bContext *C, Panel *panel)
+static void constant_offset_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);
uiLayout *col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_constant_offset"));
- uiItemR(col, &ptr, "constant_offset_displace", 0, IFACE_("Distance"), ICON_NONE);
+ uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_constant_offset"));
+ uiItemR(col, ptr, "constant_offset_displace", 0, IFACE_("Distance"), ICON_NONE);
}
/**
* Object offset in a subpanel for consistency with the other offset types.
*/
-static void object_offset_header_draw(const bContext *C, Panel *panel)
+static void object_offset_header_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, "use_object_offset", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_object_offset", 0, NULL, ICON_NONE);
}
-static void object_offset_draw(const bContext *C, Panel *panel)
+static void object_offset_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);
uiLayout *col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_object_offset"));
- uiItemR(col, &ptr, "offset_object", 0, IFACE_("Object"), ICON_NONE);
+ uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_object_offset"));
+ uiItemR(col, ptr, "offset_object", 0, IFACE_("Object"), ICON_NONE);
}
-static void symmetry_panel_header_draw(const bContext *C, Panel *panel)
+static void symmetry_panel_header_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, "use_merge_vertices", 0, IFACE_("Merge"), ICON_NONE);
+ uiItemR(layout, ptr, "use_merge_vertices", 0, IFACE_("Merge"), ICON_NONE);
}
-static void symmetry_panel_draw(const bContext *C, Panel *panel)
+static void symmetry_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);
uiLayout *col = uiLayoutColumn(layout, false);
- uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_merge_vertices"));
- uiItemR(col, &ptr, "merge_threshold", 0, IFACE_("Distance"), ICON_NONE);
- uiItemR(col, &ptr, "use_merge_vertices_cap", 0, IFACE_("First and Last Copies"), ICON_NONE);
+ uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_merge_vertices"));
+ uiItemR(col, ptr, "merge_threshold", 0, IFACE_("Distance"), ICON_NONE);
+ uiItemR(col, ptr, "use_merge_vertices_cap", 0, IFACE_("First and Last Copies"), ICON_NONE);
}
-static void uv_panel_draw(const bContext *C, Panel *panel)
+static void uv_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);
- uiItemR(col, &ptr, "offset_u", UI_ITEM_R_EXPAND, IFACE_("Offset U"), ICON_NONE);
- uiItemR(col, &ptr, "offset_v", UI_ITEM_R_EXPAND, IFACE_("V"), ICON_NONE);
+ uiItemR(col, ptr, "offset_u", UI_ITEM_R_EXPAND, IFACE_("Offset U"), ICON_NONE);
+ uiItemR(col, ptr, "offset_v", UI_ITEM_R_EXPAND, IFACE_("V"), ICON_NONE);
}
-static void caps_panel_draw(const bContext *C, Panel *panel)
+static void caps_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, "start_cap", 0, IFACE_("Cap Start"), ICON_NONE);
- uiItemR(col, &ptr, "end_cap", 0, IFACE_("End"), ICON_NONE);
+ uiItemR(col, ptr, "start_cap", 0, IFACE_("Cap Start"), ICON_NONE);
+ uiItemR(col, ptr, "end_cap", 0, IFACE_("End"), ICON_NONE);
}
static void panelRegister(ARegionType *region_type)