Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_action/action_select.c
| Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_gpencil.h" | |||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_mask.h" | #include "ED_mask.h" | ||||
| #include "ED_keyframes_draw.h" | #include "ED_keyframes_draw.h" | ||||
| #include "ED_keyframes_edit.h" | #include "ED_keyframes_edit.h" | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static void deselect_action_keys(bAnimContext *ac, short test, short sel) | ||||
| } | } | ||||
| /* Cleanup */ | /* Cleanup */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| } | } | ||||
| /* ------------------- */ | /* ------------------- */ | ||||
| /* helper to update grease pencil related data */ | |||||
| static void gpencil_action_redraw(bContext *C, bAnimContext *ac) | |||||
| { | |||||
| if ((ac) && (ac->datatype == ANIMCONT_GPENCIL)) { | |||||
| BKE_gpencil_batch_cache_alldirty(); | |||||
| WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); | |||||
| } | |||||
| } | |||||
| static int actkeys_deselectall_exec(bContext *C, wmOperator *op) | static int actkeys_deselectall_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) | if (ANIM_animdata_get_context(C, &ac) == 0) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* 'standard' behavior - check if selected, then apply relevant selection */ | /* 'standard' behavior - check if selected, then apply relevant selection */ | ||||
| if (RNA_boolean_get(op->ptr, "invert")) | if (RNA_boolean_get(op->ptr, "invert")) | ||||
| deselect_action_keys(&ac, 0, SELECT_INVERT); | deselect_action_keys(&ac, 0, SELECT_INVERT); | ||||
| else | else | ||||
| deselect_action_keys(&ac, 1, SELECT_ADD); | deselect_action_keys(&ac, 1, SELECT_ADD); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection have changed */ | /* set notifier that keyframe selection have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_all_toggle(wmOperatorType *ot) | void ACTION_OT_select_all_toggle(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | else | ||||
| mode = ACTKEYS_BORDERSEL_CHANNELS; | mode = ACTKEYS_BORDERSEL_CHANNELS; | ||||
| } | } | ||||
| else | else | ||||
| mode = ACTKEYS_BORDERSEL_ALLKEYS; | mode = ACTKEYS_BORDERSEL_ALLKEYS; | ||||
| /* apply borderselect action */ | /* apply borderselect action */ | ||||
| borderselect_action(&ac, rect, mode, selectmode); | borderselect_action(&ac, rect, mode, selectmode); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection have changed */ | /* set notifier that keyframe selection have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_border(wmOperatorType *ot) | void ACTION_OT_select_border(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | static int actkeys_lassoselect_exec(bContext *C, wmOperator *op) | ||||
| BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); | BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); | ||||
| BLI_rctf_rcti_copy(&rect_fl, &rect); | BLI_rctf_rcti_copy(&rect_fl, &rect); | ||||
| /* apply borderselect action */ | /* apply borderselect action */ | ||||
| region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso); | region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso); | ||||
| MEM_freeN((void *)data_lasso.mcords); | MEM_freeN((void *)data_lasso.mcords); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* send notifier that keyframe selection has changed */ | /* send notifier that keyframe selection has changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_lasso(wmOperatorType *ot) | void ACTION_OT_select_lasso(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static int action_circle_select_exec(bContext *C, wmOperator *op) | ||||
| rect_fl.xmin = x - radius; | rect_fl.xmin = x - radius; | ||||
| rect_fl.xmax = x + radius; | rect_fl.xmax = x + radius; | ||||
| rect_fl.ymin = y - radius; | rect_fl.ymin = y - radius; | ||||
| rect_fl.ymax = y + radius; | rect_fl.ymax = y + radius; | ||||
| /* apply region select action */ | /* apply region select action */ | ||||
| region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data); | region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* send notifier that keyframe selection has changed */ | /* send notifier that keyframe selection has changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_circle(wmOperatorType *ot) | void ACTION_OT_select_circle(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | static int actkeys_columnselect_exec(bContext *C, wmOperator *op) | ||||
| /* action to take depends on the mode */ | /* action to take depends on the mode */ | ||||
| mode = RNA_enum_get(op->ptr, "mode"); | mode = RNA_enum_get(op->ptr, "mode"); | ||||
| if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) | if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) | ||||
| markers_selectkeys_between(&ac); | markers_selectkeys_between(&ac); | ||||
| else | else | ||||
| columnselect_action_keys(&ac, mode); | columnselect_action_keys(&ac, mode); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection have changed */ | /* set notifier that keyframe selection have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_column(wmOperatorType *ot) | void ACTION_OT_select_column(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { | ||||
| /* select every keyframe in this curve then */ | /* select every keyframe in this curve then */ | ||||
| ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); | ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* Cleanup */ | /* Cleanup */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection has changed */ | /* set notifier that keyframe selection has changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_linked(wmOperatorType *ot) | void ACTION_OT_select_linked(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) | if (ANIM_animdata_get_context(C, &ac) == 0) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* perform select changes */ | /* perform select changes */ | ||||
| select_moreless_action_keys(&ac, SELMAP_MORE); | select_moreless_action_keys(&ac, SELMAP_MORE); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection has changed */ | /* set notifier that keyframe selection has changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_more(wmOperatorType *ot) | void ACTION_OT_select_more(wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 18 Lines | static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) | if (ANIM_animdata_get_context(C, &ac) == 0) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* perform select changes */ | /* perform select changes */ | ||||
| select_moreless_action_keys(&ac, SELMAP_LESS); | select_moreless_action_keys(&ac, SELMAP_LESS); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection has changed */ | /* set notifier that keyframe selection has changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ACTION_OT_select_less(wmOperatorType *ot) | void ACTION_OT_select_less(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | static int actkeys_select_leftright_exec(bContext *C, wmOperator *op) | ||||
| /* if "test" mode is set, we don't have any info to set this with */ | /* if "test" mode is set, we don't have any info to set this with */ | ||||
| if (leftright == ACTKEYS_LRSEL_TEST) | if (leftright == ACTKEYS_LRSEL_TEST) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| /* do the selecting now */ | /* do the selecting now */ | ||||
| actkeys_select_leftright(&ac, leftright, selectmode); | actkeys_select_leftright(&ac, leftright, selectmode); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection (and channels too) have changed */ | /* set notifier that keyframe selection (and channels too) have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| /* column selection */ | /* column selection */ | ||||
| column = RNA_boolean_get(op->ptr, "column"); | column = RNA_boolean_get(op->ptr, "column"); | ||||
| channel = RNA_boolean_get(op->ptr, "channel"); | channel = RNA_boolean_get(op->ptr, "channel"); | ||||
| /* select keyframe(s) based upon mouse position*/ | /* select keyframe(s) based upon mouse position*/ | ||||
| mouse_action_keys(&ac, event->mval, selectmode, column, channel); | mouse_action_keys(&ac, event->mval, selectmode, column, channel); | ||||
| /* if grease pencil, redraw first */ | |||||
| gpencil_action_redraw(C, &ac); | |||||
| /* set notifier that keyframe selection (and channels too) have changed */ | /* set notifier that keyframe selection (and channels too) have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); | WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); | ||||
| /* for tweak grab to work */ | /* for tweak grab to work */ | ||||
| return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; | return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| void ACTION_OT_clickselect(wmOperatorType *ot) | void ACTION_OT_clickselect(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 27 Lines | |||||