~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_action/action_select.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: action_select.c 29537 2010-06-18 04:39:32Z broken $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
24
22
 * ***** END GPL LICENSE BLOCK *****
25
23
 */
26
24
 
 
25
/** \file blender/editors/space_action/action_select.c
 
26
 *  \ingroup spaction
 
27
 */
 
28
 
 
29
 
27
30
#include <math.h>
28
31
#include <stdlib.h>
29
32
#include <string.h>
34
37
#include "BLI_blenlib.h"
35
38
#include "BLI_math.h"
36
39
#include "BLI_dlrbTree.h"
 
40
#include "BLI_utildefines.h"
37
41
 
38
42
#include "DNA_anim_types.h"
 
43
#include "DNA_gpencil_types.h"
39
44
#include "DNA_object_types.h"
40
45
#include "DNA_scene_types.h"
41
46
 
42
47
#include "RNA_access.h"
43
48
#include "RNA_define.h"
44
49
 
45
 
#include "BKE_action.h"
46
 
#include "BKE_depsgraph.h"
47
50
#include "BKE_fcurve.h"
48
 
#include "BKE_key.h"
49
 
#include "BKE_material.h"
50
51
#include "BKE_nla.h"
51
 
#include "BKE_object.h"
52
52
#include "BKE_context.h"
53
 
#include "BKE_utildefines.h"
54
53
 
55
54
#include "UI_view2d.h"
56
55
 
57
56
#include "ED_anim_api.h"
 
57
#include "ED_gpencil.h"
58
58
#include "ED_keyframes_draw.h"
59
59
#include "ED_keyframes_edit.h"
60
60
#include "ED_markers.h"
65
65
 
66
66
#include "action_intern.h"
67
67
 
 
68
 
68
69
/* ************************************************************************** */
69
70
/* KEYFRAMES STUFF */
70
71
 
79
80
 *      - This is called by the deselect all operator, as well as other ones!
80
81
 *
81
82
 *      - test: check if select or deselect all
82
 
 *      - sel: how to select keyframes 
83
 
 *              0 = deselect
84
 
 *              1 = select
85
 
 *              2 = invert
 
83
 *      - sel: how to select keyframes (SELECT_*)
86
84
 */
87
85
static void deselect_action_keys (bAnimContext *ac, short test, short sel)
88
86
{
90
88
        bAnimListElem *ale;
91
89
        int filter;
92
90
        
93
 
        KeyframeEditData ked;
 
91
        KeyframeEditData ked= {{NULL}};
94
92
        KeyframeEditFunc test_cb, sel_cb;
95
93
        
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);
99
97
        else
100
 
                filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 
98
                filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
101
99
        
102
100
        /* filter data */
103
101
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
104
102
        
105
103
        /* init BezTriple looping data */
106
 
        memset(&ked, 0, sizeof(KeyframeEditData));
107
104
        test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
108
105
        
109
106
        /* See if we should be selecting or deselecting */
110
107
        if (test) {
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)) {
114
 
                                //      sel= 0;
115
 
                                //      break;
116
 
                                //}
 
110
                                if (is_gplayer_frame_selected(ale->data)) {
 
111
                                        sel= SELECT_SUBTRACT;
 
112
                                        break;
 
113
                                }
117
114
                        }
118
115
                        else {
119
116
                                if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
129
126
        
130
127
        /* Now set the flags */
131
128
        for (ale= anim_data.first; ale; ale= ale->next) {
132
 
                //if (ale->type == ACTTYPE_GPLAYER)
133
 
                //      set_gplayer_frame_selection(ale->data, sel);
134
 
                //else
135
 
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
 
129
                if (ale->type == ANIMTYPE_GPLAYER)
 
130
                        set_gplayer_frame_selection(ale->data, sel);
 
131
                else
 
132
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); 
136
133
        }
137
134
        
138
135
        /* Cleanup */
149
146
        if (ANIM_animdata_get_context(C, &ac) == 0)
150
147
                return OPERATOR_CANCELLED;
151
148
                
