Graph Editor: Ctrl-Click keyframing now deselects all existing keyframes by default
authorJoshua Leung <aligorith@gmail.com>
Mon, 9 May 2016 04:58:12 +0000 (16:58 +1200)
committerJoshua Leung <aligorith@gmail.com>
Mon, 9 May 2016 05:23:35 +0000 (17:23 +1200)
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
source/blender/editors/space_graph/graph_intern.h
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_graph/graph_select.c

index effcd80e1f057202613d1858b89d4899fc679e35..f1063996ca3dc8f4ddba91b5d4c85a1359165b79 100644 (file)
@@ -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 ************************* */
index b6b711e129f1213e913cf0ae2340218ebbb6e0c9..534b712fd5e6c9cd7b0c9cc693b48b781b0380ef 100644 (file)
@@ -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);
index 7ffa82500676e89303d99c0a3d62d00c72aef5e3..6b860990c1085d5896e5744b6dc286c8d7b4197c 100644 (file)
@@ -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);
index 6727410031295363096dcd248c0e9a36d1555904..eb786d872ec09185eb8c707e014b6f3616a80206 100644 (file)
@@ -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;