operator renaming for more consistent word ordering (_add/_remmove shold be last...
[blender.git] / source / blender / editors / animation / anim_ops.c
index 80077a6d4b3c5ddd11f525a4384d91dbe24f81a7..6c8a982b3235a635accbc94f49a7b1c215cc0f8d 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_anim_types.h"
 #include "DNA_action_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -41,6 +42,7 @@
 
 #include "BKE_context.h"
 #include "BKE_utildefines.h"
+#include "BKE_sound.h"
 
 #include "UI_interface.h"
 #include "UI_view2d.h"
 #include "WM_types.h"
 
 #include "ED_anim_api.h"
-#include "ED_keyframing.h" // XXX remove?
+#include "ED_keyframing.h"
 #include "ED_markers.h"
 #include "ED_screen.h"
 
-#include "BKE_sound.h"
+#include "anim_intern.h"
 
 /* ********************** frame change operator ***************************/
 
+/* Check if the operator can be run from the current context */
+static int change_frame_poll(bContext *C)
+{
+       ScrArea *curarea= CTX_wm_area(C);
+       
+       /* as long as there is an active area, and it isn't a Graph Editor 
+        * (since the Graph Editor has its own version which does extra stuff),
+        * we're fine
+        */
+       return ((curarea) && (curarea->spacetype != SPACE_IPO));
+}
+
 /* Set any flags that are necessary to indicate modal time-changing operation */
 static int change_frame_init(bContext *C, wmOperator *op)
 {
@@ -83,18 +97,12 @@ static int change_frame_init(bContext *C, wmOperator *op)
 static void change_frame_apply(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       int cfra;
        
-       /* get frame, and clamp to MINAFRAME 
-        *      - not MINFRAME, since it's useful to be able to key a few-frames back
-        */
-       cfra= RNA_int_get(op->ptr, "frame");
-       
-       if (cfra < MINAFRAME) cfra= MINAFRAME;
-       CFRA= cfra;
+       /* set the new frame number */
+       CFRA= RNA_int_get(op->ptr, "frame");
        
+       /* do updates */
        sound_scrub(C);
-
        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
 }
 
@@ -193,7 +201,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
                        /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
                         * the modal op) doesn't work for some reason
                         */
-                       if (event->val==0) {
+                       if (event->val==KM_RELEASE) {
                                change_frame_exit(C, op);
                                return OPERATOR_FINISHED;
                        }
@@ -208,12 +216,14 @@ void ANIM_OT_change_frame(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Change frame";
        ot->idname= "ANIM_OT_change_frame";
+       ot->description= "Interactively change the current frame number.";
        
        /* api callbacks */
        ot->exec= change_frame_exec;
        ot->invoke= change_frame_invoke;
        ot->cancel= change_frame_cancel;
        ot->modal= change_frame_modal;
+       ot->poll= change_frame_poll;
        
        /* flags */
        ot->flag= OPTYPE_BLOCKING;
@@ -250,6 +260,9 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
        scene->r.psfra= (int)floor(sfra + 0.5f);
        scene->r.pefra= (int)floor(efra + 0.5f);
        
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+       
        return OPERATOR_FINISHED;
 } 
 
@@ -389,24 +402,34 @@ void ED_operatortypes_anim(void)
        WM_operatortype_append(ANIM_OT_previewrange_clear);
        
        /* Entire UI --------------------------------------- */
-       WM_operatortype_append(ANIM_OT_insert_keyframe);
-       WM_operatortype_append(ANIM_OT_delete_keyframe);
-       WM_operatortype_append(ANIM_OT_insert_keyframe_menu);
-       WM_operatortype_append(ANIM_OT_delete_keyframe_v3d);
-       WM_operatortype_append(ANIM_OT_insert_keyframe_button);
-       WM_operatortype_append(ANIM_OT_delete_keyframe_button);
+       WM_operatortype_append(ANIM_OT_keyframe_insert);
+       WM_operatortype_append(ANIM_OT_keyframe_delete);
+       WM_operatortype_append(ANIM_OT_keyframe_insert_menu);
+       WM_operatortype_append(ANIM_OT_keyframe_delete_v3d);
+       WM_operatortype_append(ANIM_OT_keyframe_insert_button);
+       WM_operatortype_append(ANIM_OT_keyframe_delete_button);
+       
+       
+       WM_operatortype_append(ANIM_OT_driver_button_add);
+       WM_operatortype_append(ANIM_OT_driver_button_remove);
+       WM_operatortype_append(ANIM_OT_copy_driver_button);
+       WM_operatortype_append(ANIM_OT_paste_driver_button);
+       
+       WM_operatortype_append(ANIM_OT_copy_clipboard_button);
 
        
-       WM_operatortype_append(ANIM_OT_add_driver_button);
-       WM_operatortype_append(ANIM_OT_remove_driver_button);
+       WM_operatortype_append(ANIM_OT_keyingset_button_add);
+       WM_operatortype_append(ANIM_OT_keyingset_button_remove);
        
-       WM_operatortype_append(ANIM_OT_add_keyingset_button);
-       WM_operatortype_append(ANIM_OT_remove_keyingset_button);
+       WM_operatortype_append(ANIM_OT_keying_set_add);
+       WM_operatortype_append(ANIM_OT_keying_set_remove);
+       WM_operatortype_append(ANIM_OT_keying_set_path_add);
+       WM_operatortype_append(ANIM_OT_keying_set_path_remove);
 }
 
-void ED_keymap_anim(wmWindowManager *wm)
+void ED_keymap_anim(wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(wm, "Animation", 0, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "Animation", 0, 0);
        
        /* frame management */
                /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */