Blender V5.3
action_select.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cfloat>
10#include <cmath>
11#include <cstdlib>
12#include <cstring>
13
14#include "MEM_guardedalloc.h"
15
16#include "BLI_lasso_2d.hh"
17#include "BLI_listbase.hh"
18#include "BLI_utildefines.hh"
19
20#include "DNA_anim_types.h"
22#include "DNA_mask_types.h"
23#include "DNA_object_types.h"
24#include "DNA_scene_types.h"
25
26#include "RNA_access.hh"
27#include "RNA_define.hh"
28#include "RNA_enum_types.hh"
29
30#include "BKE_context.hh"
31#include "BKE_fcurve.hh"
32#include "BKE_grease_pencil.hh"
33#include "BKE_nla.hh"
34
35#include "UI_view2d.hh"
36
37#include "ED_anim_api.hh"
38#include "ED_gpencil_legacy.hh"
39#include "ED_grease_pencil.hh"
40#include "ED_keyframes_edit.hh"
42#include "ED_markers.hh"
43#include "ED_mask.hh"
44#include "ED_screen.hh"
45#include "ED_select_utils.hh"
46
47#include "WM_api.hh"
48#include "WM_types.hh"
49
50#include "action_intern.hh"
51
52namespace blender {
53
54/* -------------------------------------------------------------------- */
57
60 float region_x,
61 float region_y)
62{
63 View2D *v2d = &ac->region->v2d;
64
65 float view_x, view_y;
66 int channel_index;
67 ui::view2d_region_to_view(v2d, region_x, region_y, &view_x, &view_y);
70 0,
72 view_x,
73 view_y,
74 nullptr,
75 &channel_index);
76
77 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
78 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
79
80 bAnimListElem *ale = static_cast<bAnimListElem *>(BLI_findlink(&anim_data, channel_index));
81 if (ale != nullptr) {
82 BLI_remlink(&anim_data, ale);
83 ale->next = ale->prev = nullptr;
84 }
85 ANIM_animdata_freelist(&anim_data);
86
87 return ale;
88}
89
91 AnimKeylist *keylist,
92 bAnimListElem *ale)
93{
94 bDopeSheet *ads = nullptr;
96 ads = static_cast<bDopeSheet *>(ac->data);
97 }
98
99 float2 range = {ac->region->v2d.cur.xmin, ac->region->v2d.cur.xmax};
100
101 if (ale->key_data) {
102 switch (ale->datatype) {
103 case ALE_SCE: {
104 Scene *scene = static_cast<Scene *>(ale->key_data);
105 scene_to_keylist(ads, scene, keylist, 0, range);
106 break;
107 }
108 case ALE_OB: {
109 Object *ob = static_cast<Object *>(ale->key_data);
110 ob_to_keylist(ads, ob, keylist, 0, range);
111 break;
112 }
113 case ALE_ACTION_LAYERED: {
114 /* This is only called for action summaries in the Dope-sheet, *not* the
115 * Action Editor. Therefore despite the name `ALE_ACTION_LAYERED`, this
116 * is only used to show a *single slot* of the action: the slot used by
117 * the ID the action is listed under.
118 *
119 * Thus we use the same function as the `ALE_ACTION_SLOT` case below
120 * because in practice the only distinction between these cases is where
121 * they get the slot from. In this case, we get it from `elem`'s ADT. */
122 animrig::Action *action = static_cast<animrig::Action *>(ale->key_data);
123 BLI_assert(action);
124 BLI_assert(ale->adt);
126 ac, ale->id, *action, ale->adt->slot_handle, keylist, 0, range);
127 break;
128 }
129 case ALE_ACTION_SLOT: {
130 animrig::Action *action = static_cast<animrig::Action *>(ale->key_data);
131 animrig::Slot *slot = static_cast<animrig::Slot *>(ale->data);
132 BLI_assert(action);
133 BLI_assert(slot);
134 action_slot_summary_to_keylist(ac, ale->id, *action, slot->handle, keylist, 0, range);
135 break;
136 }
137 case ALE_ACT: {
138 /* Legacy action. */
139 bAction *act = static_cast<bAction *>(ale->key_data);
140 action_to_keylist(ale->adt, act, keylist, 0, range);
141 break;
142 }
143 case ALE_FCURVE: {
144 FCurve *fcu = static_cast<FCurve *>(ale->key_data);
145 fcurve_to_keylist(ale->adt, fcu, keylist, 0, range, ANIM_nla_mapping_allowed(ale));
146 break;
147 }
148 case ALE_NONE:
149 case ALE_GPFRAME:
150 case ALE_MASKLAY:
151 case ALE_NLASTRIP:
152 case ALE_ALL:
153 case ALE_GROUP:
157 break;
158 }
159 }
160 else if (ale->type == ANIMTYPE_SUMMARY) {
161 /* Dope-sheet summary covers everything. */
162 summary_to_keylist(ac, keylist, 0, range);
163 }
164 else if (ale->type == ANIMTYPE_GROUP) {
165 /* TODO: why don't we just give groups key_data too? */
166 bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
167 action_group_to_keylist(ale->adt, agrp, keylist, 0, range);
168 }
169 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) {
170 /* TODO: why don't we just give grease pencil layers key_data too? */
172 ale->adt, static_cast<const GreasePencilLayer *>(ale->data), keylist, 0);
173 }
174 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER_GROUP) {
175 /* TODO: why don't we just give grease pencil layers key_data too? */
177 ale->adt, static_cast<const GreasePencilLayerTreeGroup *>(ale->data), keylist, 0);
178 }
179 else if (ale->type == ANIMTYPE_GREASE_PENCIL_DATABLOCK) {
180 /* TODO: why don't we just give grease pencil layers key_data too? */
182 ale->adt, static_cast<const GreasePencil *>(ale->data), keylist, 0, false);
183 }
184 else if (ale->type == ANIMTYPE_GPLAYER) {
185 /* TODO: why don't we just give gplayers key_data too? */
186 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
187 gpl_to_keylist(ads, gpl, keylist);
188 }
189 else if (ale->type == ANIMTYPE_MASKLAYER) {
190 /* TODO: why don't we just give masklayers key_data too? */
191 MaskLayer *masklay = static_cast<MaskLayer *>(ale->data);
192 mask_to_keylist(ads, masklay, keylist);
193 }
194}
195
197 bAnimListElem *ale,
198 float region_x,
199 float *r_selx,
200 float *r_frame,
201 bool *r_found,
202 bool *r_is_selected)
203{
204 *r_found = false;
205
206 View2D *v2d = &ac->region->v2d;
207
208 AnimKeylist *keylist = ED_keylist_create();
209 actkeys_list_element_to_keylist(ac, keylist, ale);
211
212 /* standard channel height (to allow for some slop) */
213 float key_hsize = ANIM_UI_get_channel_height() * 0.8f;
214 /* half-size (for either side), but rounded up to nearest int (for easier targeting) */
215 key_hsize = roundf(key_hsize / 2.0f);
216
217 const Bounds<float> range = {
218 ui::view2d_region_to_view_x(v2d, region_x - int(key_hsize)),
219 ui::view2d_region_to_view_x(v2d, region_x + int(key_hsize)),
220 };
221 const ActKeyColumn *ak = ED_keylist_find_any_between(keylist, range);
222 if (ak) {
223
224 /* set the frame to use, and apply inverse-correction for NLA-mapping
225 * so that the frame will get selected by the selection functions without
226 * requiring to map each frame once again...
227 */
229 *r_frame = ak->cfra;
230 *r_found = true;
231 *r_is_selected = (ak->sel & SELECT) != 0;
232 }
233
234 /* cleanup temporary lists */
235 ED_keylist_free(keylist);
236}
237
240 float region_x,
241 float region_y,
242 bAnimListElem **r_ale,
243 float *r_selx,
244 float *r_frame,
245 bool *r_found,
246 bool *r_is_selected)
247
248{
249 *r_found = false;
250 *r_ale = actkeys_find_list_element_at_position(ac, filter, region_x, region_y);
251
252 if (*r_ale != nullptr) {
254 ac, *r_ale, region_x, r_selx, r_frame, r_found, r_is_selected);
255 }
256}
257
258static bool actkeys_is_key_at_position(bAnimContext *ac, float region_x, float region_y)
259{
260 bAnimListElem *ale;
261 float selx, frame;
262 bool found;
263 bool is_selected;
264
268 ac, filter, region_x, region_y, &ale, &selx, &frame, &found, &is_selected);
269
270 if (ale != nullptr) {
271 MEM_delete(ale);
272 }
273 return found;
274}
275
277
278/* -------------------------------------------------------------------- */
286
287/* Deselects keyframes in the action editor
288 * - This is called by the deselect all operator, as well as other ones!
289 *
290 * - test: check if select or deselect all
291 * - sel: how to select keyframes (SELECT_*)
292 */
294{
295 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
297
298 KeyframeEditData ked = {{nullptr}};
299 KeyframeEditFunc test_cb, sel_cb;
300
301 /* determine type-based settings */
303
304 /* filter data */
305 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
306
307 /* init BezTriple looping data */
309
310 /* See if we should be selecting or deselecting */
311 if (test) {
312 for (bAnimListElem &ale : anim_data) {
313 if (ale.type == ANIMTYPE_GPLAYER) {
314 if (ED_gpencil_layer_frame_select_check(static_cast<bGPDlayer *>(ale.data))) {
315 sel = SELECT_SUBTRACT;
316 break;
317 }
318 }
319 else if (ale.type == ANIMTYPE_MASKLAYER) {
320 if (ED_masklayer_frame_select_check(static_cast<MaskLayer *>(ale.data))) {
321 sel = SELECT_SUBTRACT;
322 break;
323 }
324 }
325 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
327 static_cast<GreasePencilLayer *>(ale.data)->wrap()))
328 {
329 sel = SELECT_SUBTRACT;
330 }
331 break;
332 }
333 else {
335 &ked, static_cast<FCurve *>(ale.key_data), nullptr, test_cb, nullptr))
336 {
337 sel = SELECT_SUBTRACT;
338 break;
339 }
340 }
341 }
342 }
343
344 /* convert sel to selectmode, and use that to get editor */
345 sel_cb = ANIM_editkeyframes_select(sel);
346
347 /* Now set the flags */
348 for (bAnimListElem &ale : anim_data) {
349 if (ale.type == ANIMTYPE_GPLAYER) {
350 ED_gpencil_layer_frame_select_set(static_cast<bGPDlayer *>(ale.data), sel);
351 ale.update |= ANIM_UPDATE_DEPS;
352 }
353 else if (ale.type == ANIMTYPE_MASKLAYER) {
354 ED_masklayer_frame_select_set(static_cast<MaskLayer *>(ale.data), sel);
355 }
356 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
357 ed::greasepencil::select_all_frames(static_cast<GreasePencilLayer *>(ale.data)->wrap(), sel);
358 ale.update |= ANIM_UPDATE_DEPS;
359 }
360 else {
362 &ked, static_cast<FCurve *>(ale.key_data), nullptr, sel_cb, nullptr);
363 }
364 }
365
366 /* Cleanup */
367 ANIM_animdata_update(ac, &anim_data);
368 ANIM_animdata_freelist(&anim_data);
369}
370
371/* ------------------- */
372
374{
375 bAnimContext ac;
376
377 /* get editor data */
378 if (ANIM_animdata_get_context(C, &ac) == 0) {
379 return OPERATOR_CANCELLED;
380 }
381
382 /* 'standard' behavior - check if selected, then apply relevant selection */
383 const int action = RNA_enum_get(op->ptr, "action");
384 switch (action) {
385 case SEL_TOGGLE:
387 break;
388 case SEL_SELECT:
390 break;
391 case SEL_DESELECT:
393 break;
394 case SEL_INVERT:
396 break;
397 default:
398 BLI_assert(0);
399 break;
400 }
401
402 /* set notifier that keyframe selection have changed */
406 }
407 return OPERATOR_FINISHED;
408}
409
411{
412 /* identifiers */
413 ot->name = "Select All";
414 ot->idname = "ACTION_OT_select_all";
415 ot->description = "Toggle selection of all keyframes";
416
417 /* API callbacks. */
420
421 /* flags */
423
424 /* properties */
426}
427
429
430/* -------------------------------------------------------------------- */
440
441/* defines for box_select mode */
442enum {
446} /*eActKeys_BoxSelect_Mode*/;
447
455
456static void box_select_elem(
457 BoxSelectData *sel_data, bAnimListElem *ale, float xmin, float xmax, bool summary)
458{
459 bAnimContext *ac = sel_data->ac;
460
461 switch (ale->type) {
463 GreasePencil *grease_pencil = static_cast<GreasePencil *>(ale->data);
464 for (bke::greasepencil::Layer *layer : grease_pencil->layers_for_write()) {
466 layer->wrap().as_node(), xmin, xmax, sel_data->selectmode);
467 }
468 ale->update |= ANIM_UPDATE_DEPS;
469 break;
470 }
474 static_cast<GreasePencilLayerTreeNode *>(ale->data)->wrap(),
475 xmin,
476 xmax,
477 sel_data->selectmode);
478 ale->update |= ANIM_UPDATE_DEPS;
479 break;
480 case ANIMTYPE_GPLAYER: {
482 static_cast<bGPDlayer *>(ale->data), xmin, xmax, sel_data->selectmode);
483 ale->update |= ANIM_UPDATE_DEPS;
484 break;
485 }
487 Mask *mask = static_cast<Mask *>(ale->data);
488 MaskLayer *masklay;
489 for (masklay = mask->masklayers.first(); masklay; masklay = masklay->next) {
490 ED_masklayer_frames_select_box(masklay, xmin, xmax, sel_data->selectmode);
491 }
492 break;
493 }
494 case ANIMTYPE_MASKLAYER: {
496 static_cast<MaskLayer *>(ale->data), xmin, xmax, sel_data->selectmode);
497 break;
498 }
499 default: {
500 if (summary) {
501 break;
502 }
503
504 if (ale->type == ANIMTYPE_SUMMARY) {
505 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
507 ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, eAnimCont_Types(ac->datatype));
508
509 for (bAnimListElem &ale2 : anim_data) {
510 box_select_elem(sel_data, &ale2, xmin, xmax, true);
511 }
512
513 ANIM_animdata_update(ac, &anim_data);
514 ANIM_animdata_freelist(&anim_data);
515 }
516
519 &sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, nullptr);
520 }
521 }
522 }
523}
524
526 const rcti rect,
527 short mode,
528 const eEditKeyframes_Select selectmode)
529{
530 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
531 bAnimListElem *ale;
533
534 BoxSelectData sel_data{};
535 sel_data.ac = ac;
536 sel_data.selectmode = selectmode;
537
538 View2D *v2d = &ac->region->v2d;
539 rctf rectf;
540
541 /* Convert mouse coordinates to frame ranges and channel
542 * coordinates corrected for view pan/zoom. */
543 ui::view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
544 ui::view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
545
546 /* filter data */
548 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
549
550 /* Get beztriple editing/validation functions. */
551 sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
552
555 }
556 else {
557 sel_data.ok_cb = nullptr;
558 }
559
560 /* init editing data */
561 memset(&sel_data.ked, 0, sizeof(KeyframeEditData));
562
563 float ymax = ANIM_UI_get_first_channel_top(v2d);
564 const float channel_step = ANIM_UI_get_channel_step();
565
566 /* loop over data, doing box select */
567 for (ale = anim_data.first(); ale; ale = ale->next, ymax -= channel_step) {
568 /* get new vertical minimum extent of channel */
569 float ymin = ymax - channel_step;
570
571 /* set horizontal range (if applicable) */
573 /* if channel is mapped in NLA, apply correction */
574 if (ANIM_nla_mapping_allowed(ale)) {
576 const float f1 = ANIM_nla_tweakedit_remap(ale, rectf.xmin, NLATIME_CONVERT_UNMAP);
577 const float f2 = ANIM_nla_tweakedit_remap(ale, rectf.xmax, NLATIME_CONVERT_UNMAP);
578
579 /* Make sure f1 & f2 are in order (e.g. in case of NLASTRIP_FLAG_REVERSE). Note: will still
580 * fail for the Summary (since that is excluded from NLA remapping). */
581 sel_data.ked.f1 = math::min(f1, f2);
582 sel_data.ked.f2 = math::max(f1, f2);
583 }
584 else {
585 sel_data.ked.iterflags |= (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP); /* for summary tracks */
586 sel_data.ked.f1 = rectf.xmin;
587 sel_data.ked.f2 = rectf.xmax;
588 }
589 }
590
591 /* perform vertical suitability check (if applicable) */
592 if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
593 box_select_elem(&sel_data, ale, rectf.xmin, rectf.xmax, false);
594 }
595 }
596
597 /* cleanup */
598 ANIM_animdata_update(ac, &anim_data);
599 ANIM_animdata_freelist(&anim_data);
600}
601
602/* ------------------- */
603
605 wmOperator *op,
606 const wmEvent *event)
607{
608 bAnimContext ac;
609 if (ANIM_animdata_get_context(C, &ac) == 0) {
610 return OPERATOR_CANCELLED;
611 }
612
613 bool tweak = RNA_boolean_get(op->ptr, "tweak");
614 if (tweak) {
615 int mval[2];
616 WM_event_drag_start_mval(event, ac.region, mval);
617 if (actkeys_is_key_at_position(&ac, mval[0], mval[1])) {
619 }
620 }
621
622 /* `SPACE_ACTION` clamps view at draw-time (foot-gun, draw code should probably be
623 * read-only...), so prevent panning past that. We shouldn't limit horizontal range to
624 * `tot`, however, because for timelines it is the scene playback range. */
625 const wmOperatorStatus opstatus = WM_gesture_box_invoke(C, op, event);
626 wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
627 if (gesture->edge_pan_data && ac.region) {
628 gesture->edge_pan_data->limit.ymin = ac.region->v2d.tot.ymin;
629 gesture->edge_pan_data->limit.ymax = ac.region->v2d.tot.ymax;
630 }
631 return opstatus;
632}
633
635{
636 bAnimContext ac;
637 rcti rect;
638 short mode = 0;
639
640 /* get editor data */
641 if (ANIM_animdata_get_context(C, &ac) == 0) {
642 return OPERATOR_CANCELLED;
643 }
644
645 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
646 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
647 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
649 }
650
651 /* get settings from operator */
653
654 /* selection 'mode' depends on whether box_select region only matters on one axis */
655 if (RNA_boolean_get(op->ptr, "axis_range")) {
656 /* Mode depends on which axis of the range is larger to determine which axis to use:
657 * - checking this in region-space is fine,
658 * as it's fundamentally still going to be a different rect size.
659 * - the frame-range select option is favored over the channel one (x over y),
660 * as frame-range one is often used for tweaking timing when "blocking",
661 * while channels is not that useful...
662 */
663 if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
665 }
666 else {
668 }
669 }
670 else {
672 }
673
674 /* apply box_select action */
675 box_select_action(&ac, rect, mode, selectmode);
676
677 /* set notifier that keyframe selection have changed */
681 }
682 return OPERATOR_FINISHED;
683}
684
686{
687 /* identifiers */
688 ot->name = "Box Select";
689 ot->idname = "ACTION_OT_select_box";
690 ot->description = "Select all keyframes within the specified region";
691
692 /* API callbacks. */
697
699
700 /* flags */
701 ot->flag = OPTYPE_UNDO;
702
703 /* rna */
704 ot->prop = RNA_def_boolean(ot->srna, "axis_range", false, "Axis Range", "");
705
706 /* properties */
709
711 ot->srna, "tweak", false, "Tweak", "Operator has been activated using a click-drag event");
713}
714
716
717/* -------------------------------------------------------------------- */
724
733
734static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, bool summary)
735{
736 bAnimContext *ac = sel_data->ac;
737
738 switch (ale->type) {
739 case ANIMTYPE_GPLAYER: {
741 static_cast<bGPDlayer *>(ale->data),
742 sel_data->mode,
743 sel_data->selectmode);
744 ale->update |= ANIM_UPDATE_DEPS;
745 break;
746 }
750 &sel_data->ked,
751 static_cast<GreasePencilLayerTreeNode *>(ale->data)->wrap(),
752 sel_data->mode,
753 sel_data->selectmode);
754 ale->update |= ANIM_UPDATE_DEPS;
755 break;
756 }
758 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
760 ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, eAnimCont_Types(ac->datatype));
761
762 for (bAnimListElem &ale2 : anim_data) {
763 if ((ale2.type == ANIMTYPE_GREASE_PENCIL_LAYER) && (ale2.id == ale->data)) {
764 region_select_elem(sel_data, &ale2, true);
765 }
766 }
767
768 ANIM_animdata_update(ac, &anim_data);
769 ANIM_animdata_freelist(&anim_data);
770 break;
771 }
773 Mask *mask = static_cast<Mask *>(ale->data);
774 MaskLayer *masklay;
775 for (masklay = mask->masklayers.first(); masklay; masklay = masklay->next) {
777 &sel_data->ked, masklay, sel_data->mode, sel_data->selectmode);
778 }
779 break;
780 }
781 case ANIMTYPE_MASKLAYER: {
783 static_cast<MaskLayer *>(ale->data),
784 sel_data->mode,
785 sel_data->selectmode);
786 break;
787 }
788 default: {
789 if (summary) {
790 break;
791 }
792
793 if (ale->type == ANIMTYPE_SUMMARY) {
794 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
796 ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, eAnimCont_Types(ac->datatype));
797
798 for (bAnimListElem &ale2 : anim_data) {
799 region_select_elem(sel_data, &ale2, true);
800 }
801
802 ANIM_animdata_update(ac, &anim_data);
803 ANIM_animdata_freelist(&anim_data);
804 }
805
808 &sel_data->ked, ac->ads, ale, sel_data->ok_cb, sel_data->select_cb, nullptr);
809 }
810 }
811 }
812}
813
815 const rctf *rectf_view,
816 short mode,
817 eEditKeyframes_Select selectmode,
818 void *data)
819{
820 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
821 bAnimListElem *ale;
823
824 RegionSelectData sel_data{};
825 sel_data.ac = ac;
826 sel_data.mode = mode;
827 sel_data.selectmode = selectmode;
828 View2D *v2d = &ac->region->v2d;
829 rctf rectf, scaled_rectf;
830
831 /* Convert mouse coordinates to frame ranges and channel
832 * coordinates corrected for view pan/zoom. */
833 ui::view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
834
835 /* filter data */
837 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
838
839 /* Get beztriple editing/validation functions. */
840 sel_data.select_cb = ANIM_editkeyframes_select(selectmode);
841 sel_data.ok_cb = ANIM_editkeyframes_ok(mode);
842
843 /* init editing data */
844 memset(&sel_data.ked, 0, sizeof(KeyframeEditData));
845 if (mode == BEZT_OK_CHANNEL_LASSO) {
846 KeyframeEdit_LassoData *data_lasso = static_cast<KeyframeEdit_LassoData *>(data);
847 data_lasso->rectf_scaled = &scaled_rectf;
848 sel_data.ked.data = data_lasso;
849 }
850 else if (mode == BEZT_OK_CHANNEL_CIRCLE) {
851 KeyframeEdit_CircleData *data_circle = static_cast<KeyframeEdit_CircleData *>(data);
852 data_circle->rectf_scaled = &scaled_rectf;
853 sel_data.ked.data = data;
854 }
855 else {
856 sel_data.ked.data = &scaled_rectf;
857 }
858
859 float ymax = ANIM_UI_get_first_channel_top(v2d);
860 const float channel_step = ANIM_UI_get_channel_step();
861
862 /* loop over data, doing region select */
863 for (ale = anim_data.first(); ale; ale = ale->next, ymax -= channel_step) {
864 /* get new vertical minimum extent of channel */
865 const float ymin = ymax - channel_step;
866
867 /* compute midpoint of channel (used for testing if the key is in the region or not) */
868 sel_data.ked.channel_y = (ymin + ymax) / 2.0f;
869
870 /* if channel is mapped in NLA, apply correction
871 * - Apply to the bounds being checked, not all the keyframe points,
872 * to avoid having scaling everything
873 * - Save result to the scaled_rect, which is all that these operators
874 * will read from
875 */
876 if (ANIM_nla_mapping_allowed(ale)) {
878 const float f1 = ANIM_nla_tweakedit_remap(ale, rectf.xmin, NLATIME_CONVERT_UNMAP);
879 const float f2 = ANIM_nla_tweakedit_remap(ale, rectf.xmax, NLATIME_CONVERT_UNMAP);
880
881 /* Make sure f1 & f2 are in order (e.g. in case of NLASTRIP_FLAG_REVERSE). Note: will still
882 * fail for the Summary (since that is excluded from NLA remapping). */
883 sel_data.ked.f1 = math::min(f1, f2);
884 sel_data.ked.f2 = math::max(f1, f2);
885 }
886 else {
887 sel_data.ked.iterflags |= (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP); /* for summary tracks */
888 sel_data.ked.f1 = rectf.xmin;
889 sel_data.ked.f2 = rectf.xmax;
890 }
891
892 /* Update values for scaled_rectf - which is used to compute the mapping in the callbacks
893 * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these
894 * with the properly remapped ked.f1/f2 values, when needed
895 */
896 scaled_rectf.xmin = sel_data.ked.f1;
897 scaled_rectf.xmax = sel_data.ked.f2;
898 scaled_rectf.ymin = ymin;
899 scaled_rectf.ymax = ymax;
900
901 /* perform vertical suitability check (if applicable) */
902 if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
903 region_select_elem(&sel_data, ale, false);
904 }
905 }
906
907 /* cleanup */
908 ANIM_animdata_update(ac, &anim_data);
909 ANIM_animdata_freelist(&anim_data);
910}
911
912/* ----------------------------------- */
913
915{
916 bAnimContext ac;
917
918 KeyframeEdit_LassoData data_lasso;
919 rcti rect;
920 rctf rect_fl;
921
922 /* get editor data */
923 if (ANIM_animdata_get_context(C, &ac) == 0) {
924 return OPERATOR_CANCELLED;
925 }
926
927 data_lasso.rectf_view = &rect_fl;
928 data_lasso.mcoords = WM_gesture_lasso_path_to_array(C, op);
929 if (data_lasso.mcoords.is_empty()) {
930 return OPERATOR_CANCELLED;
931 }
932
933 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
934 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
935 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
937 }
938
939 /* get settings from operator */
940 BLI_lasso_boundbox(&rect, data_lasso.mcoords);
941 BLI_rctf_rcti_copy(&rect_fl, &rect);
942
943 /* apply box_select action */
944 region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso);
945
946 /* send notifier that keyframe selection has changed */
950 }
951 return OPERATOR_FINISHED;
952}
953
955{
956 /* identifiers */
957 ot->name = "Lasso Select";
958 ot->description = "Select keyframe points using lasso selection";
959 ot->idname = "ACTION_OT_select_lasso";
960
961 /* API callbacks. */
967
968 /* flags */
970
971 /* properties */
974}
975
976/* ------------------- */
977
979{
980 bAnimContext ac;
981
982 KeyframeEdit_CircleData data = {nullptr};
983 rctf rect_fl;
984
985 float x = RNA_int_get(op->ptr, "x");
986 float y = RNA_int_get(op->ptr, "y");
987 float radius = RNA_int_get(op->ptr, "radius");
988
989 /* get editor data */
990 if (ANIM_animdata_get_context(C, &ac) == 0) {
991 return OPERATOR_CANCELLED;
992 }
993
994 const eSelectOp sel_op = ED_select_op_modal(
995 eSelectOp(RNA_enum_get(op->ptr, "mode")),
996 WM_gesture_is_modal_first(static_cast<wmGesture *>(op->customdata)));
997 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
998 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
1000 }
1001
1002 data.mval[0] = x;
1003 data.mval[1] = y;
1004 data.radius_squared = radius * radius;
1005 data.rectf_view = &rect_fl;
1006
1007 rect_fl.xmin = x - radius;
1008 rect_fl.xmax = x + radius;
1009 rect_fl.ymin = y - radius;
1010 rect_fl.ymax = y + radius;
1011
1012 /* apply region select action */
1013 region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data);
1014
1015 /* send notifier that keyframe selection has changed */
1019 }
1020 return OPERATOR_FINISHED;
1021}
1022
1024{
1025 ot->name = "Circle Select";
1026 ot->description = "Select keyframe points using circle selection";
1027 ot->idname = "ACTION_OT_select_circle";
1028
1035
1036 /* flags */
1037 ot->flag = OPTYPE_UNDO;
1038
1039 /* properties */
1042}
1043
1045
1046/* -------------------------------------------------------------------- */
1055
1056/* defines for column-select mode */
1058 {ACTKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""},
1059 {ACTKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""},
1060 {ACTKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""},
1062 "MARKERS_BETWEEN",
1063 0,
1064 "Between Min/Max Selected Markers",
1065 ""},
1066 {0, nullptr, 0, nullptr, nullptr},
1067};
1068
1069/* ------------------- */
1070
1071/* Selects all visible keyframes between the specified markers */
1072/* TODO(@ideasman42): this is almost an _exact_ duplicate of a function of the same name in
1073 * `graph_select.cc` should de-duplicate. */
1075{
1076 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1078
1079 KeyframeEditFunc ok_cb, select_cb;
1080 KeyframeEditData ked = {{nullptr}};
1081 float min, max;
1082
1083 /* get extreme markers */
1085 min -= 0.5f;
1086 max += 0.5f;
1087
1088 /* Get editing functions + data. */
1091
1092 ked.f1 = min;
1093 ked.f2 = max;
1094
1095 /* filter data */
1097 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1098
1099 /* select keys in-between */
1100 for (bAnimListElem &ale : anim_data) {
1101 switch (ale.type) {
1104 static_cast<GreasePencilLayerTreeNode *>(ale.data)->wrap(), min, max, SELECT_ADD);
1105 ale.update |= ANIM_UPDATE_DEPS;
1106 break;
1107 case ANIMTYPE_GPLAYER:
1109 static_cast<bGPDlayer *>(ale.data), min, max, SELECT_ADD);
1110 ale.update |= ANIM_UPDATE_DEPS;
1111 break;
1112
1113 case ANIMTYPE_MASKLAYER:
1114 ED_masklayer_frames_select_box(static_cast<MaskLayer *>(ale.data), min, max, SELECT_ADD);
1115 break;
1116
1117 case ANIMTYPE_FCURVE:
1118 case ANIMTYPE_NLACURVE: {
1119 FCurve *fcurve = static_cast<FCurve *>(ale.key_data);
1120 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, false, true);
1121 ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
1122 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, true, true);
1123 break;
1124 }
1125
1126 default:
1127 BLI_assert_msg(false, "Keys cannot be selected into this animation type.");
1128 }
1129 }
1130
1131 /* Cleanup */
1132 ANIM_animdata_update(ac, &anim_data);
1133 ANIM_animdata_freelist(&anim_data);
1134}
1135
1136/* Selects all visible keyframes in the same frames as the specified elements */
1137static void columnselect_action_keys(bAnimContext *ac, short mode)
1138{
1139 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1141
1142 Scene *scene = ac->scene;
1143 CfraElem *ce;
1144 KeyframeEditFunc select_cb, ok_cb;
1145 KeyframeEditData ked = {{nullptr}};
1146
1147 /* build list of columns */
1148 switch (mode) {
1149 case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */
1150 if (ac->datatype == ANIMCONT_GPENCIL) {
1152 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1153
1154 for (bAnimListElem &ale : anim_data) {
1155 switch (ale.type) {
1156 case ANIMTYPE_GPLAYER:
1158 static_cast<bGPDlayer *>(ale.data), &ked.cfra_elem_list, true);
1159 break;
1161 ed::greasepencil ::create_keyframe_edit_data_selected_frames_list(
1162 &ked, static_cast<GreasePencilLayer *>(ale.data)->wrap());
1163 break;
1164 default:
1165 /* Invalid channel type. */
1167 }
1168 }
1169 }
1170 else {
1172 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1173
1174 for (bAnimListElem &ale : anim_data) {
1175 if (ale.datatype == ALE_GPFRAME) {
1177 static_cast<bGPDlayer *>(ale.data), &ked.cfra_elem_list, true);
1178 }
1179 else {
1180 ked.data = &ale;
1182 &ked, static_cast<FCurve *>(ale.key_data), nullptr, bezt_to_cfraelem, nullptr);
1183 }
1184 }
1185 }
1186 ANIM_animdata_freelist(&anim_data);
1187 break;
1188
1189 case ACTKEYS_COLUMNSEL_CFRA: /* current frame */
1190 /* make a single CfraElem for storing this */
1191 ce = MEM_new_zeroed<CfraElem>("cfraElem");
1192 BLI_addtail(&ked.cfra_elem_list, ce);
1193
1194 ce->cfra = float(scene->r.cfra);
1195 break;
1196
1197 case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
1199 break;
1200
1201 default: /* invalid option */
1202 return;
1203 }
1204
1205 /* set up BezTriple edit callbacks */
1208
1209 /* loop through all of the keys and select additional keyframes
1210 * based on the keys found to be selected above
1211 */
1213 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1214
1215 for (bAnimListElem &ale : anim_data) {
1216 /* loop over cfraelems (stored in the KeyframeEditData->list)
1217 * - we need to do this here, as we can apply fewer NLA-mapping conversions
1218 */
1219 for (CfraElem &ce : ked.cfra_elem_list) {
1220 /* set frame for validation callback to refer to */
1222
1223 /* select elements with frame number matching cfraelem */
1224 if (ale.type == ANIMTYPE_GPLAYER) {
1225 ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale.data), ce.cfra, SELECT_ADD);
1226 ale.update |= ANIM_UPDATE_DEPS;
1227 }
1228 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1230 static_cast<GreasePencilLayer *>(ale.data)->wrap(), ce.cfra, SELECT_ADD);
1231 ale.update |= ANIM_UPDATE_DEPS;
1232 }
1233 else if (ale.type == ANIMTYPE_MASKLAYER) {
1234 ED_mask_select_frame(static_cast<MaskLayer *>(ale.data), ce.cfra, SELECT_ADD);
1235 }
1236 else {
1238 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1239 }
1240 }
1241 }
1242
1243 /* free elements */
1244 ked.cfra_elem_list.free_no_destruct();
1245 ked.time_marker_list.free_no_destruct();
1246
1247 ANIM_animdata_update(ac, &anim_data);
1248 ANIM_animdata_freelist(&anim_data);
1249}
1250
1251/* ------------------- */
1252
1254{
1255 bAnimContext ac;
1256 short mode;
1257
1258 /* get editor data */
1259 if (ANIM_animdata_get_context(C, &ac) == 0) {
1260 return OPERATOR_CANCELLED;
1261 }
1262
1263 /* action to take depends on the mode */
1264 mode = RNA_enum_get(op->ptr, "mode");
1265
1268 }
1269 else {
1270 columnselect_action_keys(&ac, mode);
1271 }
1272
1273 /* set notifier that keyframe selection have changed */
1277 }
1278 return OPERATOR_FINISHED;
1279}
1280
1282{
1283 /* identifiers */
1284 ot->name = "Select All";
1285 ot->idname = "ACTION_OT_select_column";
1286 ot->description = "Select all keyframes on the specified frame(s)";
1287
1288 /* API callbacks. */
1291
1292 /* flags */
1294
1295 /* props */
1296 ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
1298}
1299
1301
1302/* -------------------------------------------------------------------- */
1305
1307{
1308 bAnimContext ac;
1309
1310 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1312
1315
1316 /* get editor data */
1317 if (ANIM_animdata_get_context(C, &ac) == 0) {
1318 return OPERATOR_CANCELLED;
1319 }
1320
1321 /* loop through all of the keys and select additional keyframes based on these */
1324 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1325
1326 for (bAnimListElem &ale : anim_data) {
1327 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1328
1329 /* check if anything selected? */
1330 if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, ok_cb, nullptr)) {
1331 /* select every keyframe in this curve then */
1332 ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr);
1333 }
1334 }
1335
1336 /* Cleanup */
1337 ANIM_animdata_freelist(&anim_data);
1338
1339 /* set notifier that keyframe selection has changed */
1343 }
1344 return OPERATOR_FINISHED;
1345}
1346
1348{
1349 /* identifiers */
1350 ot->name = "Select Linked";
1351 ot->idname = "ACTION_OT_select_linked";
1352 ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
1353
1354 /* API callbacks. */
1357
1358 /* flags */
1360}
1361
1363
1364/* -------------------------------------------------------------------- */
1367
1368/* Common code to perform selection */
1369static void select_moreless_action_keys(bAnimContext *ac, short mode)
1370{
1371 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1373
1374 KeyframeEditData ked = {{nullptr}};
1375 KeyframeEditFunc build_cb;
1376
1377 /* init selmap building data */
1378 build_cb = ANIM_editkeyframes_buildselmap(mode);
1379
1380 /* loop through all of the keys and select additional keyframes based on these */
1383 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1384
1385 for (bAnimListElem &ale : anim_data) {
1386
1387 /* TODO: other types. */
1388 if (ale.datatype != ALE_FCURVE) {
1389 continue;
1390 }
1391
1392 /* only continue if F-Curve has keyframes */
1393 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1394 if (fcu->bezt == nullptr) {
1395 continue;
1396 }
1397
1398 /* build up map of whether F-Curve's keyframes should be selected or not */
1399 ked.data = MEM_new_zeroed(fcu->totvert, "selmap actEdit more");
1400 ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, build_cb, nullptr);
1401
1402 /* based on this map, adjust the selection status of the keyframes */
1403 ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, bezt_selmap_flush, nullptr);
1404
1405 /* free the selmap used here */
1406 MEM_delete_void(ked.data);
1407 ked.data = nullptr;
1408 }
1409
1410 /* Cleanup */
1411 ANIM_animdata_freelist(&anim_data);
1412}
1413
1414/* ----------------- */
1415
1417{
1418 bAnimContext ac;
1419
1420 /* get editor data */
1421 if (ANIM_animdata_get_context(C, &ac) == 0) {
1422 return OPERATOR_CANCELLED;
1423 }
1424
1425 /* perform select changes */
1427
1428 /* set notifier that keyframe selection has changed */
1432 }
1433 return OPERATOR_FINISHED;
1434}
1435
1437{
1438 /* identifiers */
1439 ot->name = "Select More";
1440 ot->idname = "ACTION_OT_select_more";
1441 ot->description = "Select keyframes beside already selected ones";
1442
1443 /* API callbacks. */
1446
1447 /* flags */
1449}
1450
1451/* ----------------- */
1452
1454{
1455 bAnimContext ac;
1456
1457 /* get editor data */
1458 if (ANIM_animdata_get_context(C, &ac) == 0) {
1459 return OPERATOR_CANCELLED;
1460 }
1461
1462 /* perform select changes */
1464
1465 /* set notifier that keyframe selection has changed */
1469 }
1470 return OPERATOR_FINISHED;
1471}
1472
1474{
1475 /* identifiers */
1476 ot->name = "Select Less";
1477 ot->idname = "ACTION_OT_select_less";
1478 ot->description = "Deselect keyframes on ends of selection islands";
1479
1480 /* API callbacks. */
1483
1484 /* flags */
1486}
1487
1489
1490/* -------------------------------------------------------------------- */
1495
1496/* defines for left-right select tool */
1498 {ACTKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
1499 {ACTKEYS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
1500 {ACTKEYS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
1501 {0, nullptr, 0, nullptr, nullptr},
1502};
1503
1504/* --------------------------------- */
1505
1507 short leftright,
1508 eEditKeyframes_Select select_mode)
1509{
1510 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1512
1513 KeyframeEditFunc ok_cb, select_cb;
1514 KeyframeEditData ked = {{nullptr}};
1515 Scene *scene = ac->scene;
1516
1517 /* if select mode is replace, deselect all keyframes (and channels) first */
1518 if (select_mode == SELECT_REPLACE) {
1519 select_mode = SELECT_ADD;
1520
1521 /* - deselect all other keyframes, so that just the newly selected remain
1522 * - channels aren't deselected, since we don't re-select any as a consequence
1523 */
1525 }
1526
1527 /* set callbacks and editing data */
1529 select_cb = ANIM_editkeyframes_select(select_mode);
1530
1531 if (leftright == ACTKEYS_LRSEL_LEFT) {
1532 ked.f1 = MINAFRAMEF;
1533 ked.f2 = float(scene->r.cfra + 0.1f);
1534 }
1535 else {
1536 ked.f1 = float(scene->r.cfra - 0.1f);
1537 ked.f2 = MAXFRAMEF;
1538 }
1539
1540 /* filter data */
1542 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1543
1544 /* select keys */
1545 for (bAnimListElem &ale : anim_data) {
1546 switch (ale.type) {
1549 static_cast<GreasePencilLayerTreeNode *>(ale.data)->wrap(),
1550 ked.f1,
1551 ked.f2,
1552 select_mode);
1553 ale.update |= ANIM_UPDATE_DEPS;
1554 break;
1555 case ANIMTYPE_GPLAYER:
1557 static_cast<bGPDlayer *>(ale.data), ked.f1, ked.f2, select_mode);
1558 ale.update |= ANIM_UPDATE_DEPS;
1559 break;
1560
1561 case ANIMTYPE_MASKLAYER:
1563 static_cast<MaskLayer *>(ale.data), ked.f1, ked.f2, select_mode);
1564 break;
1565
1566 case ANIMTYPE_FCURVE:
1567 case ANIMTYPE_NLACURVE: {
1568 FCurve *fcurve = static_cast<FCurve *>(ale.key_data);
1569 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, false, true);
1570 ANIM_fcurve_keyframes_loop(&ked, fcurve, ok_cb, select_cb, nullptr);
1571 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, true, true);
1572 break;
1573 }
1574
1575 default:
1576 BLI_assert_msg(false, "Keys cannot be selected into this animation type.");
1577 }
1578 }
1579
1580 /* Sync marker support */
1581 if (select_mode == SELECT_ADD) {
1582 SpaceAction *saction = reinterpret_cast<SpaceAction *>(ac->sl);
1583
1584 if (saction && ac->markers && (saction->flag & SACTION_MARKERS_MOVE)) {
1585 for (TimeMarker &marker : *ac->markers) {
1586 if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker.frame < scene->r.cfra)) ||
1587 ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker.frame >= scene->r.cfra)))
1588 {
1589 marker.flag |= SELECT;
1590 }
1591 else {
1592 marker.flag &= ~SELECT;
1593 }
1594 }
1595 }
1596 }
1597
1598 /* Cleanup */
1599 ANIM_animdata_update(ac, &anim_data);
1600 ANIM_animdata_freelist(&anim_data);
1601}
1602
1603/* ----------------- */
1604
1606{
1607 bAnimContext ac;
1608 short leftright = RNA_enum_get(op->ptr, "mode");
1609 eEditKeyframes_Select selectmode;
1610
1611 /* get editor data */
1612 if (ANIM_animdata_get_context(C, &ac) == 0) {
1613 return OPERATOR_CANCELLED;
1614 }
1615
1616 /* select mode is either replace (deselect all, then add) or add/extend */
1617 if (RNA_boolean_get(op->ptr, "extend")) {
1618 selectmode = SELECT_INVERT;
1619 }
1620 else {
1621 selectmode = SELECT_REPLACE;
1622 }
1623
1624 /* if "test" mode is set, we don't have any info to set this with */
1625 if (leftright == ACTKEYS_LRSEL_TEST) {
1626 return OPERATOR_CANCELLED;
1627 }
1628
1629 /* do the selecting now */
1630 actkeys_select_leftright(&ac, leftright, selectmode);
1631
1632 /* set notifier that keyframe selection (and channels too) have changed */
1635
1636 return OPERATOR_FINISHED;
1637}
1638
1640 wmOperator *op,
1641 const wmEvent *event)
1642{
1643 bAnimContext ac;
1644 short leftright = RNA_enum_get(op->ptr, "mode");
1645
1646 /* get editor data */
1647 if (ANIM_animdata_get_context(C, &ac) == 0) {
1648 return OPERATOR_CANCELLED;
1649 }
1650
1651 /* handle mode-based testing */
1652 if (leftright == ACTKEYS_LRSEL_TEST) {
1653 Scene *scene = ac.scene;
1654 ARegion *region = ac.region;
1655 View2D *v2d = &region->v2d;
1656 float x;
1657
1658 /* determine which side of the current frame mouse is on */
1659 x = ui::view2d_region_to_view_x(v2d, event->mval[0]);
1660 if (x < scene->r.cfra) {
1661 RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
1662 }
1663 else {
1664 RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
1665 }
1666 }
1667
1668 /* perform selection */
1669 return actkeys_select_leftright_exec(C, op);
1670}
1671
1673{
1674 PropertyRNA *prop;
1675
1676 /* identifiers */
1677 ot->name = "Select Left/Right";
1678 ot->idname = "ACTION_OT_select_leftright";
1679 ot->description = "Select keyframes to the left or the right of the current frame";
1680
1681 /* API callbacks. */
1685
1686 /* flags */
1688
1689 /* properties */
1690 ot->prop = RNA_def_enum(
1693
1694 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", "");
1696}
1697
1699
1700/* -------------------------------------------------------------------- */
1712
1713/* option 1) select keyframe directly under mouse */
1715 bAnimListElem *ale,
1716 const eEditKeyframes_Select select_mode,
1717 float selx)
1718{
1719 KeyframeEditData ked = {{nullptr}};
1720 KeyframeEditFunc select_cb, ok_cb;
1721
1722 /* get functions for selecting keyframes */
1723 select_cb = ANIM_editkeyframes_select(select_mode);
1725 ked.f1 = selx;
1727
1728 /* select the nominated keyframe on the given frame */
1729 if (ale->type == ANIMTYPE_GPLAYER) {
1730 ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale->data), selx, select_mode);
1731 ale->update |= ANIM_UPDATE_DEPS;
1732 }
1733 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1735 static_cast<GreasePencilLayer *>(ale->data)->wrap(), selx, select_mode);
1736 ale->update |= ANIM_UPDATE_DEPS;
1737 }
1738 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER_GROUP) {
1740 static_cast<GreasePencilLayerTreeGroup *>(ale->data)->wrap(), selx, select_mode);
1741 }
1742 else if (ale->type == ANIMTYPE_GREASE_PENCIL_DATABLOCK) {
1743 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1745
1747 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1748
1749 /* Loop over all keys that are represented by this data-block key. */
1750 for (bAnimListElem &ale2 : anim_data) {
1751 if ((ale2.type != ANIMTYPE_GREASE_PENCIL_LAYER) || (ale2.id != ale->data)) {
1752 continue;
1753 }
1755 static_cast<GreasePencilLayer *>(ale2.data)->wrap(), selx, select_mode);
1756 ale2.update |= ANIM_UPDATE_DEPS;
1757 }
1758 }
1759 else if (ale->type == ANIMTYPE_MASKLAYER) {
1760 ED_mask_select_frame(static_cast<MaskLayer *>(ale->data), selx, select_mode);
1761 }
1762 else {
1763 if (ale->type == ANIMTYPE_SUMMARY && ale->datatype == ALE_ALL) {
1764 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1766
1768 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1769
1770 /* Loop over all keys that are represented by this summary key. */
1771 for (bAnimListElem &ale2 : anim_data) {
1772 switch (ale2.type) {
1773 case ANIMTYPE_GPLAYER:
1774 ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale2.data), selx, select_mode);
1775 ale2.update |= ANIM_UPDATE_DEPS;
1776 break;
1777
1778 case ANIMTYPE_MASKLAYER:
1779 ED_mask_select_frame(static_cast<MaskLayer *>(ale2.data), selx, select_mode);
1780 break;
1781
1784 static_cast<GreasePencilLayer *>(ale2.data)->wrap(), selx, select_mode);
1785 ale2.update |= ANIM_UPDATE_DEPS;
1786 break;
1787
1788 default:
1789 break;
1790 }
1791 }
1792
1793 ANIM_animdata_update(ac, &anim_data);
1794 ANIM_animdata_freelist(&anim_data);
1795 }
1796
1798 ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, nullptr);
1799 }
1800 }
1801}
1802
1803/* Option 2) Selects all the keyframes on either side of the current frame
1804 * (depends on which side the mouse is on) */
1805/* (see actkeys_select_leftright) */
1806
1807/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
1808static void actkeys_mselect_column(bAnimContext *ac, eEditKeyframes_Select select_mode, float selx)
1809{
1810 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1812
1813 KeyframeEditFunc select_cb, ok_cb;
1814 KeyframeEditData ked = {{nullptr}};
1815
1816 /* set up BezTriple edit callbacks */
1817 select_cb = ANIM_editkeyframes_select(select_mode);
1819
1820 /* loop through all of the keys and select additional keyframes
1821 * based on the keys found to be selected above
1822 */
1824 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1825
1826 for (bAnimListElem &ale : anim_data) {
1827 /* select elements with frame number matching cfra */
1828 if (ale.type == ANIMTYPE_GPLAYER) {
1829 ED_gpencil_select_frame(static_cast<bGPDlayer *>(ale.data), selx, select_mode);
1830 ale.update |= ANIM_UPDATE_DEPS;
1831 }
1832 else if (ale.type == ANIMTYPE_MASKLAYER) {
1833 ED_mask_select_frame(static_cast<MaskLayer *>(ale.data), selx, select_mode);
1834 }
1835 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1837 static_cast<GreasePencilLayer *>(ale.data)->wrap(), selx, select_mode);
1838 ale.update |= ANIM_UPDATE_DEPS;
1839 }
1840 else {
1841 /* set frame for validation callback to refer to */
1843
1845 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1846 }
1847 }
1848
1849 /* free elements */
1850 ked.cfra_elem_list.free_no_destruct();
1851 ked.time_marker_list.free_no_destruct();
1852
1853 ANIM_animdata_update(ac, &anim_data);
1854 ANIM_animdata_freelist(&anim_data);
1855}
1856
1857/* option 4) select all keyframes in same channel */
1859 bAnimListElem *ale,
1860 eEditKeyframes_Select select_mode)
1861{
1862 KeyframeEditFunc select_cb;
1863
1864 /* get functions for selecting keyframes */
1865 select_cb = ANIM_editkeyframes_select(select_mode);
1866
1867 /* select all keyframes in this channel */
1868 if (ale->type == ANIMTYPE_GPLAYER) {
1869 ED_gpencil_select_frames(static_cast<bGPDlayer *>(ale->data), select_mode);
1870 ale->update = ANIM_UPDATE_DEPS;
1871 }
1872 else if (ale->type == ANIMTYPE_MASKLAYER) {
1873 ED_mask_select_frames(static_cast<MaskLayer *>(ale->data), select_mode);
1874 }
1875 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1876 ed::greasepencil::select_all_frames(static_cast<GreasePencilLayer *>(ale->data)->wrap(),
1877 select_mode);
1878 ale->update |= ANIM_UPDATE_DEPS;
1879 }
1880 else {
1881 if (ale->type == ANIMTYPE_SUMMARY && ale->datatype == ALE_ALL) {
1882 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1884
1886 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1887
1888 for (bAnimListElem &ale2 : anim_data) {
1889 if (ale2.type == ANIMTYPE_GPLAYER) {
1890 ED_gpencil_select_frames(static_cast<bGPDlayer *>(ale2.data), select_mode);
1891 ale2.update |= ANIM_UPDATE_DEPS;
1892 }
1893 else if (ale2.type == ANIMTYPE_MASKLAYER) {
1894 ED_mask_select_frames(static_cast<MaskLayer *>(ale2.data), select_mode);
1895 }
1896 }
1897
1898 ANIM_animdata_update(ac, &anim_data);
1899 ANIM_animdata_freelist(&anim_data);
1900 }
1901
1903 ANIM_animchannel_keyframes_loop(nullptr, ac->ads, ale, nullptr, select_cb, nullptr);
1904 }
1905 }
1906}
1907
1908/* ------------------- */
1909
1911 const int mval[2],
1912 eEditKeyframes_Select select_mode,
1913 const bool deselect_all,
1914 const bool column,
1915 const bool same_channel,
1916 bool wait_to_deselect_others)
1917{
1918 /* NOTE: keep this functionality in sync with #MARKER_OT_select.
1919 * The logic here closely matches its internals.
1920 * From a user perspective the functions should also behave in much the same way. */
1921
1924
1925 bAnimListElem *ale = nullptr;
1926 bool found = false;
1927 bool is_selected = false;
1928 float frame = 0.0f; /* frame of keyframe under mouse - NLA corrections not applied/included */
1929 float selx = 0.0f; /* frame of keyframe under mouse */
1931
1933 ac, filter, mval[0], mval[1], &ale, &selx, &frame, &found, &is_selected);
1934
1935 if (select_mode != SELECT_REPLACE) {
1936 wait_to_deselect_others = false;
1937 }
1938
1939 /* For replacing selection, if we have something to select, we have to clear existing selection.
1940 * The same goes if we found nothing to select, and deselect_all is true
1941 * (deselect on nothing behavior). */
1942 if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) {
1943 /* reset selection mode for next steps */
1944 select_mode = SELECT_ADD;
1945
1946 /* Rather than deselecting others, users may want to drag to box-select (drag from empty space)
1947 * or tweak-translate an already selected item. If these cases may apply, delay deselection. */
1948 if (wait_to_deselect_others && (!found || is_selected)) {
1949 ret_value = OPERATOR_RUNNING_MODAL;
1950 }
1951 else {
1952 /* deselect all keyframes */
1954
1955 /* highlight channel clicked on */
1957 /* deselect all other channels first */
1959
1960 /* Highlight Action-Group or F-Curve? */
1961 if (ale != nullptr && ale->data) {
1962 if (ale->type == ANIMTYPE_GROUP) {
1963 bActionGroup *agrp = static_cast<bActionGroup *>(ale->data);
1964
1965 agrp->flag |= AGRP_SELECTED;
1967 ac, ac->data, eAnimCont_Types(ac->datatype), filter, agrp, ANIMTYPE_GROUP);
1968 }
1969 else if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
1970 FCurve *fcu = static_cast<FCurve *>(ale->data);
1971
1972 fcu->flag |= FCURVE_SELECTED;
1974 ac->data,
1976 filter,
1977 fcu,
1978 eAnim_ChannelType(ale->type));
1979 }
1980 else if (ale->type == ANIMTYPE_GPLAYER) {
1981 bGPdata *gpd = id_cast<bGPdata *>(ale->id);
1982 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
1983
1985 }
1986 else if (ale->type == ANIMTYPE_ACTION_SLOT) {
1988 "fcurve_owner_id of an Action Slot should be an Action");
1989 animrig::Action *action = reinterpret_cast<animrig::Action *>(ale->fcurve_owner_id);
1990 animrig::Slot *slot = static_cast<animrig::Slot *>(ale->data);
1991 slot->set_selected(true);
1992 action->slot_active_set(slot->handle);
1993 }
1994 }
1995 }
1996 else if (ac->datatype == ANIMCONT_GPENCIL) {
1997 /* Deselect all other channels first. */
1999
2000 /* Highlight the grease pencil channel, and set the corresponding layer as active. */
2001 if (ale != nullptr && ale->data != nullptr && ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) {
2003 *reinterpret_cast<GreasePencil *>(ale->id),
2004 static_cast<bke::greasepencil::Layer *>(ale->data));
2005 }
2006
2007 /* Highlight GPencil Layer (Legacy). */
2008 if (ale != nullptr && ale->data != nullptr && ale->type == ANIMTYPE_GPLAYER) {
2009 bGPdata *gpd = id_cast<bGPdata *>(ale->id);
2010 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
2011
2013 }
2014 }
2015 else if (ac->datatype == ANIMCONT_MASK) {
2016 /* deselect all other channels first */
2018
2019 if (ale != nullptr && ale->data != nullptr && ale->type == ANIMTYPE_MASKLAYER) {
2020 MaskLayer *masklay = static_cast<MaskLayer *>(ale->data);
2021
2022 masklay->flag |= MASK_LAYERFLAG_SELECT;
2023 }
2024 }
2025 }
2026 }
2027
2028 /* only select keyframes if we clicked on a valid channel and hit something */
2029 if (ale != nullptr) {
2030 if (found) {
2031 /* apply selection to keyframes */
2032 if (column) {
2033 /* select all keyframes in the same frame as the one we hit on the active channel
2034 * [#41077]: "frame" not "selx" here (i.e. no NLA corrections yet) as the code here
2035 * does that itself again as it needs to work on multiple data-blocks.
2036 */
2037 actkeys_mselect_column(ac, select_mode, frame);
2038 }
2039 else if (same_channel) {
2040 /* select all keyframes in the active channel */
2041 actkeys_mselect_channel_only(ac, ale, select_mode);
2042 }
2043 else {
2044 /* select the nominated keyframe on the given frame */
2045 actkeys_mselect_single(ac, ale, select_mode, selx);
2046 }
2047 }
2048
2049 /* flush tagged updates
2050 * NOTE: We temporarily add this channel back to the list so that this can happen
2051 */
2052 ListBaseT<bAnimListElem> anim_data = {ale, ale};
2053 ANIM_animdata_update(ac, &anim_data);
2054
2055 /* free this channel */
2056 MEM_delete(ale);
2057 }
2058
2059 return ret_value;
2060}
2061
2062/* handle clicking */
2064{
2065 bAnimContext ac;
2066 wmOperatorStatus ret_value;
2067
2068 /* get editor data */
2069 if (ANIM_animdata_get_context(C, &ac) == 0) {
2070 return OPERATOR_CANCELLED;
2071 }
2072
2073 /* get useful pointers from animation context data */
2074 // region = ac.region; /* UNUSED. */
2075
2076 /* select mode is either replace (deselect all, then add) or add/extend */
2077 const eEditKeyframes_Select selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT :
2079 const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
2080 const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
2081 int mval[2];
2082
2083 /* column selection */
2084 const bool column = RNA_boolean_get(op->ptr, "column");
2085 const bool channel = RNA_boolean_get(op->ptr, "channel");
2086
2087 mval[0] = RNA_int_get(op->ptr, "mouse_x");
2088 mval[1] = RNA_int_get(op->ptr, "mouse_y");
2089
2090 /* Select keyframe(s) based upon mouse position. */
2091 ret_value = mouse_action_keys(
2092 &ac, mval, selectmode, deselect_all, column, channel, wait_to_deselect_others);
2093
2094 /* set notifier that keyframe selection (and channels too) have changed */
2097
2098 /* for tweak grab to work */
2099 return ret_value | OPERATOR_PASS_THROUGH;
2100}
2101
2103{
2104 PropertyRNA *prop;
2105
2106 /* identifiers */
2107 ot->name = "Select Keyframes";
2108 ot->idname = "ACTION_OT_clickselect";
2109 ot->description = "Select keyframes by clicking on them";
2110
2111 /* callbacks */
2116
2117 /* flags */
2118 ot->flag = OPTYPE_UNDO;
2119
2120 /* properties */
2122 /* Key-map: Enable with `Shift`. */
2123 prop = RNA_def_boolean(
2124 ot->srna,
2125 "extend",
2126 false,
2127 "Extend Select",
2128 "Toggle keyframe selection instead of leaving newly selected keyframes only");
2130
2131 prop = RNA_def_boolean(ot->srna,
2132 "deselect_all",
2133 false,
2134 "Deselect On Nothing",
2135 "Deselect all when nothing under the cursor");
2137
2138 /* Key-map: Enable with `Alt`. */
2139 prop = RNA_def_boolean(
2140 ot->srna,
2141 "column",
2142 false,
2143 "Column Select",
2144 "Select all keyframes that occur on the same frame as the one under the mouse");
2146
2147 /* Key-map: Enable with `Ctrl-Alt`. */
2148 prop = RNA_def_boolean(ot->srna,
2149 "channel",
2150 false,
2151 "Only Channel",
2152 "Select all the keyframes in the channel under the mouse");
2154}
2155
2157
2158/* -------------------------------------------------------------------- */
2161
2163{
2164 bAnimContext ac;
2165
2166 if (ANIM_animdata_get_context(C, &ac) == 0) {
2167 return OPERATOR_CANCELLED;
2168 }
2169
2170 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2174 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
2175 const eBezTriple_KeyframeType key_type = eBezTriple_KeyframeType(RNA_enum_get(op->ptr, "type"));
2176 const bool extend = RNA_boolean_get(op->ptr, "extend");
2177 for (bAnimListElem &elem : anim_data) {
2178 FCurve *fcurve = static_cast<FCurve *>(elem.data);
2179 if (!fcurve->bezt) {
2180 continue;
2181 }
2182 for (int i = 0; i < fcurve->totvert; i++) {
2183 BezTriple &key = fcurve->bezt[i];
2184 if (BEZKEYTYPE(&key) == key_type) {
2185 BEZT_SEL_ALL(&key);
2186 }
2187 else if (!extend) {
2188 BEZT_DESEL_ALL(&key);
2189 }
2190 }
2191 }
2192
2194 ANIM_animdata_freelist(&anim_data);
2195
2196 return OPERATOR_FINISHED;
2197}
2198
2203
2205{
2206 ot->name = "Select by Type";
2207 ot->idname = "ACTION_OT_select_by_type";
2208 ot->description = "Select all keyframes of the given type";
2209
2212
2214
2215 PropertyRNA *prop = RNA_def_boolean(ot->srna,
2216 "extend",
2217 true,
2218 "Extend Selection",
2219 "Keeps the current selection and adds the given type to it. "
2220 "If disabled, only keys of the type will be selected");
2222
2223 RNA_def_enum(ot->srna,
2224 "type",
2226 0,
2227 "Type",
2228 "The type of keyframe to select");
2229}
2230
2232
2233} // namespace blender
Low-level operations for grease pencil.
#define SELECT
Definition BKE_mask.hh:19
#define BEZT_SEL_ALL(bezt)
#define BEZT_DESEL_ALL(bezt)
#define BEZKEYTYPE(bezt)
Object is a sort of wrapper for general info.
#define MAXFRAMEF
#define MINAFRAMEF
#define SEL_OP_USE_PRE_DESELECT(sel_op)
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NC_ANIMATION
Definition WM_types.hh:401
#define ND_KEYFRAME
Definition WM_types.hh:537
#define ND_ANIMCHAN
Definition WM_types.hh:539
#define NA_SELECTED
Definition WM_types.hh:639
#define BLI_assert_unreachable()
#define ELEM(...)
#define BLI_assert_msg(a, msg)
btScalar max
void slot_active_set(slot_handle_t slot_handle)
#define roundf(x)
#define layer
void select_frames_at(bke::greasepencil::LayerGroup &layer_group, const int frame_number, const short select_mode)
void select_frames_range(bke::greasepencil::TreeNode &node, const float min, const float max, const short select_mode)
void select_frames_region(KeyframeEditData *ked, bke::greasepencil::TreeNode &node, const short tool, const short select_mode)
bool has_any_frame_selected(const bke::greasepencil::Layer &layer)
void select_all_frames(bke::greasepencil::Layer &layer, const short select_mode)
void select_layer_channel(GreasePencil &grease_pencil, bke::greasepencil::Layer *layer)
bool select_frame_at(bke::greasepencil::Layer &layer, const int frame_number, const short select_mode)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
void view2d_listview_view_to_cell(float columnwidth, float rowheight, float startx, float starty, float viewx, float viewy, int *r_column, int *r_row)
Definition view2d.cc:1604
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
BMesh Iterators.
void ACTION_OT_clickselect(wmOperatorType *ot)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::string ED_select_circle_get_name(wmOperatorType *ot, PointerRNA *ptr)
static void box_select_action(bAnimContext *ac, const rcti rect, short mode, const eEditKeyframes_Select selectmode)
void action_to_keylist(AnimData *adt, bAction *dna_action, AnimKeylist *keylist, const int saction_flag, float2 range)
void grease_pencil_cels_to_keylist(AnimData *, const GreasePencilLayer *gpl, AnimKeylist *keylist, int)
static wmOperatorStatus actkeys_select_more_exec(bContext *C, wmOperator *)
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
static bool actkeys_is_key_at_position(bAnimContext *ac, float region_x, float region_y)
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void gpl_to_keylist(bDopeSheet *, bGPDlayer *gpl, AnimKeylist *keylist)
bool ED_operator_graphedit_active(bContext *C)
void ED_markers_make_cfra_list(ListBaseT< TimeMarker > *markers, ListBaseT< CfraElem > *lb, const bool only_selected)
static wmOperatorStatus actkeys_select_linked_exec(bContext *C, wmOperator *)
static const EnumPropertyItem prop_actkeys_leftright_select_types[]
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt)
static void markers_selectkeys_between(bAnimContext *ac)
@ ANIMCONT_TIMELINE
@ ANIMCONT_ACTION
@ ANIMCONT_DOPESHEET
@ ANIMCONT_GPENCIL
void grease_pencil_layer_group_to_keylist(AnimData *adt, const GreasePencilLayerTreeGroup *layer_group, AnimKeylist *keylist, const int saction_flag)
static wmOperatorStatus action_circle_select_exec(bContext *C, wmOperator *op)
void ACTION_OT_select_circle(wmOperatorType *ot)
eSelectOp ED_select_op_modal(eSelectOp sel_op, bool is_first)
void ACTION_OT_select_lasso(wmOperatorType *ot)
void ANIM_anim_channels_select_set(bAnimContext *ac, eAnimChannels_SetFlag sel)
static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, bool summary)
void ED_gpencil_layer_frames_select_region(KeyframeEditData *ked, bGPDlayer *gpl, short tool, short select_mode)
void ACTION_OT_select_less(wmOperatorType *ot)
void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datatype, eAnimFilter_Flags filter, void *channel_data, eAnim_ChannelType channel_type)
static bool select_by_type_poll(bContext *C)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
static void columnselect_action_keys(bAnimContext *ac, short mode)
void ACTION_OT_select_box(wmOperatorType *ot)
@ ACTKEYS_LRSEL_TEST
@ ACTKEYS_LRSEL_LEFT
@ ACTKEYS_LRSEL_RIGHT
@ NLATIME_CONVERT_UNMAP
Definition BKE_nla.hh:560
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
float ANIM_nla_tweakedit_remap(bAnimListElem *ale, const float cframe, const eNlaTime_ConvertModes mode)
Definition anim_draw.cc:329
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void ED_masklayer_frames_select_region(KeyframeEditData *ked, MaskLayer *mask_layer, short tool, short select_mode)
static void actkeys_select_leftright(bAnimContext *ac, short leftright, eEditKeyframes_Select select_mode)
int RNA_int_get(PointerRNA *ptr, const char *name)
void summary_to_keylist(bAnimContext *ac, AnimKeylist *keylist, const int saction_flag, float2 range)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@ ACHANNEL_SETFLAG_CLEAR
static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, short mode, eEditKeyframes_Select selectmode, void *data)
static void box_select_elem(BoxSelectData *sel_data, bAnimListElem *ale, float xmin, float xmax, bool summary)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, const eEditKeyframes_Select select_mode, float selx)
static wmOperatorStatus actkeys_select_leftright_exec(bContext *C, wmOperator *op)
bool ANIM_nla_mapping_allowed(const bAnimListElem *ale)
Definition anim_draw.cc:279
@ ANIMTYPE_MASKDATABLOCK
@ ANIMTYPE_NLACURVE
@ ANIMTYPE_GREASE_PENCIL_LAYER_GROUP
@ ANIMTYPE_GREASE_PENCIL_DATABLOCK
@ ANIMTYPE_FCURVE
@ ANIMTYPE_GPLAYER
@ ANIMTYPE_GREASE_PENCIL_LAYER
@ ANIMTYPE_SUMMARY
@ ANIMTYPE_ACTION_SLOT
@ ANIMTYPE_MASKLAYER
static wmOperatorStatus actkeys_columnselect_exec(bContext *C, wmOperator *op)
wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_circle_cancel(bContext *C, wmOperator *op)
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void MEM_delete_void(void *vmemh)
void ED_mask_select_frames(MaskLayer *mask_layer, short select_mode)
@ ACTKEYS_BORDERSEL_CHANNELS
@ ACTKEYS_BORDERSEL_ALLKEYS
@ ACTKEYS_BORDERSEL_FRAMERANGE
bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
void ANIM_nla_mapping_apply_if_needed_fcurve(bAnimListElem *ale, FCurve *fcu, const bool restore, const bool only_keys)
Definition anim_draw.cc:406
void ANIM_animdata_update(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:365
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void WM_operator_properties_select_all(wmOperatorType *ot)
void ED_gpencil_layer_frame_select_set(bGPDlayer *gpl, short mode)
float ANIM_UI_get_channel_height()
bool ED_operator_action_active(bContext *C)
void ACTION_OT_select_leftright(wmOperatorType *ot)
void ACTION_OT_select_by_type(wmOperatorType *ot)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, float2 range, const bool use_nla_remapping)
float ANIM_UI_get_first_channel_top(View2D *v2d)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
@ ALE_GREASE_PENCIL_GROUP
@ ALE_ACTION_LAYERED
@ ALE_GREASE_PENCIL_DATA
@ ALE_ACTION_SLOT
@ ALE_GREASE_PENCIL_CEL
VecBase< float, 2 > float2
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static wmOperatorStatus actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_NODUPLIS
@ ANIMFILTER_LIST_CHANNELS
void grease_pencil_data_block_to_keylist(AnimData *adt, const GreasePencil *grease_pencil, AnimKeylist *keylist, const int saction_flag, const bool active_layer_only)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
static void select_moreless_action_keys(bAnimContext *ac, short mode)
BMesh const char void * data
static wmOperatorStatus actkeys_select_less_exec(bContext *C, wmOperator *)
void ACTION_OT_select_linked(wmOperatorType *ot)
void ACTION_OT_select_more(wmOperatorType *ot)
void ED_gpencil_layer_frames_select_box(bGPDlayer *gpl, float min, float max, short select_mode)
@ ACTKEYS_COLUMNSEL_CFRA
@ ACTKEYS_COLUMNSEL_KEYS
@ ACTKEYS_COLUMNSEL_MARKERS_COLUMN
@ ACTKEYS_COLUMNSEL_MARKERS_BETWEEN
void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode)
void ACTION_OT_select_all(wmOperatorType *ot)
static wmOperatorStatus mouse_action_keys(bAnimContext *ac, const int mval[2], eEditKeyframes_Select select_mode, const bool deselect_all, const bool column, const bool same_channel, bool wait_to_deselect_others)
static bAnimListElem * actkeys_find_list_element_at_position(bAnimContext *ac, eAnimFilter_Flags filter, float region_x, float region_y)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)
wmOperatorStatus WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void actkeys_find_key_at_position(bAnimContext *ac, eAnimFilter_Flags filter, float region_x, float region_y, bAnimListElem **r_ale, float *r_selx, float *r_frame, bool *r_found, bool *r_is_selected)
bool ED_gpencil_layer_frame_select_check(const bGPDlayer *gpl)
const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[]
Definition rna_fcurve.cc:84
void action_group_to_keylist(AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, float2 range)
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
void action_slot_summary_to_keylist(bAnimContext *ac, ID *animated_id, animrig::Action &action, const animrig::slot_handle_t slot_handle, AnimKeylist *keylist, const int saction_flag, float2 range)
KeyframeEditFunc ANIM_editkeyframes_select(const eEditKeyframes_Select selectmode)
AnimKeylist * ED_keylist_create()
void WM_operator_properties_gesture_box(wmOperatorType *ot)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static void deselect_action_keys(bAnimContext *ac, short test, eEditKeyframes_Select sel)
wmOperatorStatus WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
static wmOperatorStatus select_by_type_exec(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void ob_to_keylist(bDopeSheet *ads, Object *ob, AnimKeylist *keylist, const int saction_flag, float2 range)
static wmOperatorStatus actkeys_deselectall_exec(bContext *C, wmOperator *op)
void ED_mask_select_frame(MaskLayer *mask_layer, int selx, short select_mode)
const ActKeyColumn * ED_keylist_find_any_between(const AnimKeylist *keylist, const Bounds< float > frame_range)
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
void scene_to_keylist(bDopeSheet *ads, Scene *sce, AnimKeylist *keylist, const int saction_flag, float2 range)
short(*)(KeyframeEditData *ked, BezTriple *bezt) KeyframeEditFunc
static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, eEditKeyframes_Select select_mode)
bool ED_operator_region_action_active(bContext *C)
static void actkeys_mselect_column(bAnimContext *ac, eEditKeyframes_Select select_mode, float selx)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void ED_gpencil_layer_make_cfra_list(bGPDlayer *gpl, ListBaseT< CfraElem > *elems, bool onlysel)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus actkeys_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus actkeys_clickselect_exec(bContext *C, wmOperator *op)
void ED_masklayer_frames_select_box(MaskLayer *mask_layer, float min, float max, short select_mode)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
@ MASK_LAYERFLAG_SELECT
void ACTION_OT_select_column(wmOperatorType *ot)
static wmOperatorStatus actkeys_box_select_exec(bContext *C, wmOperator *op)
void mask_to_keylist(bDopeSheet *, MaskLayer *masklay, AnimKeylist *keylist)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
void ED_keylist_free(AnimKeylist *keylist)
static void actkeys_find_key_in_list_element(bAnimContext *ac, bAnimListElem *ale, float region_x, float *r_selx, float *r_frame, bool *r_found, bool *r_is_selected)
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
static wmOperatorStatus actkeys_lassoselect_exec(bContext *C, wmOperator *op)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
bool WM_gesture_is_modal_first(const wmGesture *gesture)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void ED_masklayer_frame_select_set(MaskLayer *mask_layer, short mode)
static void actkeys_list_element_to_keylist(bAnimContext *ac, AnimKeylist *keylist, bAnimListElem *ale)
wmOperatorStatus WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
void ED_gpencil_set_active_channel(bGPdata *gpd, bGPDlayer *gpl)
void ED_markers_get_minmax(ListBaseT< TimeMarker > *markers, short sel, float *r_first, float *r_last)
void WM_operator_properties_generic_select(wmOperatorType *ot)
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
Definition lasso_2d.cc:21
static const EnumPropertyItem prop_column_select_types[]
float ANIM_UI_get_channel_step()
@ ANIM_UPDATE_DEPS
bool ED_masklayer_frame_select_check(const MaskLayer *mask_layer)
short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
KeyframeEditFunc ok_cb
KeyframeEditFunc select_cb
eFCurve_Flags flag
unsigned int totvert
char name[258]
Definition DNA_ID.h:433
ListBaseT< TimeMarker > time_marker_list
ListBaseT< CfraElem > cfra_elem_list
struct MaskLayer * next
struct RenderData r
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
eAnim_ChannelType type
eAnim_Update_Flags update
bAnimListElem * prev
bAnimListElem * next
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191