Sculpt: split generic part of image paint undo system into separate
[blender-staging.git] / source / blender / editors / util / undo.c
index e175f7c1393ce70928b2f0c25335b7f8894f1865..18e3304c1910a48e08da37156a630ce2d1d4c382 100644 (file)
@@ -58,6 +58,7 @@
 #include "ED_armature.h"
 #include "ED_particle.h"
 #include "ED_curve.h"
+#include "ED_mball.h"
 #include "ED_mesh.h"
 #include "ED_object.h"
 #include "ED_screen.h"
@@ -79,6 +80,7 @@ void ED_undo_push(bContext *C, char *str)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
        Object *obedit= CTX_data_edit_object(C);
+       Object *obact= CTX_data_active_object(C);
 
        if(obedit) {
                if (U.undosteps == 0) return;
@@ -96,7 +98,7 @@ void ED_undo_push(bContext *C, char *str)
                else if (obedit->type==OB_ARMATURE)
                        undo_push_armature(C, str);
        }
-       else if(G.f & G_PARTICLEEDIT) {
+       else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
                if (U.undosteps == 0) return;
                
                PE_undo_push(CTX_data_scene(C), str);
@@ -115,13 +117,14 @@ void ED_undo_push(bContext *C, char *str)
 static int ed_undo_step(bContext *C, int step, const char *undoname)
 {      
        Object *obedit= CTX_data_edit_object(C);
+       Object *obact= CTX_data_active_object(C);
        ScrArea *sa= CTX_wm_area(C);
 
        if(sa && sa->spacetype==SPACE_IMAGE) {
                SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
                
-               if(G.f & G_TEXTUREPAINT || sima->flag & SI_DRAWTOOL) {
-                       undo_imagepaint_step(step);
+               if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
+                       ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step);
 
                        WM_event_add_notifier(C, NC_WINDOW, NULL);
                        return OPERATOR_FINISHED;
@@ -142,9 +145,9 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
        else {
                int do_glob_undo= 0;
                
-               if(G.f & G_TEXTUREPAINT)
-                       undo_imagepaint_step(step);
-               else if(G.f & G_PARTICLEEDIT) {
+               if(obact && obact->mode & OB_MODE_TEXTURE_PAINT)
+                       ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step);
+               else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
                        if(step==1)
                                PE_undo(CTX_data_scene(C));
                        else
@@ -209,13 +212,14 @@ static int ed_redo_exec(bContext *C, wmOperator *op)
 void ED_undo_menu(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
+       Object *obact= CTX_data_active_object(C);
        
        if(obedit) {
                //if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
                //      undo_editmode_menu();
        }
        else {
-               if(G.f & G_PARTICLEEDIT)
+               if(obact && obact->mode & OB_MODE_PARTICLE_EDIT)
                        PE_undo_menu(CTX_data_scene(C), CTX_data_active_object(C));
                else if(U.uiflag & USER_GLOBALUNDO) {
                        char *menu= BKE_undo_menu_string();
@@ -236,6 +240,7 @@ void ED_OT_undo(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Undo";
+    ot->description= "Undo previous action.";
        ot->idname= "ED_OT_undo";
        
        /* api callbacks */
@@ -247,6 +252,7 @@ void ED_OT_redo(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Redo";
+    ot->description= "Redo previous action.";
        ot->idname= "ED_OT_redo";
        
        /* api callbacks */