2.5
authorTon Roosendaal <ton@blender.org>
Tue, 6 Jan 2009 18:14:37 +0000 (18:14 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 6 Jan 2009 18:14:37 +0000 (18:14 +0000)
Cleaned area prevspace, and made exported API for it.
Also added operator-free on 'cancel' in filewindow.

source/blender/editors/include/ED_screen.h
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/space_file/file_draw.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c

index 7f01cc36c7cd79f1c203db7a7d13d6f087e39e8a..bd9d31288ceb1236e047358f2437968af043f341 100644 (file)
@@ -68,6 +68,8 @@ void  ED_area_tag_redraw(ScrArea *sa);
 void   ED_area_tag_refresh(ScrArea *sa);
 void   ED_area_do_refresh(struct bContext *C, ScrArea *sa);
 void   ED_area_headerprint(ScrArea *sa, const char *str);
+void   ED_area_newspace(struct bContext *C, ScrArea *sa, int type);
+void   ED_area_prevspace(struct bContext *C);
 
 /* screens */
 void   ED_screens_initialize(struct wmWindowManager *wm);
index ee0da138941a8411de5eb0dcd53ade6535e0b801..e2cafeceb9e257afb5f5c244d28a57a024354ba1 100644 (file)
@@ -586,10 +586,9 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
 #endif
 }
 
-/* *********** Space switching code, local now *********** */
-/* XXX make operator for this */
+/* *********** Space switching code *********** */
 
-void area_newspace(bContext *C, ScrArea *sa, int type)
+void ED_area_newspace(bContext *C, ScrArea *sa, int type)
 {
        if(sa->spacetype != type) {
                SpaceType *st;
@@ -646,10 +645,12 @@ void area_newspace(bContext *C, ScrArea *sa, int type)
                
                /* tell WM to refresh, cursor types etc */
                WM_event_add_mousemove(C);
+               
+               ED_area_tag_redraw(sa);
        }
 }
 
-void area_prevspace(bContext *C)
+void ED_area_prevspace(bContext *C)
 {
        SpaceLink *sl= CTX_wm_space_data(C);
        ScrArea *sa= CTX_wm_area(C);
@@ -665,11 +666,6 @@ void area_prevspace(bContext *C)
 #endif
 
        if(sl->next) {
-       
-               BLI_remlink(&sa->spacedata, sl);
-               BLI_addtail(&sa->spacedata, sl);
-
-               sl= sa->spacedata.first;
 
 #if 0 // XXX check whether this is still needed
                if (sfile->spacetype == SPACE_SCRIPT) {
@@ -678,11 +674,12 @@ void area_prevspace(bContext *C)
                }
 #endif
 
-               area_newspace(C, sa, SPACE_FILE);
+               ED_area_newspace(C, sa, sl->next->spacetype);
        }
        else {
-               area_newspace(C, sa, SPACE_INFO);
+               ED_area_newspace(C, sa, SPACE_INFO);
        }
+       ED_area_tag_redraw(sa);
 }
 
 static char *windowtype_pup(void)
@@ -725,7 +722,7 @@ static char *windowtype_pup(void)
 
 static void spacefunc(struct bContext *C, void *arg1, void *arg2)
 {
-       area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
+       ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
        ED_area_tag_redraw(CTX_wm_area(C));
 }
 
index a838e833883411ae8f81371733eb404d32354153..f96a84535adb315058646349cb7fd83c8fbd5627 100644 (file)
@@ -1282,7 +1282,7 @@ void ed_screen_fullarea(bContext *C)
                
                /* returns the top small area */
                newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
-               area_newspace(C, newa, SPACE_INFO);
+               ED_area_newspace(C, newa, SPACE_INFO);
 
                /* copy area */
                newa= newa->prev;
index 37932ee87a3e549aee364cbc4b45014fc0768750..fea46175f8d3ad649e4ce40d4c44a9aac42c2b5e 100644 (file)
@@ -34,8 +34,6 @@ struct Scene;
 
 /* area.c */
 void           area_copy_data  (ScrArea *sa1, ScrArea *sa2, int swap_space);
-void           area_newspace(bContext *C, ScrArea *sa, int type);
-void           area_prevspace(bContext *C);
 
 /* screen_edit.c */
 bScreen                *screen_add(struct wmWindow *win, struct Scene *scene, char *name);
index b2b77e9dfb93ac7bcec06ebbce348e4c9534bb35..6f842da6dd042bb2916be77da49d6b638e9985f9 100644 (file)
@@ -49,8 +49,6 @@
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
 
-#include "ED_fileselect.h"
-
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
  
@@ -60,6 +58,9 @@
 
 #include "RNA_access.h"
 
+#include "ED_fileselect.h"
+#include "ED_screen.h"
+
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
 #include "UI_resources.h"
@@ -86,9 +87,6 @@ enum {
        B_FS_CANCEL,
 } eFile_ButEvents;
 
-// XXX for Ton: bad level, maybe needs export in ED_screen?
-extern void area_prevspace(bContext *C);
-
 static void do_file_buttons(bContext *C, void *arg, int event)
 {
        SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
@@ -97,7 +95,7 @@ static void do_file_buttons(bContext *C, void *arg, int event)
                        {
                                char name[FILE_MAX];
 
-                               area_prevspace(C);
+                               ED_area_prevspace(C);
                                if(sfile->op) {
                                        wmOperator *op= sfile->op;
                                        
@@ -117,9 +115,12 @@ static void do_file_buttons(bContext *C, void *arg, int event)
                        }
                        break;
                case B_FS_CANCEL:
-                       /* XXX for Ton: the call to area_prevspace crashes
-                                  area_prevspace(C);
-                       */
+                       if(sfile->op) {
+                               WM_operator_free(sfile->op);
+                               sfile->op = NULL;
+                       }
+                       ED_area_prevspace(C);
+                       
                        break;
        }
 }
index 3bb49b6071522901b0285a6fccd19ec742239d76..8a1c4a54a614e9b0820c4680e588b9095be27893 100644 (file)
@@ -82,6 +82,7 @@
 #include "wm_files.h"
 #include "wm_window.h"
 
+#include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_util.h"
 
index 9e7988ab6e9400ccaf4686d326dbcf85cae1aa05..a74e6c1d92956d9b7e9f3fac5e5c0e1fcf5adddc 100644 (file)
@@ -309,9 +309,6 @@ static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
-// XXX for Ton: bad level, maybe this needs export in ED_screen?
-extern void    area_newspace(bContext *C, ScrArea *sa, int type);
-
 static void WM_OT_open_recentfile(wmOperatorType *ot)
 {
        ot->name= "Open Recent File";
@@ -364,9 +361,9 @@ static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
        CTX_wm_screen_set(C, newsc);
        sa= (ScrArea*)newsc->areabase.first;
        CTX_wm_area_set(C, sa);
-       area_newspace(C, sa, SPACE_FILE);
+       ED_area_newspace(C, sa, SPACE_FILE);
 #else 
-       area_newspace(C, oldsa, SPACE_FILE);
+       ED_area_newspace(C, oldsa, SPACE_FILE);
 #endif
 
        /* settings for filebrowser */