converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / editors / screen / screen_ops.c
index b52937a..56a27da 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
+#include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "BKE_report.h"
@@ -108,6 +109,16 @@ int ED_operator_screenactive(bContext *C)
        return 1;
 }
 
+/* XXX added this to prevent anim state to change during renders */
+int ED_operator_screenactive_norender(bContext *C)
+{
+       if(G.rendering) return 0;
+       if(CTX_wm_window(C)==NULL) return 0;
+       if(CTX_wm_screen(C)==NULL) return 0;
+       return 1;
+}
+
+
 static int screen_active_editable(bContext *C)
 {
        if(ED_operator_screenactive(C)) {
@@ -1716,7 +1727,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot)
        
        ot->exec= frame_offset_exec;
        
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_screenactive_norender;
        ot->flag= 0;
        
        /* rna */
@@ -1766,7 +1777,7 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot)
        
        ot->exec= frame_jump_exec;
        
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_screenactive_norender;
        ot->flag= OPTYPE_UNDO;
        
        /* rna */
@@ -1846,7 +1857,7 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
        
        ot->exec= keyframe_jump_exec;
        
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_screenactive_norender;
        ot->flag= OPTYPE_UNDO;
        
        /* rna */
@@ -1918,7 +1929,18 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
 /* function to be called outside UI context, or for redo */
 static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       ED_screen_full_toggle(C, CTX_wm_window(C), CTX_wm_area(C));
+       bScreen *screen = CTX_wm_screen(C);
+       ScrArea *sa=NULL;
+       
+       /* search current screen for 'fullscreen' areas */
+       /* prevents restoring info header, when mouse is over it */
+       for (sa=screen->areabase.first; sa; sa=sa->next) {
+               if (sa->full) break;
+       }
+       
+       if(sa==NULL) sa= CTX_wm_area(C);
+       
+       ED_screen_full_toggle(C, CTX_wm_window(C), sa);
        return OPERATOR_FINISHED;
 }
 
@@ -2766,7 +2788,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                else sync= (scene->flag & SCE_FRAME_DROP);
                
                if((scene->audio.flag & AUDIO_SYNC) && !(sad->flag & ANIMPLAY_FLAG_REVERSE) && finite(time = sound_sync_scene(scene)))
-                       scene->r.cfra = time * FPS + 0.5;
+                       scene->r.cfra = (double)time * FPS + 0.5;
                else
                {
                        if (sync) {
@@ -2776,7 +2798,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
                                        scene->r.cfra -= step;
                                else
                                        scene->r.cfra += step;
-                               wt->duration -= ((float)step)/FPS;
+                               wt->duration -= ((double)step)/FPS;
                        }
                        else {
                                /* one frame +/- */
@@ -2875,7 +2897,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
        /* api callbacks */
        ot->invoke= screen_animation_step;
        
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_screenactive_norender;
        
 }
 
@@ -2932,26 +2954,29 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot)
        /* api callbacks */
        ot->exec= screen_animation_play_exec;
        
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_screenactive_norender;
        
        RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
        RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate");
 }
 
-static int screen_animation_cancel_exec(bContext *C, wmOperator *UNUSED(op))
+static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
 {
        bScreen *screen= CTX_wm_screen(C);
-       
+
        if (screen->animtimer) {
-               ScreenAnimData *sad= screen->animtimer->customdata;
-               Scene *scene= CTX_data_scene(C);
-               
-               /* reset current frame before stopping, and just send a notifier to deal with the rest 
-                * (since playback still needs to be stopped)
-                */
-               scene->r.cfra= sad->sfra;
-               WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
-               
+               if(RNA_boolean_get(op->ptr, "restore_frame")) {
+                       ScreenAnimData *sad= screen->animtimer->customdata;
+                       Scene *scene= CTX_data_scene(C);
+
+                       /* reset current frame before stopping, and just send a notifier to deal with the rest
+                        * (since playback still needs to be stopped)
+                        */
+                       scene->r.cfra= sad->sfra;
+
+                       WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+               }
+
                /* call the other "toggling" operator to clean up now */
                ED_screen_animation_play(C, 0, 0);
        }
@@ -2970,6 +2995,8 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
        ot->exec= screen_animation_cancel_exec;
        
        ot->poll= ED_operator_screenactive;
+
+       RNA_def_boolean(ot->srna, "restore_frame", TRUE, "Restore Frame", "Restore the frame when animation was initialized.");
 }
 
 /* ************** border select operator (template) ***************************** */
@@ -3157,26 +3184,39 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
 static int scene_new_exec(bContext *C, wmOperator *op)
 {
        Scene *newscene, *scene= CTX_data_scene(C);
+       bScreen *screen= CTX_wm_screen(C);
        Main *bmain= CTX_data_main(C);
        int type= RNA_enum_get(op->ptr, "type");
+
+       if(type == SCE_COPY_NEW) {
+               newscene= add_scene("Scene");
+       }
+       else { /* different kinds of copying */
+               newscene= copy_scene(scene, type);
+
+               /* these can't be handled in blenkernel curently, so do them here */
+               if(type == SCE_COPY_LINK_DATA) {
+                       ED_object_single_users(bmain, newscene, 0);
+               }
+               else if(type == SCE_COPY_FULL) {
+                       ED_object_single_users(bmain, newscene, 1);
+               }
+       }
        
-       newscene= copy_scene(scene, type);
-       
-       /* these can't be handled in blenkernel curently, so do them here */
-       if(type == SCE_COPY_LINK_DATA)
-               ED_object_single_users(bmain, newscene, 0);
-       else if(type == SCE_COPY_FULL)
-               ED_object_single_users(bmain, newscene, 1);
-       
+       /* this notifier calls ED_screen_set_scene, doing a lot of UI stuff, not for inside event loops */
        WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
        
+       if(screen)
+               screen->scene= newscene;
+       
        return OPERATOR_FINISHED;
 }
 
 static void SCENE_OT_new(wmOperatorType *ot)
 {
        static EnumPropertyItem type_items[]= {
-               {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene"},
+               {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"},
+               {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"},
                {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"},
                {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"},
                {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"},
@@ -3306,7 +3346,7 @@ static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSE
 {
        if(drag->type==WM_DRAG_PATH) {
                if(drag->icon==ICON_FILE_BLEND)
-                  return 1;
+                       return 1;
        }
        return 0;
 }