soc-2008-mxcurioni: merged changes to revision 23516
[blender.git] / source / blender / editors / space_graph / graph_ops.c
index 2b35b639a4795718205dbe497112ad2289ef285d..b82055064f8b5a59e8c5e604fa21f888377a1b9b 100644 (file)
@@ -47,8 +47,7 @@
 #include "UI_view2d.h"
 
 #include "ED_screen.h"
-
-#include "BIF_transform.h"
+#include "ED_transform.h"
 
 #include "graph_intern.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
+/* ************************** poll callbacks **********************************/
+
+
+
 /* ************************** view-based operators **********************************/
 // XXX this probably shouldn't be here..
 
@@ -65,7 +68,7 @@
 
 static int view_toggle_handles_exec (bContext *C, wmOperator *op)
 {
-       SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
+       SpaceIpo *sipo= CTX_wm_space_graph(C);
        ARegion *ar= CTX_wm_region(C);
        
        if (sipo == NULL)
@@ -80,15 +83,15 @@ static int view_toggle_handles_exec (bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-void GRAPHEDIT_OT_view_togglehandles (wmOperatorType *ot)
+void GRAPH_OT_view_togglehandles (wmOperatorType *ot)
 {
        /* identification */
        ot->name= "Show/Hide All Handles";
-       ot->idname= "GRAPHEDIT_OT_handles_view_toggle";
+       ot->idname= "GRAPH_OT_handles_view_toggle";
        
        /* callbacks */
        ot->exec= view_toggle_handles_exec;
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_ipo_active;
 }
 
 /* ************************** registration - operator types **********************************/
@@ -96,116 +99,129 @@ void GRAPHEDIT_OT_view_togglehandles (wmOperatorType *ot)
 void graphedit_operatortypes(void)
 {
        /* view */
-       WM_operatortype_append(GRAPHEDIT_OT_view_togglehandles);
-       WM_operatortype_append(GRAPHEDIT_OT_previewrange_set);
-       WM_operatortype_append(GRAPHEDIT_OT_view_all);
-       WM_operatortype_append(GRAPHEDIT_OT_properties);
+       WM_operatortype_append(GRAPH_OT_view_togglehandles);
+       WM_operatortype_append(GRAPH_OT_previewrange_set);
+       WM_operatortype_append(GRAPH_OT_view_all);
+       WM_operatortype_append(GRAPH_OT_properties);
        
-       WM_operatortype_append(GRAPHEDIT_OT_ghost_curves_create);
-       WM_operatortype_append(GRAPHEDIT_OT_ghost_curves_clear);
+       WM_operatortype_append(GRAPH_OT_ghost_curves_create);
+       WM_operatortype_append(GRAPH_OT_ghost_curves_clear);
        
        /* keyframes */
                /* selection */
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_clickselect);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_select_all_toggle);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_select_border);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_columnselect);
+       WM_operatortype_append(GRAPH_OT_clickselect);
+       WM_operatortype_append(GRAPH_OT_select_all_toggle);
+       WM_operatortype_append(GRAPH_OT_select_border);
+       WM_operatortype_append(GRAPH_OT_select_column);
        
                /* editing */
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_snap);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_mirror);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_cfrasnap);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_handletype);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_interpolation_type);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_extrapolation_type);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_sample);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_bake);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_smooth);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_clean);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_delete);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_duplicate);
-       
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_copy);
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_paste);
-       
-       WM_operatortype_append(GRAPHEDIT_OT_keyframes_click_insert);
-       
-       //TODO: insertkey...
+       WM_operatortype_append(GRAPH_OT_snap);
+       WM_operatortype_append(GRAPH_OT_mirror);
+       WM_operatortype_append(GRAPH_OT_frame_jump);
+       WM_operatortype_append(GRAPH_OT_handle_type);
+       WM_operatortype_append(GRAPH_OT_interpolation_type);
+       WM_operatortype_append(GRAPH_OT_extrapolation_type);
+       WM_operatortype_append(GRAPH_OT_sample);
+       WM_operatortype_append(GRAPH_OT_bake);
+       WM_operatortype_append(GRAPH_OT_smooth);
+       WM_operatortype_append(GRAPH_OT_clean);
+       WM_operatortype_append(GRAPH_OT_delete);
+       WM_operatortype_append(GRAPH_OT_duplicate);
+       
+       WM_operatortype_append(GRAPH_OT_copy);
+       WM_operatortype_append(GRAPH_OT_paste);
+       
+       WM_operatortype_append(GRAPH_OT_insert_keyframe);
+       WM_operatortype_append(GRAPH_OT_click_insert);
        
        /* F-Curve Modifiers */
        // XXX temporary?
