Fix #94080: clicking empty space in timeline creates undo step #105913

Open
Melissa-Goon wants to merge 7 commits from Melissa-Goon/blender:my-feature into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 11 additions and 8 deletions
Showing only changes of commit 67bf4755c1 - Show all commits

View File

@ -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) {
Melissa-Goon marked this conversation as resolved Outdated

This condition doesn't depend on anything inside this else clause, so it can be moved outside of it. I think that's also better, because after deselect_action_keys() has called something may have changed, and having that undo step is important.

found and ale do not change after the call to actkeys_find_key_at_position(), so this code can be moved directly after that.

This condition doesn't depend on anything inside this `else` clause, so it can be moved outside of it. I think that's also better, because after `deselect_action_keys()` has called something may have changed, and having that undo step is important. `found` and `ale` do not change after the call to `actkeys_find_key_at_position()`, so this code can be moved directly after that.
/* 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);