Today's progress; half working, but i better commit to prevent
conflicts tomorrow :)

- added storage for regions in spacedata
- added space switching (unfinished, gives mem-free errors)
- bugfix: icon of timewindow gave error on split-area
- cleaned interface_icons.c a bit, no warnings
- first work on space new() callbacks, they have to make regions too


NOTE: probably files saved with 2.5 crash now. Have to look at
patching this.

NOTE2: the Makefiles required libeditor screen twice... scons too?
This commit is contained in:
Ton Roosendaal 2008-12-11 19:35:27 +00:00
parent d39b43aa20
commit 7a1100c8b5
14 changed files with 240 additions and 100 deletions

View File

@ -230,6 +230,7 @@ ifeq ($(WITH_OPENEXR), true)
COMLIB += $(NAN_OPENEXR_LIBS)
endif
# silly: libed_screen.a twice :(
PULIB = $(NAN_MOTO)/lib/libmoto.a
PULIB += $(NAN_ELBEEM)/lib/$(DEBUG_DIR)libelbeem.a
PULIB += $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
@ -241,6 +242,7 @@ PULIB += $(OCGDIR)/blender/ed_interface/libed_interface.a
PULIB += $(OCGDIR)/blender/ed_util/libed_util.a
PULIB += $(OCGDIR)/blender/ed_datafiles/libed_datafiles.a
PULIB += $(OCGDIR)/blender/windowmanager/libwindowmanager.a
PULIB += $(OCGDIR)/blender/ed_screen/libed_screen.a
PULIB += $(OCGDIR)/blender/python/$(DEBUG_DIR)libpython.a
PULIB += $(OCGDIR)/blender/makesrna/$(DEBUG_DIR)librna.a

View File

