diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-07-07 15:29:36 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-07-07 15:29:36 +0400 |
commit | bc9432b9056fc28b668949375b353a47215e3683 (patch) | |
tree | c3f24c7c6669683aad61f8010c8200f30d9a2b3a /source/blender | |
parent | 242ca1bdce4ea29e0b05e6e1936f491ca0717147 (diff) |
Grease Pencil ActEdit Mode: Filtering Cleanup
* Ported filtering code for Grease Pencil frames editing to the newer-
style refactored stuff
* Decoupled active status of layers from selection status, bringing
this into line with everything else again
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 73 | ||||
-rw-r--r-- | source/blender/editors/include/ED_anim_api.h | 2 |
2 files changed, 49 insertions, 26 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index d5048984e7f..047a7763fd8 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1236,42 +1236,65 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K return items; } +static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, int filter_mode) +{ + bGPDlayer *gpl; + size_t items = 0; + + /* loop over layers as the conditions are acceptable */ + for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + /* 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)) { + /* add to list */ + ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd); + } + } + } + } + + return items; +} + /* Grab all Grase Pencil datablocks in file */ // TODO: should this be amalgamated with the dopesheet filtering code? static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode) { bGPdata *gpd; - bGPDlayer *gpl; size_t items = 0; - /* check if filtering types are appropriate */ - { - /* for now, grab grease pencil datablocks directly from main*/ - for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { - /* only show if gpd is used by something... */ - if (ID_REAL_USERS(gpd) < 1) - continue; + /* for now, grab grease pencil datablocks directly from main */ + // XXX: this is not good... + for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { + ListBase tmp_data = {NULL, NULL}; + size_t tmp_items = 0; + + /* only show if gpd is used by something... */ + if (ID_REAL_USERS(gpd) < 1) + continue; - /* add gpd as channel too (if for drawing, and it has layers) */ - if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (gpd->layers.first)) { - /* add to list */ + /* add gpencil animation channels */ + BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd)) + { + tmp_items += animdata_filter_gpencil_data(&tmp_data, gpd, filter_mode); + } + END_ANIMFILTER_SUBCHANNELS; + + /* did we find anything? */ + if (tmp_items) { + /* include data-expand widget first */ + if (filter_mode & ANIMFILTER_LIST_CHANNELS) { + /* add gpd as channel too (if for drawing, and it has layers) */ ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL); } - /* only add layers if they will be visible (if drawing channels) */ - if ( !(filter_mode & ANIMFILTER_LIST_VISIBLE) || (EXPANDED_GPD(gpd)) ) { - /* loop over layers as the conditions are acceptable */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { - /* only if selected */ - if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) { - /* only if editable */ - if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) { - /* add to list */ - ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd); - } - } - } - } + /* now add the list of collected channels */ + BLI_movelisttolist(anim_data, &tmp_data); + BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + items += tmp_items; } } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 7726b02d511..513f0bba808 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -274,7 +274,7 @@ typedef enum eAnimFilter_Flags { #define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND) /* Grease Pencil Layer settings */ #define EDITABLE_GPL(gpl) ((gpl->flag & GP_LAYER_LOCKED)==0) -#define SEL_GPL(gpl) ((gpl->flag & GP_LAYER_ACTIVE) || (gpl->flag & GP_LAYER_SELECT)) +#define SEL_GPL(gpl) (gpl->flag & GP_LAYER_SELECT) /* NLA only */ #define SEL_NLT(nlt) (nlt->flag & NLATRACK_SELECTED) |