From 0578d3ef3e53faa447880bb939aa33272464cef1 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 9 May 2016 16:58:12 +1200 Subject: Graph Editor: Ctrl-Click keyframing now deselects all existing keyframes by default Now, when creating new keyframes in the graph editor by ctrl-clicking, only the newly created keyframes will be selected. This is a little workflow tweak to make it faster to work, as you no longer have to deselect all, and then re-select the newly added keys in order to manipulate them. The old behaviour (not modifying the selection status of the old keys) has been kept, but is now available via Shift-Ctrl-Click. Feature request from @Shhlife --- source/blender/editors/space_graph/graph_edit.c | 10 ++++++++++ source/blender/editors/space_graph/graph_intern.h | 2 ++ source/blender/editors/space_graph/graph_ops.c | 6 +++++- source/blender/editors/space_graph/graph_select.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index effcd80e1f0..f1063996ca3 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -693,6 +693,14 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) short mapping_flag = ANIM_get_normalization_flags(&ac); float scale, offset; + /* preserve selection? */ + if (RNA_boolean_get(op->ptr, "extend") == false) { + /* deselect all keyframes first, so that we can immediately start manipulating the newly added one(s) + * - only affect the keyframes themselves, as we don't want channels popping in and out... + */ + deselect_graph_keys(&ac, false, SELECT_SUBTRACT, false); + } + /* get frame and value from props */ frame = RNA_float_get(op->ptr, "frame"); val = RNA_float_get(op->ptr, "value"); @@ -782,6 +790,8 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) /* properties */ RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100); RNA_def_float(ot->srna, "value", 1.0f, -FLT_MAX, FLT_MAX, "Value", "Value for keyframe on", 0, 100); + + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); } /* ******************** Copy/Paste Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index b6b711e129f..534b712fd5e 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -56,6 +56,8 @@ void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, str /* ***************************************** */ /* graph_select.c */ +void deselect_graph_keys(struct bAnimContext *ac, bool test, short sel, bool do_channels); + void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot); void GRAPH_OT_select_border(struct wmOperatorType *ot); void GRAPH_OT_select_lasso(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 7ffa8250067..6b860990c10 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -610,7 +610,11 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* insertkey */ WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); + + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "extend", false); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", true); /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 67274100312..eb786d872ec 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -83,7 +83,7 @@ * 2 = invert * - do_channels: whether to affect selection status of channels */ -static void deselect_graph_keys(bAnimContext *ac, short test, short sel, short do_channels) +void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channels) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; -- cgit v1.2.3