152
 
        /* 'standard' behaviour - check if selected, then apply relevant selection */
 
149
        /* 'standard' behavior - check if selected, then apply relevant selection */
153
150
        if (RNA_boolean_get(op->ptr, "invert"))
154
151
                deselect_action_keys(&ac, 0, SELECT_INVERT);
155
152
        else
164
161
void ACTION_OT_select_all_toggle (wmOperatorType *ot)
165
162
{
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";
170
167
        
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;
174
171
        
175
172
        /* flags */
176
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
173
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
177
174
        
178
175
        /* props */
179
 
        ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
 
176
        ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
180
177
}
181
178
 
182
179
/* ******************** Border Select Operator **************************** */
192
189
        ACTKEYS_BORDERSEL_ALLKEYS       = 0,
193
190
        ACTKEYS_BORDERSEL_FRAMERANGE,
194
191
        ACTKEYS_BORDERSEL_CHANNELS,
195
 
} eActKeys_BorderSelect_Mode;
 
192
} /*eActKeys_BorderSelect_Mode*/;
196
193
 
197
194
 
198
195
static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short selectmode)
199
196
{
200
197
        ListBase anim_data = {NULL, NULL};
201
198
        bAnimListElem *ale;
202
 
        int filter, filterflag;
 
199
        int filter;
203
200
        
204
201
        KeyframeEditData ked;
205
202
        KeyframeEditFunc ok_cb, select_cb;
212
209
        UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax);
213
210
        
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);
217
214
        
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;
222
 
        }
223
 
        else
224
 
                filterflag= 0;
225
 
        
226
215
        /* get beztriple editing/validation funcs  */
227
216
        select_cb= ANIM_editkeyframes_select(selectmode);
228
217
        
259
248
                        !((ymax < rectf.ymin) || (ymin > rectf.ymax)) )
260
249
                {
261
250
                        /* loop over data selecting */
262
 
                        //if (ale->type == ANIMTYPE_GPLAYER)
263
 
                        //      borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
264
 
                        //else
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);
 
253
                        else
 
254
                                ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
266
255
                }
267
256
                
268
257
                /* set minimum extent to be the maximum of the next channel */
280
269
        bAnimContext ac;
281
270
        rcti rect;
282
271
        short mode=0, selectmode=0;
283
 
        int gesture_mode;
 
272
        int gesture_mode, extend;
284
273
        
285
274
        /* get editor data */
286
275
        if (ANIM_animdata_get_context(C, &ac) == 0)
287
276
                return OPERATOR_CANCELLED;
 
277
 
 
278
        /* clear all selection if not extending selection */
 
279
        extend= RNA_boolean_get(op->ptr, "extend");
 
280
        if (!extend)
 
281
                deselect_action_keys(&ac, 1, SELECT_SUBTRACT);
288
282
        
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");
294
288
                
295
289
        gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
296
290
        if (gesture_mode == GESTURE_MODAL_SELECT)
302
296
        if (RNA_boolean_get(op->ptr, "axis_range")) {
303
297
                /* mode depends on which axis of the range is larger to determine which axis to use 
304
298
                 *      - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
305
 
                 *      - the frame-range select option is favoured over the channel one (x over y), as frame-range one is often
 
299
                 *      - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
306
300
                 *        used for tweaking timing when "blocking", while channels is not that useful...
307
301
                 */
308
302
                if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin))
325
319
void ACTION_OT_select_border(wmOperatorType *ot)
326
320
{
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";
331
325
        
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;
336
331
        
337
 
        ot->poll= ED_operator_action_active;
 
332
        ot->poll = ED_operator_action_active;
338
333
        
339
334
        /* flags */
340
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
335
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
341
336
        
342
337
        /* rna */
343
 
        WM_operator_properties_gesture_border(ot, FALSE);
 
338
        WM_operator_properties_gesture_border(ot, TRUE);
344
339
        
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", "");
346
341
}
347
342
 
348
343
/* ******************** Column Select Operator **************************** */
365
360
/* ------------------- */ 
366
361
 
