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_multires.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_multires.c')
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 9ced297bb48..7bdc1da33c2 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -333,39 +333,37 @@ static void panel_draw(const bContext *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, "levels", 0, IFACE_("Level Viewport"), ICON_NONE);
- uiItemR(col, &ptr, "sculpt_levels", 0, IFACE_("Sculpt"), ICON_NONE);
- uiItemR(col, &ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE);
+ uiItemR(col, ptr, "levels", 0, IFACE_("Level Viewport"), ICON_NONE);
+ uiItemR(col, ptr, "sculpt_levels", 0, IFACE_("Sculpt"), ICON_NONE);
+ uiItemR(col, ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE);
const bool is_sculpt_mode = CTX_data_active_object(C)->mode & OB_MODE_SCULPT;
uiBlock *block = uiLayoutGetBlock(panel->layout);
UI_block_lock_set(block, !is_sculpt_mode, IFACE_("Sculpt Base Mesh"));
- uiItemR(col, &ptr, "use_sculpt_base_mesh", 0, IFACE_("Sculpt Base Mesh"), ICON_NONE);
+ uiItemR(col, ptr, "use_sculpt_base_mesh", 0, IFACE_("Sculpt Base Mesh"), ICON_NONE);
UI_block_lock_clear(block);
- uiItemR(layout, &ptr, "show_only_control_edges", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "show_only_control_edges", 0, NULL, ICON_NONE);
- modifier_panel_end(layout, &ptr);
+ modifier_panel_end(layout, ptr);
}
-static void subdivisions_panel_draw(const bContext *C, Panel *panel)
+static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *row;
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);
uiLayoutSetEnabled(layout, RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
- MultiresModifierData *mmd = (MultiresModifierData *)ptr.data;
+ MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
/**
* Changing some of the properties can not be done once there is an
@@ -418,14 +416,13 @@ static void subdivisions_panel_draw(const bContext *C, Panel *panel)
uiItemO(layout, IFACE_("Delete Higher"), ICON_NONE, "OBJECT_OT_multires_higher_levels_delete");
}
-static void shape_panel_draw(const bContext *C, Panel *panel)
+static void shape_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
PointerRNA ob_ptr;
- modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
+ modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetEnabled(layout, RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
@@ -434,16 +431,15 @@ static void shape_panel_draw(const bContext *C, Panel *panel)
uiItemO(row, IFACE_("Apply Base"), ICON_NONE, "OBJECT_OT_multires_base_apply");
}
-static void generate_panel_draw(const bContext *C, Panel *panel)
+static void generate_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col, *row;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
- MultiresModifierData *mmd = (MultiresModifierData *)ptr.data;
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+ MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
- bool is_external = RNA_boolean_get(&ptr, "is_external");
+ bool is_external = RNA_boolean_get(ptr, "is_external");
if (mmd->totlvl == 0) {
uiItemO(
@@ -456,36 +452,35 @@ static void generate_panel_draw(const bContext *C, Panel *panel)
uiItemO(row, IFACE_("Pack External"), ICON_NONE, "OBJECT_OT_multires_external_pack");
uiLayoutSetPropSep(col, true);
row = uiLayoutRow(col, false);
- uiItemR(row, &ptr, "filepath", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "filepath", 0, NULL, ICON_NONE);
}
else {
uiItemO(col, IFACE_("Save External..."), ICON_NONE, "OBJECT_OT_multires_external_save");
}
}
-static void advanced_panel_draw(const bContext *C, Panel *panel)
+static void advanced_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 has_displacement = RNA_int_get(&ptr, "total_levels") != 0;
+ bool has_displacement = RNA_int_get(ptr, "total_levels") != 0;
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !has_displacement);
- uiItemR(layout, &ptr, "subdivision_type", 0, NULL, ICON_NONE);
- uiItemR(layout, &ptr, "quality", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "subdivision_type", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "quality", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, false);
uiLayoutSetEnabled(col, true);
- uiItemR(col, &ptr, "uv_smooth", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "uv_smooth", 0, NULL, ICON_NONE);
- uiItemR(layout, &ptr, "use_creases", 0, NULL, ICON_NONE);
- uiItemR(layout, &ptr, "use_custom_normals", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_creases", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "use_custom_normals", 0, NULL, ICON_NONE);
}
static void panelRegister(ARegionType *region_type)