diff options
author | Hans Goudey <h.goudey@me.com> | 2020-07-03 18:58:43 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-07-03 18:58:43 +0300 |
commit | a21cb22f8b12ea73937e7e6eda8465f1cba02b6e (patch) | |
tree | 17fa94d2e1a22f8c0ece10b4a680a39784aae981 /source/blender/editors/interface | |
parent | 33a74941c5fd4efb6eefcaace3315d3e2b65681f (diff) |
Cleanup: Deduplicate code for finding context object
Instead of manually checking the pinned object, use the existing
ED_object_active_context function. This requires adding const
to the context in that function.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 992c9e07033..f3e2eef6f31 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1836,18 +1836,6 @@ void uiTemplatePathBuilder(uiLayout *layout, * Template for building the panel layout for the active object's modifiers. * \{ */ -/** - * Get the active object or the property region's pinned object. - */ -static Object *get_context_object(const bContext *C) -{ - SpaceProperties *sbuts = CTX_wm_space_properties(C); - if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) { - return (Object *)sbuts->pinid; - } - return CTX_data_active_object(C); -} - static void modifier_panel_id(void *md_link, char *r_name) { ModifierData *md = (ModifierData *)md_link; @@ -1859,7 +1847,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *modifiers = &ob->modifiers; bool panels_match = UI_panel_list_matches_data(region, modifiers, modifier_panel_id); @@ -1952,7 +1940,7 @@ static ListBase *get_constraints(const bContext *C, bool use_bone_constraints) } } else { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); if (ob != NULL) { constraints = &ob->constraints; } @@ -2095,7 +2083,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *modifiers = &ob->greasepencil_modifiers; bool panels_match = UI_panel_list_matches_data(region, modifiers, gpencil_modifier_panel_id); @@ -2183,7 +2171,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *shaderfx = &ob->shader_fx; bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id); |