-       WM_operatortype_append(GRAPHEDIT_OT_fmodifier_add);
+       WM_operatortype_append(GRAPH_OT_fmodifier_add);
 }
 
 /* ************************** registration - keymaps **********************************/
 
-static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
+static void graphedit_keymap_keyframes (wmWindowManager *wm, wmKeyMap *keymap)
 {
+       wmKeymapItem *kmi;
+       
        /* view */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_handles_view_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_handles_view_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
        
        /* graph_select.c - selection tools */
                /* click-select */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "column", 1);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
-       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "left_right", GRAPHKEYS_LRSEL_TEST);
+       WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "column", 1);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "extend", 1);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "extend", 1);
+               RNA_boolean_set(kmi->ptr, "column", 1);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
+               RNA_enum_set(kmi->ptr, "left_right", GRAPHKEYS_LRSEL_TEST);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
+               RNA_boolean_set(kmi->ptr, "curves", 1);
+       kmi= WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0);
+               RNA_boolean_set(kmi->ptr, "curves", 1);
+               RNA_boolean_set(kmi->ptr, "extend", 1);
        
                /* deselect all */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_select_all_toggle", AKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
+       WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
        
                /* borderselect */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_select_border", BKEY, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
+       WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
        
                /* column select */
                // XXX KKEY would be nice to keep for 'keyframe' lines
-       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
-       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
-       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
-       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
+       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
+       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
+       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
+       RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
        
        
        /* graph_edit.c */
                /* snap - current frame to selected keys */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_cfrasnap", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+               // TODO: maybe since this is called jump, we're better to have it on <something>-J?
+       WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
                
                /* menu + single-step transform */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
        
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_handle_type", HKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
        
        
                /* destructive */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clean", OKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_smooth", OKEY, KM_PRESS, KM_ALT, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_clean", OKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
        
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_bake", CKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_bake", CKEY, KM_PRESS, KM_ALT, 0);
        
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_delete", XKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_delete", XKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_delete", DELKEY, KM_PRESS, 0, 0);
        
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
        
                /* insertkey */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_click_insert", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
        
                /* copy/paste */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_copy", CKEY, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_paste", VKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
        
                /* auto-set range */
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        
-               /* F-Curve Modifiers */
-               // XXX these are temporary? operators...
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+               /* F-Modifiers */
+       RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "only_active", 0);
        
        
        /* transform system */
@@ -216,11 +232,11 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
 
 void graphedit_keymap(wmWindowManager *wm)
 {
-       ListBase *keymap;
+       wmKeyMap *keymap;
        
        /* keymap for all regions */
-       keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
-       WM_keymap_add_item(keymap, "GRAPHEDIT_OT_properties", NKEY, KM_PRESS, 0, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Generic", SPACE_IPO, 0);
+       WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0);
 
        /* channels */
        /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module. 
@@ -229,7 +245,7 @@ void graphedit_keymap(wmWindowManager *wm)
         */
        
        /* keyframes */
-       keymap= WM_keymap_listbase(wm, "GraphEdit Keys", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm, "GraphEdit Keys", SPACE_IPO, 0);
        graphedit_keymap_keyframes(wm, keymap);
 }