From 98c7e7589754500eb4a24825f71e46dd77e29983 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 12 Sep 2016 15:31:28 +0200 Subject: Graph editor: Add channel option to make it persistent on display The idea is to allow certain animation channels to be always visible in animation editors. So, for example, one can pin Camera animation to the editor so it is always possible to refine/tweak camera animation when animating something else in the scene. There is probably some more polishing required, and some current limitations could be solved in the future but should be a good starting point already. Currently only works for object without recursing into deeper datablock (so for example, it's not possible to pin object material animation). Studio request by Colin Levy. --- .../editors/animation/anim_channels_defines.c | 62 +++++++++++++++++----- .../blender/editors/animation/anim_channels_edit.c | 6 ++- source/blender/editors/animation/anim_filter.c | 7 ++- 3 files changed, 61 insertions(+), 14 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index d727ea0a957..be92b0394a6 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -529,7 +529,10 @@ static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: return true; - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return false; + default: return false; } @@ -555,7 +558,7 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + default: /* unsupported */ return 0; } @@ -682,7 +685,10 @@ static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnim case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: return true; - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return ((ac) && (ac->spacetype == SPACE_IPO) && (ob->adt)); + default: return false; } @@ -708,7 +714,10 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return ADT_CURVES_ALWAYS_VISIBLE; + default: /* unsupported */ return 0; } @@ -732,6 +741,7 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + case ACHANNEL_SETTING_ALWAYS_VISIBLE: if (ob->adt) return GET_ACF_FLAG_PTR(ob->adt->flag, type); return NULL; @@ -839,7 +849,10 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) /* conditionally supported */ case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return false; + default: /* always supported */ return true; } @@ -965,7 +978,10 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnim case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return false; + /* always available */ default: return true; @@ -3749,7 +3765,9 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float * - in Grease Pencil mode, color swatches for layer color */ if (ac->sl) { - if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + if ((ac->spacetype == SPACE_IPO) && + (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || + acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) { /* for F-Curves, draw color-preview of curve behind checkbox */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; @@ -3763,9 +3781,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float */ glRectf(offset, yminc, offset + ICON_WIDTH, ymaxc); } - /* icon is drawn as widget now... */ - offset += ICON_WIDTH; + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + offset += ICON_WIDTH; + } + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) { + offset += ICON_WIDTH; + } } else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { /* just skip - drawn as widget now */ @@ -4110,6 +4132,11 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni tooltip = TIP_("Channels are visible in Graph Editor for editing"); break; + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + icon = ICON_UNPINNED; + tooltip = TIP_("Channels are visible in Graph Editor for editing"); + break; + case ACHANNEL_SETTING_MOD_OFF: /* modifiers disabled */ icon = ICON_MODIFIER; usetoggle = false; @@ -4219,6 +4246,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni case ACHANNEL_SETTING_MUTE: /* General - muting flags */ case ACHANNEL_SETTING_PINNED: /* NLA Actions - 'map/nomap' */ case ACHANNEL_SETTING_MOD_OFF: + case ACHANNEL_SETTING_ALWAYS_VISIBLE: UI_but_funcN_set(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting)); break; @@ -4282,10 +4310,20 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle * - in Grease Pencil mode, color swatches for layer color */ if (ac->sl) { - if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + if ((ac->spacetype == SPACE_IPO) && + (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || + acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) + { + /* pin toggle */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) { + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_ALWAYS_VISIBLE); + offset += ICON_WIDTH; + } /* visibility toggle */ - draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE); - offset += ICON_WIDTH; + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { + draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE); + offset += ICON_WIDTH; + } } else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { /* 'solo' setting for NLA Tracks */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index cb65a9aecad..4cbdf77b11a 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -435,7 +435,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* sanity check */ if (ELEM(NULL, anim_data, anim_data->first)) return; - + + if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) { + return; + } + /* find the channel that got changed */ for (ale = anim_data->first; ale; ale = ale->next) { /* compare data, and type as main way of identifying the channel */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 5cd305f69f5..ca207a7e695 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2825,7 +2825,12 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) return false; } - + + /* Pinned curves are visible regardless of selection flags. */ + if ((ob->adt) && (ob->adt->flag & ADT_CURVES_ALWAYS_VISIBLE)) { + //return true; + } + /* check selection and object type filters */ if ((ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & SELECT) /*|| (base == sce->basact)*/)) { /* only selected should be shown */ -- cgit v1.2.3 From 91eb1c2e2af7d25a58140d393e8e8550ba4766c0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 12 Sep 2016 16:29:54 +0200 Subject: Fix code which was commented by accident Well, more like some last-minute checks which i did not see before commit. Let's increase commit ratio! --- source/blender/editors/animation/anim_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index ca207a7e695..5cee414c690 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2828,7 +2828,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base /* Pinned curves are visible regardless of selection flags. */ if ((ob->adt) && (ob->adt->flag & ADT_CURVES_ALWAYS_VISIBLE)) { - //return true; + return true; } /* check selection and object type filters */ -- cgit v1.2.3 From 9a7891da900262a9fb67cad1b9e2e3605d8bdedd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 16 Sep 2016 15:56:09 +0200 Subject: Tweak for pinned/always visible curves in Graph Editor Allow such kind of pin for armature bones. --- source/blender/editors/animation/anim_channels_defines.c | 7 +++++-- source/blender/editors/animation/anim_filter.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index be92b0394a6..e60cb3fbedf 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -851,7 +851,7 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) return (ac->spacetype == SPACE_IPO); case ACHANNEL_SETTING_ALWAYS_VISIBLE: - return false; + return (ac->spacetype == SPACE_IPO); default: /* always supported */ return true; @@ -892,7 +892,10 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ *neg = 1; return AGRP_NOTVISIBLE; - + + case ACHANNEL_SETTING_ALWAYS_VISIBLE: + return ADT_CURVES_ALWAYS_VISIBLE; + default: /* this shouldn't happen */ return 0; diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 5cee414c690..72c20c00029 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -478,7 +478,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, nlaKeysOk, keysOk) \ { \ if ((id)->adt) { \ - if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) { \ + if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE) || 1) { \ if (filter_mode & ANIMFILTER_ANIMDATA) { \ adtOk \ } \ @@ -952,6 +952,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne */ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) { + if (fcu->grp != NULL && fcu->grp->flag & ADT_CURVES_ALWAYS_VISIBLE) { + return false; + } /* hidden items should be skipped if we only care about visible data, but we aren't interested in hidden stuff */ const bool skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN); -- cgit v1.2.3 From 9883899d62a7b275c05ee6b15b5383dff6043cfc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 16 Sep 2016 16:11:38 +0200 Subject: Remove debug only code Thanks Severin for spotting it! --- source/blender/editors/animation/anim_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 72c20c00029..87c73810e63 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -478,7 +478,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, nlaKeysOk, keysOk) \ { \ if ((id)->adt) { \ - if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE) || 1) { \ + if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) { \ if (filter_mode & ANIMFILTER_ANIMDATA) { \ adtOk \ } \ -- cgit v1.2.3