367
362
/* Selects all visible keyframes between the specified markers */
 
363
/* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c
 
364
 * should de-duplicate - campbell */
368
365
static void markers_selectkeys_between (bAnimContext *ac)
369
366
{
370
367
        ListBase anim_data = {NULL, NULL};
372
369
        int filter;
373
370
        
374
371
        KeyframeEditFunc ok_cb, select_cb;
375
 
        KeyframeEditData ked;
 
372
        KeyframeEditData ked= {{NULL}};
376
373
        float min, max;
377
374
        
378
375
        /* get extreme markers */
383
380
        /* get editing funcs + data */
384
381
        ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
385
382
        select_cb= ANIM_editkeyframes_select(SELECT_ADD);
386
 
        
387
 
        memset(&ked, 0, sizeof(KeyframeEditData));
 
383
 
388
384
        ked.f1= min; 
389
385
        ked.f2= max;
390
386
        
391
387
        /* filter data */
392
 
        filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 
388
        filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
393
389
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
394
390
        
395
391
        /* select keys in-between */
401
397
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
402
398
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
403
399
                }
 
400
                else if (ale->type == ANIMTYPE_GPLAYER) {
 
401
                        borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD);
 
402
                }
404
403
                else {
405
404
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
406
405
                }
421
420
        Scene *scene= ac->scene;
422
421
        CfraElem *ce;
423
422
        KeyframeEditFunc select_cb, ok_cb;
424
 
        KeyframeEditData ked;
 
423
        KeyframeEditData ked= {{NULL}};
425
424
        
426
 
        /* initialise keyframe editing data */
427
 
        memset(&ked, 0, sizeof(KeyframeEditData));
 
425
        /* initialize keyframe editing data */
428
426
        
429
427
        /* build list of columns */
430
428
        switch (mode) {
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);
435
433
                                
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);
438
436
                        }
439
437
                        else {
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);
442
440
                                
443
441
                                for (ale= anim_data.first; ale; ale= ale->next)
455
453
                        break;
456
454
                        
457
455
                case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
458
 
                        ED_markers_make_cfra_list(ac->markers, &ked.list, 1);
 
456
                        ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT);
459
457
                        break;
460
458
                        
461
459
                default: /* invalid option */
470
468
         * based on the keys found to be selected above
471
469
         */
472
470
        if (ac->datatype == ANIMCONT_GPENCIL)
473
 
                filter= (ANIMFILTER_VISIBLE);
 
471
                filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
474
472
        else
475
 
                filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
 
473
                filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
476
474
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
477
475
        
478
476
        for (ale= anim_data.first; ale; ale= ale->next) {
489
487
                                ked.f1= ce->cfra;
490
488
                        
491
489
                        /* select elements with frame number matching cfraelem */
492
 
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
493
 
                        
494
 
#if 0 // XXX reenable when Grease Pencil stuff is back
495
 
                        if (ale->type == ANIMTYPE_GPLAYER) {
496
 
                                bGPDlayer *gpl= (bGPDlayer *)ale->data;
497
 
                                bGPDframe *gpf;
498
 
                                
499
 
                                for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
500
 
                                        if (ecfra == gpf->framenum) 
501
 
                                                gpf->flag |= GP_FRAME_SELECT;
502
 
                                }
503
 
                        }
504
 
                        //else... 
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);
 
492
                        else
 
493
                                ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
506
494
                }
507
495
        }
508
496
        
539
527
void ACTION_OT_select_column (wmOperatorType *ot)
540
528
{
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)";
545
533
        
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;
549
537
        
550
538
        /* flags */
551
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
539
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
552
540
        
553
541
        /* props */
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", "");
555
543
}
556
544
 
557
545
/* ******************** Select Linked Operator *********************** */
558
546
 
559
 
static int actkeys_select_linked_exec (bContext *C, wmOperator *op)
 
