Cleaned area prevspace, and made exported API for it.
Also added operator-free on 'cancel' in filewindow.
This commit is contained in:
2009-01-06 18:14:37 +00:00
parent e99d12508e
commit 1c933cdb78
7 changed files with 25 additions and 29 deletions

View 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);

View 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));
}

View 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;

View 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);

View 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;
}
}

View 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"

View 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 */