From c592bff0474548d69b3d1a63b05c670c4f499727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 6 Oct 2022 19:06:48 +0200 Subject: Animation: Expose "mute" for drivers in their properties UI In the driver editor and the "edit driver" popover, add a checkbox that can mute the driver. This is the same functionality as the checkbox in the driver editor's channel list, but then exposed in a different place in the UI. This is for convenience, such that a driver can now be muted by right-clicking on the driven property, choosing "Edit Driver", then muting it there. The same checkbox was added to the regular driver editor's header for consistency. Reviewed By: Severin Maniphest Tasks: T101592 Differential Revision: https://developer.blender.org/D16173 --- source/blender/editors/space_graph/graph_buttons.c | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index edba3c39042..8ada6d31a2d 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -905,6 +905,45 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar /* ----------------------------------------------------------------- */ /* property driven by the driver - duplicates Active FCurve, but useful for clarity */ + +static void graph_draw_driven_property_enabled_btn(uiLayout *layout, + ID *id, + FCurve *fcu, + const char *label) +{ + PointerRNA fcurve_ptr; + RNA_pointer_create(id, &RNA_FCurve, fcu, &fcurve_ptr); + + uiBlock *block = uiLayoutGetBlock(layout); + uiDefButR(block, + UI_BTYPE_CHECKBOX_N, + 0, + label, + 0, + 0, + UI_UNIT_X, + UI_UNIT_Y, + &fcurve_ptr, + "mute", + 0, + 0, + 0, + 0, + 0, + TIP_("Let the driver determine this property's value")); +} + +static void graph_panel_drivers_header(const bContext *C, Panel *panel) +{ + bAnimListElem *ale; + FCurve *fcu; + if (!graph_panel_context(C, &ale, &fcu)) { + return; + } + + graph_draw_driven_property_enabled_btn(panel->layout, ale->id, fcu, IFACE_("Driver")); +} + static void graph_draw_driven_property_panel(uiLayout *layout, ID *id, FCurve *fcu) { PointerRNA fcu_ptr; @@ -1315,7 +1354,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel) uiItemS(layout); /* Drivers Settings */ - uiItemL(layout, IFACE_("Driver Settings:"), ICON_NONE); + graph_draw_driven_property_enabled_btn(panel->layout, id, fcu, IFACE_("Driver:")); graph_draw_driver_settings_panel(panel->layout, id, fcu, true); } } @@ -1432,6 +1471,7 @@ void graph_buttons_register(ARegionType *art) strcpy(pt->category, "Drivers"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = graph_panel_drivers; + pt->draw_header = graph_panel_drivers_header; pt->poll = graph_panel_drivers_poll; BLI_addtail(&art->paneltypes, pt); -- cgit v1.2.3