547
static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op))
560
548
{
561
549
        bAnimContext ac;
562
550
        
572
560
                return OPERATOR_CANCELLED;
573
561
        
574
562
        /* loop through all of the keys and select additional keyframes based on these */
575
 
        filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 
563
        filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
576
564
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
577
565
        
578
566
        for (ale= anim_data.first; ale; ale= ale->next) {
598
586
{
599
587
        /* identifiers */
600
588
        ot->name = "Select Linked";
601
 
        ot->idname= "ACTION_OT_select_linked";
602
 
        ot->description = "Select keyframes occurring the same F-Curves as selected ones";
 
589
        ot->idname = "ACTION_OT_select_linked";
 
590
        ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
603
591
        
604
592
        /* api callbacks */
605
 
        ot->exec= actkeys_select_linked_exec;
606
 
        ot->poll= ED_operator_action_active;
 
593
        ot->exec = actkeys_select_linked_exec;
 
594
        ot->poll = ED_operator_action_active;
607
595
        
608
596
        /* flags */
609
 
        ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
 
597
        ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
610
598
}
611
599
 
612
600
/* ******************** Select More/Less Operators *********************** */
618
606
        bAnimListElem *ale;
619
607
        int filter;
620
608
        
621
 
        KeyframeEditData ked;
 
609
        KeyframeEditData ked= {{NULL}};
622
610
        KeyframeEditFunc build_cb;
623
611
        
624
612
        
625
613
        /* init selmap building data */
626
614
        build_cb= ANIM_editkeyframes_buildselmap(mode);
627
 
        memset(&ked, 0, sizeof(KeyframeEditData)); 
628
615
        
629
616
        /* loop through all of the keys and select additional keyframes based on these */
630
 
        filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 
617
        filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
631
618
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
632
619
        
633
620
        for (ale= anim_data.first; ale; ale= ale->next) {
655
642
 
656
643
/* ----------------- */
657
644
 
658
 
static int actkeys_select_more_exec (bContext *C, wmOperator *op)
 
645
static int actkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op))
659
646
{
660
647
        bAnimContext ac;
661
648
        
676
663
{
677
664
        /* identifiers */
678
665
        ot->name = "Select More";
679
 
        ot->idname= "ACTION_OT_select_more";
 
666
        ot->idname = "ACTION_OT_select_more";
680
667
        ot->description = "Select keyframes beside already selected ones";
681
668
        
682
669
        /* api callbacks */
683
 
        ot->exec= actkeys_select_more_exec;
684
 
        ot->poll= ED_operator_action_active;
 
670
        ot->exec = actkeys_select_more_exec;
 
671
        ot->poll = ED_operator_action_active;
685
672
        
686
673
        /* flags */
687
 
        ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
 
674
        ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
688
675
}
689
676
 
690
677
/* ----------------- */
691
678
 
692
 
static int actkeys_select_less_exec (bContext *C, wmOperator *op)
 
679
static int actkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op))
693
680
{
694
681
        bAnimContext ac;
695
682
        
710
697
{
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";
715
702
        
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;
719
706
        
720
707
        /* flags */
721
 
        ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
 
708
        ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
722
709
}
723
710
 
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
729
 
 *
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).
732
 
 */
 
711
/* ******************** Select Left/Right Operator ************************* */
 
712
/* Select keyframes left/right of the current frame indicator */
733
713
 
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}
741
720
};
742
721
 
743
 
/* sensitivity factor for frame-selections */
744
 
#define FRAME_CLICK_THRESH              0.1f
745
 
 
746
 
/* ------------------- */
747
 
 
748
 
/* option 1) select keyframe directly under mouse */
749
 
static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx)
750
 
{
751
 
        bDopeSheet *ads= (ac->datatype == ANIMCONT_DOPESHEET) ? ac->data : NULL;
752
 
        int ds_filter = ((ads) ? (ads->filterflag) : (0));
753
 
        
754
 
        KeyframeEditData ked;
755
 
        KeyframeEditFunc select_cb, ok_cb;
756
 
        
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)); 
761
 
        ked.f1= selx;
762
 
        
763
 
        /* select the nominated keyframe on the given frame */
764
 
        ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, ds_filter);
