2.5/Posemode:
[blender-staging.git] / source / blender / editors / screen / screen_ops.c
index f04e4c5b34794478baf4410472ef326567c454fe..9453c7ffe098916378dda89adde9e57ffdd1af49 100644 (file)
 #include "BKE_mesh.h"
 #include "BKE_multires.h"
 #include "BKE_report.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
+#include "BKE_sound.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -230,7 +232,7 @@ int ED_operator_posemode(bContext *C)
        Object *obedit= CTX_data_edit_object(C);
        
        if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
-               return (obact->flag & OB_POSEMODE)!=0;
+               return (obact->mode & OB_MODE_POSE)!=0;
                
        return 0;
 }
@@ -2277,7 +2279,9 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
 
                /* since we follow drawflags, we can't send notifier but tag regions ourselves */
                ED_update_for_newframe(C, 1);
-               
+
+               sound_update_playing(C);
+
                for(sa= screen->areabase.first; sa; sa= sa->next) {
                        ARegion *ar;
                        for(ar= sa->regionbase.first; ar; ar= ar->next) {
@@ -2322,6 +2326,7 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
        
        if(screen->animtimer) {
                ED_screen_animation_timer(C, 0, 0);
+               sound_stop_all(C);
        }
        else {
                ScrArea *sa= CTX_wm_area(C);
@@ -3083,7 +3088,124 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
        ot->poll= ED_operator_screenactive;
 }
 
+/********************* new screen operator *********************/
+
+static int screen_new_exec(bContext *C, wmOperator *op)
+{
+       wmWindow *win= CTX_wm_window(C);
+       bScreen *sc= CTX_wm_screen(C);
+
+       sc= ED_screen_duplicate(win, sc);
+       WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_new(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "New Screen";
+       ot->idname= "SCREEN_OT_new";
+       
+       /* api callbacks */
+       ot->exec= screen_new_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************* delete screen operator *********************/
+
+static int screen_delete_exec(bContext *C, wmOperator *op)
+{
+       bScreen *sc= CTX_wm_screen(C);
+
+       WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_delete(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Delete Scene";
+       ot->idname= "SCREEN_OT_delete";
+       
+       /* api callbacks */
+       ot->exec= screen_delete_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************* new scene operator *********************/
 
+static int scene_new_exec(bContext *C, wmOperator *op)
+{
+       Scene *newscene, *scene= CTX_data_scene(C);
+       Main *bmain= CTX_data_main(C);
+       int type= RNA_enum_get(op->ptr, "type");
+
+       newscene= copy_scene(bmain, scene, type);
+
+       /* these can't be handled in blenkernel curently, so do them here */
+       if(type == SCE_COPY_LINK_DATA)
+               ED_object_single_users(newscene, 0);
+       else if(type == SCE_COPY_FULL)
+               ED_object_single_users(newscene, 1);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_new(wmOperatorType *ot)
+{
+       static EnumPropertyItem type_items[]= {
+               {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene."},
+               {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."},
+               {0, NULL, 0, NULL, NULL}};
+
+       /* identifiers */
+       ot->name= "New Scene";
+       ot->idname= "SCENE_OT_new";
+       
+       /* api callbacks */
+       ot->exec= scene_new_exec;
+       ot->invoke= WM_menu_invoke;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* properties */
+       RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
+}
+
+/********************* delete scene operator *********************/
+
+static int scene_delete_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_SCENEDELETE, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_delete(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Delete Scene";
+       ot->idname= "SCENE_OT_delete";
+       
+       /* api callbacks */
+       ot->exec= scene_delete_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
 
 /* ****************  Assigning operatortypes to global list, adding handlers **************** */
 
@@ -3125,6 +3247,12 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_render_view_cancel);
        WM_operatortype_append(SCREEN_OT_render_view_show);
 
+       /* new/delete */
+       WM_operatortype_append(SCREEN_OT_new);
+       WM_operatortype_append(SCREEN_OT_delete);
+       WM_operatortype_append(SCENE_OT_new);
+       WM_operatortype_append(SCENE_OT_delete);
+
        /* tools shared by more space types */
        WM_operatortype_append(ED_OT_undo);
        WM_operatortype_append(ED_OT_redo);