Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-04-30 18:20:21 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-04-30 18:20:21 +0300
commitd48a2f4a37b85c33917acd8dd514b69f017aac7f (patch)
tree56244a018f78a610efb278e7eccaad8b3cc19f72 /source/blender/editors/space_nla
parent26bc7414f7a4c3eb7afff8c56eec034146e72e37 (diff)
Select: Add 'deselect on nothing' to NLA editor.
Should be last part of T63995.
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r--source/blender/editors/space_nla/nla_select.c48
1 files changed, 19 insertions, 29 deletions
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);
}
/* *********************************************** */