765
 
}
766
 
 
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
/* --------------------------------- */
 
723
 
 
724
static void actkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode)
769
725
{
770
726
        ListBase anim_data = {NULL, NULL};
771
727
        bAnimListElem *ale;
772
728
        int filter;
773
729
        
774
730
        KeyframeEditFunc ok_cb, select_cb;
775
 
        KeyframeEditData ked;
 
731
        KeyframeEditData ked= {{NULL}};
776
732
        Scene *scene= ac->scene;
777
733
        
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;
781
737
                
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
 
740
                 */
784
741
                deselect_action_keys(ac, 0, SELECT_SUBTRACT);
785
742
        }
786
743
        
788
745
        ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
789
746
        select_cb= ANIM_editkeyframes_select(select_mode);
790
747
        
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);
795
751
        } 
796
752
        else {
797
 
                ked.f1 = (float)(CFRA - FRAME_CLICK_THRESH);
 
753
                ked.f1 = (float)(CFRA - 0.1f);
798
754
                ked.f2 = MAXFRAMEF;
799
755
        }
800
756
        
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);
804
760
        else
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);
807
763
                
808
 
        /* select keys on the side where most data occurs */
 
764
        /* select keys */
809
765
        for (ale= anim_data.first; ale; ale= ale->next) {
810
766
                AnimData *adt= ANIM_nla_mapping_get(ac, ale);
811
767
                
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);
816
772
                }
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);
819
775
                else
820
776
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
821
777
        }
822
778
        
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;
826
782
                
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;
829
786
                        
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)) ) 
833
790
                                {
834
791
                                        marker->flag |= SELECT;
844
801
        BLI_freelistN(&anim_data);
845
802
}
846
803
 
 
804
/* ----------------- */
 
805
 
 
806
static int actkeys_select_leftright_exec (bContext *C, wmOperator *op)
 
807
{
 
808
        bAnimContext ac;
 
809
        short leftright = RNA_enum_get(op->ptr, "mode");
 
810
        short selectmode;
 
811
        
 
812
        /* get editor data */
 
813
        if (ANIM_animdata_get_context(C, &ac) == 0)
 
814
                return OPERATOR_CANCELLED;
 
815
        
 
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;
 
819
        else
 
820
                selectmode= SELECT_REPLACE;
 
821
                
 
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;
 
825
        
 
826
        /* do the selecting now */
 
827
        actkeys_select_leftright(&ac, leftright, selectmode);
 
828
        
 
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);
 
831
        
 
832
        return OPERATOR_FINISHED;
 
833
}
 
834
 
 
835
static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event)
 
836
{
 
837
        bAnimContext ac;
 
838
        short leftright = RNA_enum_get(op->ptr, "mode");
 
839
        
 
840
        /* get editor data */
 
841
        if (ANIM_animdata_get_context(C, &ac) == 0)
 
842
                return OPERATOR_CANCELLED;
 
843
                
 
844
        /* handle mode-based testing */
 
845
        if (leftright == ACTKEYS_LRSEL_TEST) {
 
846
                Scene *scene= ac.scene;
 
847
                ARegion *ar= ac.ar;
 
848
                View2D *v2d= &ar->v2d;
 
849
                float x;
 
850
 
 
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);
 
853
                if (x < CFRA)
 
854
                        RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
 
855
                else    
 
856
                        RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
 
857
        }
 
858
        
 
859
        /* perform selection */
 
860
        return actkeys_select_leftright_exec(C, op);
 
861
}
 
862
 
 
863
void ACTION_OT_select_leftright (wmOperatorType *ot)
 
864
{
 
865
        /* identifiers */
 
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";
 
869
        
 
870
        /* api callbacks  */
 
871
        ot->invoke = actkeys_select_leftright_invoke;
 
872
        ot->exec = actkeys_select_leftright_exec;
 
873
        ot->poll = ED_operator_action_active;
 
874
        
 
875
        /* flags */
 
876
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 
877
        
 
878
        /* id-props */
 
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", "");
 
881
}
 
882
 
 
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
 
888
 *
 
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).
 
