90
88
bAnimListElem *ale;
91
KeyframeEditData ked= {{NULL}};
94
92
KeyframeEditFunc test_cb, sel_cb;
96
94
/* determine type-based settings */
97
95
if (ac->datatype == ANIMCONT_GPENCIL)
98
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NODUPLIS);
96
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
100
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
98
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
102
100
/* filter data */
103
101
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
105
103
/* init BezTriple looping data */
106
memset(&ked, 0, sizeof(KeyframeEditData));
107
104
test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
109
106
/* See if we should be selecting or deselecting */
111
108
for (ale= anim_data.first; ale; ale= ale->next) {
112
109
if (ale->type == ANIMTYPE_GPLAYER) {
113
//if (is_gplayer_frame_selected(ale->data)) {
110
if (is_gplayer_frame_selected(ale->data)) {
111
sel= SELECT_SUBTRACT;
119
116
if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
164
161
void ACTION_OT_select_all_toggle (wmOperatorType *ot)
166
163
/* identifiers */
167
ot->name= "Select All";
168
ot->idname= "ACTION_OT_select_all_toggle";
169
ot->description= "Toggle selection of all keyframes";
164
ot->name = "Select All";
165
ot->idname = "ACTION_OT_select_all_toggle";
166
ot->description = "Toggle selection of all keyframes";
171
168
/* api callbacks */
172
ot->exec= actkeys_deselectall_exec;
173
ot->poll= ED_operator_action_active;
169
ot->exec = actkeys_deselectall_exec;
170
ot->poll = ED_operator_action_active;
176
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
173
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
179
ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
176
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
182
179
/* ******************** Border Select Operator **************************** */
212
209
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax);
214
211
/* filter data */
215
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS | ANIMFILTER_NODUPLIS);
212
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS);
216
213
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
218
/* get filtering flag for dopesheet data (if applicable) */
219
if (ac->datatype == ANIMCONT_DOPESHEET) {
220
bDopeSheet *ads= (bDopeSheet *)ac->data;
221
filterflag= ads->filterflag;
226
215
/* get beztriple editing/validation funcs */
227
216
select_cb= ANIM_editkeyframes_select(selectmode);
259
248
!((ymax < rectf.ymin) || (ymin > rectf.ymax)) )
261
250
/* loop over data selecting */
262
//if (ale->type == ANIMTYPE_GPLAYER)
263
// borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
265
ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, filterflag);
251
if (ale->type == ANIMTYPE_GPLAYER)
252
borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
254
ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
268
257
/* set minimum extent to be the maximum of the next channel */
282
271
short mode=0, selectmode=0;
272
int gesture_mode, extend;
285
274
/* get editor data */
286
275
if (ANIM_animdata_get_context(C, &ac) == 0)
287
276
return OPERATOR_CANCELLED;
278
/* clear all selection if not extending selection */
279
extend= RNA_boolean_get(op->ptr, "extend");
281
deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
289
283
/* get settings from operator */
290
rect.xmin= RNA_int_get(op->ptr, "xmin");
291
rect.ymin= RNA_int_get(op->ptr, "ymin");
292
rect.xmax= RNA_int_get(op->ptr, "xmax");
293
rect.ymax= RNA_int_get(op->ptr, "ymax");
284
rect.xmin = RNA_int_get(op->ptr, "xmin");
285
rect.ymin = RNA_int_get(op->ptr, "ymin");
286
rect.xmax = RNA_int_get(op->ptr, "xmax");
287
rect.ymax = RNA_int_get(op->ptr, "ymax");
295
289
gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
296
290
if (gesture_mode == GESTURE_MODAL_SELECT)
325
319
void ACTION_OT_select_border(wmOperatorType *ot)
327
321
/* identifiers */
328
ot->name= "Border Select";
329
ot->idname= "ACTION_OT_select_border";
330
ot->description= "Select all keyframes within the specified region";
322
ot->name = "Border Select";
323
ot->idname = "ACTION_OT_select_border";
324
ot->description = "Select all keyframes within the specified region";
332
326
/* api callbacks */
333
ot->invoke= WM_border_select_invoke;
334
ot->exec= actkeys_borderselect_exec;
335
ot->modal= WM_border_select_modal;
327
ot->invoke = WM_border_select_invoke;
328
ot->exec = actkeys_borderselect_exec;
329
ot->modal = WM_border_select_modal;
330
ot->cancel = WM_border_select_cancel;
337
ot->poll= ED_operator_action_active;
332
ot->poll = ED_operator_action_active;
340
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
335
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
343
WM_operator_properties_gesture_border(ot, FALSE);
338
WM_operator_properties_gesture_border(ot, TRUE);
345
ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
340
ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
348
343
/* ******************** Column Select Operator **************************** */
421
420
Scene *scene= ac->scene;
423
422
KeyframeEditFunc select_cb, ok_cb;
424
KeyframeEditData ked;
423
KeyframeEditData ked= {{NULL}};
426
/* initialise keyframe editing data */
427
memset(&ked, 0, sizeof(KeyframeEditData));
425
/* initialize keyframe editing data */
429
427
/* build list of columns */
431
429
case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */
432
430
if (ac->datatype == ANIMCONT_GPENCIL) {
433
filter= (ANIMFILTER_VISIBLE);
431
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
434
432
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
436
//for (ale= anim_data.first; ale; ale= ale->next)
437
// gplayer_make_cfra_list(ale->data, &elems, 1);
434
for (ale= anim_data.first; ale; ale= ale->next)
435
gplayer_make_cfra_list(ale->data, &ked.list, 1);
440
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
438
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
441
439
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
443
441
for (ale= anim_data.first; ale; ale= ale->next)
489
487
ked.f1= ce->cfra;
491
489
/* select elements with frame number matching cfraelem */
492
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
494
#if 0 // XXX reenable when Grease Pencil stuff is back
495
if (ale->type == ANIMTYPE_GPLAYER) {
496
bGPDlayer *gpl= (bGPDlayer *)ale->data;
499
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
500
if (ecfra == gpf->framenum)
501
gpf->flag |= GP_FRAME_SELECT;
505
#endif // XXX reenable when Grease Pencil stuff is back
490
if (ale->type == ANIMTYPE_GPLAYER)
491
select_gpencil_frame(ale->data, ce->cfra, SELECT_ADD);
493
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
539
527
void ACTION_OT_select_column (wmOperatorType *ot)
541
529
/* identifiers */
542
ot->name= "Select All";
543
ot->idname= "ACTION_OT_select_column";
544
ot->description= "Select all keyframes on the specified frame(s)";
530
ot->name = "Select All";
531
ot->idname = "ACTION_OT_select_column";
532
ot->description = "Select all keyframes on the specified frame(s)";
546
534
/* api callbacks */
547
ot->exec= actkeys_columnselect_exec;
548
ot->poll= ED_operator_action_active;
535
ot->exec = actkeys_columnselect_exec;
536
ot->poll = ED_operator_action_active;
551
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
539
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
554
ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
542
ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
557
545
/* ******************** Select Linked Operator *********************** */
559
static int actkeys_select_linked_exec (bContext *C, wmOperator *op)
547
static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op))
711
698
/* identifiers */
712
699
ot->name = "Select Less";
713
ot->idname= "ACTION_OT_select_less";
700
ot->idname = "ACTION_OT_select_less";
714
701
ot->description = "Deselect keyframes on ends of selection islands";
716
703
/* api callbacks */
717
ot->exec= actkeys_select_less_exec;
718
ot->poll= ED_operator_action_active;
704
ot->exec = actkeys_select_less_exec;
705
ot->poll = ED_operator_action_active;
721
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
708
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
724
/* ******************** Mouse-Click Select Operator *********************** */
725
/* This operator works in one of three ways:
726
* - 1) keyframe under mouse - no special modifiers
727
* - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier
728
* - 3) column select all keyframes in frame under mouse - CTRL modifier
730
* In addition to these basic options, the SHIFT modifier can be used to toggle the
731
* selection mode between replacing the selection (without) and inverting the selection (with).
711
/* ******************** Select Left/Right Operator ************************* */
712
/* Select keyframes left/right of the current frame indicator */
734
714
/* defines for left-right select tool */
735
715
static EnumPropertyItem prop_actkeys_leftright_select_types[] = {
736
716
{ACTKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
737
{ACTKEYS_LRSEL_NONE, "OFF", 0, "Don't select", ""},
738
717
{ACTKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""},
739
718
{ACTKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""},
740
719
{0, NULL, 0, NULL, NULL}
743
/* sensitivity factor for frame-selections */
744
#define FRAME_CLICK_THRESH 0.1f
746
/* ------------------- */
748
/* option 1) select keyframe directly under mouse */
749
static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx)
751
bDopeSheet *ads= (ac->datatype == ANIMCONT_DOPESHEET) ? ac->data : NULL;
752
int ds_filter = ((ads) ? (ads->filterflag) : (0));
754
KeyframeEditData ked;
755
KeyframeEditFunc select_cb, ok_cb;
757
/* get functions for selecting keyframes */
758
select_cb= ANIM_editkeyframes_select(select_mode);
759
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME);
760
memset(&ked, 0, sizeof(KeyframeEditData));
763
/* select the nominated keyframe on the given frame */
764
ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, ds_filter);
767
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
768
static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short select_mode)
722
/* --------------------------------- */
724
static void actkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode)
770
726
ListBase anim_data = {NULL, NULL};
771
727
bAnimListElem *ale;
774
730
KeyframeEditFunc ok_cb, select_cb;
775
KeyframeEditData ked;
731
KeyframeEditData ked= {{NULL}};
776
732
Scene *scene= ac->scene;
778
734
/* if select mode is replace, deselect all keyframes (and channels) first */
779
735
if (select_mode==SELECT_REPLACE) {
780
736
select_mode= SELECT_ADD;
782
/* deselect all other channels and keyframes */
783
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
738
/* - deselect all other keyframes, so that just the newly selected remain
739
* - channels aren't deselected, since we don't re-select any as a consequence
784
741
deselect_action_keys(ac, 0, SELECT_SUBTRACT);
788
745
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
789
746
select_cb= ANIM_editkeyframes_select(select_mode);
791
memset(&ked, 0, sizeof(KeyframeEditFunc));
792
748
if (leftright == ACTKEYS_LRSEL_LEFT) {
793
749
ked.f1 = MINAFRAMEF;
794
ked.f2 = (float)(CFRA + FRAME_CLICK_THRESH);
750
ked.f2 = (float)(CFRA + 0.1f);
797
ked.f1 = (float)(CFRA - FRAME_CLICK_THRESH);
753
ked.f1 = (float)(CFRA - 0.1f);
798
754
ked.f2 = MAXFRAMEF;
801
757
/* filter data */
802
758
if (ac->datatype == ANIMCONT_GPENCIL)
803
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NODUPLIS);
759
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
805
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
761
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
806
762
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
808
/* select keys on the side where most data occurs */
809
765
for (ale= anim_data.first; ale; ale= ale->next) {
810
766
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
814
770
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
815
771
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
817
//else if (ale->type == ANIMTYPE_GPLAYER)
818
// borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD);
773
else if (ale->type == ANIMTYPE_GPLAYER)
774
borderselect_gplayer_frames(ale->data, ked.f1, ked.f2, select_mode);
820
776
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
823
779
/* Sync marker support */
824
if((select_mode==SELECT_ADD) && (ac->spacetype==SPACE_ACTION) && ELEM(leftright, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT)) {
825
SpaceAction *saction= ac->sa->spacedata.first;
780
if (select_mode==SELECT_ADD) {
781
SpaceAction *saction= (SpaceAction *)ac->sl;
827
if (saction && saction->flag & SACTION_MARKERS_MOVE) {
783
if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) {
784
ListBase *markers = ED_animcontext_get_markers(ac);
828
785
TimeMarker *marker;
830
for (marker= scene->markers.first; marker; marker= marker->next) {
831
if( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) ||
787
for (marker= markers->first; marker; marker= marker->next) {
788
if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) ||
832
789
((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) )
834
791
marker->flag |= SELECT;
844
801
BLI_freelistN(&anim_data);
804
/* ----------------- */
806
static int actkeys_select_leftright_exec (bContext *C, wmOperator *op)
809
short leftright = RNA_enum_get(op->ptr, "mode");
812
/* get editor data */
813
if (ANIM_animdata_get_context(C, &ac) == 0)
814
return OPERATOR_CANCELLED;
816
/* select mode is either replace (deselect all, then add) or add/extend */
817
if (RNA_boolean_get(op->ptr, "extend"))
818
selectmode= SELECT_INVERT;
820
selectmode= SELECT_REPLACE;
822
/* if "test" mode is set, we don't have any info to set this with */
823
if (leftright == ACTKEYS_LRSEL_TEST)
824
return OPERATOR_CANCELLED;
826
/* do the selecting now */
827
actkeys_select_leftright(&ac, leftright, selectmode);
829
/* set notifier that keyframe selection (and channels too) have changed */
830
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
832
return OPERATOR_FINISHED;
835
static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event)
838
short leftright = RNA_enum_get(op->ptr, "mode");
840
/* get editor data */
841
if (ANIM_animdata_get_context(C, &ac) == 0)
842
return OPERATOR_CANCELLED;
844
/* handle mode-based testing */
845
if (leftright == ACTKEYS_LRSEL_TEST) {
846
Scene *scene= ac.scene;
848
View2D *v2d= &ar->v2d;
851
/* determine which side of the current frame mouse is on */
852
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL);
854
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
856
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
859
/* perform selection */
860
return actkeys_select_leftright_exec(C, op);
863
void ACTION_OT_select_leftright (wmOperatorType *ot)
866
ot->name = "Select Left/Right";
867
ot->idname = "ACTION_OT_select_leftright";
868
ot->description = "Select keyframes to the left or the right of the current frame";
871
ot->invoke = actkeys_select_leftright_invoke;
872
ot->exec = actkeys_select_leftright_exec;
873
ot->poll = ED_operator_action_active;
876
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
879
ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", "");
880
RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
883
/* ******************** Mouse-Click Select Operator *********************** */
884
/* This operator works in one of three ways:
885
* - 1) keyframe under mouse - no special modifiers
886
* - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier
887
* - 3) column select all keyframes in frame under mouse - CTRL modifier
889
* In addition to these basic options, the SHIFT modifier can be used to toggle the
890
* selection mode between replacing the selection (without) and inverting the selection (with).
893
/* sensitivity factor for frame-selections */
894
#define FRAME_CLICK_THRESH 0.1f
896
/* ------------------- */
898
/* option 1) select keyframe directly under mouse */
899
static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx)
901
KeyframeEditData ked= {{NULL}};
902
KeyframeEditFunc select_cb, ok_cb;
904
/* get functions for selecting keyframes */
905
select_cb= ANIM_editkeyframes_select(select_mode);
906
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME);
909
/* select the nominated keyframe on the given frame */
910
if (ale->type == ANIMTYPE_GPLAYER)
911
select_gpencil_frame(ale->data, selx, select_mode);
913
ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
916
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
917
/* (see actkeys_select_leftright) */
847
919
/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
848
920
static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float selx)
882
951
/* select elements with frame number matching cfra */
883
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
885
#if 0 // XXX reenable when Grease Pencil stuff is back
886
if (ale->type == ANIMTYPE_GPLAYER) {
887
bGPDlayer *gpl= (bGPDlayer *)ale->data;
890
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
891
if (ecfra == gpf->framenum)
892
gpf->flag |= GP_FRAME_SELECT;
896
#endif // XXX reenable when Grease Pencil stuff is back
952
if (ale->type == ANIMTYPE_GPLAYER)
953
select_gpencil_frame(ale->key_data, selx, select_mode);
955
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
899
958
/* free elements */
983
1041
/* dopesheet summary covers everything */
984
1042
summary_to_keylist(ac, &anim_keys, NULL);
986
else if (ale->type == ANIMTYPE_GROUP) {
1044
else if (ale->type == ANIMTYPE_GROUP) {
1045
// TODO: why don't we just give groups key_data too?
987
1046
bActionGroup *agrp= (bActionGroup *)ale->data;
988
1047
agroup_to_keylist(adt, agrp, &anim_keys, NULL);
990
else if (ale->type == ANIMTYPE_GPDATABLOCK) {
993
BLI_freelistN(&anim_data);
996
1049
else if (ale->type == ANIMTYPE_GPLAYER) {
997
bGPDlayer *gpl= (bGPDlayer *)ale->data;
998
gpl_to_keylist(ads, gpl, &anim_keys, NULL);
1050
// TODO: why don't we just give gplayers key_data too?
1051
bGPDlayer *gpl = (bGPDlayer *)ale->data;
1052
gpl_to_keylist(ads, gpl, &anim_keys);
1001
/* loop through keyframes, finding one that was within the range clicked on */
1002
// TODO: replace this with API calls instead of inlining
1055
/* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */
1003
1056
for (ak= anim_keys.root; ak; ak= akn) {
1004
1057
if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) {
1005
1058
/* set the frame to use, and apply inverse-correction for NLA-mapping
1006
* so that the frame will get selected by the selection functiosn without
1059
* so that the frame will get selected by the selection functions without
1007
1060
* requiring to map each frame once again...
1009
1062
selx= BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP);
1091
1145
static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *event)
1093
1147
bAnimContext ac;
1148
/* ARegion *ar; */ /* UNUSED */
1097
1149
short selectmode, column;
1100
1151
/* get editor data */
1101
1152
if (ANIM_animdata_get_context(C, &ac) == 0)
1102
1153
return OPERATOR_CANCELLED;
1104
1155
/* get useful pointers from animation context data */
1109
/* get mouse coordinates (in region coordinates) */
1110
mval[0]= (event->x - ar->winrct.xmin);
1111
mval[1]= (event->y - ar->winrct.ymin);
1156
/* ar= ac.ar; */ /* UNUSED */
1113
1158
/* select mode is either replace (deselect all, then add) or add/extend */
1114
1159
if (RNA_boolean_get(op->ptr, "extend"))
1115
1160
selectmode= SELECT_INVERT;
1119
1164
/* column selection */
1120
1165
column= RNA_boolean_get(op->ptr, "column");
1122
/* figure out action to take */
1123
if (RNA_enum_get(op->ptr, "left_right")) {
1124
/* select all keys on same side of current frame as mouse */
1127
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
1129
RNA_int_set(op->ptr, "left_right", ACTKEYS_LRSEL_LEFT);
1131
RNA_int_set(op->ptr, "left_right", ACTKEYS_LRSEL_RIGHT);
1133
actkeys_mselect_leftright(&ac, RNA_enum_get(op->ptr, "left_right"), selectmode);
1136
/* select keyframe(s) based upon mouse position*/
1137
mouse_action_keys(&ac, mval, selectmode, column);
1167
/* select keyframe(s) based upon mouse position*/
1168
mouse_action_keys(&ac, event->mval, selectmode, column);
1140
1170
/* set notifier that keyframe selection (and channels too) have changed */
1141
1171
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
1147
1177
void ACTION_OT_clickselect (wmOperatorType *ot)
1149
1179
/* identifiers */
1150
ot->name= "Mouse Select Keys";
1151
ot->idname= "ACTION_OT_clickselect";
1152
ot->description= "Select keyframes by clicking on them";
1180
ot->name = "Mouse Select Keys";
1181
ot->idname = "ACTION_OT_clickselect";
1182
ot->description = "Select keyframes by clicking on them";
1154
1184
/* api callbacks - absolutely no exec() this yet... */
1155
ot->invoke= actkeys_clickselect_invoke;
1156
ot->poll= ED_operator_action_active;
1185
ot->invoke = actkeys_clickselect_invoke;
1186
ot->poll = ED_operator_action_active;
1159
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1189
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1162
// XXX should we make this into separate operators?
1163
RNA_def_enum(ot->srna, "left_right", prop_actkeys_leftright_select_types, 0, "Left Right", ""); // CTRLKEY
1164
1192
RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
1165
1193
RNA_def_boolean(ot->srna, "column", 0, "Column Select", ""); // ALTKEY