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_bevel.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_bevel.c')
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c86
1 files changed, 41 insertions, 45 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index c0428785009..ab024bd824d 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -276,63 +276,61 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
return (bmd->value == 0.0f);
}
-static void panel_draw(const bContext *C, Panel *panel)
+static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col, *sub;
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);
- bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+ bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
- uiItemR(layout, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "offset_type", 0, NULL, ICON_NONE);
- if (RNA_enum_get(&ptr, "offset_type") == BEVEL_AMT_PERCENT) {
- uiItemR(col, &ptr, "width_pct", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "offset_type", 0, NULL, ICON_NONE);
+ if (RNA_enum_get(ptr, "offset_type") == BEVEL_AMT_PERCENT) {
+ uiItemR(col, ptr, "width_pct", 0, NULL, ICON_NONE);
}
else {
- uiItemR(col, &ptr, "width", 0, IFACE_("Amount"), ICON_NONE);
+ uiItemR(col, ptr, "width", 0, IFACE_("Amount"), ICON_NONE);
}
- uiItemR(layout, &ptr, "segments", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "segments", 0, NULL, ICON_NONE);
uiItemS(layout);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "limit_method", 0, NULL, ICON_NONE);
- int limit_method = RNA_enum_get(&ptr, "limit_method");
+ uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
+ int limit_method = RNA_enum_get(ptr, "limit_method");
if (limit_method == MOD_BEVEL_ANGLE) {
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, edge_bevel);
- uiItemR(col, &ptr, "angle_limit", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "angle_limit", 0, NULL, ICON_NONE);
}
else if (limit_method == MOD_BEVEL_VGROUP) {
- 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 profile_panel_draw(const bContext *C, Panel *panel)
+static void profile_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- int profile_type = RNA_enum_get(&ptr, "profile_type");
- int miter_inner = RNA_enum_get(&ptr, "miter_inner");
- int miter_outer = RNA_enum_get(&ptr, "miter_outer");
- bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+ int profile_type = RNA_enum_get(ptr, "profile_type");
+ int miter_inner = RNA_enum_get(ptr, "miter_inner");
+ int miter_outer = RNA_enum_get(ptr, "miter_outer");
+ bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
- uiItemR(layout, &ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiLayoutSetPropSep(layout, true);
@@ -344,7 +342,7 @@ static void profile_panel_draw(const bContext *C, Panel *panel)
(profile_type == MOD_BEVEL_PROFILE_CUSTOM && edge_bevel &&
!((miter_inner == MOD_BEVEL_MITER_SHARP) && (miter_outer == MOD_BEVEL_MITER_SHARP))));
uiItemR(row,
- &ptr,
+ ptr,
"profile",
UI_ITEM_R_SLIDER,
(profile_type == MOD_BEVEL_PROFILE_SUPERELLIPSE) ? IFACE_("Shape") :
@@ -354,66 +352,64 @@ static void profile_panel_draw(const bContext *C, Panel *panel)
if (profile_type == MOD_BEVEL_PROFILE_CUSTOM) {
uiLayout *sub = uiLayoutColumn(layout, false);
uiLayoutSetPropDecorate(sub, false);
- uiTemplateCurveProfile(sub, &ptr, "custom_profile");
+ uiTemplateCurveProfile(sub, ptr, "custom_profile");
}
}
}
-static void geometry_panel_draw(const bContext *C, Panel *panel)
+static void geometry_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+ bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
uiLayoutSetPropSep(layout, true);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, edge_bevel);
- uiItemR(row, &ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE);
+ uiItemR(row, ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, edge_bevel);
- uiItemR(row, &ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE);
- if (RNA_enum_get(&ptr, "miter_inner") == BEVEL_MITER_ARC) {
+ uiItemR(row, ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE);
+ if (RNA_enum_get(ptr, "miter_inner") == BEVEL_MITER_ARC) {
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, edge_bevel);
- uiItemR(row, &ptr, "spread", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "spread", 0, NULL, ICON_NONE);
}
uiItemS(layout);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, edge_bevel);
- uiItemR(row, &ptr, "vmesh_method", 0, IFACE_("Intersections"), ICON_NONE);
- uiItemR(layout, &ptr, "use_clamp_overlap", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "vmesh_method", 0, IFACE_("Intersections"), ICON_NONE);
+ uiItemR(layout, ptr, "use_clamp_overlap", 0, NULL, ICON_NONE);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, edge_bevel);
- uiItemR(row, &ptr, "loop_slide", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "loop_slide", 0, NULL, ICON_NONE);
}
-static void shading_panel_draw(const bContext *C, Panel *panel)
+static void shading_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);
- bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
+ bool edge_bevel = RNA_enum_get(ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES;
uiLayoutSetPropSep(layout, true);
- uiItemR(layout, &ptr, "harden_normals", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "harden_normals", 0, NULL, ICON_NONE);
col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark"));
uiLayoutSetActive(col, edge_bevel);
- uiItemR(col, &ptr, "mark_seam", 0, IFACE_("Seam"), ICON_NONE);
- uiItemR(col, &ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE);
+ uiItemR(col, ptr, "mark_seam", 0, IFACE_("Seam"), ICON_NONE);
+ uiItemR(col, ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE);
- uiItemR(layout, &ptr, "material", 0, NULL, ICON_NONE);
- uiItemR(layout, &ptr, "face_strength_mode", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "material", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "face_strength_mode", 0, NULL, ICON_NONE);
}
static void panelRegister(ARegionType *region_type)