2.5
authorTon Roosendaal <ton@blender.org>
Wed, 31 Dec 2008 18:52:15 +0000 (18:52 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 31 Dec 2008 18:52:15 +0000 (18:52 +0000)
My last one for 2008: global undo/redo back :)
Happy 2009 all!

source/blender/blenkernel/intern/blender.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_util.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/util/undo.c

index 7b1406146a4e70df79be3187966b630d966b0c51..8adfe33dfe3daa43a6f6524b6d21be4d2b32ec7c 100644 (file)
@@ -301,8 +301,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
        /* no load screens? */
        if(mode) {
                /* comes from readfile.c */
-               extern void lib_link_screen_restore(Main *, Scene *);
+               extern void lib_link_screen_restore(Main *, bScreen *, Scene *);
                
+               SWAP(ListBase, G.main->wm, bfd->main->wm);
                SWAP(ListBase, G.main->screen, bfd->main->screen);
                SWAP(ListBase, G.main->script, bfd->main->script);
                
@@ -315,7 +316,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
                curscreen->scene= curscene;
 
                /* clear_global will free G.main, here we can still restore pointers */
-               lib_link_screen_restore(bfd->main, curscene);
+               lib_link_screen_restore(bfd->main, curscreen, curscene);
        }
        
        /* free G.main Main database */
index 04903adc03a91480f9203ef6e25cc15433b3ab31..f79625094c8bae525611856ba2a5b24f3cabccd3 100644 (file)
@@ -4046,11 +4046,26 @@ static void *restore_pointer_by_name(Main *mainp, ID *id, int user)
 /* called from kernel/blender.c */
 /* used to link a file (without UI) to the current UI */
 /* note that it assumes the old pointers in UI are still valid, so old Main is not freed */
-void lib_link_screen_restore(Main *newmain, Scene *curscene)
+void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
 {
+       wmWindow *win;
+       wmWindowManager *wm;
        bScreen *sc;
        ScrArea *sa;
 
+       /* first windowmanager */
+       for(wm= newmain->wm.first; wm; wm= wm->id.next) {
+               for(win= wm->windows.first; win; win= win->next) {
+                       win->screen= restore_pointer_by_name(newmain, (ID *)win->screen, 1);
+                       
+                       if(win->screen==NULL)
+                               win->screen= curscreen;
+
+                       win->screen->winid= win->winid;
+               }
+       }
+       
+       
        for(sc= newmain->screen.first; sc; sc= sc->id.next) {
                
                sc->scene= restore_pointer_by_name(newmain, (ID *)sc->scene, 1);
index a691ab97798ab8f6ee5b86a8039bd474b3b541db..411c3f250da5e6b252ad0fe3ff1626f3f410653d 100644 (file)
@@ -32,6 +32,7 @@ struct Object;
 struct bContext;
 struct uiMenuBlockHandle;
 struct uiBlock;
+struct wmOperatorType;
 
 /* ed_util.c */
 
@@ -40,10 +41,9 @@ void ED_editors_exit                 (struct bContext *C);
 /* ************** Undo ************************ */
 
 /* undo.c */
-void   ED_redo                                 (struct bContext *C);
-void   ED_undo                                 (struct bContext *C);
 void   ED_undo_push                    (struct bContext *C, char *str);
-void   ED_undo_menu                    (struct bContext *C);
+void   ED_OT_undo                              (struct wmOperatorType *ot);
+void   ED_OT_redo                              (struct wmOperatorType *ot);
 
 /* undo_editmode.c */
 void   undo_editmode_push                      (char *name, void (*freedata)(void *), 
index a64d8cbfb11f040ced127bb04d1cc350802401a0..94c003f2f3bdb31747ed0f5957164374a90315aa 100644 (file)
@@ -41,6 +41,7 @@
 #include "WM_types.h"
 
 #include "ED_markers.h"
+#include "ED_util.h"
 #include "ED_screen.h"
 #include "ED_screen_types.h"
 
@@ -1502,6 +1503,8 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_animation_play);
        
        /* tools shared by more space types */
+       WM_operatortype_append(ED_OT_undo);
+       WM_operatortype_append(ED_OT_redo);
        ED_marker_operatortypes();      
        
 }
@@ -1536,7 +1539,13 @@ void ED_keymap_screen(wmWindowManager *wm)
 
        WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
-       
+
+       /* undo */
+       WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
+       WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
+                                                 
        /* screen level global keymaps */
        // err...
        ED_marker_keymap(wm);
index c7d4d1a2719a7485c3f9501108618689f97f0b56..6773575ca84348d0b407d1d46171dbaadaa890bc 100644 (file)
 
 #include "BKE_utildefines.h"
 
-#include "ED_util.h"
 #include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_util.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -117,7 +121,7 @@ static void undo_do(bContext *C)
        
 }
 
-void ED_undo(bContext *C)
+static int ed_undo_exec(bContext *C, wmOperator *op)
 {      
        ScrArea *sa= CTX_wm_area(C);
        
@@ -141,15 +145,19 @@ void ED_undo(bContext *C)
                        undo_do(C);
                }
        }
+       
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
+       
+       return OPERATOR_FINISHED;
 }
 
-void ED_redo(bContext *C)
+static int ed_redo_exec(bContext *C, wmOperator *op)
 {
        ScrArea *sa= CTX_wm_area(C);
        
        if(G.obedit) {
-               if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
-                       undo_editmode_step(-1);
+               //if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
+               //      undo_editmode_step(-1);
        }
        else {
                if(G.f & G_TEXTUREPAINT)
@@ -173,13 +181,16 @@ void ED_redo(bContext *C)
                        }
                }
        }
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
+       return OPERATOR_FINISHED;
+
 }
 
 void ED_undo_menu(bContext *C)
 {
        if(G.obedit) {
-               if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
-                       undo_editmode_menu();
+               //if ELEM7(G.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)
@@ -198,3 +209,28 @@ void ED_undo_menu(bContext *C)
        }
 }
 
+/* ********************** */
+
+void ED_OT_undo(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Undo";
+       ot->idname= "ED_OT_undo";
+       
+       /* api callbacks */
+       ot->exec= ed_undo_exec;
+       ot->poll= ED_operator_screenactive;
+}
+
+void ED_OT_redo(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Redo";
+       ot->idname= "ED_OT_redo";
+       
+       /* api callbacks */
+       ot->exec= ed_redo_exec;
+       ot->poll= ED_operator_screenactive;
+}
+
+