From 67bf4755c16c956274c941c246719011e4726b1e Mon Sep 17 00:00:00 2001 From: Melissa Date: Sun, 19 Mar 2023 12:01:23 -0700 Subject: [PATCH 1/3] Fix #94080: clicking empty space in timeline creates undo step --- .../editors/space_action/action_select.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 0c416712a0e..a6a3e0145f7 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1716,7 +1716,7 @@ static int mouse_action_keys(bAnimContext *ac, if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; - + /* Rather than deselecting others, users may want to drag to box-select (drag from empty space) * or tweak-translate an already selected item. If these cases may apply, delay deselection. */ if (wait_to_deselect_others && (!found || is_selected)) { @@ -1725,14 +1725,19 @@ static int mouse_action_keys(bAnimContext *ac, else { /* deselect all keyframes */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); - + + /* If nothing selected, return OPERATOR_CANCELLED.*/ + if (!found && ale == NULL) { + ret_value = OPERATOR_CANCELLED; + } /* highlight channel clicked on */ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) { /* deselect all other channels first */ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight Action-Group or F-Curve? */ if (ale != NULL && ale->data) { + if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = ale->data; @@ -1756,7 +1761,6 @@ static int mouse_action_keys(bAnimContext *ac, else if (ac->datatype == ANIMCONT_GPENCIL) { /* deselect all other channels first */ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); - /* Highlight GPencil Layer */ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) { bGPdata *gpd = (bGPdata *)ale->id; @@ -1807,8 +1811,7 @@ static int mouse_action_keys(bAnimContext *ac, /* free this channel */ MEM_freeN(ale); - } - + } return ret_value; } @@ -1838,11 +1841,11 @@ static int actkeys_clickselect_exec(bContext *C, wmOperator *op) mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); - + /* Select keyframe(s) based upon mouse position. */ ret_value = mouse_action_keys( &ac, mval, selectmode, deselect_all, column, channel, wait_to_deselect_others); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); -- 2.30.2 From 243de047d072bc9c10205c59a78496bea6d44f6b Mon Sep 17 00:00:00 2001 From: Melissa Date: Fri, 24 Mar 2023 12:42:19 -0700 Subject: [PATCH 2/3] Refactor: Moved check for no selection out of loop. --- .../editors/space_action/action_select.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index a6a3e0145f7..6ee83d0cb67 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1706,6 +1706,11 @@ static int mouse_action_keys(bAnimContext *ac, actkeys_find_key_at_position( ac, filter, mval[0], mval[1], &ale, &selx, &frame, &found, &is_selected); + /* If nothing selected, return #OPERATOR_CANCELLED.*/ + if (!found && ale == NULL) { + ret_value = OPERATOR_CANCELLED; + } + if (select_mode != SELECT_REPLACE) { wait_to_deselect_others = false; } @@ -1716,7 +1721,7 @@ static int mouse_action_keys(bAnimContext *ac, if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; - + /* Rather than deselecting others, users may want to drag to box-select (drag from empty space) * or tweak-translate an already selected item. If these cases may apply, delay deselection. */ if (wait_to_deselect_others && (!found || is_selected)) { @@ -1725,19 +1730,14 @@ static int mouse_action_keys(bAnimContext *ac, else { /* deselect all keyframes */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); - - /* If nothing selected, return OPERATOR_CANCELLED.*/ - if (!found && ale == NULL) { - ret_value = OPERATOR_CANCELLED; - } + /* highlight channel clicked on */ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) { /* deselect all other channels first */ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight Action-Group or F-Curve? */ if (ale != NULL && ale->data) { - if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = ale->data; @@ -1761,6 +1761,7 @@ static int mouse_action_keys(bAnimContext *ac, else if (ac->datatype == ANIMCONT_GPENCIL) { /* deselect all other channels first */ ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); + /* Highlight GPencil Layer */ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) { bGPdata *gpd = (bGPdata *)ale->id; @@ -1811,7 +1812,7 @@ static int mouse_action_keys(bAnimContext *ac, /* free this channel */ MEM_freeN(ale); - } + } return ret_value; } @@ -1841,11 +1842,11 @@ static int actkeys_clickselect_exec(bContext *C, wmOperator *op) mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); - + /* Select keyframe(s) based upon mouse position. */ ret_value = mouse_action_keys( &ac, mval, selectmode, deselect_all, column, channel, wait_to_deselect_others); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); -- 2.30.2 From 6b22a61d221a8a9d199d637ab1eff22ec5956306 Mon Sep 17 00:00:00 2001 From: Melissa Date: Fri, 24 Mar 2023 13:42:36 -0700 Subject: [PATCH 3/3] Cleanup: Whitespace removed. --- source/blender/editors/space_action/action_select.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 1848d9b37ab..c7ac5b596fa 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1844,6 +1844,7 @@ static int mouse_action_keys(bAnimContext *ac, /* free this channel */ MEM_freeN(ale); } + return ret_value; } -- 2.30.2