/* option 1) select keyframe directly under mouse */ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) { KeyframeEditData ked = {{NULL}}; KeyframeEditFunc select_cb, ok_cb; /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); ked.f1 = selx; /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->data, selx, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, selx, select_mode); else { if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) && (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL)) { ListBase anim_data = {NULL, NULL}; int filter; filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->data, selx, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, selx, select_mode); } } else { ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); } } }
/* Option 3) Selects all visible keyframes in the same frame as the mouse click */ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float selx) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ if (adt) ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else ked.f1 = selx; /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->key_data, selx, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->key_data, selx, select_mode); else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); }
/* Selects all visible keyframes in the same frames as the specified elements */ static void columnselect_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; /* build list of columns */ switch (mode) { case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */ if (ac->datatype == ANIMCONT_GPENCIL) { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) ED_gplayer_make_cfra_list(ale->data, &ked.list, 1); } else { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); } ANIM_animdata_freelist(&anim_data); break; case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); ce->cfra = (float)CFRA; break; case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; default: /* invalid option */ return; } /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(SELECT_ADD); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ for (ce = ked.list.first; ce; ce = ce->next) { /* set frame for validation callback to refer to */ if (adt) ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); else ked.f1 = ce->cfra; /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->data, ce->cfra, SELECT_ADD); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, ce->cfra, SELECT_ADD); else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); }