From cbf936a332728212c3805555c4761853d2d41981 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 15 Apr 2015 15:58:25 +0200 Subject: Gooseberry animation feature: Add toggle that disables modifiers on fcurves. Feature is found as per channel option in graph editor. --- .../editors/animation/anim_channels_defines.c | 45 ++++++++++++++++++---- source/blender/editors/include/ED_anim_api.h | 3 +- source/blender/editors/space_graph/graph_buttons.c | 3 ++ 3 files changed, 42 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 61dc6389b6c..db222f945b5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -867,7 +867,11 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin case ACHANNEL_SETTING_MUTE: /* muted */ return AGRP_MUTED; - + + case ACHANNEL_SETTING_MOD_OFF: /* muted */ + *neg = 1; + return AGRP_MODIFIERS_OFF; + case ACHANNEL_SETTING_PROTECT: /* protected */ return AGRP_PROTECTED; @@ -985,6 +989,10 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ return FCURVE_VISIBLE; + case ACHANNEL_SETTING_MOD_OFF: + *neg = 1; + return FCURVE_MOD_OFF; + default: /* unsupported */ return 0; } @@ -3979,6 +3987,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni { short ptrsize, butType; bool negflag; + bool usetoggle = true; int flag, icon; void *ptr; const char *tooltip; @@ -4000,7 +4009,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni else tooltip = TIP_("Channels are visible in Graph Editor for editing"); break; - + + case ACHANNEL_SETTING_MOD_OFF: /* modifiers disabled */ + icon = ICON_MODIFIER; + usetoggle = false; + tooltip = TIP_("F-Curve modifiers are disabled"); + break; + case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ //icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); icon = ICON_TRIA_RIGHT; @@ -4061,11 +4076,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni } /* type of button */ - if (negflag) - butType = UI_BTYPE_ICON_TOGGLE_N; - else - butType = UI_BTYPE_ICON_TOGGLE; - + if (usetoggle) { + if (negflag) + butType = UI_BTYPE_ICON_TOGGLE_N; + else + butType = UI_BTYPE_ICON_TOGGLE; + } + else { + if (negflag) + butType = UI_BTYPE_TOGGLE_N; + else + butType = UI_BTYPE_TOGGLE; + } /* draw button for setting */ if (ptr && flag) { switch (ptrsize) { @@ -4093,6 +4115,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni case ACHANNEL_SETTING_PROTECT: /* General - protection flags */ case ACHANNEL_SETTING_MUTE: /* General - muting flags */ case ACHANNEL_SETTING_PINNED: /* NLA Actions - 'map/nomap' */ + case ACHANNEL_SETTING_MOD_OFF: UI_but_funcN_set(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting)); break; @@ -4264,7 +4287,13 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle offset += ICON_WIDTH; draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MUTE); } - + + /* modifiers disable */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MOD_OFF)) { + offset += ICON_WIDTH; + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MOD_OFF); + } + /* ----------- */ /* pinned... */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 0f70bf3c745..dfa667d095a 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -412,7 +412,8 @@ typedef enum eAnimChannel_Settings { ACHANNEL_SETTING_EXPAND = 3, ACHANNEL_SETTING_VISIBLE = 4, /* only for Graph Editor */ ACHANNEL_SETTING_SOLO = 5, /* only for NLA Tracks */ - ACHANNEL_SETTING_PINNED = 6 /* only for NLA Actions */ + ACHANNEL_SETTING_PINNED = 6, /* only for NLA Actions */ + ACHANNEL_SETTING_MOD_OFF = 7 } eAnimChannel_Settings; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 59532912b8c..ee49f2cf028 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -883,6 +883,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) FModifier *fcm; uiLayout *col, *row; uiBlock *block; + bool active; if (!graph_panel_context(C, &ale, &fcu)) return; @@ -907,9 +908,11 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } + active = !(fcu->flag & FCURVE_MOD_OFF); /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { col = uiLayoutColumn(pa->layout, true); + uiLayoutSetActive(col, active); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } -- cgit v1.2.3