Blender V5.3
graph_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 <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_lasso_2d.hh"
16#include "BLI_listbase.hh"
17#include "BLI_math_vector_c.hh"
18
19#include "DNA_anim_types.h"
20#include "DNA_scene_types.h"
21#include "DNA_screen_types.h"
22#include "DNA_space_types.h"
23
24#include "RNA_access.hh"
25#include "RNA_define.hh"
26
27#include "BKE_fcurve.hh"
28#include "BKE_nla.hh"
29
30#include "UI_interface_c.hh"
31#include "UI_view2d.hh"
32
33#include "ED_anim_api.hh"
34#include "ED_keyframes_edit.hh"
35#include "ED_markers.hh"
36#include "ED_select_utils.hh"
37
38#include "WM_api.hh"
39#include "WM_types.hh"
40
41#include "graph_intern.hh"
42
43namespace blender {
44
45/* -------------------------------------------------------------------- */
48
49/* temp info for caching handle vertices close */
52
53 FCurve *fcu; /* F-Curve that keyframe comes from */
54
55 BezTriple *bezt; /* keyframe to consider */
56 FPoint *fpt; /* sample point to consider */
57
58 short hpoint; /* the handle index that we hit (eHandleIndex) */
59 short sel; /* whether the handle is selected or not */
60 int dist; /* distance from mouse to vert */
61
62 eAnim_ChannelType ctype; /* type of animation channel this FCurve comes from */
63
64 float frame; /* frame that point was on when it matched (global time) */
65};
66
67/* Tags for the type of graph vert that we have */
73
74/* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */
75/* TODO: perhaps this should depend a bit on the size that the user set the vertices to be? */
76#define GVERTSEL_TOL (10 * U.pixelsize)
77
78/* ....... */
79
80/* check if its ok to select a handle */
81/* XXX also need to check for int-values only? */
83{
84 if (sipo->flag & SIPO_NOHANDLES) {
85 return false;
86 }
87 if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) {
88 return false;
89 }
90 return true;
91}
92
93/* check if the given vertex is within bounds or not */
94/* TODO: should we return if we hit something? */
95static void nearest_fcurve_vert_store(ListBaseT<tNearestVertInfo> *matches,
96 View2D *v2d,
97 FCurve *fcu,
99 BezTriple *bezt,
100 FPoint *fpt,
101 short hpoint,
102 const int mval[2],
103 float unit_scale,
104 float offset)
105{
106 /* Keyframes or Samples? */
107 if (bezt) {
108 int screen_co[2], dist;
109
110 /* convert from data-space to screen coordinates
111 * NOTE: `hpoint +1` gives us 0,1,2 respectively for each handle,
112 * needed to access the relevant vertex coordinates in the 3x3 'vec' matrix */
114 bezt->vec[hpoint + 1][0],
115 (bezt->vec[hpoint + 1][1] + offset) * unit_scale,
116 &screen_co[0],
117 &screen_co[1]) &&
118 /* check if distance from mouse cursor to vert in screen space is within tolerance */
119 ((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL))
120 {
121 tNearestVertInfo *nvi = matches->last();
122 bool replace = false;
123
124 /* If there is already a point for the F-Curve,
125 * check if this point is closer than that was. */
126 if ((nvi) && (nvi->fcu == fcu)) {
127 /* replace if we are closer, or if equal and that one wasn't selected but we are... */
128 if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) {
129 replace = true;
130 }
131 }
132 /* add new if not replacing... */
133 if (replace == 0) {
134 nvi = MEM_new_zeroed<tNearestVertInfo>("Nearest Graph Vert Info - Bezt");
135 }
136
137 /* store values */
138 nvi->fcu = fcu;
139 nvi->ctype = ctype;
140
141 nvi->bezt = bezt;
142 nvi->hpoint = hpoint;
143 nvi->dist = dist;
144
145 nvi->frame = bezt->vec[1][0]; /* currently in global time... */
146
147 /* NOTE: `hpoint` is -1,0,1, but `BEZT_ISSEL_IDX` expects 0,1,2. */
148 nvi->sel = BEZT_ISSEL_IDX(bezt, hpoint + 1);
149
150 /* add to list of matches if appropriate... */
151 if (replace == 0) {
152 BLI_addtail(matches, nvi);
153 }
154 }
155 }
156 else if (fpt) {
157 /* TODO: support #FPoint. */
158 }
159}
160
161/* helper for find_nearest_fcurve_vert() - build the list of nearest matches */
163 const int mval[2],
164 ListBaseT<tNearestVertInfo> *matches)
165{
166 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
167 int filter;
168
169 SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(ac->sl);
170 View2D *v2d = &ac->region->v2d;
171 short mapping_flag = 0;
172
173 /* get curves to search through
174 * - if the option to only show keyframes that belong to selected F-Curves is enabled,
175 * include the 'only selected' flag...
176 */
179 /* FIXME: this should really be check for by the filtering code. */
180 if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
182 }
183 mapping_flag |= ANIM_get_normalization_flags(ac->sl);
185 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
186
187 for (bAnimListElem &ale : anim_data) {
188 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
189 float offset;
190 float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale.id, fcu, mapping_flag, &offset);
191
192 /* apply NLA mapping to all the keyframes */
194 &ale, static_cast<FCurve *>(ale.key_data), false, false);
195
196 if (fcu->bezt) {
197 BezTriple *bezt1 = fcu->bezt, *prevbezt = nullptr;
198 int i;
199
200 for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
201 /* keyframe */
203 v2d,
204 fcu,
205 eAnim_ChannelType(ale.type),
206 bezt1,
207 nullptr,
209 mval,
210 unit_scale,
211 offset);
212
213 /* Handles. */
214 if (fcurve_handle_sel_check(sipo, bezt1)) {
215 /* first handle only visible if previous segment had handles */
216 if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) ||
217 (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))
218 {
220 v2d,
221 fcu,
222 eAnim_ChannelType(ale.type),
223 bezt1,
224 nullptr,
226 mval,
227 unit_scale,
228 offset);
229 }
230
231 /* second handle only visible if this segment is bezier */
232 if (bezt1->ipo == BEZT_IPO_BEZ) {
234 v2d,
235 fcu,
236 eAnim_ChannelType(ale.type),
237 bezt1,
238 nullptr,
240 mval,
241 unit_scale,
242 offset);
243 }
244 }
245 }
246 }
247 else if (fcu->fpt) {
248 /* TODO: do this for samples too. */
249 }
250
251 /* un-apply NLA mapping from all the keyframes */
253 &ale, static_cast<FCurve *>(ale.key_data), true, false);
254 }
255
256 /* free channels */
257 ANIM_animdata_freelist(&anim_data);
258}
259
260/* helper for find_nearest_fcurve_vert() - get the best match to use */
261static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBaseT<tNearestVertInfo> *matches)
262{
263 /* abort if list is empty */
264 if (matches->is_empty()) {
265 return nullptr;
266 }
267
268 /* if list only has 1 item, remove it from the list and return */
269 if (matches->is_single()) {
270 /* need to remove from the list, otherwise it gets freed and then we can't return it */
271 return static_cast<tNearestVertInfo *>(BLI_pophead(matches));
272 }
273
274 /* The goal of the remaining code below is to prioritize selecting verts on
275 * selected fcurves, but to still cycle through the vertices in `matches` if
276 * a selected-fcurve vertex is already selected. */
277
278 /* Try to find the first selected vert in `matches`. Additionally, if
279 * one exists, rotate `matches` to put it last in the list and the vert
280 * following it first, since that's the order we'll want to scan in. */
281 tNearestVertInfo *nvi_first_selected = nullptr;
282 for (tNearestVertInfo &nvi : *matches) {
283 if (nvi.sel) {
284 nvi_first_selected = &nvi;
285 BLI_listbase_rotate_last(matches, nvi_first_selected);
286 break;
287 }
288 }
289
290 /* Try to find the next vert that's on the active fcurve, falling back
291 * to the next vert on any selected fcurve if that's not found. */
292 tNearestVertInfo *nvi_to_select = nullptr;
293 for (tNearestVertInfo &nvi : *matches) {
294 if (&nvi == nvi_first_selected) {
295 continue;
296 }
297
298 if (nvi.fcu->flag & FCURVE_ACTIVE) {
299 nvi_to_select = &nvi;
300 break;
301 }
302
303 if (nvi.fcu->flag & FCURVE_SELECTED && !nvi_to_select) {
304 nvi_to_select = &nvi;
305 }
306 }
307
308 /* If we found a vert on a selected fcurve, return it. */
309 if (nvi_to_select) {
310 BLI_remlink(matches, nvi_to_select);
311 return nvi_to_select;
312 }
313
314 /* If we're still here, that means we didn't find any verts on selected
315 * fcurves. So return the head (which is also the item following
316 * `nvi_first_selected` if that was found). */
317 return static_cast<tNearestVertInfo *>(BLI_pophead(matches));
318}
319
327{
328 ListBaseT<tNearestVertInfo> matches = {nullptr, nullptr};
329 tNearestVertInfo *nvi;
330
331 /* step 1: get the nearest verts */
332 get_nearest_fcurve_verts_list(ac, mval, &matches);
333
334 /* step 2: find the best vert */
335 nvi = get_best_nearest_fcurve_vert(&matches);
336
337 matches.free_no_destruct();
338
339 /* return the best vert found */
340 return nvi;
341}
342
344
345/* -------------------------------------------------------------------- */
353
354void deselect_graph_keys(bAnimContext *ac, bool test, eEditKeyframes_Select sel, bool do_channels)
355{
356 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
357 int filter;
358
359 KeyframeEditData ked = {{nullptr}};
360 KeyframeEditFunc test_cb, sel_cb;
361
362 /* determine type-based settings */
365
366 /* filter data */
368 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
369
370 /* init BezTriple looping data */
372
373 /* See if we should be selecting or deselecting */
374 if (test) {
375 for (bAnimListElem &ale : anim_data) {
377 &ked, static_cast<FCurve *>(ale.key_data), nullptr, test_cb, nullptr))
378 {
379 sel = SELECT_SUBTRACT;
380 break;
381 }
382 }
383 }
384
385 /* convert sel to selectmode, and use that to get editor */
386 sel_cb = ANIM_editkeyframes_select(sel);
387
388 /* Now set the flags */
389 for (bAnimListElem &ale : anim_data) {
390 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
391
392 /* Keyframes First */
394 &ked, static_cast<FCurve *>(ale.key_data), nullptr, sel_cb, nullptr);
395
396 /* affect channel selection status? */
397 if (do_channels) {
398 /* Only change selection of channel when the visibility of keyframes
399 * doesn't depend on this. */
400 if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
401 /* deactivate the F-Curve, and deselect if deselecting keyframes.
402 * otherwise select the F-Curve too since we've selected all the keyframes
403 */
404 if (sel == SELECT_SUBTRACT) {
405 fcu->flag &= ~FCURVE_SELECTED;
406 }
407 else {
408 fcu->flag |= FCURVE_SELECTED;
409 }
410 }
411
412 /* always deactivate all F-Curves if we perform batch ops for selection */
413 fcu->flag &= ~FCURVE_ACTIVE;
414 }
415 }
416
417 /* Cleanup */
418 ANIM_animdata_freelist(&anim_data);
419}
420
421/* ------------------- */
422
424{
425 bAnimContext ac;
426 bAnimListElem *ale_active = nullptr;
427
428 /* get editor data */
429 if (ANIM_animdata_get_context(C, &ac) == 0) {
430 return OPERATOR_CANCELLED;
431 }
432
433 /* find active F-Curve, and preserve this for later
434 * or else it becomes annoying with the current active
435 * curve keeps fading out even while you're editing it
436 */
437 ale_active = get_active_fcurve_channel(&ac);
438
439 /* 'standard' behavior - check if selected, then apply relevant selection */
440 const int action = RNA_enum_get(op->ptr, "action");
441 switch (action) {
442 case SEL_TOGGLE:
443 deselect_graph_keys(&ac, true, SELECT_ADD, true);
444 break;
445 case SEL_SELECT:
446 deselect_graph_keys(&ac, false, SELECT_ADD, true);
447 break;
448 case SEL_DESELECT:
449 deselect_graph_keys(&ac, false, SELECT_SUBTRACT, true);
450 break;
451 case SEL_INVERT:
452 deselect_graph_keys(&ac, false, SELECT_INVERT, true);
453 break;
454 default:
455 BLI_assert(0);
456 break;
457 }
458
459 /* restore active F-Curve... */
460 if (ale_active) {
461 FCurve *fcu = static_cast<FCurve *>(ale_active->data);
462
463 /* all others should not be disabled, so we should be able to just set this directly...
464 * - selection needs to be set too, or else this won't work...
465 */
467
468 MEM_delete(ale_active);
469 ale_active = nullptr;
470 }
471
472 /* set notifier that things have changed */
474
475 return OPERATOR_FINISHED;
476}
477
479{
480 /* identifiers */
481 ot->name = "Select All";
482 ot->idname = "GRAPH_OT_select_all";
483 ot->description = "Toggle selection of all keyframes";
484
485 /* API callbacks. */
488
489 /* flags */
491
492 /* properties */
494}
495
497
498/* -------------------------------------------------------------------- */
510
511static rctf initialize_box_select_coords(const bAnimContext *ac, const rctf *rectf_view)
512{
513 const View2D *v2d = &ac->region->v2d;
514 rctf rectf;
515
516 /* Convert mouse coordinates to frame ranges and
517 * channel coordinates corrected for view pan/zoom. */
518 ui::view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
519 return rectf;
520}
521
531
532static ListBaseT<bAnimListElem> initialize_box_select_anim_data(const int filter, bAnimContext *ac)
533{
534 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
536 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
537 return anim_data;
538}
539
540static void initialize_box_select_key_editing_data(const bool incl_handles,
541 const short mode,
542 bAnimContext *ac,
543 void *data,
544 rctf *scaled_rectf,
545 KeyframeEditData *r_ked,
546 int *r_mapping_flag)
547{
548 memset(r_ked, 0, sizeof(KeyframeEditData));
549 switch (mode) {
551 KeyframeEdit_LassoData *data_lasso = static_cast<KeyframeEdit_LassoData *>(data);
552 data_lasso->rectf_scaled = scaled_rectf;
553 r_ked->data = data_lasso;
554 break;
555 }
557 KeyframeEdit_CircleData *data_circle = static_cast<KeyframeEdit_CircleData *>(data);
558 data_circle->rectf_scaled = scaled_rectf;
559 r_ked->data = data_circle;
560 break;
561 }
562 default:
563 r_ked->data = scaled_rectf;
564 break;
565 }
566 SpaceGraph *sgraph = reinterpret_cast<SpaceGraph *>(ac->sl);
567
568 if (sgraph->flag & SIPO_NOHANDLES) {
570 }
571
572 if (sgraph->flag & SIPO_SELVHANDLESONLY) {
574 }
575
576 /* Consider handles selection. Used in #keyframe_ok_checks, #select_bezier_add,
577 * #select_bezier_subtract. */
578 if (incl_handles) {
580 *r_mapping_flag = 0;
581 }
582 else {
583 *r_mapping_flag = ANIM_UNITCONV_ONLYKEYS;
584 }
585
586 *r_mapping_flag |= ANIM_get_normalization_flags(ac->sl);
587}
588
599 const rctf *rectf_view,
600 short mode,
601 eEditKeyframes_Select selectmode,
602 bool incl_handles,
603 void *data)
604{
605 const rctf rectf = initialize_box_select_coords(ac, rectf_view);
607 ListBaseT<bAnimListElem> anim_data = initialize_box_select_anim_data(filter, ac);
608 rctf scaled_rectf;
610 int mapping_flag;
612 incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
613
614 /* Get beztriple editing/validation functions. */
615 const KeyframeEditFunc select_cb = ANIM_editkeyframes_select(selectmode);
616 const KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(mode);
617
618 /* This variable will be set to true if any key is selected or deselected. */
619 bool any_key_selection_changed = false;
620
621 /* First loop over data, doing box select. try selecting keys only. */
622 for (bAnimListElem &ale : anim_data) {
623 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
624 float offset;
625 const float unit_scale = ANIM_unit_mapping_get_factor(
626 ac->scene, ale.id, fcu, mapping_flag, &offset);
627
628 /* Apply NLA mapping to all the keyframes, since it's easier than trying to
629 * guess when a callback might use something different.
630 */
632 &ale, static_cast<FCurve *>(ale.key_data), false, (mapping_flag & ANIM_UNITCONV_ONLYKEYS));
633
634 scaled_rectf.xmin = rectf.xmin;
635 scaled_rectf.xmax = rectf.xmax;
636 scaled_rectf.ymin = rectf.ymin / unit_scale - offset;
637 scaled_rectf.ymax = rectf.ymax / unit_scale - offset;
638
639 /* Set horizontal range (if applicable).
640 * NOTE: these values are only used for x-range and y-range but not region
641 * (which uses ked.data, i.e. rectf)
642 */
643 if (mode != BEZT_OK_VALUERANGE) {
644 ked.f1 = rectf.xmin;
645 ked.f2 = rectf.xmax;
646 }
647 else {
648 ked.f1 = rectf.ymin;
649 ked.f2 = rectf.ymax;
650 }
651
652 /* Firstly, check if any keyframes will be hit by this. */
653 if (ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, ok_cb, nullptr)) {
654 /* select keyframes that are in the appropriate places */
655 ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, nullptr);
656 any_key_selection_changed = true;
657 /* Only change selection of channel when the visibility of keyframes
658 * doesn't depend on this. */
659 if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
660 /* select the curve too now that curve will be touched */
661 if (selectmode == SELECT_ADD) {
662 fcu->flag |= FCURVE_SELECTED;
663 }
664 }
665 }
666
667 /* Un-apply NLA mapping from all the keyframes. */
669 &ale, static_cast<FCurve *>(ale.key_data), true, (mapping_flag & ANIM_UNITCONV_ONLYKEYS));
670 }
671
672 /* Cleanup. */
673 ANIM_animdata_freelist(&anim_data);
674
675 return any_key_selection_changed;
676}
677
682static short ok_bezier_always_ok(KeyframeEditData * /*ked*/, BezTriple * /*bezt*/)
683{
685}
686
687#define ABOVE 1
688#define INSIDE 0
689#define BELOW -1
690static int rectf_curve_zone_y(const FCurve *fcu,
691 const rctf *rectf,
692 const float offset,
693 const float unit_scale,
694 const float eval_x)
695{
696 const float fcurve_y = (evaluate_fcurve_only_curve(fcu, eval_x) + offset) * unit_scale;
697 return fcurve_y < rectf->ymin ? BELOW : fcurve_y <= rectf->ymax ? INSIDE : ABOVE;
698}
699
700/* Checks whether the given rectangle intersects the given fcurve's calculated curve (i.e. not
701 * only keyframes, but also all the interpolated values). This is done by sampling the curve at
702 * different points between the xmin and the xmax of the rectangle.
703 */
704static bool rectf_curve_intersection(const float offset,
705 const float unit_scale,
706 const rctf *rectf,
707 bAnimListElem *ale,
708 const FCurve *fcu)
709{
710 /* 30 sampling points. This worked well in tests. */
711 int num_steps = 30;
712
713 /* Remap the range at which to evaluate the fcurves. This enables us to avoid remapping
714 * the keys themselves. */
715 const float mapped_max = ANIM_nla_tweakedit_remap(ale, rectf->xmax, NLATIME_CONVERT_UNMAP);
716 const float mapped_min = ANIM_nla_tweakedit_remap(ale, rectf->xmin, NLATIME_CONVERT_UNMAP);
717 const float eval_step = (mapped_max - mapped_min) / num_steps;
718
719 /* Sample points on the given fcurve in the interval defined by the
720 * mapped_min and mapped_max of the selected rectangle.
721 * For each point, check if it is inside of the selection box. If it is, then select
722 * all the keyframes of the curve, the curve, and stop the loop.
723 */
724 struct {
725 float eval_x;
726 int zone;
727 } cur, prev;
728
729 prev.eval_x = mapped_min;
730 prev.zone = rectf_curve_zone_y(fcu, rectf, offset, unit_scale, prev.eval_x);
731 if (prev.zone == INSIDE) {
732 return true;
733 }
734
735 while (num_steps--) {
736 cur.eval_x = prev.eval_x + eval_step;
737 cur.zone = rectf_curve_zone_y(fcu, rectf, offset, unit_scale, cur.eval_x);
738 if (cur.zone != prev.zone) {
739 return true;
740 }
741
742 prev = cur;
743 }
744 return false;
745}
746#undef ABOVE
747#undef INSIDE
748#undef BELOW
749
758 const rctf *rectf_view,
759 const short mode,
760 const eEditKeyframes_Select selectmode,
761 const bool incl_handles,
762 void *data)
763{
765 ListBaseT<bAnimListElem> anim_data = initialize_box_select_anim_data(filter, ac);
766 rctf scaled_rectf;
768 int mapping_flag;
770 incl_handles, mode, ac, data, &scaled_rectf, &ked, &mapping_flag);
771
772 FCurve *last_selected_curve = nullptr;
773
774 /* Go through all the curves and try selecting them. This function is only called
775 * if no keyframe is in the selection area, so we only have to check if the curve
776 * intersects the area in order to check if the selection/deselection must happen.
777 */
778
779 for (bAnimListElem &ale : anim_data) {
780 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
781 float offset;
782 const float unit_scale = ANIM_unit_mapping_get_factor(
783 ac->scene, ale.id, fcu, mapping_flag, &offset);
784
785 const rctf rectf = initialize_box_select_coords(ac, rectf_view);
786
787 /* scaled_rectf is declared at the top of the block because it is required by the
788 * initialize_box_select_key_editing_data function (which does
789 * data_xxx->rectf_scaled = scaled_rectf). The below assignment therefore modifies the
790 * data we use to iterate over the curves (ked).
791 */
792 scaled_rectf.xmin = rectf.xmin;
793 scaled_rectf.xmax = rectf.xmax;
794 scaled_rectf.ymin = rectf.ymin / unit_scale - offset;
795 scaled_rectf.ymax = rectf.ymax / unit_scale - offset;
796
797 const KeyframeEditFunc select_cb = ANIM_editkeyframes_select(selectmode);
798 if (rectf_curve_intersection(offset, unit_scale, &rectf, &ale, fcu)) {
799 if ((selectmode & SELECT_ADD) || (selectmode & SELECT_REPLACE)) {
800 fcu->flag |= FCURVE_SELECTED;
801 last_selected_curve = fcu;
802 }
803 else {
804 fcu->flag &= ~FCURVE_SELECTED;
805 }
806 ANIM_fcurve_keyframes_loop(&ked, fcu, ok_bezier_always_ok, select_cb, nullptr);
807 }
808 }
809
810 /* Make sure that one of the selected curves is active in the end. */
811 if (last_selected_curve != nullptr) {
813 ac->data,
816 last_selected_curve,
818 }
819
820 ANIM_animdata_freelist(&anim_data);
821}
822
823/* ------------------- */
824
826 wmOperator *op,
827 const wmEvent *event)
828{
829 bAnimContext ac;
830 if (ANIM_animdata_get_context(C, &ac) == 0) {
831 return OPERATOR_CANCELLED;
832 }
833
834 if (RNA_boolean_get(op->ptr, "tweak")) {
835 int mval[2];
836 WM_event_drag_start_mval(event, ac.region, mval);
837 tNearestVertInfo *under_mouse = find_nearest_fcurve_vert(&ac, mval);
838 bool mouse_is_over_element = under_mouse != nullptr;
839 if (under_mouse) {
840 MEM_delete(under_mouse);
841 }
842
843 if (mouse_is_over_element) {
845 }
846 }
847
848 return WM_gesture_box_invoke(C, op, event);
849}
850
852{
853 bAnimContext ac;
854 rcti rect;
855 rctf rect_fl;
856 short mode = 0;
857
858 /* get editor data */
859 if (ANIM_animdata_get_context(C, &ac) == 0) {
860 return OPERATOR_CANCELLED;
861 }
862
863 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
864 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
865 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
866 deselect_graph_keys(&ac, true, SELECT_SUBTRACT, true);
867 }
868
869 /* 'include_handles' from the operator specifies whether to include handles in the selection. */
870 bool incl_handles = RNA_boolean_get(op->ptr, "include_handles");
871
872 /* Get settings from operator. */
874
875 /* Selection 'mode' depends on whether box_select region only matters on one axis. */
876 if (RNA_boolean_get(op->ptr, "axis_range")) {
877 /* Mode depends on which axis of the range is larger to determine which axis to use
878 * - Checking this in region-space is fine, as it's fundamentally still going to be a
879 * different rect size.
880 * - The frame-range select option is favored over the channel one (x over y),
881 * as frame-range one is often used for tweaking timing when "blocking",
882 * while channels is not that useful.
883 */
884 if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
885 mode = BEZT_OK_FRAMERANGE;
886 }
887 else {
888 mode = BEZT_OK_VALUERANGE;
889 }
890 }
891 else {
892 mode = BEZT_OK_REGION;
893 }
894
895 BLI_rctf_rcti_copy(&rect_fl, &rect);
896
897 /* Apply box_select action. */
898 const bool any_key_selection_changed = box_select_graphkeys(
899 &ac, &rect_fl, mode, selectmode, incl_handles, nullptr);
900 const bool use_curve_selection = RNA_boolean_get(op->ptr, "use_curve_selection");
901 if (use_curve_selection && !any_key_selection_changed) {
902 box_select_graphcurves(&ac, &rect_fl, mode, selectmode, incl_handles, nullptr);
903 }
904 /* Send notifier that keyframe selection has changed. */
906
907 return OPERATOR_FINISHED;
908}
909
911{
912 /* Identifiers. */
913 ot->name = "Box Select";
914 ot->idname = "GRAPH_OT_select_box";
915 ot->description = "Select all keyframes within the specified region";
916
917 /* API callbacks. */
922
924
925 /* Flags. */
926 ot->flag = OPTYPE_UNDO;
927
928 /* Properties. */
929 ot->prop = RNA_def_boolean(ot->srna, "axis_range", false, "Axis Range", "");
931
932 PropertyRNA *prop;
933 prop = RNA_def_boolean(
934 ot->srna,
935 "include_handles",
936 true,
937 "Include Handles",
938 "Are handles tested individually against the selection criteria, independently from their "
939 "keys. When unchecked, handles are (de)selected in unison with their keys");
941
942 prop = RNA_def_boolean(
943 ot->srna, "tweak", false, "Tweak", "Operator has been activated using a click-drag event");
945
946 prop = RNA_def_boolean(
947 ot->srna,
948 "use_curve_selection",
949 true,
950 "Select Curves",
951 "Allow selecting all the keyframes of a curve by selecting the calculated F-curve");
953
956}
957
958/* ------------------- */
959
961{
962 bAnimContext ac;
963
964 KeyframeEdit_LassoData data_lasso{};
965 rcti rect;
966 rctf rect_fl;
967
968 /* Get editor data. */
969 if (ANIM_animdata_get_context(C, &ac) == 0) {
970 return OPERATOR_CANCELLED;
971 }
972
973 data_lasso.rectf_view = &rect_fl;
974 data_lasso.mcoords = WM_gesture_lasso_path_to_array(C, op);
975 if (data_lasso.mcoords.is_empty()) {
976 return OPERATOR_CANCELLED;
977 }
978
979 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
980 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
981 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
982 deselect_graph_keys(&ac, false, SELECT_SUBTRACT, true);
983 }
984
985 /* Get settings from operator. */
986 BLI_lasso_boundbox(&rect, data_lasso.mcoords);
987 BLI_rctf_rcti_copy(&rect_fl, &rect);
988
989 /* 'include_handles' from the operator specifies whether to consider handles in the selection. */
990 const bool incl_handles = RNA_boolean_get(op->ptr, "include_handles");
991
992 /* Apply box_select action. */
993 const bool any_key_selection_changed = box_select_graphkeys(
994 &ac, &rect_fl, BEZT_OK_REGION_LASSO, selectmode, incl_handles, &data_lasso);
995 const bool use_curve_selection = RNA_boolean_get(op->ptr, "use_curve_selection");
996 if (use_curve_selection && !any_key_selection_changed) {
998 &ac, &rect_fl, BEZT_OK_REGION_LASSO, selectmode, incl_handles, &data_lasso);
999 }
1000
1001 /* Send notifier that keyframe selection has changed. */
1003
1004 return OPERATOR_FINISHED;
1005}
1006
1008{
1009 /* Identifiers. */
1010 ot->name = "Lasso Select";
1011 ot->description = "Select keyframe points using lasso selection";
1012 ot->idname = "GRAPH_OT_select_lasso";
1013
1014 /* API callbacks. */
1020
1021 /* Flags. */
1023
1024 /* Properties. */
1027
1028 PropertyRNA *prop;
1029 prop = RNA_def_boolean(
1030 ot->srna,
1031 "include_handles",
1032 true,
1033 "Include Handles",
1034 "Are handles tested individually against the selection criteria, independently from their "
1035 "keys. When unchecked, handles are (de)selected in unison with their keys");
1037
1038 prop = RNA_def_boolean(
1039 ot->srna,
1040 "use_curve_selection",
1041 true,
1042 "Select Curves",
1043 "Allow selecting all the keyframes of a curve by selecting the curve itself");
1045}
1046
1047/* ------------------- */
1048
1050{
1051 bAnimContext ac;
1052
1053 KeyframeEdit_CircleData data = {nullptr};
1054 rctf rect_fl;
1055
1056 float x = RNA_int_get(op->ptr, "x");
1057 float y = RNA_int_get(op->ptr, "y");
1058 float radius = RNA_int_get(op->ptr, "radius");
1059
1060 /* Get editor data. */
1061 if (ANIM_animdata_get_context(C, &ac) == 0) {
1062 return OPERATOR_CANCELLED;
1063 }
1064
1065 const eSelectOp sel_op = ED_select_op_modal(
1066 eSelectOp(RNA_enum_get(op->ptr, "mode")),
1067 WM_gesture_is_modal_first(static_cast<const wmGesture *>(op->customdata)));
1068 const eEditKeyframes_Select selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
1069 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
1070 deselect_graph_keys(&ac, false, SELECT_SUBTRACT, true);
1071 }
1072
1073 data.mval[0] = x;
1074 data.mval[1] = y;
1075 data.radius_squared = radius * radius;
1076 data.rectf_view = &rect_fl;
1077
1078 rect_fl.xmin = x - radius;
1079 rect_fl.xmax = x + radius;
1080 rect_fl.ymin = y - radius;
1081 rect_fl.ymax = y + radius;
1082
1083 /* 'include_handles' from the operator specifies whether to consider handles in the selection. */
1084 const bool incl_handles = RNA_boolean_get(op->ptr, "include_handles");
1085
1086 /* Apply box_select action. */
1087 const bool any_key_selection_changed = box_select_graphkeys(
1088 &ac, &rect_fl, BEZT_OK_REGION_CIRCLE, selectmode, incl_handles, &data);
1089 if (any_key_selection_changed) {
1090 /* If any key was selected at any time during this process, the entire-curve selection should
1091 * be disabled. Otherwise, sliding over any keyless part of the curve will immediately cause
1092 * the entire curve to be selected. */
1093 RNA_boolean_set(op->ptr, "use_curve_selection", false);
1094 }
1095 const bool use_curve_selection = RNA_boolean_get(op->ptr, "use_curve_selection");
1096 if (use_curve_selection && !any_key_selection_changed) {
1097 box_select_graphcurves(&ac, &rect_fl, BEZT_OK_REGION_CIRCLE, selectmode, incl_handles, &data);
1098 }
1099
1100 /* Send notifier that keyframe selection has changed. */
1102
1103 return OPERATOR_FINISHED;
1104}
1105
1107{
1108 ot->name = "Circle Select";
1109 ot->description = "Select keyframe points using circle selection";
1110 ot->idname = "GRAPH_OT_select_circle";
1111
1118
1119 /* flags */
1120 ot->flag = OPTYPE_UNDO;
1121
1122 /* properties */
1125
1126 PropertyRNA *prop;
1127 prop = RNA_def_boolean(
1128 ot->srna,
1129 "include_handles",
1130 true,
1131 "Include Handles",
1132 "Are handles tested individually against the selection criteria, independently from their "
1133 "keys. When unchecked, handles are (de)selected in unison with their keys");
1135
1136 prop = RNA_def_boolean(
1137 ot->srna,
1138 "use_curve_selection",
1139 true,
1140 "Select Curves",
1141 "Allow selecting all the keyframes of a curve by selecting the curve itself");
1143}
1144
1146
1147/* -------------------------------------------------------------------- */
1156
1157/* defines for column-select mode */
1159 {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""},
1160 {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""},
1161 {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""},
1163 "MARKERS_BETWEEN",
1164 0,
1165 "Between Min/Max Selected Markers",
1166 ""},
1167 {0, nullptr, 0, nullptr, nullptr},
1168};
1169
1170/* ------------------- */
1171
1172/* Selects all visible keyframes between the specified markers */
1173/* TODO(@ideasman42): this is almost an _exact_ duplicate of a function of the same name in
1174 * `action_select.cc` should de-duplicate. */
1176{
1177 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1178 int filter;
1179
1180 KeyframeEditFunc ok_cb, select_cb;
1181 KeyframeEditData ked = {{nullptr}};
1182 float min, max;
1183
1184 /* get extreme markers */
1186 min -= 0.5f;
1187 max += 0.5f;
1188
1189 /* Get editing functions + data. */
1192
1193 ked.f1 = min;
1194 ked.f2 = max;
1195
1196 /* filter data */
1200 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1201
1202 /* select keys in-between */
1203 for (bAnimListElem &ale : anim_data) {
1205 &ale, static_cast<FCurve *>(ale.key_data), false, true);
1207 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1208 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, static_cast<FCurve *>(ale.key_data), true, true);
1209 }
1210
1211 /* Cleanup */
1212 ANIM_animdata_freelist(&anim_data);
1213}
1214
1215/* Selects all visible keyframes in the same frames as the specified elements */
1216static void columnselect_graph_keys(bAnimContext *ac, short mode)
1217{
1218 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1219 int filter;
1220
1221 Scene *scene = ac->scene;
1222 CfraElem *ce;
1223 KeyframeEditFunc select_cb, ok_cb;
1224 KeyframeEditData ked;
1225
1226 /* initialize keyframe editing data */
1227 memset(&ked, 0, sizeof(KeyframeEditData));
1228
1229 /* build list of columns */
1230 switch (mode) {
1231 case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */
1235 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1236
1237 for (bAnimListElem &ale : anim_data) {
1238 ked.data = &ale;
1240 &ked, static_cast<FCurve *>(ale.key_data), nullptr, bezt_to_cfraelem, nullptr);
1241 }
1242
1243 ANIM_animdata_freelist(&anim_data);
1244 break;
1245
1246 case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */
1247 /* make a single CfraElem for storing this */
1248 ce = MEM_new_zeroed<CfraElem>("cfraElem");
1249 BLI_addtail(&ked.cfra_elem_list, ce);
1250
1251 ce->cfra = float(scene->r.cfra);
1252 break;
1253
1254 case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
1256 break;
1257
1258 default: /* invalid option */
1259 return;
1260 }
1261
1262 /* set up BezTriple edit callbacks */
1265
1266 /* loop through all of the keys and select additional keyframes
1267 * based on the keys found to be selected above
1268 */
1272 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1273
1274 for (bAnimListElem &ale : anim_data) {
1275 /* loop over cfraelems (stored in the KeyframeEditData->list)
1276 * - we need to do this here, as we can apply fewer NLA-mapping conversions
1277 */
1278 for (CfraElem &ce : ked.cfra_elem_list) {
1279 /* set frame for validation callback to refer to */
1281
1282 /* select elements with frame number matching cfraelem */
1284 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1285 }
1286 }
1287
1288 /* free elements */
1289 ked.cfra_elem_list.free_no_destruct();
1290 ked.time_marker_list.free_no_destruct();
1291 ANIM_animdata_freelist(&anim_data);
1292}
1293
1294/* ------------------- */
1295
1297{
1298 bAnimContext ac;
1299 short mode;
1300
1301 /* get editor data */
1302 if (ANIM_animdata_get_context(C, &ac) == 0) {
1303 return OPERATOR_CANCELLED;
1304 }
1305
1306 /* action to take depends on the mode */
1307 mode = RNA_enum_get(op->ptr, "mode");
1308
1311 }
1312 else {
1313 columnselect_graph_keys(&ac, mode);
1314 }
1315
1316 /* set notifier that keyframe selection has changed */
1318
1319 return OPERATOR_FINISHED;
1320}
1321
1323{
1324 /* identifiers */
1325 ot->name = "Select All";
1326 ot->idname = "GRAPH_OT_select_column";
1327 ot->description = "Select all keyframes on the specified frame(s)";
1328
1329 /* API callbacks. */
1332
1333 /* flags */
1335
1336 /* props */
1337 ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
1339}
1340
1342
1343/* -------------------------------------------------------------------- */
1346
1348{
1349 bAnimContext ac;
1350
1351 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1352 int filter;
1353
1356
1357 /* get editor data */
1358 if (ANIM_animdata_get_context(C, &ac) == 0) {
1359 return OPERATOR_CANCELLED;
1360 }
1361
1362 /* loop through all of the keys and select additional keyframes based on these */
1366 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1367
1368 for (bAnimListElem &ale : anim_data) {
1369 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1370
1371 /* check if anything selected? */
1372 if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, ok_cb, nullptr)) {
1373 /* select every keyframe in this curve then */
1374 ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr);
1375 }
1376 }
1377
1378 /* Cleanup */
1379 ANIM_animdata_freelist(&anim_data);
1380
1381 /* set notifier that keyframe selection has changed */
1383
1384 return OPERATOR_FINISHED;
1385}
1386
1388{
1389 /* identifiers */
1390 ot->name = "Select Linked";
1391 ot->idname = "GRAPH_OT_select_linked";
1392 ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
1393
1394 /* API callbacks. */
1397
1398 /* flags */
1400}
1401
1403
1404/* -------------------------------------------------------------------- */
1407
1408/* Common code to perform selection */
1409static void select_moreless_graph_keys(bAnimContext *ac, short mode)
1410{
1411 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1412 int filter;
1413
1414 KeyframeEditData ked;
1415 KeyframeEditFunc build_cb;
1416
1417 /* init selmap building data */
1418 build_cb = ANIM_editkeyframes_buildselmap(mode);
1419 memset(&ked, 0, sizeof(KeyframeEditData));
1420
1421 /* loop through all of the keys and select additional keyframes based on these */
1425 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1426
1427 for (bAnimListElem &ale : anim_data) {
1428 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1429
1430 /* only continue if F-Curve has keyframes */
1431 if (fcu->bezt == nullptr) {
1432 continue;
1433 }
1434
1435 /* build up map of whether F-Curve's keyframes should be selected or not */
1436 ked.data = MEM_new_zeroed(fcu->totvert, "selmap graphEdit");
1437 ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, build_cb, nullptr);
1438
1439 /* based on this map, adjust the selection status of the keyframes */
1440 ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, bezt_selmap_flush, nullptr);
1441
1442 /* free the selmap used here */
1443 MEM_delete_void(ked.data);
1444 ked.data = nullptr;
1445 }
1446
1447 /* Cleanup */
1448 ANIM_animdata_freelist(&anim_data);
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 */
1467
1468 return OPERATOR_FINISHED;
1469}
1470
1472{
1473 /* identifiers */
1474 ot->name = "Select More";
1475 ot->idname = "GRAPH_OT_select_more";
1476 ot->description = "Select keyframes beside already selected ones";
1477
1478 /* API callbacks. */
1481
1482 /* flags */
1484}
1485
1486/* ----------------- */
1487
1489{
1490 bAnimContext ac;
1491
1492 /* get editor data */
1493 if (ANIM_animdata_get_context(C, &ac) == 0) {
1494 return OPERATOR_CANCELLED;
1495 }
1496
1497 /* perform select changes */
1499
1500 /* set notifier that keyframe selection has changed */
1502
1503 return OPERATOR_FINISHED;
1504}
1505
1507{
1508 /* identifiers */
1509 ot->name = "Select Less";
1510 ot->idname = "GRAPH_OT_select_less";
1511 ot->description = "Deselect keyframes on ends of selection islands";
1512
1513 /* API callbacks. */
1516
1517 /* flags */
1519}
1520
1522
1523/* -------------------------------------------------------------------- */
1528
1529/* defines for left-right select tool */
1531 {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
1532 {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
1533 {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Mouse Click Side", ""},
1534 {0, nullptr, 0, nullptr, nullptr},
1535};
1536
1537/* --------------------------------- */
1538
1540 short leftright,
1541 eEditKeyframes_Select select_mode)
1542{
1543 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1544 int filter;
1545
1546 KeyframeEditFunc ok_cb, select_cb;
1547 KeyframeEditData ked = {{nullptr}};
1548 Scene *scene = ac->scene;
1549
1550 /* if select mode is replace, deselect all keyframes (and channels) first */
1551 if (select_mode == SELECT_REPLACE) {
1552 select_mode = SELECT_ADD;
1553
1554 /* - deselect all other keyframes, so that just the newly selected remain
1555 * - channels aren't deselected, since we don't re-select any as a consequence
1556 */
1557 deselect_graph_keys(ac, false, SELECT_SUBTRACT, false);
1558 }
1559
1560 /* set callbacks and editing data */
1562 select_cb = ANIM_editkeyframes_select(select_mode);
1563
1564 if (leftright == GRAPHKEYS_LRSEL_LEFT) {
1565 ked.f1 = MINAFRAMEF;
1566 ked.f2 = float(scene->r.cfra + 0.1f);
1567 }
1568 else {
1569 ked.f1 = float(scene->r.cfra - 0.1f);
1570 ked.f2 = MAXFRAMEF;
1571 }
1572
1573 /* filter data */
1576 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1577
1578 /* select keys */
1579 for (bAnimListElem &ale : anim_data) {
1581 &ale, static_cast<FCurve *>(ale.key_data), false, true);
1583 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1584 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, static_cast<FCurve *>(ale.key_data), true, true);
1585 }
1586
1587 /* Cleanup */
1588 ANIM_animdata_freelist(&anim_data);
1589}
1590
1591/* ----------------- */
1592
1594{
1595 bAnimContext ac;
1596 short leftright = RNA_enum_get(op->ptr, "mode");
1597 eEditKeyframes_Select selectmode;
1598
1599 /* get editor data */
1600 if (ANIM_animdata_get_context(C, &ac) == 0) {
1601 return OPERATOR_CANCELLED;
1602 }
1603
1604 /* select mode is either replace (deselect all, then add) or add/extend */
1605 if (RNA_boolean_get(op->ptr, "extend")) {
1606 selectmode = SELECT_INVERT;
1607 }
1608 else {
1609 selectmode = SELECT_REPLACE;
1610 }
1611
1612 /* if "test" mode is set, we don't have any info to set this with */
1613 if (leftright == GRAPHKEYS_LRSEL_TEST) {
1614 return OPERATOR_CANCELLED;
1615 }
1616
1617 /* do the selecting now */
1618 graphkeys_select_leftright(&ac, leftright, selectmode);
1619
1620 /* set notifier that keyframe selection (and channels too) have changed */
1623
1624 return OPERATOR_FINISHED;
1625}
1626
1628 wmOperator *op,
1629 const wmEvent *event)
1630{
1631 bAnimContext ac;
1632 short leftright = RNA_enum_get(op->ptr, "mode");
1633
1634 /* get editor data */
1635 if (ANIM_animdata_get_context(C, &ac) == 0) {
1636 return OPERATOR_CANCELLED;
1637 }
1638
1639 /* handle mode-based testing */
1640 if (leftright == GRAPHKEYS_LRSEL_TEST) {
1641 Scene *scene = ac.scene;
1642 ARegion *region = ac.region;
1643 View2D *v2d = &region->v2d;
1644 float x;
1645
1646 /* determine which side of the current frame mouse is on */
1647 x = ui::view2d_region_to_view_x(v2d, event->mval[0]);
1648 if (x < scene->r.cfra) {
1650 }
1651 else {
1653 }
1654 }
1655
1656 /* perform selection */
1658}
1659
1661{
1662 PropertyRNA *prop;
1663
1664 /* identifiers */
1665 ot->name = "Select Left/Right";
1666 ot->idname = "GRAPH_OT_select_leftright";
1667 ot->description = "Select keyframes to the left or the right of the current frame";
1668
1669 /* API callbacks. */
1673
1674 /* flags */
1676
1677 /* id-props */
1678 ot->prop = RNA_def_enum(
1681
1682 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", "");
1684}
1685
1687
1688/* -------------------------------------------------------------------- */
1699
1700/* option 1) select keyframe directly under mouse */
1702 const int mval[2],
1703 eEditKeyframes_Select select_mode,
1704 const bool deselect_all,
1705 const bool curves_only,
1706 bool wait_to_deselect_others)
1707{
1708 SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(ac->sl);
1709 tNearestVertInfo *nvi;
1710 BezTriple *bezt = nullptr;
1711 bool run_modal = false;
1712
1713 /* find the beztriple that we're selecting, and the handle that was clicked on */
1714 nvi = find_nearest_fcurve_vert(ac, mval);
1715
1716 if (select_mode != SELECT_REPLACE) {
1717 /* The modal execution to delay deselecting other items is only needed for normal click
1718 * selection, i.e. for SELECT_REPLACE. */
1719 wait_to_deselect_others = false;
1720 }
1721
1724
1725 const bool already_selected =
1726 (nvi != nullptr) && (((nvi->hpoint == NEAREST_HANDLE_KEY) && (nvi->bezt->f2 & SELECT)) ||
1727 ((nvi->hpoint == NEAREST_HANDLE_LEFT) && (nvi->bezt->f1 & SELECT)) ||
1728 ((nvi->hpoint == NEAREST_HANDLE_RIGHT) && (nvi->bezt->f3 & SELECT)));
1729
1730 if (wait_to_deselect_others && nvi && already_selected) {
1731 run_modal = true;
1732 }
1733 /* For replacing selection, if we have something to select, we have to clear existing selection.
1734 * The same goes if we found nothing to select, and deselect_all is true
1735 * (deselect on nothing behavior). */
1736 else if ((nvi != nullptr && select_mode == SELECT_REPLACE) || (nvi == nullptr && deselect_all)) {
1737 /* reset selection mode */
1738 select_mode = SELECT_ADD;
1739
1740 /* deselect all other keyframes (+ F-Curves too) */
1741 deselect_graph_keys(ac, false, SELECT_SUBTRACT, true);
1742
1743 /* Deselect other channels too, but only do this if selection of channel
1744 * when the visibility of keyframes doesn't depend on this. */
1745 if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
1747 }
1748 }
1749
1750 if (nvi == nullptr) {
1751 return deselect_all ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1752 }
1753
1754 /* if points can be selected on this F-Curve */
1755 /* TODO: what about those with no keyframes? */
1756 bool something_was_selected = false;
1757 if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
1758 /* only if there's keyframe */
1759 if (nvi->bezt) {
1760 bezt = nvi->bezt; /* Used to check `bezt` selection is set. */
1761 if (select_mode == SELECT_INVERT) {
1762 if (nvi->hpoint == NEAREST_HANDLE_KEY) {
1763 bezt->f2 ^= BEZT_FLAG_SELECT;
1764 something_was_selected = (bezt->f2 & SELECT);
1765 }
1766 else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
1767 /* toggle selection */
1768 bezt->f1 ^= BEZT_FLAG_SELECT;
1769 something_was_selected = (bezt->f1 & SELECT);
1770 }
1771 else {
1772 /* toggle selection */
1773 bezt->f3 ^= BEZT_FLAG_SELECT;
1774 something_was_selected = (bezt->f3 & SELECT);
1775 }
1776 }
1777 else {
1778 if (nvi->hpoint == NEAREST_HANDLE_KEY) {
1779 bezt->f2 |= BEZT_FLAG_SELECT;
1780 }
1781 else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
1782 bezt->f1 |= BEZT_FLAG_SELECT;
1783 }
1784 else {
1785 bezt->f3 |= BEZT_FLAG_SELECT;
1786 }
1787 something_was_selected = true;
1788 }
1789
1790 if (!run_modal && BEZT_ISSEL_ANY(bezt)) {
1791 const bool may_activate = !already_selected ||
1794 if (may_activate) {
1796 }
1797 }
1798 }
1799 else if (nvi->fpt) {
1800 /* TODO: need to handle sample points */
1801 }
1802 }
1803 else {
1804 KeyframeEditFunc select_cb;
1805 KeyframeEditData ked;
1806
1807 /* initialize keyframe editing data */
1808 memset(&ked, 0, sizeof(KeyframeEditData));
1809
1810 /* set up BezTriple edit callbacks */
1811 select_cb = ANIM_editkeyframes_select(select_mode);
1812
1813 /* select all keyframes */
1814 ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, nullptr, select_cb, nullptr);
1815 }
1816
1817 /* only change selection of channel when the visibility of keyframes doesn't depend on this */
1818 if ((U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) == 0) {
1819 /* select or deselect curve? */
1820 if (bezt) {
1821 /* take selection status from item that got hit, to prevent flip/flop on channel
1822 * selection status when shift-selecting (i.e. "SELECT_INVERT") points
1823 */
1824 if (BEZT_ISSEL_ANY(bezt)) {
1825 nvi->fcu->flag |= FCURVE_SELECTED;
1826 }
1827 else {
1828 nvi->fcu->flag &= ~FCURVE_SELECTED;
1829 }
1830 }
1831 else {
1832 /* Didn't hit any channel,
1833 * so just apply that selection mode to the curve's selection status. */
1834 if (select_mode == SELECT_INVERT) {
1835 nvi->fcu->flag ^= FCURVE_SELECTED;
1836 }
1837 else if (select_mode == SELECT_ADD) {
1838 nvi->fcu->flag |= FCURVE_SELECTED;
1839 }
1840 }
1841 }
1842
1843 /* Set active F-Curve when something was actually selected (so not on a deselect), except when
1844 * dragging the selected keys. Needs to be called with
1845 * (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS),
1846 * otherwise the active flag won't be set #26452. */
1847 if (!run_modal && (nvi->fcu->flag & FCURVE_SELECTED) && something_was_selected) {
1848 /* NOTE: Sync the filter flags with findnearest_fcurve_vert. */
1852 ac->data,
1855 nvi->fcu,
1856 nvi->ctype);
1857 }
1858
1859 if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
1861 }
1862 else if (nvi->hpoint == NEAREST_HANDLE_RIGHT) {
1864 }
1865
1866 /* free temp sample data for filtering */
1867 MEM_delete(nvi);
1868
1869 return run_modal ? OPERATOR_RUNNING_MODAL : OPERATOR_FINISHED;
1870}
1871
1872/* Option 2) Selects all the keyframes on either side of the current frame
1873 * (depends on which side the mouse is on) */
1874/* (see graphkeys_select_leftright) */
1875
1876/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
1878 const int mval[2],
1879 eEditKeyframes_Select select_mode,
1880 bool wait_to_deselect_others)
1881{
1882 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1883 int filter;
1884 bool run_modal = false;
1885
1886 KeyframeEditFunc select_cb, ok_cb;
1887 KeyframeEditData ked;
1888 tNearestVertInfo *nvi;
1889
1890 /* find the beztriple that we're selecting, and the handle that was clicked on */
1891 nvi = find_nearest_fcurve_vert(ac, mval);
1892
1893 /* check if anything to select */
1894 if (nvi == nullptr) {
1895 return OPERATOR_CANCELLED;
1896 }
1897
1898 /* get frame number on which elements should be selected */
1899 /* TODO: should we restrict to integer frames only? */
1900 const float selx = nvi->frame;
1901
1902 if (select_mode != SELECT_REPLACE) {
1903 /* Doesn't need to deselect anything -> Pass. */
1904 }
1905 else if (wait_to_deselect_others && (nvi->bezt->f2 & SELECT)) {
1906 run_modal = true;
1907 }
1908 /* If select mode is replace (and we don't do delayed deselection on mouse release), deselect all
1909 * keyframes first. */
1910 else {
1911 /* reset selection mode to add to selection */
1912 select_mode = SELECT_ADD;
1913
1914 /* - deselect all other keyframes, so that just the newly selected remain
1915 * - channels aren't deselected, since we don't re-select any as a consequence
1916 */
1917 deselect_graph_keys(ac, false, SELECT_SUBTRACT, false);
1918 }
1919
1920 /* initialize keyframe editing data */
1921 memset(&ked, 0, sizeof(KeyframeEditData));
1922
1923 /* set up BezTriple edit callbacks */
1924 select_cb = ANIM_editkeyframes_select(select_mode);
1926
1927 /* loop through all of the keys and select additional keyframes
1928 * based on the keys found to be selected above
1929 */
1933 ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype));
1934
1935 for (bAnimListElem &ale : anim_data) {
1936 /* set frame for validation callback to refer to */
1938
1939 /* select elements with frame number matching cfra */
1941 &ked, static_cast<FCurve *>(ale.key_data), ok_cb, select_cb, nullptr);
1942 }
1943
1944 /* free elements */
1945 MEM_delete(nvi);
1946 ked.cfra_elem_list.free_no_destruct();
1947 ked.time_marker_list.free_no_destruct();
1948 ANIM_animdata_freelist(&anim_data);
1949
1950 return run_modal ? OPERATOR_RUNNING_MODAL : OPERATOR_FINISHED;
1951}
1952
1954
1955/* -------------------------------------------------------------------- */
1958
1960{
1961 bAnimContext ac;
1962
1963 /* get editor data */
1964 if (ANIM_animdata_get_context(C, &ac) == 0) {
1965 return OPERATOR_CANCELLED;
1966 }
1967
1968 /* select mode is either replace (deselect all, then add) or add/extend */
1969 const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
1970 const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
1971 /* See #WM_operator_properties_generic_select() for a detailed description of the how and why of
1972 * this. */
1973 const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
1974 int mval[2];
1975 wmOperatorStatus ret_val;
1976
1977 mval[0] = RNA_int_get(op->ptr, "mouse_x");
1978 mval[1] = RNA_int_get(op->ptr, "mouse_y");
1979
1980 /* figure out action to take */
1981 if (RNA_boolean_get(op->ptr, "column")) {
1982 /* select all keyframes in the same frame as the one that was under the mouse */
1983 ret_val = graphkeys_mselect_column(
1984 &ac, mval, eEditKeyframes_Select(selectmode), wait_to_deselect_others);
1985 }
1986 else if (RNA_boolean_get(op->ptr, "curves")) {
1987 /* select all keyframes in the same F-Curve as the one under the mouse */
1988 ret_val = mouse_graph_keys(
1989 &ac, mval, eEditKeyframes_Select(selectmode), deselect_all, true, wait_to_deselect_others);
1990 }
1991 else {
1992 /* select keyframe under mouse */
1993 ret_val = mouse_graph_keys(&ac,
1994 mval,
1995 eEditKeyframes_Select(selectmode),
1996 deselect_all,
1997 false,
1998 wait_to_deselect_others);
1999 }
2000
2001 /* set notifier that keyframe selection (and also channel selection in some cases) has
2002 * changed */
2005
2006 /* for tweak grab to work */
2007 return ret_val | OPERATOR_PASS_THROUGH;
2008}
2009
2011{
2012 PropertyRNA *prop;
2013
2014 /* identifiers */
2015 ot->name = "Select Keyframes";
2016 ot->idname = "GRAPH_OT_clickselect";
2017 ot->description = "Select keyframes by clicking on them";
2018
2019 /* callbacks */
2024
2025 /* flags */
2026 ot->flag = OPTYPE_UNDO;
2027
2028 /* properties */
2030
2031 /* Key-map: Enable with `Shift`. */
2032 prop = RNA_def_boolean(ot->srna,
2033 "extend",
2034 false,
2035 "Extend Select",
2036 "Toggle keyframe selection instead of leaving newly selected "
2037 "keyframes only");
2039
2040 prop = RNA_def_boolean(ot->srna,
2041 "deselect_all",
2042 false,
2043 "Deselect On Nothing",
2044 "Deselect all when nothing under the cursor");
2046
2047 /* Key-map: Enable with `Alt`. */
2048 prop = RNA_def_boolean(ot->srna,
2049 "column",
2050 false,
2051 "Column Select",
2052 "Select all keyframes that occur on the same frame as the one under "
2053 "the mouse");
2055
2056 /* Key-map: Enable with `Ctrl-Atl`. */
2057 prop = RNA_def_boolean(
2058 ot->srna, "curves", false, "Only Curves", "Select all the keyframes in the curve");
2060}
2061
2063
2064/* -------------------------------------------------------------------- */
2067
2068/* Defines for key/handles select tool. */
2070 {GRAPHKEYS_KEYHANDLESSEL_SELECT, "SELECT", 0, "Select", ""},
2071 {GRAPHKEYS_KEYHANDLESSEL_DESELECT, "DESELECT", 0, "Deselect", ""},
2072 {GRAPHKEYS_KEYHANDLESSEL_KEEP, "KEEP", 0, "Keep", "Leave as is"},
2073 {0, nullptr, 0, nullptr, nullptr},
2074};
2075
2087 bAnimContext *ac,
2088 const enum eGraphKey_SelectKeyHandles_Action left_handle_action,
2089 const enum eGraphKey_SelectKeyHandles_Action key_action,
2090 const enum eGraphKey_SelectKeyHandles_Action right_handle_action)
2091{
2092 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2093
2096 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
2097 for (bAnimListElem &ale : anim_data) {
2098 BLI_assert(ale.type & ANIMTYPE_FCURVE);
2099 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
2100
2101 /* Only continue if F-Curve has keyframes. */
2102 if (fcu->bezt == nullptr) {
2103 continue;
2104 }
2105
2106 for (int i = 0; i < fcu->totvert; i++) {
2107 BezTriple *bezt = &fcu->bezt[i];
2108
2109 if (!BEZT_ISSEL_ANY(bezt)) {
2110 continue;
2111 }
2112
2113 switch (left_handle_action) {
2115 BEZT_SEL_IDX(bezt, 0);
2116 break;
2118 BEZT_DESEL_IDX(bezt, 0);
2119 break;
2121 /* Do nothing. */
2122 break;
2123 }
2124
2125 switch (key_action) {
2127 BEZT_SEL_IDX(bezt, 1);
2128 break;
2130 BEZT_DESEL_IDX(bezt, 1);
2131 break;
2133 /* Do nothing. */
2134 break;
2135 }
2136
2137 switch (right_handle_action) {
2139 BEZT_SEL_IDX(bezt, 2);
2140 break;
2142 BEZT_DESEL_IDX(bezt, 2);
2143 break;
2145 /* Do nothing. */
2146 break;
2147 }
2148 }
2149 }
2150
2151 /* Cleanup */
2152 ANIM_animdata_freelist(&anim_data);
2153}
2154
2156{
2157 bAnimContext ac;
2158
2159 /* Get editor data. */
2160 if (ANIM_animdata_get_context(C, &ac) == 0) {
2161 return OPERATOR_CANCELLED;
2162 }
2163
2164 const eGraphKey_SelectKeyHandles_Action left_handle_action =
2165 static_cast<eGraphKey_SelectKeyHandles_Action>(RNA_enum_get(op->ptr, "left_handle_action"));
2166 const eGraphKey_SelectKeyHandles_Action key_action =
2167 static_cast<eGraphKey_SelectKeyHandles_Action>(RNA_enum_get(op->ptr, "key_action"));
2168 const eGraphKey_SelectKeyHandles_Action right_handle_action =
2169 static_cast<eGraphKey_SelectKeyHandles_Action>(RNA_enum_get(op->ptr, "right_handle_action"));
2170
2171 graphkeys_select_key_handles(&ac, left_handle_action, key_action, right_handle_action);
2172
2174
2175 return OPERATOR_FINISHED;
2176}
2177
2179{
2180 /* identifiers */
2181 ot->name = "Select Key / Handles";
2182 ot->idname = "GRAPH_OT_select_key_handles";
2183 ot->description =
2184 "For selected keyframes, select/deselect any combination of the key itself and its handles";
2185
2186 /* callbacks */
2189
2190 /* flags */
2192
2193 RNA_def_enum(ot->srna,
2194 "left_handle_action",
2197 "Left Handle",
2198 "Effect on the left handle");
2199 RNA_def_enum(ot->srna,
2200 "right_handle_action",
2203 "Right Handle",
2204 "Effect on the right handle");
2205 RNA_def_enum(ot->srna,
2206 "key_action",
2209 "Key",
2210 "Effect on the key itself");
2211}
2212
2214
2215} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
#define FCURVE_ACTIVE_KEYFRAME_NONE
#define BEZT_DESEL_IDX(bezt, i)
#define BEZT_ISSEL_IDX(bezt, i)
#define BEZT_ISSEL_ANY(bezt)
#define BEZT_SEL_IDX(bezt, i)
#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
btScalar max
#define INSIDE
#define BELOW
#define ABOVE
#define GVERTSEL_TOL
bool view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1684
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::string ED_select_circle_get_name(wmOperatorType *ot, PointerRNA *ptr)
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
static tNearestVertInfo * find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2])
@ NEAREST_HANDLE_KEY
@ NEAREST_HANDLE_RIGHT
@ NEAREST_HANDLE_LEFT
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void GRAPH_OT_select_column(wmOperatorType *ot)
void GRAPH_OT_select_linked(wmOperatorType *ot)
void GRAPH_OT_select_all(wmOperatorType *ot)
void ED_markers_make_cfra_list(ListBaseT< TimeMarker > *markers, ListBaseT< CfraElem > *lb, const bool only_selected)
@ GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN
@ GRAPHKEYS_COLUMNSEL_CFRA
@ GRAPHKEYS_COLUMNSEL_KEYS
@ GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN
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)
static wmOperatorStatus graphkeys_columnselect_exec(bContext *C, wmOperator *op)
eSelectOp ED_select_op_modal(eSelectOp sel_op, bool is_first)
bool graphop_visible_keyframes_poll(bContext *C)
void ANIM_anim_channels_select_set(bAnimContext *ac, eAnimChannels_SetFlag sel)
static void select_moreless_graph_keys(bAnimContext *ac, short mode)
@ ANIM_UNITCONV_ONLYKEYS
void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datatype, eAnimFilter_Flags filter, void *channel_data, eAnim_ChannelType channel_type)
static wmOperatorStatus graphkeys_select_more_exec(bContext *C, wmOperator *)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
MINLINE float len_v2v2_int(const int v1[2], const int v2[2])
static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
@ 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)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@ ACHANNEL_SETFLAG_CLEAR
static wmOperatorStatus graphkeys_box_select_exec(bContext *C, wmOperator *op)
static int initialize_animdata_selection_filter()
void GRAPH_OT_select_circle(wmOperatorType *ot)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
@ USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS
@ ANIMTYPE_FCURVE
wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBaseT< tNearestVertInfo > *matches)
void WM_gesture_circle_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void void BLI_listbase_rotate_last(ListBase *lb, void *vlink) ATTR_NONNULL(1
Definition listbase.cc:882
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 GRAPH_OT_select_less(wmOperatorType *ot)
@ GRAPHKEYS_LRSEL_RIGHT
@ GRAPHKEYS_LRSEL_TEST
@ GRAPHKEYS_LRSEL_LEFT
static short ok_bezier_always_ok(KeyframeEditData *, BezTriple *)
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 BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void GRAPH_OT_select_leftright(wmOperatorType *ot)
void WM_operator_properties_select_all(wmOperatorType *ot)
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:259
static wmOperatorStatus graphkeys_select_less_exec(bContext *C, wmOperator *)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
static void box_select_graphcurves(bAnimContext *ac, const rctf *rectf_view, const short mode, const eEditKeyframes_Select selectmode, const bool incl_handles, void *data)
static wmOperatorStatus graphkeys_select_key_handles_exec(bContext *C, wmOperator *op)
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)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_CURVE_VISIBLE
@ ANIMFILTER_NODUPLIS
@ ANIMFILTER_SELEDIT
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
BMesh const char void * data
void GRAPH_OT_select_key_handles(wmOperatorType *ot)
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 wmOperatorStatus graphkeys_deselectall_exec(bContext *C, wmOperator *op)
static int rectf_curve_zone_y(const FCurve *fcu, const rctf *rectf, const float offset, const float unit_scale, const float eval_x)
static wmOperatorStatus mouse_graph_keys(bAnimContext *ac, const int mval[2], eEditKeyframes_Select select_mode, const bool deselect_all, const bool curves_only, bool wait_to_deselect_others)
KeyframeEditFunc ANIM_editkeyframes_select(const eEditKeyframes_Select selectmode)
void GRAPH_OT_clickselect(wmOperatorType *ot)
static wmOperatorStatus graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
static wmOperatorStatus graphkeys_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bAnimListElem * get_active_fcurve_channel(bAnimContext *ac)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static void columnselect_graph_keys(bAnimContext *ac, short mode)
static wmOperatorStatus graphkeys_mselect_column(bAnimContext *ac, const int mval[2], eEditKeyframes_Select select_mode, bool wait_to_deselect_others)
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
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 RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
static bool box_select_graphkeys(bAnimContext *ac, const rctf *rectf_view, short mode, eEditKeyframes_Select selectmode, bool incl_handles, void *data)
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
short(*)(KeyframeEditData *ked, BezTriple *bezt) KeyframeEditFunc
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void GRAPH_OT_select_box(wmOperatorType *ot)
float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static tNearestVertInfo * get_best_nearest_fcurve_vert(ListBaseT< tNearestVertInfo > *matches)
@ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_RIGHT
@ SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void initialize_box_select_key_editing_data(const bool incl_handles, const short mode, bAnimContext *ac, void *data, rctf *scaled_rectf, KeyframeEditData *r_ked, int *r_mapping_flag)
void deselect_graph_keys(bAnimContext *ac, bool test, eEditKeyframes_Select sel, bool do_channels)
static wmOperatorStatus graph_circle_select_exec(bContext *C, wmOperator *op)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag, float *r_offset)
Definition anim_draw.cc:636
@ 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)
static const EnumPropertyItem prop_graphkeys_select_key_handles_actions[]
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus graphkeys_clickselect_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem prop_graphkeys_leftright_select_types[]
static void graphkeys_select_key_handles(bAnimContext *ac, const enum eGraphKey_SelectKeyHandles_Action left_handle_action, const enum eGraphKey_SelectKeyHandles_Action key_action, const enum eGraphKey_SelectKeyHandles_Action right_handle_action)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
static void graphkeys_select_leftright(bAnimContext *ac, short leftright, eEditKeyframes_Select select_mode)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
static rctf initialize_box_select_coords(const bAnimContext *ac, const rctf *rectf_view)
static wmOperatorStatus graphkeys_select_linked_exec(bContext *C, wmOperator *)
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)
static bool rectf_curve_intersection(const float offset, const float unit_scale, const rctf *rectf, bAnimListElem *ale, const FCurve *fcu)
void GRAPH_OT_select_lasso(wmOperatorType *ot)
static wmOperatorStatus graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_markers_get_minmax(ListBaseT< TimeMarker > *markers, short sel, float *r_first, float *r_last)
static void nearest_fcurve_vert_store(ListBaseT< tNearestVertInfo > *matches, View2D *v2d, FCurve *fcu, eAnim_ChannelType ctype, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale, float offset)
void GRAPH_OT_select_more(wmOperatorType *ot)
void WM_operator_properties_generic_select(wmOperatorType *ot)
@ KEYFRAME_ITER_HANDLES_INVISIBLE
@ KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
Definition lasso_2d.cc:21
static const EnumPropertyItem prop_column_select_types[]
eGraphKey_SelectKeyHandles_Action
@ GRAPHKEYS_KEYHANDLESSEL_SELECT
@ GRAPHKEYS_KEYHANDLESSEL_KEEP
@ GRAPHKEYS_KEYHANDLESSEL_DESELECT
short ANIM_get_normalization_flags(SpaceLink *space_link)
Definition anim_draw.cc:420
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
static ListBaseT< bAnimListElem > initialize_box_select_anim_data(const int filter, bAnimContext *ac)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
eBezTriple_Flag f2
eBezTriple_Flag f3
eBezTriple_Flag f1
eBezTriple_Interpolation ipo
eFCurve_Flags flag
unsigned int totvert
ListBaseT< TimeMarker > time_marker_list
ListBaseT< CfraElem > cfra_elem_list
struct RenderData r
SpaceGraph_Runtime runtime
eGraphEdit_Flag flag
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
eAnim_ChannelType ctype
tNearestVertInfo * next
tNearestVertInfo * prev
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