@ -101,12 +101,17 @@ void BKE_spacetype_register(SpaceType *st)
void BKE_spacedata_freelist(ListBase *lb)
{
SpaceLink *sl;
ARegion *ar;
for (sl= lb->first; sl; sl= sl->next) {
SpaceType *st= BKE_spacetype_from_id(sl->spacetype);
if(st && st->free)
st->free(sl);
/* regions for pushed spaces */
for(ar=sl->regionbase.first; ar; ar=ar->next)
BKE_area_region_free(ar);
BLI_freelistN(&sl->regionbase);
}
BLI_freelistN(lb);

View File

@ -5038,64 +5038,64 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me)
}
}
static void do_versions_windowmanager_2_50(bScreen *screen)
/* 2.50 patch */
static void area_add_header_region(ScrArea *sa, ListBase *lb)
{
struct ScrArea *sa;
struct ARegion *ar;
ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
/* add regions */
for(sa= screen->areabase.first; sa; sa= sa->next) {
/* we keep headertype variable to convert old files only */
if(sa->headertype) {
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
BLI_addtail(&sa->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
if(sa->headertype==1)
ar->alignment= RGN_ALIGN_BOTTOM;
else
ar->alignment= RGN_ALIGN_TOP;
/* initialise view2d data for header region, to allow panning */
ar->v2d.keepaspect= 1;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM);
ar->v2d.keepofs = V2D_LOCKOFS_Y;
ar->v2d.keeptot = 2; // this keeps the view in place when region size changes...
ar->v2d.align = V2D_ALIGN_NO_NEG_X;
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
ar->v2d.mask.xmax= sa->winx;
ar->v2d.mask.ymax= HEADERY;
ar->v2d.cur.xmin= sa->headbutofs;
ar->v2d.cur.xmax= sa->winx + sa->headbutofs;
ar->v2d.tot.xmin= 0.0f;
ar->v2d.tot.xmax= sa->headbutlen;
if (ar->alignment == RGN_ALIGN_BOTTOM) {
ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was area->headrct.ymin?
ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
}
else {
// XXX what were the extents of the old headers?
ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was area->headrct.ymin?
ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
}
}
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
BLI_addtail(&sa->regionbase, ar);
ar->winrct= sa->totrct;
ar->regiontype= RGN_TYPE_WINDOW;
BLI_addtail(lb, ar);
ar->regiontype= RGN_TYPE_HEADER;
if(sa->headertype==1)
ar->alignment= RGN_ALIGN_BOTTOM;
else
ar->alignment= RGN_ALIGN_TOP;
/* initialise view2d data for header region, to allow panning */
ar->v2d.keepaspect= 1;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM);
ar->v2d.keepofs = V2D_LOCKOFS_Y;
ar->v2d.keeptot = 2; // this keeps the view in place when region size changes...
ar->v2d.align = V2D_ALIGN_NO_NEG_X;
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
ar->v2d.mask.xmin= ar->v2d.mask.ymin= 0;
ar->v2d.mask.xmax= sa->winx;
ar->v2d.mask.ymax= HEADERY;
ar->v2d.cur.xmin= sa->headbutofs;
ar->v2d.cur.xmax= sa->winx + sa->headbutofs;
ar->v2d.tot.xmin= 0.0f;
ar->v2d.tot.xmax= sa->headbutlen;
if (ar->alignment == RGN_ALIGN_BOTTOM) {
ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was area->headrct.ymin?
ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
}
else {
// XXX what were the extents of the old headers?
ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
ar->v2d.tot.ymin= ar->v2d.cur.ymin= 0.0f; // what was area->headrct.ymin?
ar->v2d.tot.ymax= ar->v2d.cur.ymax= HEADERY;
}
}
/* 2.50 patch */
static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
{
ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
BLI_addtail(lb, ar);
ar->winrct= sa->totrct;
ar->regiontype= RGN_TYPE_WINDOW;
if(sl) {
/* if active spacetype has view2d data, copy that over to main region */
switch(sa->spacetype) {
switch(sl->spacetype) {
case SPACE_OOPS:
{
SpaceOops *soops= sa->spacedata.first;
SpaceOops *soops= (SpaceOops *)sl;
memcpy(&ar->v2d, &soops->v2d, sizeof(View2D));
@ -5107,7 +5107,7 @@ static void do_versions_windowmanager_2_50(bScreen *screen)
break;
case SPACE_TIME:
{
SpaceTime *stime= sa->spacedata.first;
SpaceTime *stime= (SpaceTime *)sl;
memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
@ -5115,9 +5115,45 @@ static void do_versions_windowmanager_2_50(bScreen *screen)
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
}
break;
//case SPACE_XXX: // FIXME... add other ones
// memcpy(&ar->v2d, &((SpaceXxx *)sa->spacedata.first)->v2d, sizeof(View2D));
// break;
//case SPACE_XXX: // FIXME... add other ones
// memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
// break;
}
/* further subdivision case, channels for ipo action nla... */
switch(sl->spacetype) {
case SPACE_IPO:
break;
case SPACE_ACTION:
break;
case SPACE_NLA:
break;
}
}
}
static void do_versions_windowmanager_2_50(bScreen *screen)
{
ScrArea *sa;
ARegion *ar;
SpaceLink *sl;
/* add regions */
for(sa= screen->areabase.first; sa; sa= sa->next) {
/* we keep headertype variable to convert old files only */
if(sa->headertype)
area_add_header_region(sa, &sa->regionbase);
area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
/* pushed back spaces also need regions! */
if(sa->spacedata.first) {
sl= sa->spacedata.first;
for(sl= sl->next; sl; sl= sl->next) {
if(sa->headertype)
area_add_header_region(sa, &sl->regionbase);
area_add_window_regions(sa, sl, &sl->regionbase);
}
}
}
}
@ -8157,6 +8193,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
do_versions_windowmanager_2_50(screen);
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */

View File

@ -51,6 +51,7 @@ ARegion *ED_region_copy(ARegion *ar);
void ED_spacetypes_init(void);
void ED_spacetypes_keymap(struct wmWindowManager *wm);
struct ARegionType *ED_regiontype_from_id(struct SpaceType *st, int regionid);
void ED_newspace(struct ScrArea *sa, int type);
/* areas */
void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);

View File

@ -98,8 +98,6 @@ typedef struct DrawInfo {
static struct ListBase iconfilelist = {0, 0};
static int preview_render_size(int miplevel);
/* **************************************************** */
static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs)
@ -684,6 +682,7 @@ void UI_icons_init(int first_dyn_id)
init_internal_icons();
}
#if 0
static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect)
{
struct ImBuf *ima;
@ -734,6 +733,16 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
IMB_freeImBuf(ima);
}
/* Render size for preview images at level miplevel */
static int preview_render_size(int miplevel)
{
switch (miplevel) {
case 0: return 32;
case 1: return PREVIEW_DEFAULT_HEIGHT;
}
return 0;
}
static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel)
{
unsigned int size = preview_render_size(miplevel);
@ -794,6 +803,7 @@ static void set_alpha(char* cp, int sizex, int sizey, char alpha)
}
}
}
#endif
/* only called when icon has changed */
/* only call with valid pointer from UI_icon_draw */
@ -881,16 +891,6 @@ static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw,
glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
}
/* Render size for preview images at level miplevel */
static int preview_render_size(int miplevel)
{
switch (miplevel) {
case 0: return 32;
case 1: return PREVIEW_DEFAULT_HEIGHT;
}
return 0;
}
/* Drawing size for preview images at level miplevel */
static int preview_size(int miplevel)
{
@ -977,7 +977,6 @@ void UI_icon_draw_preview(float x, float y, int icon_id, int nocreate)
void UI_icon_draw_aspect_blended(float x, float y, int icon_id, float aspect, int shade)
{
if(shade < 0) {
float r= (128+shade)/128.0f;
glPixelTransferf(GL_ALPHA_SCALE, r);

View File

@ -246,7 +246,7 @@ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v
sa->v3= v3;
sa->v4= v4;
sa->headertype= headertype;
sa->spacetype= spacetype;
sa->spacetype= sa->butspacetype= spacetype;
BLI_addtail(&sc->areabase, sa);

View File

@ -38,7 +38,7 @@
#include "BLI_arithb.h"
#include "BKE_global.h"
#include "BKE_colortools.h"
#include "BKE_screen.h"
#include "BLO_readfile.h"
@ -47,4 +47,56 @@
#include "ED_area.h"
#include "ED_screen.h"
/* */
void ED_newspace(ScrArea *sa, int type)
{
if(sa->spacetype != type) {
SpaceType *st= BKE_spacetype_from_id(type);
SpaceLink *slold= sa->spacedata.first;
SpaceLink *sl;
sa->spacetype= type;
sa->butspacetype= type;
/* check previously stored space */
for (sl= sa->spacedata.first; sl; sl= sl->next)
if(sl->spacetype==type)
break;
/* old spacedata... happened during work on 2.50, remove */
if(sl && sl->regionbase.first==NULL) {
st->free(sl);
MEM_freeN(sl);
sl= NULL;
}
if (sl) {
/* swap regions */
slold->regionbase= sa->regionbase;
sa->regionbase= sl->regionbase;
sl->regionbase.first= sl->regionbase.last= NULL;
/* put in front of list */
BLI_remlink(&sa->spacedata, sl);
BLI_addhead(&sa->spacedata, sl);
}
else {
/* new space */
if(st) {
sl= st->new();
BLI_addhead(&sa->spacedata, sl);
/* swap regions */
slold->regionbase= sa->regionbase;
sa->regionbase= sl->regionbase;
sl->regionbase.first= sl->regionbase.last= NULL;
}
}
}
}

View File

@ -202,19 +202,31 @@ static void time_header_area_free(ARegion *ar)
static SpaceLink *time_new(void)
{
ARegion *ar;
SpaceTime *stime;
stime= MEM_callocN(sizeof(SpaceTime), "inittime");
stime->spacetype= SPACE_TIME;
stime->blockscale= 0.7;
stime->redraws= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
stime->flag |= TIME_DRAWFRAMES;
// XXX move to region!
stime->v2d.tot.xmin= -4.0;
stime->v2d.tot.ymin= 0.0;
stime->v2d.tot.xmax= (float)EFRA + 4.0;
//stime->v2d.tot.ymax= (float)stime->winy;
/* header */
ar= MEM_callocN(sizeof(ARegion), "header for time");
BLI_addtail(&stime->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for time");
BLI_addtail(&stime->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
ar->v2d.tot.xmin= -4.0;
ar->v2d.tot.ymin= 0.0;
ar->v2d.tot.xmax= (float)EFRA + 4.0;
ar->v2d.tot.ymax= 10;
stime->v2d.cur= stime->v2d.tot;
@ -227,12 +239,9 @@ static SpaceLink *time_new(void)
stime->v2d.minzoom= 0.1f;
stime->v2d.maxzoom= 10.0;
stime->v2d.scroll= 0;
stime->v2d.keepaspect= 0;
stime->v2d.keepzoom= 0;
stime->v2d.keeptot= 0;
stime->flag |= TIME_DRAWFRAMES;
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
return (SpaceLink*)stime;
}
@ -248,7 +257,7 @@ static void time_free(SpaceLink *sl)
/* validate spacedata, add own area level handlers */
static void time_init(wmWindowManager *wm, ScrArea *sa)
{
}
static SpaceLink *time_duplicate(SpaceLink *sl)

View File

@ -372,8 +372,8 @@ static void end_animated_screen(SpaceTime *stime)
#define B_TL_PREVIEWON 757
#define B_TL_INSERTKEY 758
#define B_TL_DELETEKEY 759
#define B_NEWSPACE 760
#define B_NEWSPACE 0
#define B_FLIPINFOMENU 0
#define B_NEWFRAME 0
#define AUTOKEY_ON 0
@ -385,6 +385,10 @@ void do_time_buttons(bContext *C, void *arg, int event)
SpaceTime *stime= C->area->spacedata.first;
switch(event) {
case B_NEWSPACE:
ED_newspace(C->area, C->area->butspacetype);
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
break;
case B_REDRAWALL:
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
break;

View File

@ -55,31 +55,23 @@
static SpaceLink *view3d_new(void)
{
ARegion *ar;
View3D *vd;
vd= MEM_callocN(sizeof(View3D), "initview3d");
vd->spacetype= SPACE_VIEW3D;
vd->blockscale= 0.7f;
vd->viewquat[0]= 1.0f;
vd->viewquat[1]= vd->viewquat[2]= vd->viewquat[3]= 0.0f;
vd->persp= 1;
vd->drawtype= OB_WIRE;
vd->view= 7;
vd->dist= 10.0;
vd->lens= 35.0f;
vd->near= 0.01f;
vd->far= 500.0f;
vd->grid= 1.0f;
vd->gridlines= 16;
vd->gridsubdiv = 10;
vd->lay= vd->layact= 1;
if(G.scene) {
vd->lay= vd->layact= G.scene->lay;
vd->camera= G.scene->camera;
}
vd->scenelock= 1;
vd->grid= 1.0f;
vd->gridlines= 16;
vd->gridsubdiv = 10;
vd->drawtype= OB_WIRE;
vd->gridflag |= V3D_SHOW_X;
vd->gridflag |= V3D_SHOW_Y;
vd->gridflag |= V3D_SHOW_FLOOR;
@ -87,6 +79,28 @@ static SpaceLink *view3d_new(void)
vd->depths= NULL;
/* XXX move view data to region? */
vd->viewquat[0]= 1.0f;
vd->viewquat[1]= vd->viewquat[2]= vd->viewquat[3]= 0.0f;
vd->persp= 1;
vd->view= 7;
vd->dist= 10.0;
vd->lens= 35.0f;
vd->near= 0.01f;
vd->far= 500.0f;
/* header */
ar= MEM_callocN(sizeof(ARegion), "header for view3d");
BLI_addtail(&vd->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for view3d");
BLI_addtail(&vd->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
return (SpaceLink *)vd;
}

View File

@ -175,6 +175,7 @@ typedef struct bAction {
/* Action Editor Space. This is defined here instead of in DNA_space_types.h */
typedef struct SpaceAction {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
struct ScrArea *area;

View File

@ -132,6 +132,7 @@ typedef struct bSoundListener {
typedef struct SpaceSound {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
struct ScrArea *area;

View File

@ -60,6 +60,7 @@ struct bGPdata;
typedef struct SpaceLink {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale; /* XXX depricate this */
short blockhandler[8]; /* XXX depricate this */
@ -67,6 +68,7 @@ typedef struct SpaceLink {
typedef struct SpaceInfo {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -75,6 +77,7 @@ typedef struct SpaceInfo {
typedef struct SpaceIpo {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -102,6 +105,7 @@ typedef struct SpaceIpo {
typedef struct SpaceButs {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
struct RenderInfo *ri;
@ -133,6 +137,7 @@ typedef struct SpaceButs {
typedef struct SpaceSeq {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -152,6 +157,7 @@ typedef struct SpaceSeq {
typedef struct SpaceFile {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -186,6 +192,7 @@ typedef struct SpaceFile {
typedef struct SpaceOops {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -215,6 +222,7 @@ typedef struct SpaceOops {
typedef struct SpaceImage {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -247,6 +255,7 @@ typedef struct SpaceImage {
typedef struct SpaceNla {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -261,6 +270,7 @@ typedef struct SpaceNla {
typedef struct SpaceText {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -308,6 +318,7 @@ typedef struct Script {
typedef struct SpaceScript {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
struct Script *script;
@ -320,6 +331,7 @@ typedef struct SpaceScript {
typedef struct SpaceTime {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -331,6 +343,7 @@ typedef struct SpaceTime {
typedef struct SpaceNode {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;
@ -358,6 +371,7 @@ typedef struct SpaceNode {
typedef struct SpaceImaSel {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;

View File

@ -72,6 +72,7 @@ typedef struct BGpic {
/* 3D ViewPort Struct */
typedef struct View3D {
struct SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale;