diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_select.c | 48 |
2 files changed, 20 insertions, 30 deletions
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 6082e942842..192134949d5 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1558,7 +1558,7 @@ static void mouse_action_keys(bAnimContext *ac, /* free list of channels, since it's not used anymore */ ANIM_animdata_freelist(&anim_data); - /* For replacing selection, if we have somthing to select, we have to clear existing selection. + /* For replacing selection, if we have something to select, we have to clear existing selection. * The same goes if we found nothing to select, and deselect_all is true * (deselect on nothing behavior). */ if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) { diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 1062a86f590..5c9e48f3d5d 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -523,7 +523,8 @@ void NLA_OT_select_leftright(wmOperatorType *ot) /* ******************** Mouse-Click Select Operator *********************** */ /* select strip directly under mouse */ -static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode) +static void mouse_nla_strips( + bContext *C, bAnimContext *ac, const int mval[2], short select_mode, const bool deselect_all) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale = NULL; @@ -562,14 +563,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { - /* channel not found */ - printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n", - channel_index); - ANIM_animdata_freelist(&anim_data); - return; - } - else { + if (ale != NULL) { /* found some channel - we only really should do something when its an Nla-Track */ if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; @@ -598,8 +592,10 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); } - /* for replacing selection, firstly need to clear existing selection */ - if (select_mode == SELECT_REPLACE) { + /* For replacing selection, if we have something to select, we have to clear existing selection. + * The same goes if we found nothing to select, and deselect_all is true + * (deselect on nothing behavior). */ + if ((strip != NULL && select_mode == SELECT_REPLACE) || (strip == NULL && deselect_all)) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; @@ -611,9 +607,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s } /* only select strip if we clicked on a valid channel and hit something */ - if (ale) { + if (ale != NULL) { /* select the strip accordingly (if a matching one was found) */ - if (strip) { + if (strip != NULL) { select_mode = selmodes_to_flagmodes(select_mode); ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); @@ -647,31 +643,18 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; - /* Scene *scene; */ /* UNUSED */ - /* ARegion *ar; */ /* UNUSED */ - // View2D *v2d; /*UNUSED*/ - short selectmode; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) { return OPERATOR_CANCELLED; } - /* get useful pointers from animation context data */ - /* scene= ac.scene; */ /* UNUSED */ - /* ar= ac.ar; */ /* UNUSED */ - // v2d= &ar->v2d; - /* select mode is either replace (deselect all, then add) or add/extend */ - if (RNA_boolean_get(op->ptr, "extend")) { - selectmode = SELECT_INVERT; - } - else { - selectmode = SELECT_REPLACE; - } + const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE; + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); /* select strips based upon mouse position */ - mouse_nla_strips(C, &ac, event->mval, selectmode); + mouse_nla_strips(C, &ac, event->mval, selectmode, deselect_all); /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); @@ -699,6 +682,13 @@ void NLA_OT_click_select(wmOperatorType *ot) /* properties */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* *********************************************** */ |