891
 */
 
892
 
 
893
/* sensitivity factor for frame-selections */
 
894
#define FRAME_CLICK_THRESH              0.1f
 
895
 
 
896
/* ------------------- */
 
897
 
 
898
/* option 1) select keyframe directly under mouse */
 
899
static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx)
 
900
{
 
901
        KeyframeEditData ked= {{NULL}};
 
902
        KeyframeEditFunc select_cb, ok_cb;
 
903
        
 
904
        /* get functions for selecting keyframes */
 
905
        select_cb= ANIM_editkeyframes_select(select_mode);
 
906
        ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME);
 
907
        ked.f1= selx;
 
908
        
 
909
        /* select the nominated keyframe on the given frame */
 
910
        if (ale->type == ANIMTYPE_GPLAYER)
 
911
                select_gpencil_frame(ale->data, selx, select_mode);
 
912
        else
 
913
                ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL);
 
914
}
 
915
 
 
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) */
 
918
 
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)
849
921
{
852
924
        int filter;
853
925
        
854
926
        KeyframeEditFunc select_cb, ok_cb;
855
 
        KeyframeEditData ked;
856
 
        
857
 
        /* initialise keyframe editing data */
858
 
        memset(&ked, 0, sizeof(KeyframeEditData));
 
927
        KeyframeEditData ked= {{NULL}};
859
928
        
860
929
        /* set up BezTriple edit callbacks */
861
930
        select_cb= ANIM_editkeyframes_select(select_mode);
865
934
         * based on the keys found to be selected above
866
935
         */
867
936
        if (ac->datatype == ANIMCONT_GPENCIL)
868
 
                filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NODUPLIS);
 
937
                filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
869
938
        else
870
 
                filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 
939
                filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
871
940
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
872
941
        
873
942
        for (ale= anim_data.first; ale; ale= ale->next) {
880
949
                        ked.f1= selx;
881
950
                
882
951
                /* select elements with frame number matching cfra */
883
 
                ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
884
 
                        
885
 
#if 0 // XXX reenable when Grease Pencil stuff is back
886
 
                        if (ale->type == ANIMTYPE_GPLAYER) {
887
 
                                bGPDlayer *gpl= (bGPDlayer *)ale->data;
888
 
                                bGPDframe *gpf;
889
 
                                
890
 
                                for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
891
 
                                        if (ecfra == gpf->framenum) 
892
 
                                                gpf->flag |= GP_FRAME_SELECT;
893
 
                                }
894
 
                        }
895
 
                        //else... 
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);
 
954
                else 
 
955
                        ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
897
956
        }
898
957
        
899
958
        /* free elements */
903
962
 
904
963
/* ------------------- */
905
964
 
906
 
static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode, short column)
 
965
static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select_mode, short column)
907
966
{
908
967
        ListBase anim_data = {NULL, NULL};
909
968
        DLRBT_Tree anim_keys;
931
990
        UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &rectf.xmax, &rectf.ymax);
932
991
        
933
992
        /* filter data */
934
 
        filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
 
993
        filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
935
994
        ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
936
995
        
937
996
        /* try to get channel */
938
997
        ale= BLI_findlink(&anim_data, channel_index);
939
998
        if (ale == NULL) {
940
999
                /* channel not found */
941
 
                printf("Error: animation channel (index = %d) not found in mouse_action_keys() \n", channel_index);
 
1000
                printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n", channel_index);
942
1001
                BLI_freelistN(&anim_data);
943
1002
                return;
944
1003
        }
948
1007
                ActKeyColumn *ak, *akn=NULL;
949
1008
                
950
1009
                /* make list of keyframes */
951
 
                // TODO: it would be great if we didn't have to apply this to all the keyframes to do this...
952
1010
                BLI_dlrbTree_init(&anim_keys);
953
1011
                
954
1012
                if (ale->key_data) {
983
1041
                        /* dopesheet summary covers everything */
984
1042
                        summary_to_keylist(ac, &anim_keys, NULL);
985
1043
                }
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);
989
1048
                }
