Animation Editors: Select Linked Operator
authorJoshua Leung <aligorith@gmail.com>
Mon, 5 Apr 2010 11:47:55 +0000 (11:47 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 5 Apr 2010 11:47:55 +0000 (11:47 +0000)
This operator selects all the keyframes in the same F-Curve as a selected keyframe.

release/scripts/ui/space_dopesheet.py
release/scripts/ui/space_graph.py
source/blender/editors/space_action/action_intern.h
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_action/action_select.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 e8e2466f049d1b760f58c722913ed79672aa3573..41917acd997f60c33b85df27d1dfb3f1c010b8aa 100644 (file)
@@ -124,6 +124,9 @@ class DOPESHEET_MT_select(bpy.types.Menu):
         layout.operator("action.select_more")
         layout.operator("action.select_less")
 
+        layout.separator()
+        layout.operator("action.select_linked")
+
 
 class DOPESHEET_MT_channel(bpy.types.Menu):
     bl_label = "Channel"
index 0106833ce0d028bb9ece4d07bec6684660a528e0..b2a430eb7cd134b32cca27d3b85bfef305f0cb74 100644 (file)
@@ -126,6 +126,9 @@ class GRAPH_MT_select(bpy.types.Menu):
         layout.separator()
         layout.operator("graph.select_more")
         layout.operator("graph.select_less")
+               
+        layout.separator()
+        layout.operator("graph.select_linked")
 
 
 class GRAPH_MT_channel(bpy.types.Menu):
index ecbde7f4a21d5dc1b86a61ae741183cf57ae2776..b02e95ac1382830128270a1b87e964459febd01c 100644 (file)
@@ -56,6 +56,7 @@ void action_header_buttons(const struct bContext *C, struct ARegion *ar);
 void ACTION_OT_select_all_toggle(struct wmOperatorType *ot);
 void ACTION_OT_select_border(struct wmOperatorType *ot);
 void ACTION_OT_select_column(struct wmOperatorType *ot);
+void ACTION_OT_select_linked(struct wmOperatorType *ot);
 void ACTION_OT_select_more(struct wmOperatorType *ot);
 void ACTION_OT_select_less(struct wmOperatorType *ot);
 void ACTION_OT_clickselect(struct wmOperatorType *ot);
index f65bd67dcf8748ec5478cb48a606396f90adb5c8..8500087c00db24029eec598eebd815d0e59153ac 100644 (file)
@@ -119,6 +119,9 @@ static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
        WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
        
+               /* select linekd */
+       WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0);
+       
        
        /* action_edit.c */
                /* snap - current frame to selected keys */
index 877b40c5cb18e59aa472f9380a3b283f777672f5..8f1d2d4be0e63e158371204eb1f8e83d54e110c9 100644 (file)
@@ -558,6 +558,61 @@ void ACTION_OT_select_column (wmOperatorType *ot)
        ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
 }
 
+/* ******************** Select Linked Operator *********************** */
+
+static int actkeys_select_linked_exec (bContext *C, wmOperator *op)
+{
+       bAnimContext ac;
+       
+       ListBase anim_data= {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       
+       KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
+       KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
+       
+       /* get editor data */
+       if (ANIM_animdata_get_context(C, &ac) == 0)
+               return OPERATOR_CANCELLED;
+       
+       /* loop through all of the keys and select additional keyframes based on these */
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
+       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+       
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               FCurve *fcu= (FCurve *)ale->key_data;
+               
+               /* check if anything selected? */
+               if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
+                       /* select every keyframe in this curve then */
+                       ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
+               }
+       }
+       
+       /* Cleanup */
+       BLI_freelistN(&anim_data);
+       
+       /* set notifier that keyframe selection has changed */
+       WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void ACTION_OT_select_linked (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select Linked";
+       ot->idname= "ACTION_OT_select_linked";
+       ot->description = "Select keyframes occurring the same F-Curves as selected ones";
+       
+       /* api callbacks */
+       ot->exec= actkeys_select_linked_exec;
+       ot->poll= ED_operator_action_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+}
+
 /* ******************** Select More/Less Operators *********************** */
 
 /* Common code to perform selection */
index a875558d6ef5e2ad4d2034f137ce5c56949dd9ab..a637ed15fcda169a1e46af8f0310cee20a68a545 100644 (file)
@@ -63,6 +63,7 @@ void graph_header_buttons(const bContext *C, struct ARegion *ar);
 void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot);
 void GRAPH_OT_select_border(struct wmOperatorType *ot);
 void GRAPH_OT_select_column(struct wmOperatorType *ot);
+void GRAPH_OT_select_linked(struct wmOperatorType *ot);
 void GRAPH_OT_select_more(struct wmOperatorType *ot);
 void GRAPH_OT_select_less(struct wmOperatorType *ot);
 void GRAPH_OT_clickselect(struct wmOperatorType *ot);
@@ -149,6 +150,7 @@ void GRAPH_OT_ghost_curves_clear(struct wmOperatorType *ot);
 
 /* ***************************************** */
 /* graph_buttons.c */
+
 void GRAPH_OT_properties(struct wmOperatorType *ot);
 void graph_buttons_register(struct ARegionType *art);
 
index 07a9034e526f370dd3be224022b7dd42741d7fb0..d3d2743200b80708e51575dbf1a46d45bf3d3878 100644 (file)
@@ -231,6 +231,7 @@ void graphedit_operatortypes(void)
        WM_operatortype_append(GRAPH_OT_select_all_toggle);
        WM_operatortype_append(GRAPH_OT_select_border);
        WM_operatortype_append(GRAPH_OT_select_column);
+       WM_operatortype_append(GRAPH_OT_select_linked);
        WM_operatortype_append(GRAPH_OT_select_more);
        WM_operatortype_append(GRAPH_OT_select_less);
        
@@ -318,6 +319,9 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
        WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
        
+               /* select linked */
+       WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0);
+       
        
        /* graph_edit.c */
                /* snap - current frame to selected keys */
index c8b31f38f59863976ff632d0ddccfe6742c9f3f1..a81de25f265d8a4e6333f16b6ef859bdd592b733 100644 (file)
@@ -547,6 +547,61 @@ void GRAPH_OT_select_column (wmOperatorType *ot)
        ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
 }
 
+/* ******************** Select Linked Operator *********************** */
+
+static int graphkeys_select_linked_exec (bContext *C, wmOperator *op)
+{
+       bAnimContext ac;
+       
+       ListBase anim_data= {NULL, NULL};
+       bAnimListElem *ale;
+       int filter;
+       
+       KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
+       KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
+       
+       /* get editor data */
+       if (ANIM_animdata_get_context(C, &ac) == 0)
+               return OPERATOR_CANCELLED;
+       
+       /* loop through all of the keys and select additional keyframes based on these */
+       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
+       ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+       
+       for (ale= anim_data.first; ale; ale= ale->next) {
+               FCurve *fcu= (FCurve *)ale->key_data;
+               
+               /* check if anything selected? */
+               if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
+                       /* select every keyframe in this curve then */
+                       ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL);
+               }
+       }
+       
+       /* Cleanup */
+       BLI_freelistN(&anim_data);
+       
+       /* set notifier that keyframe selection has changed */
+       WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_select_linked (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select Linked";
+       ot->idname= "GRAPH_OT_select_linked";
+       ot->description = "Select keyframes occurring the same F-Curves as selected ones";
+       
+       /* api callbacks */
+       ot->exec= graphkeys_select_linked_exec;
+       ot->poll= graphop_visible_keyframes_poll;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+}
+
 /* ******************** Select More/Less Operators *********************** */
 
 /* Common code to perform selection */