From 741888ce086cffadd634e2877e7294b56e3d607b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 12 Mar 2020 16:54:56 +0100 Subject: Cleanup: simplified Grease Pencil animdata filter Part of the function was following an "if-ok: do-this" pattern, and then mid-function switched to a "if-bad: skip" pattern. The function now just uses the latter. No functional changes. --- source/blender/editors/animation/anim_filter.c | 36 +++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'source/blender/editors/animation/anim_filter.c') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4b0a4bcf46b..c1cd24f5a3c 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1715,22 +1715,28 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, /* loop over layers as the conditions are acceptable (top-Down order) */ for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) { /* only if selected */ - if (ANIMCHANNEL_SELOK(SEL_GPL(gpl))) { - /* only if editable */ - if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) { - /* active... */ - if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) { - /* skip layer if the name doesn't match the filter string */ - if ((ads) && (ads->searchstr[0] != '\0')) { - if (name_matches_dopesheet_filter(ads, gpl->info) == false) { - continue; - } - } - /* add to list */ - ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL); - } - } + if (!ANIMCHANNEL_SELOK(SEL_GPL(gpl))) { + continue; } + + /* only if editable */ + if ((filter_mode & ANIMFILTER_FOREDIT) && !EDITABLE_GPL(gpl)) { + continue; + } + + /* active... */ + if ((filter_mode & ANIMFILTER_ACTIVE) && (gpl->flag & GP_LAYER_ACTIVE) == 0) { + continue; + } + + /* skip layer if the name doesn't match the filter string */ + if (ads != NULL && ads->searchstr[0] != '\0' && + name_matches_dopesheet_filter(ads, gpl->info) == false) { + continue; + } + + /* add to list */ + ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL); } return items; -- cgit v1.2.3 From 38ba02285846423994c1c58f6e8477ab432c68a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 12 Mar 2020 17:33:27 +0100 Subject: Fix T66505: Dope Sheet shows empty Grease Pencil/Annotation layers The behaviour of GP layers is the same as annotation layers: they show in the dope sheet regardless of whether they have frames or not. This is easily resolved by adding some extra filtering. --- source/blender/editors/animation/anim_filter.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/editors/animation/anim_filter.c') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index c1cd24f5a3c..8dfc9cd8d1a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1735,6 +1735,11 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, continue; } + /* Skip empty layers. */ + if (BLI_listbase_is_empty(&gpl->frames)) { + continue; + } + /* add to list */ ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL); } -- cgit v1.2.3