2.5 merged 20773:21020
[blender.git] / source / blender / editors / space_graph / graph_select.c
index 4b6e55d2a03c77fe95198c05e3698f962b51b50c..a222109b0fe8a2d1e3dbeef33a63dd616e8d2f41 100644 (file)
@@ -73,6 +73,7 @@
 #include "ED_keyframing.h"
 #include "ED_keyframes_draw.h"
 #include "ED_keyframes_edit.h"
+#include "ED_markers.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
 
@@ -140,7 +141,9 @@ static void deselect_graph_keys (bAnimContext *ac, short test, short sel)
                /* Keyframes First */
                ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, sel_cb, NULL);
                
-               /* deactivate the F-Curve */
+               /* deactivate the F-Curve, and deselect if deselecting keyframes */
+               if (sel == SELECT_SUBTRACT) 
+                       fcu->flag &= ~FCURVE_SELECTED;
                fcu->flag &= ~FCURVE_ACTIVE;
        }
        
@@ -337,11 +340,11 @@ void GRAPHEDIT_OT_keyframes_select_border(wmOperatorType *ot)
 
 /* defines for column-select mode */
 static EnumPropertyItem prop_column_select_types[] = {
-       {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", "On Selected Keyframes", ""},
-       {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", "On Current Frame", ""},
-       {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", "On Selected Markers", ""},
-       {GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", "Between Min/Max Selected Markers", ""},
-       {0, NULL, NULL, NULL}
+       {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""},
+       {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""},
+       {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""},
+       {GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", 0, "Between Min/Max Selected Markers", ""},
+       {0, NULL, 0, NULL, NULL}
 };
 
 /* ------------------- */ 
@@ -353,21 +356,19 @@ static void markers_selectkeys_between (bAnimContext *ac)
        bAnimListElem *ale;
        int filter;
        
-       BeztEditFunc select_cb;
+       BeztEditFunc ok_cb, select_cb;
        BeztEditData bed;
        float min, max;
        
        /* get extreme markers */
-       //get_minmax_markers(1, &min, &max); // FIXME... add back markers api!
-       min= (float)ac->scene->r.sfra; // xxx temp code
-       max= (float)ac->scene->r.efra; // xxx temp code
-       
-       if (min==max) return;
+       ED_markers_get_minmax(ac->markers, 1, &min, &max);
        min -= 0.5f;
        max += 0.5f;
        
        /* get editing funcs + data */
+       ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
        select_cb= ANIM_editkeyframes_select(SELECT_ADD);
+       
        memset(&bed, 0, sizeof(BeztEditData));
        bed.f1= min; 
        bed.f2= max;
@@ -382,11 +383,11 @@ static void markers_selectkeys_between (bAnimContext *ac)
                
                if (nob) {      
                        ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
-                       ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, select_cb, NULL);
+                       ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
                        ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
                }
                else {
-                       ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, select_cb, NULL);
+                       ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
                }
        }
        
@@ -395,21 +396,6 @@ static void markers_selectkeys_between (bAnimContext *ac)
 }
 
 
-/* helper callback for columnselect_graph_keys() -> populate list CfraElems with frame numbers from selected beztriples */
-// TODO: if some other code somewhere needs this, it'll be time to port this over to keyframes_edit.c!!!
-static short bezt_to_cfraelem(BeztEditData *bed, BezTriple *bezt)
-{
-       /* only if selected */
-       if (bezt->f2 & SELECT) {
-               CfraElem *ce= MEM_callocN(sizeof(CfraElem), "cfraElem");
-               BLI_addtail(&bed->list, ce);
-               
-               ce->cfra= bezt->vec[1][0];
-       }
-       
-       return 0;
-}
-
 /* Selects all visible keyframes in the same frames as the specified elements */
 static void columnselect_graph_keys (bAnimContext *ac, short mode)
 {
@@ -446,9 +432,7 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode)
                        break;
                        
                case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
-                       // FIXME: markers api needs to be improved for this first!
-                       //make_marker_cfra_list(&elems, 1);
-                       return; // XXX currently, this does nothing!
+                       ED_markers_make_cfra_list(ac->markers, &bed.list, 1);
                        break;
                        
                default: /* invalid option */
@@ -542,11 +526,11 @@ void GRAPHEDIT_OT_keyframes_columnselect (wmOperatorType *ot)
 
 /* defines for left-right select tool */
 static EnumPropertyItem prop_graphkeys_leftright_select_types[] = {
-       {GRAPHKEYS_LRSEL_TEST, "CHECK", "Check if Select Left or Right", ""},
-       {GRAPHKEYS_LRSEL_NONE, "OFF", "Don't select", ""},
-       {GRAPHKEYS_LRSEL_LEFT, "LEFT", "Before current frame", ""},
-       {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", "After current frame", ""},
-       {0, NULL, NULL, NULL}
+       {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
+       {GRAPHKEYS_LRSEL_NONE, "OFF", 0, "Don't select", ""},
+       {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""},
+       {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""},
+       {0, NULL, 0, NULL, NULL}
 };
 
 /* ------------------- */
@@ -738,7 +722,7 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, s
        /* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */
        if (fcu->flag & FCURVE_SELECTED) {
                filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
-               ANIM_set_active_channel(ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
+               ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
        }
 }