990
 
                else if (ale->type == ANIMTYPE_GPDATABLOCK) {
991
 
                        /* cleanup */
992
 
                        // FIXME:...
993
 
                        BLI_freelistN(&anim_data);
994
 
                        return;
995
 
                }
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);
999
1053
                }
1000
1054
                
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...
1008
1061
                                 */
1009
1062
                                selx= BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP);
1056
1109
                        }
1057
1110
                }
1058
1111
                else if (ac->datatype == ANIMCONT_GPENCIL) {
 
1112
                        /* deselect all other channels first */
1059
1113
                        ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
1060
1114
                        
1061
 
                        /* Highlight gpencil layer */
1062
 
                        //gpl->flag |= GP_LAYER_SELECT;
1063
 
                        //gpencil_layer_setactive(gpd, gpl);
 
1115
                        /* Highlight GPencil Layer */
 
1116
                        if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) {
 
1117
                                bGPDlayer *gpl = ale->data;
 
1118
                                
 
1119
                                gpl->flag |= GP_LAYER_SELECT;
 
1120
                                //gpencil_layer_setactive(gpd, gpl);
 
1121
                        }
1064
1122
                }
1065
1123
        }
1066
1124
        
1068
1126
        if (ale) {
1069
1127
                if (found) {
1070
1128
                        /* apply selection to keyframes */
1071
 
                        if (/*gpl*/0) {
1072
 
                                /* grease pencil */
1073
 
                                //select_gpencil_frame(gpl, (int)selx, selectmode);
1074
 
                        }
1075
 
                        else if (column) {
 
1129
                        if (column) {
1076
1130
                                /* select all keyframes in the same frame as the one we hit on the active channel */
1077
1131
                                actkeys_mselect_column(ac, select_mode, selx);
1078
1132
                        }
1091
1145
static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *event)
1092
1146
{
1093
1147
        bAnimContext ac;
1094
 
        Scene *scene;
1095
 
        ARegion *ar;
1096
 
        View2D *v2d;
 
1148
        /* ARegion *ar; */ /* UNUSED */
1097
1149
        short selectmode, column;
1098
 
        int mval[2];
1099
1150
        
1100
1151
        /* get editor data */
1101
1152
        if (ANIM_animdata_get_context(C, &ac) == 0)
1102
1153
                return OPERATOR_CANCELLED;
1103
1154
                
1104
1155
        /* get useful pointers from animation context data */
1105
 
        scene= ac.scene;
1106
 
        ar= ac.ar;
1107
 
        v2d= &ar->v2d;
1108
 
        
1109
 
        /* get mouse coordinates (in region coordinates) */
1110
 
        mval[0]= (event->x - ar->winrct.xmin);
1111
 
        mval[1]= (event->y - ar->winrct.ymin);
1112
 
        
 
1156
        /* ar= ac.ar; */ /* UNUSED */
 
1157
 
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");
1121
1166
        
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 */
1125
 
                float x;
1126
 
                
1127
 
                UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL);
1128
 
                if (x < CFRA)
1129
 
                        RNA_int_set(op->ptr, "left_right", ACTKEYS_LRSEL_LEFT);
1130
 
                else    
1131
 
                        RNA_int_set(op->ptr, "left_right", ACTKEYS_LRSEL_RIGHT);
1132
 
                
1133
 
                actkeys_mselect_leftright(&ac, RNA_enum_get(op->ptr, "left_right"), selectmode);
1134
 
        }
1135
 
        else {
1136
 
                /* select keyframe(s) based upon mouse position*/
1137
 
                mouse_action_keys(&ac, mval, selectmode, column);
1138
 
        }
 
1167
        /* select keyframe(s) based upon mouse position*/
 
1168
        mouse_action_keys(&ac, event->mval, selectmode, column);
1139
1169
        
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)
1148
1178
{
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";
1153
1183
        
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;
1157
1187
        
1158
1188
        /* flags */
1159
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
1189
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1160
1190
        
1161
1191
        /* id-props */
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
1166
1194
}