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/modifiers/intern/MOD_subsurf.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/modifiers/intern/MOD_subsurf.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_subsurf.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 8424b549f85..1972f857877 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -339,9 +339,8 @@ static bool get_show_adaptive_options(const bContext *C, Panel *panel) } /* Only show adaptive options if this is the last modifier. */ - PointerRNA md_ptr; - modifier_panel_get_property_pointers(C, panel, NULL, &md_ptr); - ModifierData *md = md_ptr.data; + PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); + ModifierData *md = ptr->data; if (md->next != NULL) { return false; } @@ -365,9 +364,8 @@ static void panel_draw(const bContext *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); /* Only test for adaptive subdivision if built with cycles. */ bool show_adaptive_options = false; @@ -386,9 +384,11 @@ static void panel_draw(const bContext *C, Panel *panel) show_adaptive_options = get_show_adaptive_options(C, panel); } } +#else + UNUSED_VARS(C); #endif - uiItemR(layout, &ptr, "subdivision_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "subdivision_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiLayoutSetPropSep(layout, true); @@ -414,26 +414,25 @@ static void panel_draw(const bContext *C, Panel *panel) uiItemS(layout); - uiItemR(layout, &ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); + uiItemR(layout, ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); } else { uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, &ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); - uiItemR(col, &ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); + uiItemR(col, ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); + uiItemR(col, ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); } - 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 advanced_panel_draw(const bContext *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); bool ob_use_adaptive_subdivision = false; bool show_adaptive_options = false; @@ -446,15 +445,17 @@ static void advanced_panel_draw(const bContext *C, Panel *panel) show_adaptive_options = get_show_adaptive_options(C, panel); } } +#else + UNUSED_VARS(C); #endif uiLayoutSetPropSep(layout, true); uiLayoutSetActive(layout, !(show_adaptive_options && ob_use_adaptive_subdivision)); - uiItemR(layout, &ptr, "quality", 0, NULL, ICON_NONE); - uiItemR(layout, &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, "quality", 0, NULL, ICON_NONE); + uiItemR(layout, 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); } static void panelRegister(ARegionType *region_type) |