diff options
author | Ton Roosendaal <ton@blender.org> | 2008-01-07 21:03:41 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-01-07 21:03:41 +0300 |
commit | 1363134dee60ce96ab0772b72283fb405b6a75ed (patch) | |
tree | ece7c62b984d1ebfa8fd1fe1890332c75efa234d /source/blender | |
parent | 1005d99ea5190f34c56f6b30d5eca6bf738a78e8 (diff) |
Whole lot of changes.... here a shortlist:
- removed editors/area and put this all in screen
- added first python calls (note, a new c file for scriptlinks)
- added view3d editor callbacks (no drawing yet)
- added files in editors/interface
(Cmake and Scons has to be fixed, help welcome!)
- now areas/headers are being converted on file read
- note: previously saved 2.50 files will crash!!! (.B.blend)
- area regions are being drawn, first handler for cursor added (on edge)
- window duplicate and scale works correct for screen subdiv
Todos for me:
- need to fix things in syntax (function names) a bit still
- more operators for screen
- define how Context will work... still unresolved when it gets set
- docs!
Reviews of code structure is welcome!
There are also more todos now for others, but it can wait a couple of days
Diffstat (limited to 'source/blender')
49 files changed, 4746 insertions, 451 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index e20b00a00e7..442ef7cf003 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,12 +26,59 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BKE_SCREEN_H #define BKE_SCREEN_H +struct SpaceType; +struct ScrArea; +struct bScreen; +struct ARegion; +struct wmNotifier; + +/* spacetype has everything stored to get an editor working, it gets initialized via +spacetypes_init() in editors/area/spacetypes.c */ +/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ + +typedef struct SpaceType { + struct SpaceType *next, *prev; + + char name[32]; /* for menus */ + int spaceid; /* unique space identifier */ + int iconid; /* icon lookup for menus */ + + struct SpaceLink *(*new)(void); /* calls init too */ + void (*free)(struct SpaceLink *sl); /* not free sl itself */ + + void (*init)(struct ScrArea *); /* init is to cope with internal contextual changes, adds handlers, sets screarea regions */ + void (*refresh)(struct bContext *, struct ScrArea *); /* refresh is for external bContext changes */ + + struct SpaceLink *(*duplicate)(struct SpaceLink *sl); /* after a spacedata copy, an init should result in exact same situation */ + + /* read and write... */ + +} SpaceType; + +/* region type gets allocated and freed in spacetype init/free callback */ +/* data storage for regions is in space struct (also width/height of regions!) */ +typedef struct ARegionType { + + void (*init)(const struct bContext *, struct ARegion *); /* add handlers, stuff you only do once or on area/region changes */ + void (*refresh)(const struct bContext *, struct ARegion *); /* refresh to match contextual changes */ + void (*draw)(const struct bContext *, struct ARegion *); /* draw entirely, windowsize changes should be handled here */ + + void (*listener)(struct ARegion *, struct wmNotifier *); +} ARegionType; + + +void BKE_screen_area_free(struct ScrArea *sa); void free_screen(struct bScreen *sc); +struct SpaceType *BKE_spacetype_from_id(int spaceid); +void BKE_spacetype_register(struct SpaceType *st); +void BKE_spacedata_freelist(ListBase *lb); +void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); + #endif diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index b41fdbba5e4..33e131606c2 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -1,9 +1,7 @@ - -/* screen.c - * +/* * $Id$ * - * ***** BEGIN GP LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,9 +20,7 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. + * Contributor(s): Blender Foundation 2002-2008 * * ***** END GPL LICENSE BLOCK ***** */ @@ -34,20 +30,89 @@ #include <math.h> #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BLI_blenlib.h" #include "BKE_screen.h" -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "BPY_extern.h" + +/* keep global; this has to be accessible outside of windowmanager */ +static ListBase spacetypes= {NULL, NULL}; + +SpaceType *BKE_spacetype_from_id(int spaceid) +{ + SpaceType *st; + + for(st= spacetypes.first; st; st= st->next) { + if(st->spaceid==spaceid) + return st; + } + return NULL; +} + +void BKE_spacetype_register(SpaceType *st) +{ + BLI_addtail(&spacetypes, st); +} + +void BKE_spacedata_freelist(ListBase *lb) +{ + SpaceLink *sl; + + for (sl= lb->first; sl; sl= sl->next) { + SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + + if(st && st->free) + st->free(sl); + } + + BLI_freelistN(lb); +} + +/* lb1 should be empty */ +void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) +{ + SpaceLink *sl; + + lb1->first= lb2->last= NULL; /* to be sure */ + + for (sl= lb2->first; sl; sl= sl->next) { + SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + + if(st && st->duplicate) + BLI_addtail(lb1, st->duplicate(sl)); + } +} + + +/* not area itself */ +void BKE_screen_area_free(ScrArea *sa) +{ + + BKE_spacedata_freelist(&sa->spacedata); + + BLI_freelistN(&sa->regionbase); + + BLI_freelistN(&sa->panels); + // uiFreeBlocks(&sa->uiblocks); + // uiFreePanels(&sa->panels); + + BPY_free_scriptlink(&sa->scriptlink); + +} /* don't free screen itself */ void free_screen(bScreen *sc) { - //XXX unlink_screen(sc); /* bad level call */ - + ScrArea *sa; + + for(sa= sc->areabase.first; sa; sa= sa->next) + BKE_screen_area_free(sa); + BLI_freelistN(&sc->vertbase); BLI_freelistN(&sc->edgebase); BLI_freelistN(&sc->areabase); } + + diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a3d29ce012c..7bc60be4fd9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3844,8 +3844,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc) link_list(fd, &(sc->edgebase)); link_list(fd, &(sc->areabase)); - sc->mainwin= sc->subwinactive= NULL; - sc->handlers.first= sc->handlers.last= NULL; + sc->mainwin= sc->subwinactive= 0; /* indices */ /* hacky patch... but people have been saving files with the verse-blender, causing the handler to keep running for ever, with no means to disable it */ @@ -3884,6 +3883,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc) sa->handlers.first= sa->handlers.last= NULL; sa->uiblocks.first= sa->uiblocks.last= NULL; + sa->type= NULL; /* spacetype callbacks */ /* accident can happen when read/save new file with older version */ if(sa->spacedata.first==NULL && sa->spacetype>SPACE_NLA) @@ -3944,7 +3944,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc) for(ar= sa->regionbase.first; ar; ar= ar->next) { ar->handlers.first= ar->handlers.last= NULL; - ar->subwin= NULL; + ar->swinid= 0; + ar->type= NULL; } sa->v1= newdataadr(fd, sa->v1); @@ -4564,6 +4565,33 @@ static void do_version_ntree_242_2(bNodeTree *ntree) } } +static void do_versions_windowmanager_2_50(bScreen *screen) +{ + struct ScrArea *sa; + struct ARegion *ar; + + /* 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->winrct= sa->headrct; + ar->regiontype= RGN_TYPE_HEADER; + ar->minsize= HEADERY; // DNA_screen_types.h + if(sa->headertype==1) + ar->alignment= RGN_ALIGN_BOTTOM; + else + ar->alignment= RGN_ALIGN_TOP; + } + + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(&sa->regionbase, ar); + ar->winrct= sa->winrct; + ar->regiontype= RGN_TYPE_WINDOW; + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7316,8 +7344,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - - + + + if (main->versionfile < 250) { + bScreen *screen; + + for(screen= main->screen.first; screen; screen= screen->id.next) + 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! */ diff --git a/source/blender/editors/Makefile b/source/blender/editors/Makefile index d5002f530c1..00095860003 100644 --- a/source/blender/editors/Makefile +++ b/source/blender/editors/Makefile @@ -29,6 +29,6 @@ # Bounces make to subdirectories. SOURCEDIR = source/blender/editors -DIRS = area datafiles screen +DIRS = datafiles screen space_view3d include nan_subdirs.mk diff --git a/source/blender/editors/area/SConscript b/source/blender/editors/area/SConscript deleted file mode 100644 index 6a9ec433398..00000000000 --- a/source/blender/editors/area/SConscript +++ /dev/null @@ -1,2 +0,0 @@ - -Import('env')
\ No newline at end of file diff --git a/source/blender/editors/area/space.c b/source/blender/editors/area/space.c deleted file mode 100644 index 2ade78f93e4..00000000000 --- a/source/blender/editors/area/space.c +++ /dev/null @@ -1,246 +0,0 @@ -/** - * $Id: - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include <string.h> -#include <stdio.h> - -#include "MEM_guardedalloc.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "BLI_blenlib.h" -#include "BLI_arithb.h" - -#include "BKE_global.h" -#include "BKE_colortools.h" - -#include "BLO_readfile.h" - -#include "WM_api.h" - -#include "ED_area.h" -#include "ED_screen.h" - -void freespacelist(ScrArea *sa) -{ - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if(sl->spacetype==SPACE_FILE) { - SpaceFile *sfile= (SpaceFile*) sl; - if(sfile->libfiledata) - BLO_blendhandle_close(sfile->libfiledata); - if(sfile->filelist) - ; // XXX freefilelist(sfile); - if(sfile->pupmenu) - MEM_freeN(sfile->pupmenu); - } - else if(sl->spacetype==SPACE_BUTS) { - SpaceButs *buts= (SpaceButs*) sl; -// if(buts->ri) { -// if (buts->ri->rect) MEM_freeN(buts->ri->rect); -// MEM_freeN(buts->ri); -// XXX } - if(G.buts==buts) G.buts= NULL; - } - else if(sl->spacetype==SPACE_IPO) { - SpaceIpo *si= (SpaceIpo*) sl; - if(si->editipo) MEM_freeN(si->editipo); -// XXX free_ipokey(&si->ipokey); - if(G.sipo==si) G.sipo= NULL; - } - else if(sl->spacetype==SPACE_VIEW3D) { - View3D *vd= (View3D*) sl; - if(vd->bgpic) { - if(vd->bgpic->ima) vd->bgpic->ima->id.us--; - MEM_freeN(vd->bgpic); - } - if(vd->localvd) MEM_freeN(vd->localvd); - if(vd->clipbb) MEM_freeN(vd->clipbb); - if(vd->depths) { -// XXX if(vd->depths->depths) MEM_freeN(vd->depths->depths); - MEM_freeN(vd->depths); - vd->depths= NULL; - } -// XXX retopo_free_view_data(vd); - if(vd->properties_storage) MEM_freeN(vd->properties_storage); - if(G.vd==vd) G.vd= NULL; - if(vd->ri) { -// XXX BIF_view3d_previewrender_free(vd); - } - } - else if(sl->spacetype==SPACE_OOPS) { -// XXX SpaceOops *so= (SpaceOops *) sl; -// XXX free_oopspace(so); - } - else if(sl->spacetype==SPACE_IMASEL) { -// XXX SpaceImaSel *simasel= (SpaceImaSel*) sl; -// XXX free_imasel(simasel); - } - else if(sl->spacetype==SPACE_ACTION) { -// XXX free_actionspace((SpaceAction*)sl); - } - else if(sl->spacetype==SPACE_NLA){ - /* free_nlaspace((SpaceNla*)sl); */ - } - else if(sl->spacetype==SPACE_TEXT) { -// XXX free_textspace((SpaceText *)sl); - } - else if(sl->spacetype==SPACE_SCRIPT) { -// XXX free_scriptspace((SpaceScript *)sl); - } - else if(sl->spacetype==SPACE_SOUND) { -// XXX free_soundspace((SpaceSound *)sl); - } - else if(sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; - if(sima->cumap) - curvemapping_free(sima->cumap); - if(sima->info_str) - MEM_freeN(sima->info_str); - if(sima->info_spare) - MEM_freeN(sima->info_spare); - if(sima->spare) - IMB_freeImBuf(sima->spare); - } - else if(sl->spacetype==SPACE_NODE) { - /* SpaceNode *snode= (SpaceNode *)sl; */ - } - } - - BLI_freelistN(&sa->spacedata); -} - -/* can be called for area-full, so it should keep interesting stuff */ -void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2) -{ - SpaceLink *sl; - - BLI_duplicatelist(lb1, lb2); - - /* lb1 is copy from lb2, from lb2 we free stuff, rely on event system to properly re-alloc */ - - sl= lb2->first; - while(sl) { - if(sl->spacetype==SPACE_FILE) { - SpaceFile *sfile= (SpaceFile*) sl; - sfile->libfiledata= NULL; - sfile->filelist= NULL; - sfile->pupmenu= NULL; - sfile->menup= NULL; - } - else if(sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*)sl; -// XXX BIF_view3d_previewrender_free(v3d); - v3d->depths= NULL; - v3d->retopo_view_data= NULL; - } - else if(sl->spacetype==SPACE_OOPS) { - SpaceOops *so= (SpaceOops *)sl; - so->oops.first= so->oops.last= NULL; - so->tree.first= so->tree.last= NULL; - so->treestore= NULL; - } - else if(sl->spacetype==SPACE_IMASEL) { - SpaceImaSel *simasel= (SpaceImaSel*) sl; - simasel->pupmenu= NULL; - simasel->menup= NULL; -// XXX simasel->files = BIF_filelist_new(); -// XXX BIF_filelist_setdir(simasel->files, simasel->dir); -// XXX BIF_filelist_settype(simasel->files, simasel->type); - /* see SPACE_FILE - elubie */ - } - else if(sl->spacetype==SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; - snode->nodetree= NULL; - } - - sl= sl->next; - } - - /* but some things we copy */ - - sl= lb1->first; - while(sl) { - sl->area= newarea; - - if(sl->spacetype==SPACE_BUTS) { - SpaceButs *buts= (SpaceButs *)sl; - buts->ri= NULL; - } - else if(sl->spacetype==SPACE_FILE) { - SpaceFile *sfile= (SpaceFile*) sl; - sfile->menup= NULL; - } - else if(sl->spacetype==SPACE_IPO) { - SpaceIpo *si= (SpaceIpo *)sl; - si->editipo= NULL; - si->ipokey.first= si->ipokey.last= NULL; - } - else if(sl->spacetype==SPACE_VIEW3D) { - View3D *vd= (View3D *)sl; - if(vd->bgpic) { - vd->bgpic= MEM_dupallocN(vd->bgpic); - if(vd->bgpic->ima) vd->bgpic->ima->id.us++; - } - vd->clipbb= MEM_dupallocN(vd->clipbb); - vd->ri= NULL; - vd->properties_storage= NULL; - } - else if(sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; - if(sima->cumap) - sima->cumap= curvemapping_copy(sima->cumap); - if(sima->info_str) - sima->info_str= MEM_dupallocN(sima->info_str); - if(sima->info_spare) - sima->info_spare= MEM_dupallocN(sima->info_spare); - } - sl= sl->next; - } - - /* again: from old View3D restore localview (because full) */ - sl= lb2->first; - while(sl) { - if(sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - if(v3d->localvd) { -// XXX restore_localviewdata(v3d); - v3d->localvd= NULL; - v3d->properties_storage= NULL; - v3d->localview= 0; - v3d->lay &= 0xFFFFFF; - } - } - sl= sl->next; - } -} - - - diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 93ca90ce12f..1c8a7acde89 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -1,19 +1,12 @@ /** - * @file BIF_glutil.h - * - * OpenGL drawing utility functions. - * - * $Id: BIF_glutil.h 10207 2007-03-06 03:39:15Z halley $ + * $Id: BIF_glutil.h * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,11 +20,9 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * - * The Original Code is: all of this file. + * Contributor(s): Blender Foundation 2002-2008 * - * Contributor(s): none yet. - * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BIF_GLUTIL_H @@ -40,6 +31,11 @@ struct rcti; struct rctf; +void fdrawline(float x1, float y1, float x2, float y2); +void fdrawbox(float x1, float y1, float x2, float y2); +void sdrawline(short x1, short y1, short x2, short y2); +void sdrawbox(short x1, short y1, short x2, short y2); + void sdrawXORline(int x0, int y0, int x1, int y1); void sdrawXORline4(int nr, int x0, int y0, int x1, int y1); diff --git a/source/blender/editors/include/BIF_interface_icons.h b/source/blender/editors/include/BIF_interface_icons.h new file mode 100644 index 00000000000..63ce89eef62 --- /dev/null +++ b/source/blender/editors/include/BIF_interface_icons.h @@ -0,0 +1,72 @@ +/** + * $Id: BIF_interface_icons.h 11920 2007-09-02 17:25:03Z elubie $ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef BIF_PREVIEW_ICONS_H +#define BIF_PREVIEW_ICONS_H + +struct Image; +struct ImBuf; +struct World; +struct Tex; +struct Lamp; +struct Material; + +typedef struct IconFile { + struct IconFile *next, *prev; + char filename[80]; // FILE_MAXFILE size + int index; +} IconFile; + + +#define ICON_DEFAULT_HEIGHT 16 +#define PREVIEW_DEFAULT_HEIGHT 96 + +/* + Resizable Icons for Blender +*/ +void BIF_icons_init(int first_dyn_id); +int BIF_icon_get_width(int icon_id); +int BIF_icon_get_height(int icon_id); + +void BIF_icon_draw(float x, float y, int icon_id); +void BIF_icon_draw_preview(float x, float y, int icon_id, int nocreate); + +void BIF_icon_draw_aspect(float x, float y, int icon_id, float aspect); +void BIF_icon_draw_aspect_blended(float x, float y, int icon_id, float aspect, int shade); +void BIF_icons_free(); +void BIF_icons_free_drawinfo(void *drawinfo); + +struct ListBase *BIF_iconfile_list(void); +int BIF_iconfile_get_index(char *filename); + + +#endif /* BIF_ICONS_H */ diff --git a/source/blender/editors/include/BIF_resources.h b/source/blender/editors/include/BIF_resources.h new file mode 100644 index 00000000000..38540f1ba39 --- /dev/null +++ b/source/blender/editors/include/BIF_resources.h @@ -0,0 +1,600 @@ +/** + * $Id: BIF_resources.h 13057 2007-12-30 12:08:28Z aligorith $ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef BIF_RESOURCES_H +#define BIF_RESOURCES_H + +/* elubie: TODO: move the typedef for icons to BIF_interface_icons.h */ +/* and add/replace include of BIF_resources.h by BIF_interface_icons.h */ +typedef enum { +#define BIFICONID_FIRST (ICON_VIEW3D) + ICON_VIEW3D, + ICON_IPO, + ICON_OOPS, + ICON_BUTS, + ICON_FILESEL, + ICON_IMAGE_COL, + ICON_INFO, + ICON_SEQUENCE, + ICON_TEXT, + ICON_IMASEL, + ICON_SOUND, + ICON_ACTION, + ICON_NLA, + ICON_SCRIPTWIN, + ICON_TIME, + ICON_NODE, + ICON_SPACE2, + ICON_SPACE3, + ICON_SPACE4, + ICON_TRIA_LEFT, + ICON_TRIA_UP, + ICON_FONTPREVIEW, + ICON_BLANK4, + ICON_BLANK5, + ICON_BLANK6, + + ICON_ORTHO, + ICON_PERSP, + ICON_CAMERA, + ICON_PARTICLES, + ICON_BBOX, + ICON_WIRE, + ICON_SOLID, + ICON_SMOOTH, + ICON_POTATO, + ICON_MARKER_HLT, + ICON_PMARKER_ACT, + ICON_PMARKER_SEL, + ICON_PMARKER, + ICON_VIEWZOOM, + ICON_SORTALPHA, + ICON_SORTTIME, + ICON_SORTSIZE, + ICON_LONGDISPLAY, + ICON_SHORTDISPLAY, + ICON_TRIA_DOWN, + ICON_TRIA_RIGHT, + ICON_BLANK7, + ICON_BLANK8, + ICON_BLANK9, + ICON_BLANK10, + + ICON_VIEW_AXIS_ALL, + ICON_VIEW_AXIS_NONE, + ICON_VIEW_AXIS_NONE2, + ICON_VIEW_AXIS_TOP, + ICON_VIEW_AXIS_FRONT, + ICON_VIEW_AXIS_SIDE, + ICON_POSE_DEHLT, + ICON_POSE_HLT, + ICON_BORDERMOVE, + ICON_MAYBE_ITS_A_LASSO, + ICON_BLANK1, /* ATTENTION, someone decided to use this throughout blender + and didn't care to neither rename it nor update the PNG */ + ICON_VERSE, + ICON_MOD_BOOLEAN, + ICON_ARMATURE, + ICON_PAUSE, + ICON_ALIGN, + ICON_REC, + ICON_PLAY, + ICON_FF, + ICON_REW, + ICON_PYTHON, + ICON_BLANK11, + ICON_BLANK12, + ICON_BLANK13, + ICON_BLANK14, + + + ICON_DOTSUP, + ICON_DOTSDOWN, + ICON_MENU_PANEL, + ICON_AXIS_SIDE, + ICON_AXIS_FRONT, + ICON_AXIS_TOP, + ICON_STICKY_UVS_LOC, + ICON_STICKY_UVS_DISABLE, + ICON_STICKY_UVS_VERT, + ICON_PREV_KEYFRAME, + ICON_NEXT_KEYFRAME, + ICON_ENVMAP, + ICON_TRANSP_HLT, + ICON_TRANSP_DEHLT, + ICON_CIRCLE_DEHLT, + ICON_CIRCLE_HLT, + ICON_TPAINT_DEHLT, + ICON_TPAINT_HLT, + ICON_WPAINT_DEHLT, + ICON_WPAINT_HLT, + ICON_MARKER, + ICON_BLANK15, + ICON_BLANK16, + ICON_BLANK17, + ICON_BLANK18, + + ICON_X, + ICON_GO_LEFT, + ICON_NO_GO_LEFT, + ICON_UNLOCKED, + ICON_LOCKED, + ICON_PARLIB, + ICON_DATALIB, + ICON_AUTO, + ICON_MATERIAL_DEHLT2, + ICON_RING, + ICON_GRID, + ICON_PROPEDIT, + ICON_KEEPRECT, + ICON_DESEL_CUBE_VERTS, + ICON_EDITMODE_DEHLT, + ICON_EDITMODE_HLT, + ICON_VPAINT_DEHLT, + ICON_VPAINT_HLT, + ICON_FACESEL_DEHLT, + ICON_FACESEL_HLT, + ICON_EDIT_DEHLT, + ICON_BOOKMARKS, + ICON_BLANK20, + ICON_BLANK21, + ICON_BLANK22, + + ICON_HELP, + ICON_ERROR, + ICON_FOLDER_DEHLT, + ICON_FOLDER_HLT, + ICON_BLUEIMAGE_DEHLT, + ICON_BLUEIMAGE_HLT, + ICON_BPIBFOLDER_DEHLT, + ICON_BPIBFOLDER_HLT, + ICON_BPIBFOLDER_ERR, + ICON_UGLY_GREEN_RING, + ICON_GHOST, + ICON_SORTBYEXT, + ICON_SCULPTMODE_HLT, + ICON_VERTEXSEL, + ICON_EDGESEL, + ICON_FACESEL, + ICON_PLUS, + ICON_BPIBFOLDER_X, + ICON_BPIBFOLDERGREY, + ICON_MAGNIFY, + ICON_INFO2, + ICON_BLANK23, + ICON_BLANK24, + ICON_BLANK25, + ICON_BLANK26, + + ICON_RIGHTARROW, + ICON_DOWNARROW_HLT, + ICON_ROUNDBEVELTHING, + ICON_FULLTEXTURE, + ICON_HOOK, + ICON_DOT, + ICON_WORLD_DEHLT, + ICON_CHECKBOX_DEHLT, + ICON_CHECKBOX_HLT, + ICON_LINK, + ICON_INLINK, + ICON_ZOOMIN, + ICON_ZOOMOUT, + ICON_PASTEDOWN, + ICON_COPYDOWN, + ICON_CONSTANT, + ICON_LINEAR, + ICON_CYCLIC, + ICON_KEY_DEHLT, + ICON_KEY_HLT, + ICON_GRID2, + ICON_BLANK27, + ICON_BLANK28, + ICON_BLANK29, + ICON_BLANK30, + + ICON_EYE, + ICON_LAMP, + ICON_MATERIAL, + ICON_TEXTURE, + ICON_ANIM, + ICON_WORLD, + ICON_SCENE, + ICON_EDIT, + ICON_GAME, + ICON_PAINT, + ICON_RADIO, + ICON_SCRIPT, + ICON_SPEAKER, + ICON_PASTEUP, + ICON_COPYUP, + ICON_PASTEFLIPUP, + ICON_PASTEFLIPDOWN, + ICON_CYCLICLINEAR, + ICON_PIN_DEHLT, + ICON_PIN_HLT, + ICON_LITTLEGRID, + ICON_BLANK31, + ICON_BLANK32, + ICON_BLANK33, + ICON_BLANK34, + + ICON_FULLSCREEN, + ICON_SPLITSCREEN, + ICON_RIGHTARROW_THIN, + ICON_DISCLOSURE_TRI_RIGHT, + ICON_DISCLOSURE_TRI_DOWN, + ICON_SCENE_SEPIA, + ICON_SCENE_DEHLT, + ICON_OBJECT, + ICON_MESH, + ICON_CURVE, + ICON_MBALL, + ICON_LATTICE, + ICON_LAMP_DEHLT, + ICON_MATERIAL_DEHLT, + ICON_TEXTURE_DEHLT, + ICON_IPO_DEHLT, + ICON_LIBRARY_DEHLT, + ICON_IMAGE_DEHLT, + ICON_EYEDROPPER, + ICON_WINDOW_WINDOW, + ICON_PANEL_CLOSE, + ICON_PHYSICS, + ICON_BLANK36, + ICON_BLANK37, + ICON_BLANK38, + + ICON_BLENDER, + ICON_PACKAGE, + ICON_UGLYPACKAGE, + ICON_MATPLANE, + ICON_MATSPHERE, + ICON_MATCUBE, + ICON_SCENE_HLT, + ICON_OBJECT_HLT, + ICON_MESH_HLT, + ICON_CURVE_HLT, + ICON_MBALL_HLT, + ICON_LATTICE_HLT, + ICON_LAMP_HLT, + ICON_MATERIAL_HLT, + ICON_TEXTURE_HLT, + ICON_IPO_HLT, + ICON_LIBRARY_HLT, + ICON_IMAGE_HLT, + ICON_CONSTRAINT, + ICON_CAMERA_DEHLT, + ICON_ARMATURE_DEHLT, + ICON_SNAP_GEAR, + ICON_SNAP_GEO, + ICON_BLANK41, + ICON_BLANK42, + + ICON_SMOOTHCURVE, + ICON_SPHERECURVE, + ICON_ROOTCURVE, + ICON_SHARPCURVE, + ICON_LINCURVE, + ICON_NOCURVE, + ICON_RNDCURVE, + ICON_PROP_OFF, + ICON_PROP_ON, + ICON_PROP_CON, + ICON_SYNTAX, + ICON_SYNTAX_OFF, + ICON_MONKEY, + ICON_HAIR, + ICON_VIEWMOVE, + ICON_HOME, + ICON_CLIPUV_DEHLT, + ICON_CLIPUV_HLT, + ICON_BLANK2, + ICON_BLANK3, + ICON_VPAINT_COL, + ICON_RESTRICT_SELECT_OFF, + ICON_RESTRICT_SELECT_ON, + ICON_MUTE_IPO_OFF, + ICON_MUTE_IPO_ON, + + ICON_MAN_TRANS, + ICON_MAN_ROT, + ICON_MAN_SCALE, + ICON_MANIPUL, + ICON_BLANK_47, + ICON_MODIFIER, + ICON_MOD_WAVE, + ICON_MOD_BUILD, + ICON_MOD_DECIM, + ICON_MOD_MIRROR, + ICON_MOD_SOFT, + ICON_MOD_SUBSURF, + ICON_SEQ_SEQUENCER, + ICON_SEQ_PREVIEW, + ICON_SEQ_LUMA_WAVEFORM, + ICON_SEQ_CHROMA_SCOPE, + ICON_ROTATE, + ICON_CURSOR, + ICON_ROTATECOLLECTION, + ICON_ROTATECENTER, + ICON_ROTACTIVE, + ICON_RESTRICT_VIEW_OFF, + ICON_RESTRICT_VIEW_ON, + ICON_RESTRICT_RENDER_OFF, + ICON_RESTRICT_RENDER_ON, + + VICON_VIEW3D, + VICON_EDIT, + VICON_EDITMODE_DEHLT, + VICON_EDITMODE_HLT, + VICON_DISCLOSURE_TRI_RIGHT, + VICON_DISCLOSURE_TRI_DOWN, + VICON_MOVE_UP, + VICON_MOVE_DOWN, + VICON_X + +#define BIFICONID_LAST (VICON_X) +#define BIFNICONIDS (BIFICONID_LAST-BIFICONID_FIRST + 1) +} BIFIconID; + +typedef enum { +#define BIFCOLORSHADE_FIRST (COLORSHADE_DARK) + COLORSHADE_DARK, + COLORSHADE_GREY, + COLORSHADE_MEDIUM, + COLORSHADE_HILITE, + COLORSHADE_LIGHT, + COLORSHADE_WHITE +#define BIFCOLORSHADE_LAST (COLORSHADE_WHITE) +#define BIFNCOLORSHADES (BIFCOLORSHADE_LAST-BIFCOLORSHADE_FIRST + 1) +} BIFColorShade; + +typedef enum { +#define BIFCOLORID_FIRST (BUTGREY) + BUTGREY = 0, + BUTGREEN, + BUTBLUE, + BUTSALMON, + MIDGREY, + BUTPURPLE, + BUTYELLOW, + REDALERT, + BUTRUST, + BUTWHITE, + BUTDBLUE, + BUTPINK, + BUTDPINK, + BUTMACTIVE, + + BUTIPO, + BUTAUDIO, + BUTCAMERA, + BUTRANDOM, + BUTEDITOBJECT, + BUTPROPERTY, + BUTSCENE, + BUTMOTION, + BUTMESSAGE, + BUTACTION, + BUTCD, + BUTGAME, + BUTVISIBILITY, + BUTYUCK, + BUTSEASICK, + BUTCHOKE, + BUTIMPERIAL, + + BUTTEXTCOLOR, + BUTTEXTPRESSED, + BUTSBACKGROUND, + + VIEWPORTBACKCOLOR, + VIEWPORTGRIDCOLOR, + VIEWPORTACTIVECOLOR, + VIEWPORTSELECTEDCOLOR, + VIEWPORTUNSELCOLOR, + + EDITVERTSEL, + EDITVERTUNSEL, + EDITEDGESEL, + EDITEDGEUNSEL + +#define BIFCOLORID_LAST (EDITEDGEUNSEL) +#define BIFNCOLORIDS (BIFCOLORID_LAST-BIFCOLORID_FIRST + 1) + +} BIFColorID; + +/* XXX WARNING: this is saved in file, so do not change order! */ +enum { + TH_AUTO, /* for buttons, to signal automatic color assignment */ + +// uibutton colors + TH_BUT_OUTLINE, + TH_BUT_NEUTRAL, + TH_BUT_ACTION, + TH_BUT_SETTING, + TH_BUT_SETTING1, + TH_BUT_SETTING2, + TH_BUT_NUM, + TH_BUT_TEXTFIELD, + TH_BUT_POPUP, + TH_BUT_TEXT, + TH_BUT_TEXT_HI, + TH_MENU_BACK, + TH_MENU_ITEM, + TH_MENU_HILITE, + TH_MENU_TEXT, + TH_MENU_TEXT_HI, + + TH_BUT_DRAWTYPE, + + TH_REDALERT, + TH_CUSTOM, + + TH_BUT_TEXTFIELD_HI, + TH_ICONFILE, + + TH_THEMEUI, +// common colors among spaces + + TH_BACK, + TH_TEXT, + TH_TEXT_HI, + TH_HEADER, + TH_HEADERDESEL, + TH_PANEL, + TH_SHADE1, + TH_SHADE2, + TH_HILITE, + + TH_GRID, + TH_WIRE, + TH_SELECT, + TH_ACTIVE, + TH_GROUP, + TH_GROUP_ACTIVE, + TH_TRANSFORM, + TH_VERTEX, + TH_VERTEX_SELECT, + TH_VERTEX_SIZE, + TH_EDGE, + TH_EDGE_SELECT, + TH_EDGE_SEAM, + TH_EDGE_FACESEL, + TH_FACE, + TH_FACE_SELECT, + TH_NORMAL, + TH_FACE_DOT, + TH_FACEDOT_SIZE, + TH_CFRAME, + + TH_SYNTAX_B, + TH_SYNTAX_V, + TH_SYNTAX_C, + TH_SYNTAX_L, + TH_SYNTAX_N, + + TH_BONE_SOLID, + TH_BONE_POSE, + + TH_STRIP, + TH_STRIP_SELECT, + + TH_LAMP, + + TH_NODE, + TH_NODE_IN_OUT, + TH_NODE_OPERATOR, + TH_NODE_CONVERTOR, + TH_NODE_GROUP, + + TH_SEQ_MOVIE, + TH_SEQ_IMAGE, + TH_SEQ_SCENE, + TH_SEQ_AUDIO, + TH_SEQ_EFFECT, + TH_SEQ_PLUGIN, + TH_SEQ_TRANSITION, + TH_SEQ_META, + + TH_EDGE_SHARP, + TH_EDITMESH_ACTIVE, +}; +/* XXX WARNING: previous is saved in file, so do not change order! */ + +/* theme drawtypes */ +#define TH_MINIMAL 0 +#define TH_SHADED 1 +#define TH_ROUNDED 2 +#define TH_OLDSKOOL 3 + +/* specific defines per space should have higher define values */ + +struct bTheme; + +// THE CODERS API FOR THEMES: + +// sets the color +void BIF_ThemeColor(int colorid); + +// sets the color plus alpha +void BIF_ThemeColor4(int colorid); + +// sets color plus offset for shade +void BIF_ThemeColorShade(int colorid, int offset); + +// sets color plus offset for alpha +void BIF_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset); + +// sets color, which is blend between two theme colors +void BIF_ThemeColorBlend(int colorid1, int colorid2, float fac); +// same, with shade offset +void BIF_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset); + +// returns one value, not scaled +float BIF_GetThemeValuef(int colorid); +int BIF_GetThemeValue(int colorid); + +// get three color values, scaled to 0.0-1.0 range +void BIF_GetThemeColor3fv(int colorid, float *col); + +// get the 3 or 4 byte values +void BIF_GetThemeColor3ubv(int colorid, char *col); +void BIF_GetThemeColor4ubv(int colorid, char *col); + +// get a theme color from specified space type +void BIF_GetThemeColorType4ubv(int colorid, int spacetype, char *col); + +// blends and shades between two color pointers +void BIF_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset); + +// get a 3 byte color, blended and shaded between two other char color pointers +void BIF_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset); + + +struct ScrArea; + +// internal (blender) usage only, for init and set active +void BIF_InitTheme(void); +void BIF_SetTheme(struct ScrArea *sa); +void BIF_resources_init (void); +void BIF_resources_free (void); +void BIF_colors_init (void); +void BIF_load_ui_colors (void); + +/* only for buttons in theme editor! */ +char *BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); +char *BIF_ThemeColorsPup(int spacetype); + + +void BIF_def_color (BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b); + +#endif /* BIF_ICONS_H */ diff --git a/source/blender/editors/include/ED_area.h b/source/blender/editors/include/ED_area.h index cc11ca9a2f6..dd5f47b7c86 100644 --- a/source/blender/editors/include/ED_area.h +++ b/source/blender/editors/include/ED_area.h @@ -28,15 +28,14 @@ #ifndef ED_AREA_H #define ED_AREA_H +/* the pluginnable API for export to editors */ -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_view2d_types.h" -#include "DNA_view3d_types.h" -void freespacelist(ScrArea *sa); -void duplicatespacelist(ScrArea *newarea, struct ListBase *lb1, struct ListBase *lb2); +/* calls for registering default spaces */ +void ED_spacetype_view3d(void); +/* calls for registoering operator types */ +void ED_operatortypes_screen(void); #endif /* ED_AREA_H */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index c194632b46f..991e1177e27 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -29,6 +29,33 @@ #define ED_SCREEN_H #include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_view2d_types.h" +#include "DNA_view3d_types.h" + +struct wmWindowManager; +struct wmWindow; +struct wmNotifier; + +/* regions */ +void ED_region_do_listen(ARegion *ar, struct wmNotifier *note); +void ED_region_do_draw(struct bContext *C, ARegion *ar); +void ED_region_do_refresh(struct bContext *C, ARegion *ar); + +/* spaces */ +void ED_spacetypes_init(void); + +/* areas */ +void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa); + +/* screens */ +void ED_screens_initialize(struct wmWindowManager *wm); +void ED_screen_draw(struct wmWindow *win); +void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win); +void ED_screen_do_listen(bScreen *screen, struct wmNotifier *note); +bScreen *ED_screen_duplicate(struct wmWindow *win, bScreen *sc); + +void ed_screen_keymap(struct wmWindowManager *wm); #endif /* ED_SCREEN_H */ diff --git a/source/blender/editors/interface/Makefile b/source/blender/editors/interface/Makefile index b2aeaa145f7..d029ef88851 100644 --- a/source/blender/editors/interface/Makefile +++ b/source/blender/editors/interface/Makefile @@ -28,7 +28,7 @@ # # Makes module object directory and bounces make to subdirectories. -LIBNAME = ed_screen +LIBNAME = ed_interface DIR = $(OCGDIR)/blender/$(LIBNAME) include nan_compile.mk diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c new file mode 100644 index 00000000000..4bbf2a64b53 --- /dev/null +++ b/source/blender/editors/interface/resources.c @@ -0,0 +1,921 @@ +/** + * $Id: resources.c 12755 2007-12-02 05:50:38Z aligorith $ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include <math.h> +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "MEM_guardedalloc.h" + +#include "DNA_listBase.h" +#include "DNA_userdef_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "BKE_utildefines.h" + +#include "BIF_gl.h" +#include "BIF_resources.h" +#include "BIF_interface_icons.h" + +#include "BLI_blenlib.h" + +/* global for themes */ +typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); + +static bTheme *theme_active=NULL; +static int theme_spacetype= SPACE_VIEW3D; + + +void BIF_resources_init(void) +{ + BIF_icons_init(BIFICONID_LAST+1); +} + +void BIF_resources_free(void) +{ + BIF_icons_free(); +} + + +/* ******************************************************** */ +/* THEMES */ +/* ******************************************************** */ + +char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) +{ + ThemeSpace *ts= NULL; + static char error[4]={240, 0, 240, 255}; + static char alert[4]={240, 60, 60, 255}; + static char headerdesel[4]={0,0,0,255}; + static char custom[4]={0,0,0,255}; + + char *cp= error; + + if(btheme) { + + // first check for ui buttons theme + if(colorid < TH_THEMEUI) { + + switch(colorid) { + case TH_BUT_OUTLINE: + cp= btheme->tui.outline; break; + case TH_BUT_NEUTRAL: + cp= btheme->tui.neutral; break; + case TH_BUT_ACTION: + cp= btheme->tui.action; break; + case TH_BUT_SETTING: + cp= btheme->tui.setting; break; + case TH_BUT_SETTING1: + cp= btheme->tui.setting1; break; + case TH_BUT_SETTING2: + cp= btheme->tui.setting2; break; + case TH_BUT_NUM: + cp= btheme->tui.num; break; + case TH_BUT_TEXTFIELD: + cp= btheme->tui.textfield; break; + case TH_BUT_TEXTFIELD_HI: + cp= btheme->tui.textfield_hi; break; + case TH_BUT_POPUP: + cp= btheme->tui.popup; break; + case TH_BUT_TEXT: + cp= btheme->tui.text; break; + case TH_BUT_TEXT_HI: + cp= btheme->tui.text_hi; break; + case TH_MENU_BACK: + cp= btheme->tui.menu_back; break; + case TH_MENU_ITEM: + cp= btheme->tui.menu_item; break; + case TH_MENU_HILITE: + cp= btheme->tui.menu_hilite; break; + case TH_MENU_TEXT: + cp= btheme->tui.menu_text; break; + case TH_MENU_TEXT_HI: + cp= btheme->tui.menu_text_hi; break; + + case TH_BUT_DRAWTYPE: + cp= &btheme->tui.but_drawtype; break; + + case TH_ICONFILE: + cp= btheme->tui.iconfile; break; + + case TH_REDALERT: + cp= alert; break; + case TH_CUSTOM: + cp= custom; break; + } + } + else { + + switch(spacetype) { + case SPACE_BUTS: + ts= &btheme->tbuts; + break; + case SPACE_VIEW3D: + ts= &btheme->tv3d; + break; + case SPACE_IPO: + ts= &btheme->tipo; + break; + case SPACE_FILE: + ts= &btheme->tfile; + break; + case SPACE_NLA: + ts= &btheme->tnla; + break; + case SPACE_ACTION: + ts= &btheme->tact; + break; + case SPACE_SEQ: + ts= &btheme->tseq; + break; + case SPACE_IMAGE: + ts= &btheme->tima; + break; + case SPACE_IMASEL: + ts= &btheme->timasel; + break; + case SPACE_TEXT: + ts= &btheme->text; + break; + case SPACE_OOPS: + ts= &btheme->toops; + break; + case SPACE_SOUND: + ts= &btheme->tsnd; + break; + case SPACE_INFO: + ts= &btheme->tinfo; + break; + case SPACE_TIME: + ts= &btheme->ttime; + break; + case SPACE_NODE: + ts= &btheme->tnode; + break; + default: + ts= &btheme->tv3d; + break; + } + + switch(colorid) { + case TH_BACK: + cp= ts->back; break; + case TH_TEXT: + cp= ts->text; break; + case TH_TEXT_HI: + cp= ts->text_hi; break; + case TH_HEADER: + cp= ts->header; break; + case TH_HEADERDESEL: + /* we calculate a dynamic builtin header deselect color, also for pulldowns... */ + cp= ts->header; + headerdesel[0]= cp[0]>10?cp[0]-10:0; + headerdesel[1]= cp[1]>10?cp[1]-10:0; + headerdesel[2]= cp[2]>10?cp[2]-10:0; + cp= headerdesel; + break; + case TH_PANEL: + cp= ts->panel; break; + case TH_SHADE1: + cp= ts->shade1; break; + case TH_SHADE2: + cp= ts->shade2; break; + case TH_HILITE: + cp= ts->hilite; break; + + case TH_GRID: + cp= ts->grid; break; + case TH_WIRE: + cp= ts->wire; break; + case TH_LAMP: + cp= ts->lamp; break; + case TH_SELECT: + cp= ts->select; break; + case TH_ACTIVE: + cp= ts->active; break; + case TH_GROUP: + cp= ts->group; break; + case TH_GROUP_ACTIVE: + cp= ts->group_active; break; + case TH_TRANSFORM: + cp= ts->transform; break; + case TH_VERTEX: + cp= ts->vertex; break; + case TH_VERTEX_SELECT: + cp= ts->vertex_select; break; + case TH_VERTEX_SIZE: + cp= &ts->vertex_size; break; + case TH_EDGE: + cp= ts->edge; break; + case TH_EDGE_SELECT: + cp= ts->edge_select; break; + case TH_EDGE_SEAM: + cp= ts->edge_seam; break; + case TH_EDGE_SHARP: + cp= ts->edge_sharp; break; + case TH_EDITMESH_ACTIVE: + cp= ts->editmesh_active; break; + case TH_EDGE_FACESEL: + cp= ts->edge_facesel; break; + case TH_FACE: + cp= ts->face; break; + case TH_FACE_SELECT: + cp= ts->face_select; break; + case TH_FACE_DOT: + cp= ts->face_dot; break; + case TH_FACEDOT_SIZE: + cp= &ts->facedot_size; break; + case TH_NORMAL: + cp= ts->normal; break; + case TH_BONE_SOLID: + cp= ts->bone_solid; break; + case TH_BONE_POSE: + cp= ts->bone_pose; break; + case TH_STRIP: + cp= ts->strip; break; + case TH_STRIP_SELECT: + cp= ts->strip_select; break; + case TH_CFRAME: + cp= ts->cframe; break; + + case TH_SYNTAX_B: + cp= ts->syntaxb; break; + case TH_SYNTAX_V: + cp= ts->syntaxv; break; + case TH_SYNTAX_C: + cp= ts->syntaxc; break; + case TH_SYNTAX_L: + cp= ts->syntaxl; break; + case TH_SYNTAX_N: + cp= ts->syntaxn; break; + + case TH_NODE: + cp= ts->syntaxl; break; + case TH_NODE_IN_OUT: + cp= ts->syntaxn; break; + case TH_NODE_OPERATOR: + cp= ts->syntaxb; break; + case TH_NODE_CONVERTOR: + cp= ts->syntaxv; break; + case TH_NODE_GROUP: + cp= ts->syntaxc; break; + + case TH_SEQ_MOVIE: + cp= ts->movie; break; + case TH_SEQ_IMAGE: + cp= ts->image; break; + case TH_SEQ_SCENE: + cp= ts->scene; break; + case TH_SEQ_AUDIO: + cp= ts->audio; break; + case TH_SEQ_EFFECT: + cp= ts->effect; break; + case TH_SEQ_PLUGIN: + cp= ts->plugin; break; + case TH_SEQ_TRANSITION: + cp= ts->transition; break; + case TH_SEQ_META: + cp= ts->meta; break; + + } + + } + } + + return cp; +} + +#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; + +/* initialize + Note: when you add new colors, created & saved themes need initialized + in usiblender.c, search for "versionfile" +*/ +void BIF_InitTheme(void) +{ + bTheme *btheme= U.themes.first; + + /* we search for the theme with name Default */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + if(strcmp("Default", btheme->name)==0) break; + } + + if(btheme==NULL) { + btheme= MEM_callocN(sizeof(bTheme), "theme"); + BLI_addtail(&U.themes, btheme); + strcpy(btheme->name, "Default"); + } + + BIF_SetTheme(NULL); // make sure the global used in this file is set + + /* UI buttons (todo) */ + SETCOL(btheme->tui.outline, 0xA0,0xA0,0xA0, 255); + SETCOL(btheme->tui.neutral, 0xA0,0xA0,0xA0, 255); + SETCOL(btheme->tui.action, 0xAD,0xA0,0x93, 255); + SETCOL(btheme->tui.setting, 0x8A,0x9E,0xA1, 255); + SETCOL(btheme->tui.setting1, 0xA1,0xA1,0xAE, 255); + SETCOL(btheme->tui.setting2, 0xA1,0x99,0xA7, 255); + SETCOL(btheme->tui.num, 0x90,0x90,0x90, 255); + SETCOL(btheme->tui.textfield, 0x90,0x90,0x90, 255); + SETCOL(btheme->tui.textfield_hi,0xc6,0x77,0x77, 255); + SETCOL(btheme->tui.popup, 0xA0,0xA0,0xA0, 255); + + SETCOL(btheme->tui.text, 0,0,0, 255); + SETCOL(btheme->tui.text_hi, 255, 255, 255, 255); + + SETCOL(btheme->tui.menu_back, 0xD2,0xD2,0xD2, 255); + SETCOL(btheme->tui.menu_item, 0xDA,0xDA,0xDA, 255); + SETCOL(btheme->tui.menu_hilite, 0x7F,0x7F,0x7F, 255); + SETCOL(btheme->tui.menu_text, 0, 0, 0, 255); + SETCOL(btheme->tui.menu_text_hi, 255, 255, 255, 255); + btheme->tui.but_drawtype= TH_SHADED; + + BLI_strncpy(btheme->tui.iconfile, "", sizeof(btheme->tui.iconfile)); + + /* space view3d */ + SETCOL(btheme->tv3d.back, 115, 115, 115, 255); + SETCOL(btheme->tv3d.text, 0, 0, 0, 255); + SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tv3d.header, 195, 195, 195, 255); + SETCOL(btheme->tv3d.panel, 165, 165, 165, 127); + + SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100); + SETCOL(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100); + + SETCOL(btheme->tv3d.grid, 92, 92, 92, 255); + SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255); + SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40); + SETCOL(btheme->tv3d.select, 0xff, 0x88, 0xff, 255); + SETCOL(btheme->tv3d.active, 0xff, 0xbb, 0xff, 255); + SETCOL(btheme->tv3d.group, 0x10, 0x40, 0x10, 255); + SETCOL(btheme->tv3d.group_active, 0x55, 0xbb, 0x55, 255); + SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255); + SETCOL(btheme->tv3d.vertex, 0xff, 0x70, 0xff, 255); + SETCOL(btheme->tv3d.vertex_select, 0xff, 0xff, 0x70, 255); + btheme->tv3d.vertex_size= 2; + SETCOL(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255); + SETCOL(btheme->tv3d.edge_select, 0xb0, 0xb0, 0x30, 255); + SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255); + SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255); + SETCOL(btheme->tv3d.face, 0, 50, 150, 30); + SETCOL(btheme->tv3d.face_select, 200, 100, 200, 60); + SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); + SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255); + btheme->tv3d.facedot_size= 4; + SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); + + SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255); + SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw + + + /* space buttons */ + /* to have something initialized */ + btheme->tbuts= btheme->tv3d; + + SETCOL(btheme->tbuts.back, 180, 180, 180, 255); + SETCOL(btheme->tbuts.header, 195, 195, 195, 255); + SETCOL(btheme->tbuts.panel, 255, 255, 255, 40); + + /* space ipo */ + /* to have something initialized */ + btheme->tipo= btheme->tv3d; + + SETCOL(btheme->tipo.grid, 94, 94, 94, 255); + SETCOL(btheme->tipo.back, 120, 120, 120, 255); + SETCOL(btheme->tipo.header, 195, 195, 195, 255); + SETCOL(btheme->tipo.panel, 255, 255, 255, 150); + SETCOL(btheme->tipo.shade1, 172, 172, 172, 100); + SETCOL(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100); + SETCOL(btheme->tipo.vertex, 0xff, 0x70, 0xff, 255); + SETCOL(btheme->tipo.vertex_select, 0xff, 0xff, 0x70, 255); + SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255); + btheme->tipo.vertex_size= 3; + + /* space file */ + /* to have something initialized */ + btheme->tfile= btheme->tv3d; + SETCOL(btheme->tfile.back, 128, 128, 128, 255); + SETCOL(btheme->tfile.text, 0, 0, 0, 255); + SETCOL(btheme->tfile.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tfile.header, 182, 182, 182, 255); + SETCOL(btheme->tfile.hilite, 0xA0, 0xA0, 0xD0, 255); // selected files + + + /* space action */ + btheme->tact= btheme->tv3d; + SETCOL(btheme->tact.back, 116, 116, 116, 255); + SETCOL(btheme->tact.text, 0, 0, 0, 255); + SETCOL(btheme->tact.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tact.header, 182, 182, 182, 255); + SETCOL(btheme->tact.grid, 94, 94, 94, 255); + SETCOL(btheme->tact.face, 166, 166, 166, 255); // RVK + SETCOL(btheme->tact.shade1, 172, 172, 172, 255); // sliders + SETCOL(btheme->tact.shade2, 84, 44, 31, 100); // bar + SETCOL(btheme->tact.hilite, 17, 27, 60, 100); // bar + SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 255); + SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 255); + + /* space nla */ + btheme->tnla= btheme->tv3d; + SETCOL(btheme->tnla.back, 116, 116, 116, 255); + SETCOL(btheme->tnla.text, 0, 0, 0, 255); + SETCOL(btheme->tnla.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tnla.header, 182, 182, 182, 255); + SETCOL(btheme->tnla.grid, 94, 94, 94, 255); + SETCOL(btheme->tnla.shade1, 172, 172, 172, 255); // sliders + SETCOL(btheme->tnla.shade2, 84, 44, 31, 100); // bar + SETCOL(btheme->tnla.hilite, 17, 27, 60, 100); // bar + SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255); + SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255); + + /* space seq */ + btheme->tseq= btheme->tv3d; + SETCOL(btheme->tseq.back, 116, 116, 116, 255); + SETCOL(btheme->tseq.movie, 81, 105, 135, 255); + SETCOL(btheme->tseq.image, 109, 88, 129, 255); + SETCOL(btheme->tseq.scene, 78, 152, 62, 255); + SETCOL(btheme->tseq.audio, 46, 143, 143, 255); + SETCOL(btheme->tseq.effect, 169, 84, 124, 255); + SETCOL(btheme->tseq.plugin, 126, 126, 80, 255); + SETCOL(btheme->tseq.transition, 162, 95, 111, 255); + SETCOL(btheme->tseq.meta, 109, 145, 131, 255); + + + /* space image */ + btheme->tima= btheme->tv3d; + SETCOL(btheme->tima.back, 53, 53, 53, 255); + SETCOL(btheme->tima.vertex, 0xff, 0x70, 0xff, 255); + SETCOL(btheme->tima.vertex_select, 0xff, 0xff, 0x70, 255); + btheme->tima.vertex_size= 2; + SETCOL(btheme->tima.face, 0, 50, 150, 40); + SETCOL(btheme->tima.face_select, 200, 100, 200, 80); + + /* space imageselect */ + btheme->timasel= btheme->tv3d; + SETCOL(btheme->timasel.active, 195, 195, 195, 255); /* active tile */ + SETCOL(btheme->timasel.grid, 94, 94, 94, 255); /* active file text */ + SETCOL(btheme->timasel.back, 110, 110, 110, 255); + SETCOL(btheme->timasel.header, 195, 195, 195, 255); + SETCOL(btheme->timasel.shade1, 94, 94, 94, 255); /* bar */ + SETCOL(btheme->timasel.shade2, 172, 172, 172, 255); /* sliders */ + SETCOL(btheme->timasel.hilite, 17, 27, 60, 100); /* selected tile */ + SETCOL(btheme->timasel.text, 0, 0, 0, 255); + SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255); + SETCOL(btheme->timasel.panel, 132, 132, 132, 255); + + /* space text */ + btheme->text= btheme->tv3d; + SETCOL(btheme->text.back, 153, 153, 153, 255); + SETCOL(btheme->text.shade1, 143, 143, 143, 255); + SETCOL(btheme->text.shade2, 0xc6, 0x77, 0x77, 255); + SETCOL(btheme->text.hilite, 255, 0, 0, 255); + + /* syntax highlighting */ + SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ + SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */ + SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */ + SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */ + SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */ + + /* space oops */ + btheme->toops= btheme->tv3d; + SETCOL(btheme->toops.back, 153, 153, 153, 255); + + /* space info */ + btheme->tinfo= btheme->tv3d; + SETCOL(btheme->tinfo.back, 153, 153, 153, 255); + + /* space sound */ + btheme->tsnd= btheme->tv3d; + SETCOL(btheme->tsnd.back, 153, 153, 153, 255); + SETCOL(btheme->tsnd.shade1, 173, 173, 173, 255); // sliders + SETCOL(btheme->tsnd.grid, 140, 140, 140, 255); + + /* space time */ + btheme->ttime= btheme->tsnd; // same as sound space + + /* space node, re-uses syntax color storage */ + btheme->tnode= btheme->tv3d; + SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255); + SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */ + SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */ + SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */ + SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */ + SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ + +} + +char *BIF_ThemeColorsPup(int spacetype) +{ + char *cp= MEM_callocN(32*32, "theme pup"); + char *str = cp; + + if(spacetype==0) { + str += sprintf(str, "Outline %%x%d|", TH_BUT_OUTLINE); + str += sprintf(str, "Neutral %%x%d|", TH_BUT_NEUTRAL); + str += sprintf(str, "Action %%x%d|", TH_BUT_ACTION); + str += sprintf(str, "Setting %%x%d|", TH_BUT_SETTING); + str += sprintf(str, "Special Setting 1%%x%d|", TH_BUT_SETTING1); + str += sprintf(str, "Special Setting 2 %%x%d|", TH_BUT_SETTING2); + str += sprintf(str, "Number Input %%x%d|", TH_BUT_NUM); + str += sprintf(str, "Text Input %%x%d|", TH_BUT_TEXTFIELD); + str += sprintf(str, "Text Input Highlight %%x%d|", TH_BUT_TEXTFIELD_HI); + str += sprintf(str, "Popup %%x%d|", TH_BUT_POPUP); + str += sprintf(str, "Text %%x%d|", TH_BUT_TEXT); + str += sprintf(str, "Text Highlight %%x%d|", TH_BUT_TEXT_HI); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Menu Background %%x%d|", TH_MENU_BACK); + str += sprintf(str, "Menu Item %%x%d|", TH_MENU_ITEM); + str += sprintf(str, "Menu Item Highlight %%x%d|", TH_MENU_HILITE); + str += sprintf(str, "Menu Text %%x%d|", TH_MENU_TEXT); + str += sprintf(str, "Menu Text Highlight %%x%d|", TH_MENU_TEXT_HI); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Drawtype %%x%d|", TH_BUT_DRAWTYPE); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Icon File %%x%d|", TH_ICONFILE); + } + else { + // first defaults for each space + str += sprintf(str, "Background %%x%d|", TH_BACK); + str += sprintf(str, "Text %%x%d|", TH_TEXT); + str += sprintf(str, "Text Highlight %%x%d|", TH_TEXT_HI); + str += sprintf(str, "Header %%x%d|", TH_HEADER); + + switch(spacetype) { + case SPACE_VIEW3D: + str += sprintf(str, "Panel %%x%d|", TH_PANEL); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "Wire %%x%d|", TH_WIRE); + str += sprintf(str, "Lamp %%x%d|", TH_LAMP); + str += sprintf(str, "Object Selected %%x%d|", TH_SELECT); + str += sprintf(str, "Object Active %%x%d|", TH_ACTIVE); + str += sprintf(str, "Object Grouped %%x%d|", TH_GROUP); + str += sprintf(str, "Object Grouped Active %%x%d|", TH_GROUP_ACTIVE); + str += sprintf(str, "Transform %%x%d|", TH_TRANSFORM); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); + str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); + str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); + str += sprintf(str, "Edge Selected %%x%d|", TH_EDGE_SELECT); + str += sprintf(str, "Edge Seam %%x%d|", TH_EDGE_SEAM); + str += sprintf(str, "Edge Sharp %%x%d|", TH_EDGE_SHARP); + str += sprintf(str, "Edge UV Face Select %%x%d|", TH_EDGE_FACESEL); + str += sprintf(str, "Face (transp) %%x%d|", TH_FACE); + str += sprintf(str, "Face Selected (transp) %%x%d|", TH_FACE_SELECT); + str += sprintf(str, "Face Dot Selected %%x%d|", TH_FACE_DOT); + str += sprintf(str, "Face Dot Size %%x%d|", TH_FACEDOT_SIZE); + str += sprintf(str, "Active Vert/Edge/Face %%x%d|", TH_EDITMESH_ACTIVE); + str += sprintf(str, "Normal %%x%d|", TH_NORMAL); + str += sprintf(str, "Bone Solid %%x%d|", TH_BONE_SOLID); + str += sprintf(str, "Bone Pose %%x%d", TH_BONE_POSE); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_IPO: + str += sprintf(str, "Panel %%x%d|", TH_PANEL); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "Window Sliders %%x%d|", TH_SHADE1); + str += sprintf(str, "Ipo Channels %%x%d|", TH_SHADE2); + str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); + str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); + str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_FILE: + str += sprintf(str, "Selected file %%x%d", TH_HILITE); + break; + case SPACE_NLA: + //str += sprintf(str, "Panel %%x%d|", TH_PANEL); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "View Sliders %%x%d|", TH_SHADE1); + str += sprintf(str, "Bars %%x%d|", TH_SHADE2); + str += sprintf(str, "Bars selected %%x%d|", TH_HILITE); + str += sprintf(str, "Strips %%x%d|", TH_STRIP); + str += sprintf(str, "Strips selected %%x%d|", TH_STRIP_SELECT); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_ACTION: + //str += sprintf(str, "Panel %%x%d|", TH_PANEL); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "RVK Sliders %%x%d|", TH_FACE); + str += sprintf(str, "View Sliders %%x%d|", TH_SHADE1); + str += sprintf(str, "Channels %%x%d|", TH_SHADE2); + str += sprintf(str, "Channels Selected %%x%d|", TH_HILITE); + str += sprintf(str, "Long Key %%x%d|", TH_STRIP); + str += sprintf(str, "Long Key selected %%x%d|", TH_STRIP_SELECT); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_IMAGE: + str += sprintf(str, "%%l|"); + str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); + str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); + str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); + str += sprintf(str, "Face %%x%d|", TH_FACE); + str += sprintf(str, "Face Selected %%x%d", TH_FACE_SELECT); + break; + case SPACE_SEQ: + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "Window Sliders %%x%d|", TH_SHADE1); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Movie Strip %%x%d|", TH_SEQ_MOVIE); + str += sprintf(str, "Image Strip %%x%d|", TH_SEQ_IMAGE); + str += sprintf(str, "Scene Strip %%x%d|", TH_SEQ_SCENE); + str += sprintf(str, "Audio Strip %%x%d|", TH_SEQ_AUDIO); + str += sprintf(str, "Effect Strip %%x%d|", TH_SEQ_EFFECT); + str += sprintf(str, "Plugin Strip %%x%d|", TH_SEQ_PLUGIN); + str += sprintf(str, "Transition Strip %%x%d|", TH_SEQ_TRANSITION); + str += sprintf(str, "Meta Strip %%x%d|", TH_SEQ_META); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_SOUND: + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "Window Slider %%x%d|", TH_SHADE1); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_BUTS: + str += sprintf(str, "Panel %%x%d|", TH_PANEL); + break; + case SPACE_IMASEL: + str += sprintf(str, "Tiles %%x%d|", TH_PANEL); + str += sprintf(str, "Scrollbar %%x%d|", TH_SHADE1); + str += sprintf(str, "Scroll Handle %%x%d|", TH_SHADE2); + str += sprintf(str, "Selected File %%x%d|", TH_HILITE); + str += sprintf(str, "Active File %%x%d|", TH_ACTIVE); + str += sprintf(str, "Active File Text%%x%d|", TH_GRID); + break; + case SPACE_TEXT: + str += sprintf(str, "Scroll Bar %%x%d|", TH_SHADE1); + str += sprintf(str, "Selected Text %%x%d|", TH_SHADE2); + str += sprintf(str, "Cursor %%x%d|", TH_HILITE); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Syntax Builtin %%x%d|", TH_SYNTAX_B); + str += sprintf(str, "Syntax Special %%x%d|", TH_SYNTAX_V); + str += sprintf(str, "Syntax Comment %%x%d|", TH_SYNTAX_C); + str += sprintf(str, "Syntax Strings %%x%d|", TH_SYNTAX_L); + str += sprintf(str, "Syntax Numbers %%x%d|", TH_SYNTAX_N); + break; + case SPACE_TIME: + str += sprintf(str, "Grid %%x%d|", TH_GRID); + str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); + break; + case SPACE_NODE: + str += sprintf(str, "Wires %%x%d|", TH_WIRE); + str += sprintf(str, "Wires Select %%x%d|", TH_EDGE_SELECT); + str += sprintf(str, "%%l|"); + str += sprintf(str, "Node Backdrop %%x%d|", TH_NODE); + str += sprintf(str, "In/Out Node %%x%d|", TH_NODE_IN_OUT); + str += sprintf(str, "Convertor Node %%x%d|", TH_NODE_CONVERTOR); + str += sprintf(str, "Operator Node %%x%d|", TH_NODE_OPERATOR); + str += sprintf(str, "Group Node %%x%d|", TH_NODE_GROUP); + break; + } + } + return cp; +} + +void BIF_SetTheme(ScrArea *sa) +{ + if(sa==NULL) { // called for safety, when delete themes + theme_active= U.themes.first; + theme_spacetype= SPACE_VIEW3D; + } + else { + // later on, a local theme can be found too + theme_active= U.themes.first; + theme_spacetype= sa->spacetype; + + } +} + +// for space windows only +void BIF_ThemeColor(int colorid) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + glColor3ub(cp[0], cp[1], cp[2]); + +} + +// plus alpha +void BIF_ThemeColor4(int colorid) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + glColor4ub(cp[0], cp[1], cp[2], cp[3]); + +} + +// set the color with offset for shades +void BIF_ThemeColorShade(int colorid, int offset) +{ + int r, g, b; + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r= offset + (int) cp[0]; + CLAMP(r, 0, 255); + g= offset + (int) cp[1]; + CLAMP(g, 0, 255); + b= offset + (int) cp[2]; + CLAMP(b, 0, 255); + //glColor3ub(r, g, b); + glColor4ub(r, g, b, cp[3]); +} +void BIF_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) +{ + int r, g, b, a; + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r= coloffset + (int) cp[0]; + CLAMP(r, 0, 255); + g= coloffset + (int) cp[1]; + CLAMP(g, 0, 255); + b= coloffset + (int) cp[2]; + CLAMP(b, 0, 255); + a= alphaoffset + (int) cp[3]; + CLAMP(a, 0, 255); + glColor4ub(r, g, b, a); +} + +// blend between to theme colors, and set it +void BIF_ThemeColorBlend(int colorid1, int colorid2, float fac) +{ + int r, g, b; + char *cp1, *cp2; + + cp1= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; + r= floor((1.0-fac)*cp1[0] + fac*cp2[0]); + g= floor((1.0-fac)*cp1[1] + fac*cp2[1]); + b= floor((1.0-fac)*cp1[2] + fac*cp2[2]); + + glColor3ub(r, g, b); +} + +// blend between to theme colors, shade it, and set it +void BIF_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) +{ + int r, g, b; + char *cp1, *cp2; + + cp1= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; + r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); + g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); + b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + + r= r<0?0:(r>255?255:r); + g= g<0?0:(g>255?255:g); + b= b<0?0:(b>255?255:b); + + glColor3ub(r, g, b); +} + +// get individual values, not scaled +float BIF_GetThemeValuef(int colorid) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + return ((float)cp[0]); + +} + +// get individual values, not scaled +int BIF_GetThemeValue(int colorid) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + return ((int) cp[0]); + +} + + +// get the color, range 0.0-1.0 +void BIF_GetThemeColor3fv(int colorid, float *col) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + col[0]= ((float)cp[0])/255.0; + col[1]= ((float)cp[1])/255.0; + col[2]= ((float)cp[2])/255.0; +} + +// get the color, in char pointer +void BIF_GetThemeColor3ubv(int colorid, char *col) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + col[0]= cp[0]; + col[1]= cp[1]; + col[2]= cp[2]; +} + +// get the color, in char pointer +void BIF_GetThemeColor4ubv(int colorid, char *col) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + col[0]= cp[0]; + col[1]= cp[1]; + col[2]= cp[2]; + col[3]= cp[3]; +} + +void BIF_GetThemeColorType4ubv(int colorid, int spacetype, char *col) +{ + char *cp; + + cp= BIF_ThemeGetColorPtr(theme_active, spacetype, colorid); + col[0]= cp[0]; + col[1]= cp[1]; + col[2]= cp[2]; + col[3]= cp[3]; +} + +// blends and shades between two char color pointers +void BIF_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset) +{ + int r, g, b; + + if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; + r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); + g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); + b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + + r= r<0?0:(r>255?255:r); + g= g<0?0:(g>255?255:g); + b= b<0?0:(b>255?255:b); + + glColor3ub(r, g, b); +} + +// get a 3 byte color, blended and shaded between two other char color pointers +void BIF_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset) +{ + int r, g, b; + + if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; + r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); + g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); + b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + + r= r<0?0:(r>255?255:r); + g= g<0?0:(g>255?255:g); + b= b<0?0:(b>255?255:b); + + col[0] = r; + col[1] = g; + col[2] = b; +} diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt new file mode 100644 index 00000000000..8539db101e3 --- /dev/null +++ b/source/blender/editors/screen/CMakeLists.txt @@ -0,0 +1,86 @@ +# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $ +# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. The Blender +# Foundation also sells licenses for use in proprietary software under +# the Blender License. See http://www.blender.org/BL/ for information +# about this. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL/BL DUAL LICENSE BLOCK ***** + +FILE(GLOB SRC */*.c) + +SET(INC ../windowmanager + ../editors/include + ../../../intern/guardedalloc ../../../intern/memutil + ../blenlib ../makesdna ../blenkernel + ../include ../../../intern/bmfont ../imbuf ../render/extern/include + ../../../intern/bsp/extern ../radiosity/extern/include + ../../../intern/decimation/extern ../blenloader ../python + ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue + ../quicktime ../../../intern/elbeem/extern + ../../../intern/ghost ../../../intern/opennl/extern + ../nodes + ${PYTHON_INC} + ${SDL_INC} +) + +IF(WITH_INTERNATIONAL) + SET(INC ${INC} ../ftfont) + ADD_DEFINITIONS(-DINTERNATIONAL) + ADD_DEFINITIONS(-DFTGL_STATIC_LIBRARY) +ENDIF(WITH_INTERNATIONAL) + +IF(WITH_OPENEXR) + ADD_DEFINITIONS(-DWITH_OPENEXR) +ENDIF(WITH_OPENEXR) + +IF(WITH_QUICKTIME) + SET(INC ${INC} ${QUICKTIME_INC}) + ADD_DEFINITIONS(-DWITH_QUICKTIME) +ENDIF(WITH_QUICKTIME) + +IF(WITH_FFMPEG) + SET(INC ${INC} ${FFMPEG_INC}) + ADD_DEFINITIONS(-DWITH_FFMPEG) +ENDIF(WITH_FFMPEG) + +IF(WIN32) + SET(INC ${INC} ${PTHREADS_INC}) +ENDIF(WIN32) + +IF(WITH_VERSE) + SET(INC ${INC} ${VERSE_INC}) + ADD_DEFINITIONS(-DWITH_VERSE) +ENDIF(WITH_VERSE) + +# TODO buildinfo +IF(BF_BUILDINFO) + ADD_DEFINITIONS(-DNAN_BUILDINFO) +ENDIF(BF_BUILDINFO) + +BLENDERLIB_NOLIST(bf_editors "${SRC}" "${INC}") + +IF(WITH_VERSE) + ADD_DEPENDENCIES(bf_editors mkprot verse) +ENDIF(WITH_VERSE) + diff --git a/source/blender/editors/screen/Makefile b/source/blender/editors/screen/Makefile index b2aeaa145f7..11cd8f264ad 100644 --- a/source/blender/editors/screen/Makefile +++ b/source/blender/editors/screen/Makefile @@ -37,15 +37,15 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) CPPFLAGS += -I$(OPENGL_HEADERS) -CPPFLAGS += -I$(NAN_BMFONT)/include -CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include - +# not very neat.... CPPFLAGS += -I../../windowmanager -CPPFLAGS += -I../../blenkernel CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index d6081df51b3..ec56e557c79 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -1,9 +1,7 @@ #!/usr/bin/python Import ('env') -sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf ../../windowmanager' -incs += ' #/intern/guardedalloc' - -env.BlenderLib ( 'bf_editor_screen', sources, Split(incs), [], libtype=['core','intern'], priority=[5, 25] ) +SConscript(['area/SConscript', + 'datafiles/SConscript', + 'screen/SConscript']) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c new file mode 100644 index 00000000000..5acc3091364 --- /dev/null +++ b/source/blender/editors/screen/area.c @@ -0,0 +1,348 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_rand.h" + +#include "BKE_global.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "ED_area.h" +#include "ED_screen.h" + +#include "WM_api.h" +#include "WM_types.h" +#include "wm_subwindow.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "BPY_extern.h" + +#include "screen_intern.h" + +/* general area and region code */ + +static void region_draw_emboss(ARegion *ar) +{ + short winx, winy; + + winx= ar->winrct.xmax-ar->winrct.xmin; + winy= ar->winrct.ymax-ar->winrct.ymin; + + /* set transp line */ + glEnable( GL_BLEND ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + + /* right */ + glColor4ub(0,0,0, 50); + sdrawline(winx, 0, winx, winy); + + /* bottom */ + glColor4ub(0,0,0, 80); + sdrawline(0, 0, winx, 0); + + /* top */ + glColor4ub(255,255,255, 60); + sdrawline(0, winy, winx, winy); + + /* left */ + glColor4ub(255,255,255, 50); + sdrawline(0, 0, 0, winy); + + glDisable( GL_BLEND ); +} + + +void ED_region_do_listen(ARegion *ar, wmNotifier *note) +{ + if(ar->type->listener) + ar->type->listener(ar, note); + + /* generic notes */ + if(note->type==WM_NOTE_REDRAW) + ar->do_draw= 1; + if(note->type==WM_NOTE_REFRESH) + ar->do_refresh= 1; + +} + +void ED_region_do_draw(bContext *C, ARegion *ar) +{ + ARegionType *at= ar->type; + + wm_subwindow_set(C->window, ar->swinid); + + if(ar->swinid && at->draw) { + at->draw(C, ar); + } + else { + float fac= 0.1*ar->swinid; + + glClearColor(0.5, fac, 1.0f-fac, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + fac= BLI_frand(); + glColor3f(fac, fac, fac); + glRecti(2, 2, 12, 12); + + region_draw_emboss(ar); + } + + ar->do_draw= 0; +} + +void ED_region_do_refresh(bContext *C, ARegion *ar) +{ + ARegionType *at= ar->type; + + /* refresh can be called before window opened */ + if(ar->swinid) + wm_subwindow_set(C->window, ar->swinid); + + if (at->refresh) { + at->refresh(C, ar); + } + + ar->do_refresh= 0; +} + +/* *************************************************************** */ + + +static int rct_fits(rcti *rect, char dir, int size) +{ + if(dir=='h') { + return rect->xmax-rect->xmin - size; + } + else { // 'v' + return rect->ymax-rect->ymin - size; + } +} + +static void region_rect_recursive(ARegion *ar, rcti *remainder) +{ + if(ar==NULL) + return; + + /* clear state flag first */ + ar->flag &= ~RGN_FLAG_TOO_SMALL; + + if(ar->size<ar->minsize) + ar->size= ar->minsize; + + /* hidden is user flag */ + if(ar->flag & RGN_FLAG_HIDDEN); + /* remainder is too small for any usage */ + else if( rct_fits(remainder, 'v', 1)==0 || rct_fits(remainder, 'h', 1) < 0 ) { + ar->flag |= RGN_FLAG_TOO_SMALL; + } + else if(ar->alignment==RGN_ALIGN_NONE) { + /* typically last region */ + ar->winrct= *remainder; + BLI_init_rcti(remainder, 0, 0, 0, 0); + } + else if(ar->alignment==RGN_ALIGN_TOP || ar->alignment==RGN_ALIGN_BOTTOM) { + + if( rct_fits(remainder, 'v', ar->minsize) < 0 ) { + ar->flag |= RGN_FLAG_TOO_SMALL; + } + else { + int fac= rct_fits(remainder, 'v', ar->size); + + if(fac < 0 ) + ar->size += fac; + + ar->winrct= *remainder; + + if(ar->alignment==RGN_ALIGN_TOP) { + ar->winrct.ymin= ar->winrct.ymax - ar->size; + remainder->ymax= ar->winrct.ymin-1; + } + else { + ar->winrct.ymax= ar->winrct.ymin + ar->size; + remainder->ymin= ar->winrct.ymax+1; + } + } + } + else if(ar->alignment==RGN_ALIGN_LEFT || ar->alignment==RGN_ALIGN_RIGHT) { + + if( rct_fits(remainder, 'h', ar->minsize) < 0 ) { + ar->flag |= RGN_FLAG_TOO_SMALL; + } + else { + int fac= rct_fits(remainder, 'h', ar->size); + + if(fac < 0 ) + ar->size += fac; + + ar->winrct= *remainder; + + if(ar->alignment==RGN_ALIGN_RIGHT) { + ar->winrct.xmin= ar->winrct.xmax - ar->size; + remainder->xmax= ar->winrct.xmin-1; + } + else { + ar->winrct.xmax= ar->winrct.xmin + ar->size; + remainder->xmin= ar->winrct.xmax+1; + } + } + } + else { + /* percentage subdiv*/ + ar->winrct= *remainder; + + if(ar->alignment==RGN_ALIGN_HSPLIT) { + ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2; + remainder->xmin= ar->winrct.xmax+1; + } + else { + ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2; + remainder->ymin= ar->winrct.ymax+1; + } + } + + region_rect_recursive(ar->next, remainder); +} + +static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) +{ + + if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1; + else sa->totrct.xmin= sa->v1->vec.x; + if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1; + else sa->totrct.xmax= sa->v4->vec.x; + + if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1; + else sa->totrct.ymin= sa->v1->vec.y; + if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1; + else sa->totrct.ymax= sa->v2->vec.y; + + /* for speedup */ + sa->winx= sa->totrct.xmax-sa->totrct.xmin+1; + sa->winy= sa->totrct.ymax-sa->totrct.ymin+1; +} + +/* called in screen_refresh, or screens_init */ +void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) +{ + ARegion *ar; + rcti rect; + + /* set typedefinitions */ + sa->type= BKE_spacetype_from_id(sa->spacetype); + if(sa->type==NULL) { + sa->spacetype= SPACE_VIEW3D; + sa->type= BKE_spacetype_from_id(sa->spacetype); + } + + area_calc_totrct(sa, win->sizex, win->sizey); + + /* regiontype callback, it should create/verify the amount of subregions with minsizes etc */ + if(sa->type->init) + sa->type->init(sa); + + /* region rect sizes */ + rect= sa->totrct; + region_rect_recursive(sa->regionbase.first, &rect); + + /* region windows */ + for(ar= sa->regionbase.first; ar; ar= ar->next) { + if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if(ar->swinid) + wm_subwindow_close(win, ar->swinid); + ar->swinid= 0; + } + else if(ar->swinid==0) + ar->swinid= wm_subwindow_open(win, &ar->winrct); + else + wm_subwindow_position(win, ar->swinid, &ar->winrct); + } +} + +/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */ +/* area vertices were set */ + +void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) +{ + Panel *pa1, *pa2, *patab; + ARegion *ar; + + sa1->headertype= sa2->headertype; + sa1->spacetype= sa2->spacetype; + + if(swap_space) { + SWAP(ListBase, sa1->spacedata, sa2->spacedata); + /* exception: ensure preview is reset */ +// if(sa1->spacetype==SPACE_VIEW3D) +// XXX BIF_view3d_previewrender_free(sa1->spacedata.first); + } + else { + BKE_spacedata_freelist(&sa1->spacedata); + BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata); + } + + BLI_freelistN(&sa1->panels); + BLI_duplicatelist(&sa1->panels, &sa2->panels); + + /* copy panel pointers */ + for(pa1= sa1->panels.first; pa1; pa1= pa1->next) { + + patab= sa1->panels.first; + pa2= sa2->panels.first; + while(patab) { + if( pa1->paneltab == pa2) { + pa1->paneltab = patab; + break; + } + patab= patab->next; + pa2= pa2->next; + } + } + + /* regions */ + BLI_freelistN(&sa1->regionbase); + BLI_duplicatelist(&sa1->regionbase, &sa2->regionbase); + for(ar= sa1->regionbase.first; ar; ar= ar->next) + ar->swinid= 0; + + /* scripts */ + BPY_free_scriptlink(&sa1->scriptlink); + sa1->scriptlink= sa2->scriptlink; + BPY_copy_scriptlink(&sa1->scriptlink); /* copies internal pointers */ + +} + + diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c new file mode 100644 index 00000000000..a601b301da6 --- /dev/null +++ b/source/blender/editors/screen/glutil.c @@ -0,0 +1,756 @@ +/** + * $Id: glutil.c 11920 2007-09-02 17:25:03Z elubie $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdio.h> +#include <math.h> +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_vec_types.h" +#include "DNA_listBase.h" + +#include "BKE_utildefines.h" + +#include "BLI_arithb.h" +#include "BLI_threads.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif + + +/* ******************************************** */ + +void fdrawline(float x1, float y1, float x2, float y2) +{ + float v[2]; + + glBegin(GL_LINE_STRIP); + v[0] = x1; v[1] = y1; + glVertex2fv(v); + v[0] = x2; v[1] = y2; + glVertex2fv(v); + glEnd(); +} + +void fdrawbox(float x1, float y1, float x2, float y2) +{ + float v[2]; + + glBegin(GL_LINE_STRIP); + + v[0] = x1; v[1] = y1; + glVertex2fv(v); + v[0] = x1; v[1] = y2; + glVertex2fv(v); + v[0] = x2; v[1] = y2; + glVertex2fv(v); + v[0] = x2; v[1] = y1; + glVertex2fv(v); + v[0] = x1; v[1] = y1; + glVertex2fv(v); + + glEnd(); +} + +void sdrawline(short x1, short y1, short x2, short y2) +{ + short v[2]; + + glBegin(GL_LINE_STRIP); + v[0] = x1; v[1] = y1; + glVertex2sv(v); + v[0] = x2; v[1] = y2; + glVertex2sv(v); + glEnd(); +} + +void sdrawbox(short x1, short y1, short x2, short y2) +{ + short v[2]; + + glBegin(GL_LINE_STRIP); + + v[0] = x1; v[1] = y1; + glVertex2sv(v); + v[0] = x1; v[1] = y2; + glVertex2sv(v); + v[0] = x2; v[1] = y2; + glVertex2sv(v); + v[0] = x2; v[1] = y1; + glVertex2sv(v); + v[0] = x1; v[1] = y1; + glVertex2sv(v); + + glEnd(); +} + + +/* ******************************************** */ + + /* Invert line handling */ + +#define glToggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode)) + +void set_inverted_drawing(int enable) +{ + glLogicOp(enable?GL_INVERT:GL_COPY); + + /* Use GL_BLEND_EQUATION_EXT on sgi (if we have it), + * apparently GL_COLOR_LOGIC_OP doesn't work on O2? + * Is this an sgi bug or our bug? + */ +#if defined(__sgi) && defined(GL_BLEND_EQUATION_EXT) + glBlendEquationEXT(enable?GL_LOGIC_OP:GL_FUNC_ADD_EXT); + glToggle(GL_BLEND, enable); +#else + glToggle(GL_COLOR_LOGIC_OP, enable); +#endif + + glToggle(GL_DITHER, !enable); +} + +void sdrawXORline(int x0, int y0, int x1, int y1) +{ + if(x0==x1 && y0==y1) return; + + set_inverted_drawing(1); + + glBegin(GL_LINES); + glVertex2i(x0, y0); + glVertex2i(x1, y1); + glEnd(); + + set_inverted_drawing(0); +} + +void glutil_draw_front_xor_line(int x0, int y0, int x1, int y1) +{ + glReadBuffer(GL_FRONT); + glDrawBuffer(GL_FRONT); + sdrawXORline(x0, y0, x1, y1); + glFlush(); + glReadBuffer(GL_BACK); + glDrawBuffer(GL_BACK); + +} + +void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) +{ + static short old[4][2][2]; + static char flags[4]= {0, 0, 0, 0}; + + /* with builtin memory, max 4 lines */ + + set_inverted_drawing(1); + + glBegin(GL_LINES); + if(nr== -1) { /* flush */ + for (nr=0; nr<4; nr++) { + if (flags[nr]) { + glVertex2sv(old[nr][0]); + glVertex2sv(old[nr][1]); + flags[nr]= 0; + } + } + } else { + if(nr>=0 && nr<4) { + if(flags[nr]) { + glVertex2sv(old[nr][0]); + glVertex2sv(old[nr][1]); + } + + old[nr][0][0]= x0; + old[nr][0][1]= y0; + old[nr][1][0]= x1; + old[nr][1][1]= y1; + + flags[nr]= 1; + } + + glVertex2i(x0, y0); + glVertex2i(x1, y1); + } + glEnd(); + + set_inverted_drawing(0); +} + +void fdrawXORellipse(float xofs, float yofs, float hw, float hh) +{ + if(hw==0) return; + + set_inverted_drawing(1); + + glPushMatrix(); + glTranslatef(xofs, yofs, 0.0); + glScalef(1,hh/hw,1); + glutil_draw_lined_arc(0.0, M_PI*2.0, hw, 20); + glPopMatrix(); + + set_inverted_drawing(0); +} +void fdrawXORcirc(float xofs, float yofs, float rad) +{ + set_inverted_drawing(1); + + glPushMatrix(); + glTranslatef(xofs, yofs, 0.0); + glutil_draw_lined_arc(0.0, M_PI*2.0, rad, 20); + glPopMatrix(); + + set_inverted_drawing(0); +} + +void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments) { + int i; + + glBegin(GL_TRIANGLE_FAN); + glVertex2f(0.0, 0.0); + for (i=0; i<nsegments; i++) { + float t= (float) i/(nsegments-1); + float cur= start + t*angle; + + glVertex2f(cos(cur)*radius, sin(cur)*radius); + } + glEnd(); +} + +void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments) { + int i; + + glBegin(GL_LINE_STRIP); + for (i=0; i<nsegments; i++) { + float t= (float) i/(nsegments-1); + float cur= start + t*angle; + + glVertex2f(cos(cur)*radius, sin(cur)*radius); + } + glEnd(); +} + +int glaGetOneInteger(int param) +{ + GLint i; + glGetIntegerv(param, &i); + return i; +} + +float glaGetOneFloat(int param) +{ + GLfloat v; + glGetFloatv(param, &v); + return v; +} + +void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y) +{ + GLubyte dummy= 0; + + /* As long as known good coordinates are correct + * this is guarenteed to generate an ok raster + * position (ignoring potential (real) overflow + * issues). + */ + glRasterPos2f(known_good_x, known_good_y); + + /* Now shift the raster position to where we wanted + * it in the first place using the glBitmap trick. + */ + glBitmap(0, 0, 0, 0, x - known_good_x, y - known_good_y, &dummy); +} + +static int get_cached_work_texture(int *w_r, int *h_r) +{ + static GLint texid= -1; + static int tex_w= 256; + static int tex_h= 256; + + if (texid==-1) { + GLint ltexid= glaGetOneInteger(GL_TEXTURE_2D); + unsigned char *tbuf; + + glGenTextures(1, (GLuint *)&texid); + + glBindTexture(GL_TEXTURE_2D, texid); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + tbuf= MEM_callocN(tex_w*tex_h*4, "tbuf"); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tbuf); + MEM_freeN(tbuf); + + glBindTexture(GL_TEXTURE_2D, ltexid); + } + + *w_r= tex_w; + *h_r= tex_h; + return texid; +} + +void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect) +{ + unsigned char *uc_rect= (unsigned char*) rect; + float *f_rect= (float *)rect; + float xzoom= glaGetOneFloat(GL_ZOOM_X), yzoom= glaGetOneFloat(GL_ZOOM_Y); + int ltexid= glaGetOneInteger(GL_TEXTURE_2D); + int lrowlength= glaGetOneInteger(GL_UNPACK_ROW_LENGTH); + int subpart_x, subpart_y, tex_w, tex_h; + int texid= get_cached_work_texture(&tex_w, &tex_h); + int nsubparts_x= (img_w+(tex_w-1))/tex_w; + int nsubparts_y= (img_h+(tex_h-1))/tex_h; + + /* Specify the color outside this function, and tex will modulate it. + * This is useful for changing alpha without using glPixelTransferf() + */ + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w); + glBindTexture(GL_TEXTURE_2D, texid); + + /* don't want nasty border artifacts */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + for (subpart_y=0; subpart_y<nsubparts_y; subpart_y++) { + for (subpart_x=0; subpart_x<nsubparts_x; subpart_x++) { + int subpart_w= (subpart_x==nsubparts_x-1)?(img_w-subpart_x*tex_w):tex_w; + int subpart_h= (subpart_y==nsubparts_y-1)?(img_h-subpart_y*tex_h):tex_h; + float rast_x= x+subpart_x*tex_w*xzoom; + float rast_y= y+subpart_y*tex_h*yzoom; + + if(format==GL_FLOAT) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*tex_w)*img_w*4 + (subpart_x*tex_w)*4]); + else + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*tex_w)*img_w*4 + (subpart_x*tex_w)*4]); + + glEnable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(rast_x, rast_y); + + glTexCoord2f((float) (subpart_w-1)/tex_w, 0); + glVertex2f(rast_x+subpart_w*xzoom, rast_y); + + glTexCoord2f((float) (subpart_w-1)/tex_w, (float) subpart_h/tex_h); + glVertex2f(rast_x+subpart_w*xzoom, rast_y+subpart_h*yzoom); + + glTexCoord2f(0, (float) subpart_h/tex_h); + glVertex2f(rast_x, rast_y+subpart_h*yzoom); + glEnd(); + glDisable(GL_TEXTURE_2D); + } + } + + glBindTexture(GL_TEXTURE_2D, ltexid); + glPixelStorei(GL_UNPACK_ROW_LENGTH, lrowlength); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + +#define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val)) +void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf) +{ + float *rf; + int x, y; + char *rect32, *rc; + + /* copy imgw-imgh to a temporal 32 bits rect */ + if(img_w<1 || img_h<1) return; + + rc= rect32= MEM_mallocN(img_w*img_h*sizeof(int), "temp 32 bits"); + + for(y=0; y<img_h; y++) { + rf= rectf; + for(x=0; x<img_w; x++, rf+=4, rc+=4) { + rc[0]= FTOCHAR(rf[0]); + rc[1]= FTOCHAR(rf[1]); + rc[2]= FTOCHAR(rf[2]); + rc[3]= FTOCHAR(rf[3]); + } + rectf+= 4*row_w; + } + + glaDrawPixelsSafe(fx, fy, img_w, img_h, img_w, GL_RGBA, GL_UNSIGNED_BYTE, rect32); + + MEM_freeN(rect32); +} + +void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect) +{ + float xzoom= glaGetOneFloat(GL_ZOOM_X); + float yzoom= glaGetOneFloat(GL_ZOOM_Y); + + /* The pixel space coordinate of the intersection of + * the [zoomed] image with the origin. + */ + float ix= -x/xzoom; + float iy= -y/yzoom; + + /* The maximum pixel amounts the image can be cropped + * at the lower left without exceeding the origin. + */ + int off_x= floor(MAX2(ix, 0)); + int off_y= floor(MAX2(iy, 0)); + + /* The zoomed space coordinate of the raster position + * (starting at the lower left most unclipped pixel). + */ + float rast_x= x + off_x*xzoom; + float rast_y= y + off_y*yzoom; + + GLfloat scissor[4]; + int draw_w, draw_h; + + /* Determine the smallest number of pixels we need to draw + * before the image would go off the upper right corner. + * + * It may seem this is just an optimization but some graphics + * cards (ATI) freak out if there is a large zoom factor and + * a large number of pixels off the screen (probably at some + * level the number of image pixels to draw is getting multiplied + * by the zoom and then clamped). Making sure we draw the + * fewest pixels possible keeps everyone mostly happy (still + * fails if we zoom in on one really huge pixel so that it + * covers the entire screen). + */ + glGetFloatv(GL_SCISSOR_BOX, scissor); + draw_w = MIN2(img_w-off_x, ceil((scissor[2]-rast_x)/xzoom)); + draw_h = MIN2(img_h-off_y, ceil((scissor[3]-rast_y)/yzoom)); + + if (draw_w>0 && draw_h>0) { + int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); + + /* Don't use safe RasterPos (slower) if we can avoid it. */ + if (rast_x>=0 && rast_y>=0) { + glRasterPos2f(rast_x, rast_y); + } else { + glaRasterPosSafe2f(rast_x, rast_y, 0, 0); + } + + glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w); + if(format==GL_LUMINANCE || format==GL_RED) { + if(type==GL_FLOAT) { + float *f_rect= (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)); + } + else if(type==GL_INT || type==GL_UNSIGNED_INT) { + int *i_rect= (int *)rect; + glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x)); + } + } + else { /* RGBA */ + if(type==GL_FLOAT) { + float *f_rect= (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4); + } + else if(type==GL_UNSIGNED_BYTE) { + unsigned char *uc_rect= (unsigned char *) rect; + glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4); + } + } + + glPixelStorei(GL_UNPACK_ROW_LENGTH, old_row_length); + } +} + +/* 2D Drawing Assistance */ + +void glaDefine2DArea(rcti *screen_rect) +{ + int sc_w= screen_rect->xmax - screen_rect->xmin; + int sc_h= screen_rect->ymax - screen_rect->ymin; + + glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); + glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); + + /* The 0.375 magic number is to shift the matrix so that + * both raster and vertex integer coordinates fall at pixel + * centers properly. For a longer discussion see the OpenGL + * Programming Guide, Appendix H, Correctness Tips. + */ + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1); + glTranslatef(0.375, 0.375, 0.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +struct gla2DDrawInfo { + int orig_vp[4], orig_sc[4]; + float orig_projmat[16], orig_viewmat[16]; + + rcti screen_rect; + rctf world_rect; + + float wo_to_sc[2]; +}; + +void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) +{ + *rect= di->world_rect; +} + +void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) +{ + int sc_w, sc_h; + float wo_w, wo_h; + + di->world_rect= *rect; + + sc_w= (di->screen_rect.xmax-di->screen_rect.xmin); + sc_h= (di->screen_rect.ymax-di->screen_rect.ymin); + wo_w= (di->world_rect.xmax-di->world_rect.xmin); + wo_h= (di->world_rect.ymax-di->world_rect.ymin); + + di->wo_to_sc[0]= sc_w/wo_w; + di->wo_to_sc[1]= sc_h/wo_h; +} + + +gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) +{ + gla2DDrawInfo *di= MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); + int sc_w, sc_h; + float wo_w, wo_h; + + glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp); + glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc); + glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat); + + di->screen_rect= *screen_rect; + if (world_rect) { + di->world_rect= *world_rect; + } else { + di->world_rect.xmin= di->screen_rect.xmin; + di->world_rect.ymin= di->screen_rect.ymin; + di->world_rect.xmax= di->screen_rect.xmax; + di->world_rect.ymax= di->screen_rect.ymax; + } + + sc_w= (di->screen_rect.xmax-di->screen_rect.xmin); + sc_h= (di->screen_rect.ymax-di->screen_rect.ymin); + wo_w= (di->world_rect.xmax-di->world_rect.xmin); + wo_h= (di->world_rect.ymax-di->world_rect.ymin); + + di->wo_to_sc[0]= sc_w/wo_w; + di->wo_to_sc[1]= sc_h/wo_h; + + glaDefine2DArea(&di->screen_rect); + + return di; +} + +void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r) +{ + *sc_x_r= (wo_x - di->world_rect.xmin)*di->wo_to_sc[0]; + *sc_y_r= (wo_y - di->world_rect.ymin)*di->wo_to_sc[1]; +} +void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2]) +{ + screen_r[0]= (world[0] - di->world_rect.xmin)*di->wo_to_sc[0]; + screen_r[1]= (world[1] - di->world_rect.ymin)*di->wo_to_sc[1]; +} + +void glaEnd2DDraw(gla2DDrawInfo *di) +{ + glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); + glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(di->orig_projmat); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(di->orig_viewmat); + + MEM_freeN(di); +} + +/* **************** glPoint hack ************************ */ + +static int curmode=0; +static int pointhack=0; +static GLubyte Squaredot[16] = { 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff}; + +void bglBegin(int mode) +{ + curmode= mode; + + if(mode==GL_POINTS) { + float value[4]; + glGetFloatv(GL_POINT_SIZE_RANGE, value); + if(value[1]<2.0) { + glGetFloatv(GL_POINT_SIZE, value); + pointhack= floor(value[0]+0.5); + if(pointhack>4) pointhack= 4; + } + else glBegin(mode); + } +} + + +void bglVertex3fv(float *vec) +{ + switch(curmode) { + case GL_POINTS: + if(pointhack) { + glRasterPos3fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot); + } + else glVertex3fv(vec); + break; + } +} + +void bglVertex3f(float x, float y, float z) +{ + switch(curmode) { + case GL_POINTS: + if(pointhack) { + glRasterPos3f(x, y, z); + glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot); + } + else glVertex3f(x, y, z); + break; + } +} + +void bglVertex2fv(float *vec) +{ + switch(curmode) { + case GL_POINTS: + if(pointhack) { + glRasterPos2fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot); + } + else glVertex2fv(vec); + break; + } +} + + +void bglEnd(void) +{ + if(pointhack) pointhack= 0; + else glEnd(); + +} + +/* Uses current OpenGL state to get view matrices for gluProject/gluUnProject */ +void bgl_get_mats(bglMats *mats) +{ + const double badvalue= 1.0e-6; + + glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview); + glGetDoublev(GL_PROJECTION_MATRIX, mats->projection); + glGetIntegerv(GL_VIEWPORT, (GLint *)mats->viewport); + + /* Very strange code here - it seems that certain bad values in the + modelview matrix can cause gluUnProject to give bad results. */ + if(mats->modelview[0] < badvalue && + mats->modelview[0] > -badvalue) + mats->modelview[0]= 0; + if(mats->modelview[5] < badvalue && + mats->modelview[5] > -badvalue) + mats->modelview[5]= 0; + + /* Set up viewport so that gluUnProject will give correct values */ + mats->viewport[0] = 0; + mats->viewport[1] = 0; +} + +/* *************** glPolygonOffset hack ************* */ + +// both temporal, so here for now (ton) +#include "BKE_global.h" +#include "DNA_view3d_types.h" + +/* dist is only for ortho now... */ +void bglPolygonOffset(float dist) +{ + static float winmat[16], offset=0.0; + + if(dist!=0.0) { + float offs; + + // glEnable(GL_POLYGON_OFFSET_FILL); + // glPolygonOffset(-1.0, -1.0); + + /* hack below is to mimic polygon offset */ + glMatrixMode(GL_PROJECTION); + glGetFloatv(GL_PROJECTION_MATRIX, (float *)winmat); + + /* dist is from camera to center point */ + + if(winmat[15]>0.5) offs= 0.00001*dist*G.vd->dist; // ortho tweaking + else offs= 0.0005*dist; // should be clipping value or so... + + winmat[14]-= offs; + offset+= offs; + + glLoadMatrixf(winmat); + glMatrixMode(GL_MODELVIEW); + } + else { + + glMatrixMode(GL_PROJECTION); + winmat[14]+= offset; + offset= 0.0; + glLoadMatrixf(winmat); + glMatrixMode(GL_MODELVIEW); + } +} + +int is_a_really_crappy_intel_card(void) +{ + static int well_is_it= -1; + + /* Do you understand the implication? Do you? */ + if (well_is_it==-1) + well_is_it= (strcmp((char*) glGetString(GL_VENDOR), "Intel Inc.") == 0); + + return well_is_it; +} + +void bglFlush(void) +{ + glFlush(); +#ifdef __APPLE__ +// if(is_a_really_crappy_intel_card()) +// XXX myswapbuffers(); //hack to get mac intel graphics to show frontbuffer +#endif +} + + diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c new file mode 100644 index 00000000000..e73a4e8e77b --- /dev/null +++ b/source/blender/editors/screen/screen_edit.c @@ -0,0 +1,624 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" +#include "BIF_resources.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_area.h" +#include "ED_screen.h" + +#include "wm_subwindow.h" + +#include "screen_intern.h" /* own module include */ + +/* ******************* screen vert, edge, area managing *********************** */ + +static ScrVert *screen_addvert(bScreen *sc, short x, short y) +{ + ScrVert *sv= MEM_callocN(sizeof(ScrVert), "addscrvert"); + sv->vec.x= x; + sv->vec.y= y; + + BLI_addtail(&sc->vertbase, sv); + return sv; +} + +static void sortscrvert(ScrVert **v1, ScrVert **v2) +{ + ScrVert *tmp; + + if (*v1 > *v2) { + tmp= *v1; + *v1= *v2; + *v2= tmp; + } +} + +static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) +{ + ScrEdge *se= MEM_callocN(sizeof(ScrEdge), "addscredge"); + + sortscrvert(&v1, &v2); + se->v1= v1; + se->v2= v2; + + BLI_addtail(&sc->edgebase, se); + return se; +} + + +static ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) +{ + ScrEdge *se; + + sortscrvert(&v1, &v2); + for (se= sc->edgebase.first; se; se= se->next) + if(se->v1==v1 && se->v2==v2) + return se; + + return NULL; +} + +static void removedouble_scrverts(bScreen *sc) +{ + ScrVert *v1, *verg; + ScrEdge *se; + ScrArea *sa; + + verg= sc->vertbase.first; + while(verg) { + if(verg->newv==NULL) { /* !!! */ + v1= verg->next; + while(v1) { + if(v1->newv==NULL) { /* !?! */ + if(v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) { + /* printf("doublevert\n"); */ + v1->newv= verg; + } + } + v1= v1->next; + } + } + verg= verg->next; + } + + /* replace pointers in edges and faces */ + se= sc->edgebase.first; + while(se) { + if(se->v1->newv) se->v1= se->v1->newv; + if(se->v2->newv) se->v2= se->v2->newv; + /* edges changed: so.... */ + sortscrvert(&(se->v1), &(se->v2)); + se= se->next; + } + sa= sc->areabase.first; + while(sa) { + if(sa->v1->newv) sa->v1= sa->v1->newv; + if(sa->v2->newv) sa->v2= sa->v2->newv; + if(sa->v3->newv) sa->v3= sa->v3->newv; + if(sa->v4->newv) sa->v4= sa->v4->newv; + sa= sa->next; + } + + /* remove */ + verg= sc->vertbase.first; + while(verg) { + v1= verg->next; + if(verg->newv) { + BLI_remlink(&sc->vertbase, verg); + MEM_freeN(verg); + } + verg= v1; + } + +} + +static void removenotused_scrverts(bScreen *sc) +{ + ScrVert *sv, *svn; + ScrEdge *se; + + /* we assume edges are ok */ + + se= sc->edgebase.first; + while(se) { + se->v1->flag= 1; + se->v2->flag= 1; + se= se->next; + } + + sv= sc->vertbase.first; + while(sv) { + svn= sv->next; + if(sv->flag==0) { + BLI_remlink(&sc->vertbase, sv); + MEM_freeN(sv); + } + else sv->flag= 0; + sv= svn; + } +} + +static void removedouble_scredges(bScreen *sc) +{ + ScrEdge *verg, *se, *sn; + + /* compare */ + verg= sc->edgebase.first; + while(verg) { + se= verg->next; + while(se) { + sn= se->next; + if(verg->v1==se->v1 && verg->v2==se->v2) { + BLI_remlink(&sc->edgebase, se); + MEM_freeN(se); + } + se= sn; + } + verg= verg->next; + } +} + +static void removenotused_scredges(bScreen *sc) +{ + ScrEdge *se, *sen; + ScrArea *sa; + int a=0; + + /* sets flags when edge is used in area */ + sa= sc->areabase.first; + while(sa) { + se= screen_findedge(sc, sa->v1, sa->v2); + if(se==0) printf("error: area %d edge 1 bestaat niet\n", a); + else se->flag= 1; + se= screen_findedge(sc, sa->v2, sa->v3); + if(se==0) printf("error: area %d edge 2 bestaat niet\n", a); + else se->flag= 1; + se= screen_findedge(sc, sa->v3, sa->v4); + if(se==0) printf("error: area %d edge 3 bestaat niet\n", a); + else se->flag= 1; + se= screen_findedge(sc, sa->v4, sa->v1); + if(se==0) printf("error: area %d edge 4 bestaat niet\n", a); + else se->flag= 1; + sa= sa->next; + a++; + } + se= sc->edgebase.first; + while(se) { + sen= se->next; + if(se->flag==0) { + BLI_remlink(&sc->edgebase, se); + MEM_freeN(se); + } + else se->flag= 0; + se= sen; + } +} + +static int scredge_is_horizontal(ScrEdge *se) +{ + return (se->v1->vec.y == se->v2->vec.y); +} + +static ScrEdge *screen_find_active_scredge(bScreen *sc, short *mval) +{ + ScrEdge *se; + + for (se= sc->edgebase.first; se; se= se->next) { + if (scredge_is_horizontal(se)) { + short min, max; + min= MIN2(se->v1->vec.x, se->v2->vec.x); + max= MAX2(se->v1->vec.x, se->v2->vec.x); + + if (abs(mval[1]-se->v1->vec.y)<=2 && mval[0] >= min && mval[0]<=max) + return se; + } + else { + short min, max; + min= MIN2(se->v1->vec.y, se->v2->vec.y); + max= MAX2(se->v1->vec.y, se->v2->vec.y); + + if (abs(mval[0]-se->v1->vec.x)<=2 && mval[1] >= min && mval[1]<=max) + return se; + } + } + + return NULL; +} + +static void select_connected_scredge(bScreen *sc, ScrEdge *edge) +{ + ScrEdge *se; + ScrVert *sv; + int oneselected; + char dir; + + /* select connected, only in the right direction */ + /* 'dir' is the direction of EDGE */ + + if(edge->v1->vec.x==edge->v2->vec.x) dir= 'v'; + else dir= 'h'; + + sv= sc->vertbase.first; + while(sv) { + sv->flag= 0; + sv= sv->next; + } + + edge->v1->flag= 1; + edge->v2->flag= 1; + + oneselected= 1; + while(oneselected) { + se= sc->edgebase.first; + oneselected= 0; + while(se) { + if(se->v1->flag + se->v2->flag==1) { + if(dir=='h') if(se->v1->vec.y==se->v2->vec.y) { + se->v1->flag= se->v2->flag= 1; + oneselected= 1; + } + if(dir=='v') if(se->v1->vec.x==se->v2->vec.x) { + se->v1->flag= se->v2->flag= 1; + oneselected= 1; + } + } + se= se->next; + } + } +} + +static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) +{ + ScrArea *sa= MEM_callocN(sizeof(ScrArea), "addscrarea"); + sa->v1= v1; + sa->v2= v2; + sa->v3= v3; + sa->v4= v4; + sa->headertype= headertype; + sa->spacetype= spacetype; + + BLI_addtail(&sc->areabase, sa); + + return sa; +} + +bScreen *addscreen(wmWindow *win, char *name) +{ + bScreen *sc; + ScrVert *sv1, *sv2, *sv3, *sv4; + + sc= alloc_libblock(&G.main->screen, ID_SCR, name); + + sc->scene= G.scene; + + sv1= screen_addvert(sc, 0, 0); + sv2= screen_addvert(sc, 0, win->sizey-1); + sv3= screen_addvert(sc, win->sizex-1, win->sizey-1); + sv4= screen_addvert(sc, win->sizex-1, 0); + + screen_addedge(sc, sv1, sv2); + screen_addedge(sc, sv2, sv3); + screen_addedge(sc, sv3, sv4); + screen_addedge(sc, sv4, sv1); + + screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_INFO); + + return sc; +} + + +static void screen_copy(bScreen *to, bScreen *from) +{ + ScrVert *s1, *s2; + ScrEdge *se; + ScrArea *sa, *saf; + + /* free contents of 'to', is from blenkernel screen.c */ + free_screen(to); + + BLI_duplicatelist(&to->vertbase, &from->vertbase); + BLI_duplicatelist(&to->edgebase, &from->edgebase); + BLI_duplicatelist(&to->areabase, &from->areabase); + + s2= to->vertbase.first; + for(s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) { + s1->newv= s2; + } + + for(se= to->edgebase.first; se; se= se->next) { + se->v1= se->v1->newv; + se->v2= se->v2->newv; + sortscrvert(&(se->v1), &(se->v2)); + } + + saf= from->areabase.first; + for(sa= to->areabase.first; sa; sa= sa->next, saf= saf->next) { + sa->v1= sa->v1->newv; + sa->v2= sa->v2->newv; + sa->v3= sa->v3->newv; + sa->v4= sa->v4->newv; + + sa->spacedata.first= sa->spacedata.last= NULL; + sa->uiblocks.first= sa->uiblocks.last= NULL; + sa->panels.first= sa->panels.last= NULL; + sa->regionbase.first= sa->regionbase.last= NULL; + sa->scriptlink.totscript= 0; + + area_copy_data(sa, saf, 0); + } + + /* put at zero (needed?) */ + for(s1= from->vertbase.first; s1; s1= s1->next) + s1->newv= NULL; + +} + +bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) +{ + bScreen *newsc; + + if(sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ + + /* make new screen: */ + newsc= addscreen(win, sc->id.name+2); + /* copy all data */ + screen_copy(newsc, sc); + + return newsc; +} + + + +/* *************************************************************** */ + +/* test if screen vertices should be scaled */ +/* also check offset */ +void screen_test_scale(bScreen *sc, int winsizex, int winsizey) +{ + ScrVert *sv=NULL; + ScrEdge *se; + ScrArea *sa, *san; + int sizex, sizey, yval; + float facx, facy, tempf, min[2], max[2]; + + /* calculate size */ + min[0]= min[1]= 10000.0f; + max[0]= max[1]= 0.0f; + + for(sv= sc->vertbase.first; sv; sv= sv->next) { + min[0]= MIN2(min[0], sv->vec.x); + min[1]= MIN2(min[1], sv->vec.y); + max[0]= MAX2(max[0], sv->vec.x); + max[1]= MAX2(max[1], sv->vec.y); + } + + /* always make 0.0 left under */ + for(sv= sc->vertbase.first; sv; sv= sv->next) { + sv->vec.x -= min[0]; + sv->vec.y -= min[1]; + } + + sizex= max[0]-min[0]; + sizey= max[1]-min[1]; + + if(sizex!= winsizex || sizey!= winsizey) { + facx= winsizex; + facx/= (float)sizex; + facy= winsizey; + facy/= (float)sizey; + + /* make sure it fits! */ + for(sv= sc->vertbase.first; sv; sv= sv->next) { + tempf= ((float)sv->vec.x)*facx; + sv->vec.x= (short)(tempf+0.5); + sv->vec.x+= AREAGRID-1; + sv->vec.x-= (sv->vec.x % AREAGRID); + + CLAMP(sv->vec.x, 0, winsizex); + + tempf= ((float)sv->vec.y )*facy; + sv->vec.y= (short)(tempf+0.5); + sv->vec.y+= AREAGRID-1; + sv->vec.y-= (sv->vec.y % AREAGRID); + + CLAMP(sv->vec.y, 0, winsizey); + } + } + + /* test for collapsed areas. This could happen in some blender version... */ + for(sa= sc->areabase.first; sa; sa= san) { + san= sa->next; + if(sa->v1==sa->v2 || sa->v3==sa->v4 || sa->v2==sa->v3) { + BKE_screen_area_free(sa); + BLI_remlink(&sc->areabase, sa); + MEM_freeN(sa); + } + } + + /* make each window at least HEADERY high */ + for(sa= sc->areabase.first; sa; sa= sa->next) { + + if(sa->v1->vec.y+HEADERY > sa->v2->vec.y) { + /* lower edge */ + se= screen_findedge(sc, sa->v4, sa->v1); + if(se && sa->v1!=sa->v2 ) { + select_connected_scredge(sc, se); + + /* all selected vertices get the right offset */ + yval= sa->v2->vec.y-HEADERY; + sv= sc->vertbase.first; + while(sv) { + /* if is a collapsed area */ + if(sv!=sa->v2 && sv!=sa->v3) { + if(sv->flag) sv->vec.y= yval; + } + sv= sv->next; + } + } + } + } +} + + + +#define SCR_BACK 0.55 +#define SCR_ROUND 12 + +static void drawscredge_area(ScrArea *sa) +{ + short x1= sa->v1->vec.x; + short y1= sa->v1->vec.y; + short x2= sa->v3->vec.x; + short y2= sa->v3->vec.y; + + cpack(0x0); + + /* right border area */ + sdrawline(x2, y1, x2, y2); + + /* left border area */ + if(x1>0) { // otherwise it draws the emboss of window over + sdrawline(x1, y1, x1, y2); + } + /* top border area */ + sdrawline(x1, y2, x2, y2); + + /* bottom border area */ + sdrawline(x1, y1, x2, y1); +} + +void ED_screen_do_listen(bScreen *screen, wmNotifier *note) +{ + + /* generic notes */ + if(note->type==WM_NOTE_REDRAW) + screen->do_draw= 1; + if(note->type==WM_NOTE_REFRESH) + if(note->swinid==0) + screen->do_refresh= screen->do_draw= 1; + +} + + +void ED_screen_draw(wmWindow *win) +{ + ScrArea *sa; + + wm_subwindow_set(win, win->screen->mainwin); + + for(sa= win->screen->areabase.first; sa; sa= sa->next) + drawscredge_area(sa); + + printf("draw screen\n"); + win->screen->do_draw= 0; +} + +/* make this screen usable */ +/* for file read and first use, for scaling window */ +void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) +{ + ScrArea *sa; + rcti winrct= {0, win->sizex, 0, win->sizey}; + + screen_test_scale(win->screen, win->sizex, win->sizey); + + if(win->screen->mainwin==0) + win->screen->mainwin= wm_subwindow_open(win, &winrct); + else + wm_subwindow_position(win, win->screen->mainwin, &winrct); + + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + /* set spacetype and region callbacks */ + /* sets subwindow */ + ED_area_initialize(wm, win, sa); + } + + printf("set screen\n"); + win->screen->do_refresh= 0; + +} + +/* file read, set all screens, ... */ +void ED_screens_initialize(wmWindowManager *wm) +{ + wmWindow *win; + + for(win= wm->windows.first; win; win= win->next) { + + if(win->screen==NULL) + win->screen= G.main->screen.first; + + ED_screen_refresh(wm, win); + } +} + +void placeholder() +{ + removedouble_scrverts(NULL); + removenotused_scrverts(NULL); + removedouble_scredges(NULL); + removenotused_scredges(NULL); +} + +/* *************************************************** */ + +/* operator cb */ +int screen_cursor_test(bContext *C, wmOperator *op, wmEvent *event) +{ + short mval[2]= {event->x, event->y}; + ScrEdge *actedge= screen_find_active_scredge(C->screen, mval); + + if (actedge) { + if (scredge_is_horizontal(actedge)) { + WM_set_cursor(C, CURSOR_Y_MOVE); + } else { + WM_set_cursor(C, CURSOR_X_MOVE); + } + // this does global hotkeys too +// screen_edge_edit_event(g_activearea, actedge, event, val); + } else { + WM_set_cursor(C, CURSOR_STD); + } + + return 1; +} + + diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h new file mode 100644 index 00000000000..01c9c08ac51 --- /dev/null +++ b/source/blender/editors/screen/screen_intern.h @@ -0,0 +1,43 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef ED_SCREEN_INTERN_H +#define ED_SCREEN_INTERN_H + +/* internal exports only */ +struct wmOperator; +struct wmEvent; + +/* area.c */ +void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space); + +/* screen_edit.c */ +int screen_cursor_test(bContext *C, struct wmOperator *op, struct wmEvent *event); + + +#endif /* ED_SCREEN_INTERN_H */ + diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c new file mode 100644 index 00000000000..b88438ecdfc --- /dev/null +++ b/source/blender/editors/screen/screen_ops.c @@ -0,0 +1,104 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_area.h" +#include "ED_screen.h" + +#include "screen_intern.h" /* own module include */ + +static ListBase local_ops; + +int ED_operator_screenactive(bContext *C) +{ + if(C->window==NULL) return 0; + if(C->screen==NULL) return 0; + return 1; +} + + + +static void ED_SCR_OT_move_areas(wmOperatorType *ot) +{ + ot->name= "Move area edges"; + ot->idname= "ED_SCR_OT_move_areas"; + + ot->interactive= NULL; + ot->exec= NULL; + ot->poll= ED_operator_screenactive; +} + +static void ED_SCR_OT_cursor_type(wmOperatorType *ot) +{ + ot->name= "Cursor type"; + ot->idname= "ED_SCR_OT_cursor_type"; + + ot->interactive= screen_cursor_test; + ot->exec= NULL; + ot->poll= ED_operator_screenactive; +} + + +#define ADD_OPTYPE(opfunc) ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \ + opfunc(ot); \ + BLI_addtail(&local_ops, ot) + + + +/* called via wm_init_exit.c ED_spacetypes_init() */ +void ED_operatortypes_screen(void) +{ + wmOperatorType *ot; + + ADD_OPTYPE( ED_SCR_OT_move_areas ); + ADD_OPTYPE( ED_SCR_OT_cursor_type ); + + + + WM_operatortypelist_append(&local_ops); +} + +/* called in wm.c */ +void ed_screen_keymap(wmWindowManager *wm) +{ + WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_cursor_type", MOUSEMOVE, 0, 0, 0); + +} + + + diff --git a/source/blender/editors/screen/space.c b/source/blender/editors/screen/space.c new file mode 100644 index 00000000000..85e41c1c1c2 --- /dev/null +++ b/source/blender/editors/screen/space.c @@ -0,0 +1,50 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf_types.h" +#include "IMB_imbuf.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "BKE_global.h" +#include "BKE_colortools.h" + +#include "BLO_readfile.h" + +#include "WM_api.h" + +#include "ED_area.h" +#include "ED_screen.h" + + diff --git a/source/blender/editors/screen/spacetypes.c b/source/blender/editors/screen/spacetypes.c new file mode 100644 index 00000000000..eec6da90e1a --- /dev/null +++ b/source/blender/editors/screen/spacetypes.c @@ -0,0 +1,115 @@ +/** + * $Id: spacetypes.c + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) Blender Foundation, 2008 + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include <stdlib.h> + +#include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" + +#include "BKE_global.h" +#include "BKE_screen.h" + +#include "BIF_gl.h" + +#include "WM_api.h" + +#include "ED_screen.h" +#include "ED_area.h" + +#include "screen_intern.h" /* own module include */ + + +/* only call once on startup, storage is static data (no malloc!) in kernel listbase */ +void ED_spacetypes_init(void) +{ + ED_spacetype_view3d(); +// ED_spacetype_ipo(); +// ... + + + ED_operatortypes_screen(); +// ED_operatortypes_view3d(); +// ... + +} + + +/* ****************************** space template *********************** */ + +/* allocate and init some vars */ +static SpaceLink *xxx_new(void) +{ + return NULL; +} + +/* not spacelink itself */ +static void xxx_free(SpaceLink *sl) +{ + +} + +/* spacetype; init callback for usage, should be redoable */ +static void xxx_init(ScrArea *sa) +{ + + /* link area to SpaceXXX struct */ + + /* define how many regions, the order and types */ + + /* add types to regions */ +} + +/* spacetype; external context changed */ +static void xxx_refresh(bContext *C, ScrArea *sa) +{ + +} + +static SpaceLink *xxx_duplicate(SpaceLink *sl) +{ + + return NULL; +} + +/* only called once, from screen/spacetypes.c */ +void ED_spacetype_xxx(void) +{ + static SpaceType st; + + st.spaceid= SPACE_VIEW3D; + + st.new= xxx_new; + st.free= xxx_free; + st.init= xxx_init; + st.refresh= xxx_refresh; + st.duplicate= xxx_duplicate; + + BKE_spacetype_register(&st); +} + +/* ****************************** end template *********************** */ + + + + diff --git a/source/blender/editors/screen/stubs.c b/source/blender/editors/screen/stubs.c index b48d342f4c5..6aef4c8a585 100644 --- a/source/blender/editors/screen/stubs.c +++ b/source/blender/editors/screen/stubs.c @@ -36,6 +36,8 @@ void waitcursor() {} void pupmenu() {} void mainqenter() {} void saveover() {} +void BIF_icons_free() {} +void BIF_icons_init() {} char texstr[20][12]; diff --git a/source/blender/editors/area/Makefile b/source/blender/editors/space_ipo/Makefile index c7b6d39bcca..53f8caef97e 100644 --- a/source/blender/editors/area/Makefile +++ b/source/blender/editors/space_ipo/Makefile @@ -28,7 +28,7 @@ # # Makes module object directory and bounces make to subdirectories. -LIBNAME = ed_area +LIBNAME = ed_ipo DIR = $(OCGDIR)/blender/$(LIBNAME) include nan_compile.mk @@ -44,6 +44,7 @@ CPPFLAGS += -I../../blenkernel CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include diff --git a/source/blender/editors/space_view3d/Makefile b/source/blender/editors/space_view3d/Makefile new file mode 100644 index 00000000000..0631cf010b8 --- /dev/null +++ b/source/blender/editors/space_view3d/Makefile @@ -0,0 +1,52 @@ +# +# $Id: Makefile 14 2002-10-13 15:57:19Z hans $ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2007 Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# Makes module object directory and bounces make to subdirectories. + +LIBNAME = ed_view3d +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +CPPFLAGS += -I$(OPENGL_HEADERS) + +# not very neat.... +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +# own include + +CPPFLAGS += -I../include diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c new file mode 100644 index 00000000000..9a08c7cd016 --- /dev/null +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -0,0 +1,196 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_object_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_view3d_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_rand.h" + +#include "BKE_global.h" +#include "BKE_screen.h" + +#include "ED_area.h" + +#include "BIF_gl.h" + +#include "view3d_intern.h" // own include + +/* ******************** default callbacks for view3d space ***************** */ + +static SpaceLink *view3d_new(void) +{ + 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->gridflag |= V3D_SHOW_X; + vd->gridflag |= V3D_SHOW_Y; + vd->gridflag |= V3D_SHOW_FLOOR; + vd->gridflag &= ~V3D_SHOW_Z; + + vd->depths= NULL; + + return (SpaceLink *)vd; +} + +/* not spacelink itself */ +static void view3d_free(SpaceLink *sl) +{ + View3D *vd= (View3D *) sl; + + if(vd->bgpic) { + if(vd->bgpic->ima) vd->bgpic->ima->id.us--; + MEM_freeN(vd->bgpic); + } + + if(vd->localvd) MEM_freeN(vd->localvd); + if(vd->clipbb) MEM_freeN(vd->clipbb); + if(vd->depths) { + if(vd->depths->depths) MEM_freeN(vd->depths->depths); + MEM_freeN(vd->depths); + vd->depths= NULL; + } + +// XXX retopo_free_view_data(vd); + + if(vd->properties_storage) MEM_freeN(vd->properties_storage); + if(vd->ri) { +// XXX BIF_view3d_previewrender_free(vd); + } + +} + + +/* spacetype; init callback */ +static void view3d_init(ScrArea *sa) +{ + ARegion *ar; + + /* link area to SpaceXXX struct */ + + /* define how many regions, the order and types */ + + /* add types to regions */ + for(ar= sa->regionbase.first; ar; ar= ar->next) { + static ARegionType art={NULL, NULL, NULL, NULL}; + + /* for time being; register 1 type */ + ar->type= &art; + + } +} + +/* spacetype; context changed */ +static void view3d_refresh(bContext *C, ScrArea *sa) +{ + +} + +static SpaceLink *view3d_duplicate(SpaceLink *sl) +{ + View3D *v3do= (View3D *)sl; + View3D *v3dn= MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + +// XXX BIF_view3d_previewrender_free(v3do); + v3do->depths= NULL; + v3do->retopo_view_data= NULL; + + if(v3do->localvd) { +// XXX restore_localviewdata(v3do); + v3do->localvd= NULL; + v3do->properties_storage= NULL; + v3do->localview= 0; + v3do->lay &= 0xFFFFFF; + } + + /* copy or clear inside new stuff */ + + if(v3dn->bgpic) { + v3dn->bgpic= MEM_dupallocN(v3dn->bgpic); + if(v3dn->bgpic->ima) v3dn->bgpic->ima->id.us++; + } + v3dn->clipbb= MEM_dupallocN(v3dn->clipbb); + v3dn->ri= NULL; + v3dn->properties_storage= NULL; + + return (SpaceLink *)v3dn; +} + +/* only called once, from screen/spacetypes.c */ +void ED_spacetype_view3d(void) +{ + static SpaceType st; + + st.spaceid= SPACE_VIEW3D; + + st.new= view3d_new; + st.free= view3d_free; + st.init= view3d_init; + st.refresh= view3d_refresh; + st.duplicate= view3d_duplicate; + + BKE_spacetype_register(&st); + + +} + + + diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h new file mode 100644 index 00000000000..32c3e51c112 --- /dev/null +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -0,0 +1,44 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef ED_VIEW3D_INTERN_H +#define ED_VIEW3D_INTERN_H + +/* internal exports only */ + +typedef struct ViewDepths { + unsigned short w, h; + float *depths; + double depth_range[2]; + + char damaged; +} ViewDepths; + + + +#endif /* ED_VIEW3D_INTERN_H */ + diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 127e658308a..953877953d9 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -35,24 +35,30 @@ #include "DNA_scriptlink_types.h" struct Scene; -struct wmSubWindow; +struct SpaceType; +struct SpaceLink; +struct ARegionType; +struct bContext; +struct wmNotifier; +struct wmWindowManager; + typedef struct bScreen { ID id; ListBase vertbase, edgebase, areabase; struct Scene *scene; - short startx, endx, starty, endy; /* framebuffer coords */ - short sizex, sizey; + short scenenr, screennr; /* only for pupmenu */ + short full, winid; /* winid from WM, starts with 1 */ - int pad; - short handler[8]; /* similar to space handler now */ + short do_draw; /* notifier for drawing edges */ + short do_refresh; /* notifier for scale screen, changed screen, etc */ - struct wmSubWindow *mainwin; /* screensize subwindow, for screenedges */ - struct wmSubWindow *subwinactive; /* active subwindow */ + short mainwin; /* screensize subwindow, for screenedges and global menus */ + short subwinactive; /* active subwindow */ - ListBase handlers; /* wmEventHandler */ + short handler[8]; /* similar to space handler */ } bScreen; typedef struct ScrVert { @@ -100,21 +106,21 @@ typedef struct ScrArea { ScrVert *v1, *v2, *v3, *v4; bScreen *full; /* if area==full, this is the parent */ - float winmat[4][4]; - rcti totrct, headrct, winrct; - int pad; - short headertype; /* 0=no header, 1= down, 2= up */ - char spacetype, butspacetype; /* SPACE_... */ - short winx, winy; /* size */ - char head_swap, head_equal; - char win_swap, win_equal; + rcti totrct; /* rect bound by v1 v2 v3 v4 */ + rcti headrct, winrct; /* OLD! gets converted to region */ + + char spacetype, butspacetype; /* SPACE_..., butspacetype is button arg */ + short winx, winy; /* size */ - short headbutlen, headbutofs; + short headertype; /* OLD! 0=no header, 1= down, 2= up */ + short headbutlen, headbutofs; /* OLD! */ short cursor, flag; ScriptLink scriptlink; - + + struct SpaceType *type; /* callbacks for this space type */ + ListBase spacedata; ListBase uiblocks; ListBase panels; @@ -126,13 +132,24 @@ typedef struct ARegion { struct ARegion *next, *prev; rcti winrct; - struct wmSubWindow *subwin; + short swinid; + short regiontype; /* window, header, etc. identifier for drawing */ + short alignment; /* how it should split */ + short size; /* current split size in pixels */ + short minsize; /* set by spacedata's region init */ + short flag; /* hide, ... */ + + float fsize; /* current split size in float */ + + int pad; + short do_draw, do_refresh; /* cached notifier events */ + + struct ARegionType *type; /* callbacks for this region type */ ListBase handlers; } ARegion; -#define MAXWIN 128 /* area->flag */ #define HEADER_NO_PULLDOWN 1 @@ -182,5 +199,23 @@ typedef struct ARegion { #define SCREEN_HANDLER_PYTHON 2 #define SCREEN_HANDLER_VERSE 3 +/* regiontype, first two are the default set */ +#define RGN_TYPE_WINDOW 0 +#define RGN_TYPE_HEADER 1 + +/* region alignment */ +#define RGN_ALIGN_NONE 0 +#define RGN_ALIGN_TOP 1 +#define RGN_ALIGN_BOTTOM 2 +#define RGN_ALIGN_LEFT 3 +#define RGN_ALIGN_RIGHT 4 +#define RGN_ALIGN_HSPLIT 5 +#define RGN_ALIGN_VSPLIT 6 + +/* region flag */ +#define RGN_FLAG_HIDDEN 1 +#define RGN_FLAG_TOO_SMALL 2 + + #endif diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2250e6e43ab..d26b36bb369 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -59,20 +59,18 @@ struct FileList; * are derived (implicitly) from. Would be * good to make this explicit. */ -typedef struct SpaceLink SpaceLink; -struct SpaceLink { - SpaceLink *next, *prev; + +typedef struct SpaceLink { + struct SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; -}; +} SpaceLink; typedef struct SpaceInfo { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; } SpaceInfo; @@ -81,7 +79,6 @@ typedef struct SpaceIpo { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -109,7 +106,6 @@ typedef struct SpaceButs { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; struct RenderInfo *ri; short blockhandler[8]; @@ -141,7 +137,6 @@ typedef struct SpaceSeq { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -159,7 +154,6 @@ typedef struct SpaceFile { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -194,7 +188,6 @@ typedef struct SpaceOops { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -221,7 +214,6 @@ typedef struct SpaceImage { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -254,7 +246,6 @@ typedef struct SpaceNla { struct SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -269,7 +260,6 @@ typedef struct SpaceText { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; @@ -298,7 +288,6 @@ typedef struct SpaceScript { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; struct Script *script; short flags, menunr; @@ -311,7 +300,6 @@ typedef struct SpaceTime { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; View2D v2d; @@ -323,7 +311,6 @@ typedef struct SpaceNode { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; View2D v2d; @@ -347,7 +334,6 @@ typedef struct SpaceImaSel { SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index ee75d7b8f0f..4d1fba89624 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -70,7 +70,6 @@ typedef struct View3D { struct SpaceLink *next, *prev; int spacetype; float blockscale; - struct ScrArea *area; short blockhandler[8]; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index de32fe67fe6..193f2020463 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -60,10 +60,13 @@ typedef struct wmWindowManager { ListBase operators; /* operator registry */ + ListBase queue; /* refresh/redraw wmNotifier structs */ + /* custom keymaps */ ListBase windowkeymap; ListBase screenkeymap; + } wmWindowManager; @@ -91,7 +94,8 @@ typedef struct wmWindow { struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */ ListBase queue; /* all events (ghost level events were handled) */ - ListBase handlers; /* window handlers, overriding all queues */ + ListBase handlers; /* window+screen handlers, overriding all queues */ + ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */ } wmWindow; diff --git a/source/blender/nodes/intern/CMP_util.h b/source/blender/nodes/intern/CMP_util.h index b7f3f5b222d..44f76b0822e 100644 --- a/source/blender/nodes/intern/CMP_util.h +++ b/source/blender/nodes/intern/CMP_util.h @@ -46,8 +46,6 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_space_types.h" -#include "DNA_screen_types.h" #include "DNA_texture_types.h" #include "DNA_userdef_types.h" diff --git a/source/blender/nodes/intern/SHD_util.h b/source/blender/nodes/intern/SHD_util.h index fc74a6ccec7..fcab420f3f2 100644 --- a/source/blender/nodes/intern/SHD_util.h +++ b/source/blender/nodes/intern/SHD_util.h @@ -45,8 +45,6 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_space_types.h" -#include "DNA_screen_types.h" #include "DNA_texture_types.h" #include "DNA_userdef_types.h" diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 6eae439ce50..dda8b464680 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -1,15 +1,12 @@ /* * $Id: BPY_extern.h 12334 2007-10-21 23:00:29Z aligorith $ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): Michel Selten, Willian P. Germano, Chris Keith * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BPY_EXTERN_H diff --git a/source/blender/python/intern/BPY_scriptlink.c b/source/blender/python/intern/BPY_scriptlink.c new file mode 100644 index 00000000000..e790942aeb5 --- /dev/null +++ b/source/blender/python/intern/BPY_scriptlink.c @@ -0,0 +1,73 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_lamp_types.h" +#include "DNA_camera_types.h" +#include "DNA_world_types.h" +#include "DNA_scene_types.h" +#include "DNA_material_types.h" + +#include "BLI_blenlib.h" + +#include "BKE_blender.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" + + +/* only copies internal pointers, scriptlink usually is integral part of a struct */ +void BPY_copy_scriptlink( struct ScriptLink *scriptlink ) +{ + + if( scriptlink->totscript ) { + scriptlink->scripts = MEM_dupallocN(scriptlink->scripts); + scriptlink->flag = MEM_dupallocN(scriptlink->flag); + } + + return; +} + +/* not free slink itself */ +void BPY_free_scriptlink( struct ScriptLink *slink ) +{ + if( slink->totscript ) { + if( slink->flag ) { + MEM_freeN( slink->flag ); + slink->flag= NULL; + } + if( slink->scripts ) { + MEM_freeN( slink->scripts ); + slink->scripts= NULL; + } + } + + return; +} + diff --git a/source/blender/python/intern/Makefile b/source/blender/python/intern/Makefile new file mode 100644 index 00000000000..ea507febc2b --- /dev/null +++ b/source/blender/python/intern/Makefile @@ -0,0 +1,74 @@ +# +# $Id: Makefile 11904 2007-08-31 16:16:33Z sirdude $ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = python +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +# OpenGL and Python +CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) + +# PreProcessor stuff + +CPPFLAGS += -I$(NAN_GHOST)/include +CPPFLAGS += -I$(NAN_BMFONT)/include +CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) + +# modules +CPPFLAGS += -I../../editors/include +CPPFLAGS += -I../../python +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../nodes +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../render/extern/include + +# path to the guarded memory allocator +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_MEMUTIL)/include + + +ifeq ($(WITH_VERSE), true) + CPPFLAGS += -DWITH_VERSE + CPPFLAGS += -I$(NAN_VERSE)/include + # print some other debug information + ifeq ($(VERSE_DEBUG_PRINT), true) + CPPFLAGS += -DVERSE_DEBUG_PRINT + endif +endif + +# path to our own headerfiles +CPPFLAGS += -I.. diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 2aad763336e..6f94bfac456 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -63,7 +63,10 @@ void WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); struct wmEventHandler *WM_event_add_keymap_handler(ListBase *keymap, ListBase *handlers); struct wmEventHandler *WM_event_add_modal_keymap_handler(ListBase *keymap, ListBase *handlers, wmOperator *op); - + +void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type, int value); + + /* operator api, default callbacks */ /* confirm menu + exec */ int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event); @@ -72,7 +75,7 @@ int WM_operator_winactive (struct bContext *C); /* operator api */ wmOperatorType *WM_operatortype_find(const char *idname); -void WM_operator_register(wmWindowManager *wm, wmOperator *ot); +void WM_operatortypelist_append(ListBase *lb); /* OpenGL wrappers, mimicing opengl syntax */ void wmLoadMatrix (wmWindow *win, float mat[][4]); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index c894a8908f0..9c670aff71e 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -30,11 +30,42 @@ /* exported types for WM */ +#include "wm_cursors.h" +#include "wm_event_types.h" + /* ************** wmOperatorType ************************ */ /* flag */ #define OPTYPE_REGISTER 1 +/* ************** wmEvent ************************ */ + +/* each event should have full modifier state */ +/* event comes from eventmanager and from keymap */ +typedef struct wmEvent { + struct wmEvent *next, *prev; + + short type; /* event code itself (short, is also in keymap) */ + short val; /* press, release, scrollvalue */ + short x, y; /* mouse pointer position */ + short unicode; /* future, ghost? */ + char ascii; /* from ghost */ + char pad1; + + /* modifier states */ + short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ + short keymodifier; /* rawkey modifier */ + + /* keymap item, set by handler (weak?) */ + const char *keymap_idname; + + /* custom data */ + short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ + void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ + +} wmEvent; + + /* ************** wmKeyMap ************************ */ /* modifier */ @@ -53,6 +84,27 @@ #define KM_RELEASE 1 +/* ************** notifiers ****************** */ + +typedef struct wmNotifier { + struct wmNotifier *prev, *next; + + struct wmWindow *window; + + int swinid; + int type; + int value; + +} wmNotifier; + + +enum { + WM_NOTE_REDRAW, + WM_NOTE_REFRESH, + + WM_NOTE_LAST +}; + /* ************** custom wmEvent data ************** */ #define DEV_STYLUS 1 diff --git a/source/blender/windowmanager/intern/screen_edit.c b/source/blender/windowmanager/intern/screen_edit.c new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/source/blender/windowmanager/intern/screen_edit.c diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index d62b24ed806..19bf8e67db7 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -43,12 +43,14 @@ #include "wm_event_system.h" #include "wm_event_types.h" +#include "ED_screen.h" + /* ****************************************************** */ #define MAX_OP_REGISTERED 32 /* all operations get registered in the windowmanager here */ /* called on event handling by event_system.c */ -void WM_operator_register(wmWindowManager *wm, wmOperator *op) +void wm_operator_register(wmWindowManager *wm, wmOperator *op) { wmOperator *opc= MEM_mallocN(sizeof(wmOperator), "operator registry"); int tot; @@ -90,10 +92,17 @@ void wm_check(bContext *C) /* case: no open windows at all, for old file reads */ wm_window_add_ghostwindows(C->wm); - if(C->window==NULL) C->window= C->wm->windrawable; + if(C->window==NULL) { + wm_window_make_drawable(C, C->wm->windrawable); + } + /* case: fileread */ if(C->wm->initialized==0) { + wm_window_keymap(C->wm); + ed_screen_keymap(C->wm); + + ED_screens_initialize(C->wm); C->wm->initialized= 1; } } @@ -108,7 +117,7 @@ void wm_add_default(bContext *C) win= wm_window_new(C, C->screen); wm->windrawable= win; - C->window= win; + wm_window_make_drawable(C, win); } @@ -123,9 +132,12 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) } BLI_freelistN(&wm->operators); + BLI_freelistN(&wm->windowkeymap); BLI_freelistN(&wm->screenkeymap); + BLI_freelistN(&wm->queue); + if(C && C->wm==wm) C->wm= NULL; } @@ -151,15 +163,12 @@ void WM_main(bContext *C) /* per window, all events to the window, screen, area and region handlers */ wm_event_do_handlers(C); + /* events have left notes about changes, we handle and cache it */ + wm_event_do_notifiers(C); + + /* execute cached changes draw */ + wm_draw_update(C); } } -/* While (local_event) { -Update controller stack if active changed () -Match event to an action() -Process_event() -Do_notifications() -Do_draw_updates() -} -*/ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 782c1325e2f..37efc1a1367 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -43,6 +43,9 @@ #include "BKE_blender.h" #include "BKE_global.h" +#include "ED_screen.h" +#include "ED_area.h" + #include "WM_api.h" #include "WM_types.h" #include "wm.h" @@ -84,6 +87,122 @@ void wm_event_free_all(wmWindow *win) } } +/* ********************* notifiers, listeners *************** */ + +/* win and swinid are optional context limitors */ +void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window, int swinid, int type, int value) +{ + wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); + + BLI_addtail(&wm->queue, note); + + note->window= window; + note->swinid= swinid; + note->type= type; + note->value= value; +} + +static wmNotifier *wm_notifier_next(wmWindowManager *wm) +{ + wmNotifier *note= wm->queue.first; + + if(note) BLI_remlink(&wm->queue, note); + return note; +} + +/* called in mainloop */ +void wm_event_do_notifiers(bContext *C) +{ + wmNotifier *note; + + while( (note=wm_notifier_next(C->wm)) ) { + wmWindow *win; + + for(win= C->wm->windows.first; win; win= win->next) { + ScrArea *sa; + + if(note->window && note->window!=win) + continue; + if(win->screen==NULL) + continue; + printf("notifier win %d screen %s\n", win->winid, win->screen->id.name+2); + ED_screen_do_listen(win->screen, note); + + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + ARegion *ar= sa->regionbase.first; + + for(; ar; ar= ar->next) { + if(note->swinid && note->swinid!=ar->swinid) + continue; + ED_region_do_listen(ar, note); + } + } + } + MEM_freeN(note); + } +} + +/* quick test to prevent changing window drawable */ +static int wm_draw_update_test_window(wmWindow *win) +{ + ScrArea *sa; + + if(win->screen->do_refresh) + return 1; + if(win->screen->do_draw) + return 1; + + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + ARegion *ar= sa->regionbase.first; + + for(; ar; ar= ar->next) { + /* cached notifiers */ + if(ar->do_refresh) + return 1; + if(ar->swinid && ar->do_draw) + return 1; + } + } + return 0; +} + +void wm_draw_update(bContext *C) +{ + wmWindow *win; + + for(win= C->wm->windows.first; win; win= win->next) { + if(wm_draw_update_test_window(win)) { + ScrArea *sa; + + /* sets context window+screen */ + wm_window_make_drawable(C, win); + + /* notifiers for screen redraw */ + if(win->screen->do_refresh) + ED_screen_refresh(C->wm, win); + if(win->screen->do_draw) + ED_screen_draw(win); + + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + ARegion *ar= sa->regionbase.first; + int hasdrawn= 0; + + for(; ar; ar= ar->next) { + hasdrawn |= ar->do_draw; + + /* cached notifiers */ + if(ar->do_refresh) + ED_region_do_refresh(C, ar); + + if(ar->swinid && ar->do_draw) + ED_region_do_draw(C, ar); + } + } + wm_window_swap_buffers(win); + } + } +} + /* ********************* handlers *************** */ void wm_event_free_handlers(ListBase *lb) @@ -144,7 +263,7 @@ static int wm_handler_operator_call(bContext *C, wmEventHandler *handler, wmEven retval= op.type->exec(C, &op); if( ot->flag & OPTYPE_REGISTER) - WM_operator_register(C->wm, &op); + wm_operator_register(C->wm, &op); } } } @@ -190,10 +309,7 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) { return BLI_in_rcti(rect, event->x, event->y); } -//static int wm_event_inside_f(wmEvent *event, rctf *rect) -//{ -// return BLI_in_rctf(rect, (float)event->x, (float)event->y); -//} + /* called in main loop */ /* goes over entire hierarchy: events -> window -> screen -> area -> region */ @@ -204,21 +320,20 @@ void wm_event_do_handlers(bContext *C) for(win= C->wm->windows.first; win; win= win->next) { wmEvent *event; - /* MVC demands to not draw in event handlers... for now we leave it */ - /* it also updates context (win, screen) */ - wm_window_make_drawable(C, win); - - if( C->screen==NULL ) - wm_event_free_all(C->window); + if( win->screen==NULL ) + wm_event_free_all(win); - while( (event=wm_event_next(C->window)) ) { - int action= wm_handlers_do(C, event, &C->window->handlers); + while( (event=wm_event_next(win)) ) { + int action; - if(action==WM_HANDLER_CONTINUE) - action= wm_handlers_do(C, event, &C->screen->handlers); + /* MVC demands to not draw in event handlers... for now we leave it */ + /* it also updates context (win, screen) */ + wm_window_make_drawable(C, win); + + action= wm_handlers_do(C, event, &win->handlers); if(action==WM_HANDLER_CONTINUE) { - ScrArea *sa= C->screen->areabase.first; + ScrArea *sa= win->screen->areabase.first; for(; sa; sa= sa->next) { if(wm_event_inside_i(event, &sa->winrct)) { @@ -395,7 +510,7 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata) if(win->active) { GHOST_TEventCursorData *cd= customdata; int cx, cy; - + GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); event.type= MOUSEMOVE; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 2afc63a7363..ffc535c1d46 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -74,6 +74,8 @@ #include "wm_files.h" #include "wm_window.h" +#include "ED_screen.h" + static void initbuttons(void) { // uiDefFont(UI_HELVB, @@ -116,6 +118,8 @@ void WM_init(bContext *C) set_free_windowmanager_cb(wm_close_and_free); /* library.c */ + ED_spacetypes_init(); /* editors/area/spacetype.c */ + /* get the default database, plus a wm */ WM_read_homefile(C, 0); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a744d949e81..49989000c6f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -59,6 +59,12 @@ wmOperatorType *WM_operatortype_find(const char *idname) return NULL; } +/* all ops in 1 list (for time being... needs evaluation later) */ +void WM_operatortypelist_append(ListBase *lb) +{ + addlisttolist(&global_ops, lb); +} + /* ************ default ops, exported *********** */ int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event) @@ -109,7 +115,6 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) } - #define ADD_OPTYPE(opfunc) ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \ opfunc(ot); \ BLI_addtail(&global_ops, ot) @@ -132,3 +137,6 @@ void wm_operatortype_init(void) } + + + diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 2f4e90a2e71..23fbba7a054 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -135,7 +135,7 @@ void wm_subwindow_set(wmWindow *win, int swinid) win->curswin= swin; wm_subwindow_getsize(win, &width, &height); - + glViewport(swin->winrct.xmin, swin->winrct.ymin, width, height); glScissor(swin->winrct.xmin, swin->winrct.ymin, width, height); @@ -161,20 +161,22 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) freewinid= swin->swinid+1; win->curswin= swin= MEM_callocN(sizeof(wmSubWindow), "swinopen"); - + BLI_addtail(&win->subwindows, swin); + + printf("swin %d added\n", freewinid); swin->swinid= freewinid; swin->winrct= *winrct; Mat4One(swin->viewmat); Mat4One(swin->winmat); + /* and we appy it all right away */ + wm_subwindow_set(win, swin->swinid); + /* extra service */ wm_subwindow_getsize(win, &width, &height); wmOrtho2(win, -0.375, (float)width-0.375, -0.375, (float)height-0.375); wmLoadIdentity(win); - - /* and we appy it all right away */ - wm_subwindow_set(win, swin->swinid); return swin->swinid; } @@ -203,6 +205,8 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) wmSubWindow *swin= swin_from_swinid(win, swinid); if(swin) { + int width, height; + swin->winrct= *winrct; /* CRITICAL, this clamping ensures that @@ -222,6 +226,11 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) swin->winrct.xmax= win->sizex-1; if (swin->winrct.ymax >= win->sizey) swin->winrct.ymax= win->sizey-1; + + /* extra service */ + wm_subwindow_set(win, swinid); + wm_subwindow_getsize(win, &width, &height); + wmOrtho2(win, -0.375, (float)width-0.375, -0.375, (float)height-0.375); } else { printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid); @@ -231,10 +240,6 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) /* ---------------- WM versions of OpenGL calls, using glBlah() syntax ------------------------ */ /* ----------------- exported in WM_api.h ------------------------------------------------------ */ -int glaGetOneInteger(int a) -{ - return 0; // XXX -} void wmLoadMatrix(wmWindow *win, float mat[][4]) { @@ -473,8 +478,8 @@ void myswapbuffers(void) /* XXX */ sa= G.curscreen->areabase.first; while(sa) { - if(sa->win_swap==WIN_BACK_OK) sa->win_swap= WIN_FRONT_OK; - if(sa->head_swap==WIN_BACK_OK) sa->head_swap= WIN_FRONT_OK; +// if(sa->win_swap==WIN_BACK_OK) sa->win_swap= WIN_FRONT_OK; +// if(sa->head_swap==WIN_BACK_OK) sa->head_swap= WIN_FRONT_OK; sa= sa->next; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index cab852e1763..a802efffb96 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -46,11 +46,14 @@ #include "BIF_gl.h" #include "WM_api.h" +#include "WM_types.h" #include "wm.h" #include "wm_window.h" #include "wm_subwindow.h" #include "wm_event_system.h" +#include "ED_screen.h" + /* the global to talk to ghost */ GHOST_SystemHandle g_system= NULL; @@ -140,13 +143,17 @@ wmWindow *wm_window_new(bContext *C, bScreen *screen) /* part of wm_window.c api */ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) { - wmWindow *win= wm_window_new(C, winorig->screen); /* XXX need copy */ + wmWindow *win= wm_window_new(C, winorig->screen); win->posx= winorig->posx+10; win->posy= winorig->posy; win->sizex= winorig->sizex; win->sizey= winorig->sizey; + win->screen= ED_screen_duplicate(win, win->screen); + win->screen->do_refresh= 1; + win->screen->do_draw= 1; + return win; } @@ -182,7 +189,7 @@ static void wm_window_close(bContext *C, wmWindow *win) if(C->wm->windows.first==NULL) WM_exit(C); } - + static void wm_window_open(wmWindowManager *wm, char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; @@ -217,16 +224,18 @@ static void wm_window_open(wmWindowManager *wm, char *title, wmWindow *win) if(win->eventstate==NULL) win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); - /* add keymap handler (1 for all keys in map!) */ + /* add keymap handlers (1 for all keys in map!) */ WM_event_add_keymap_handler(&wm->windowkeymap, &win->handlers); + WM_event_add_keymap_handler(&wm->screenkeymap, &win->handlers); /* until screens get drawn, make it nice grey */ glClearColor(.55, .55, .55, 0.0); glClear(GL_COLOR_BUFFER_BIT); wm_window_swap_buffers(win); + + /* standard state vars for window */ + glEnable(GL_SCISSOR_TEST); } - - } /* for wmWindows without ghostwin, open these and clear */ @@ -300,13 +309,13 @@ void wm_window_make_drawable(bContext *C, wmWindow *win) C->wm->windrawable= win; C->window= win; C->screen= win->screen; - + printf("set drawable %d\n", win->winid); GHOST_ActivateWindowDrawingContext(win->ghostwin); } } /* called by ghost, here we handle events for windows themselves or send to event system */ -int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) +static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) { bContext *C= private; GHOST_TEventType type= GHOST_GetEventType(evt); @@ -346,7 +355,7 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->active= 1; // window_handle(win, INPUTCHANGE, win->active); - /* bad ghost support for modifier keys... */ + /* bad ghost support for modifier keys... so on activate we set the modifiers again */ kdata.ascii= 0; if (win->eventstate->shift && !query_qual('s')) { kdata.key= GHOST_kKeyLeftShift; @@ -372,6 +381,7 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->eventstate->x= cx; win->eventstate->y= (win->sizey-1) - cy; + wm_window_make_drawable(C, win); break; } case GHOST_kEventWindowClose: { @@ -379,14 +389,17 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) break; } case GHOST_kEventWindowUpdate: { -// window_handle(win, REDRAW, 1); + printf("ghost redraw\n"); + + wm_window_make_drawable(C, win); + WM_event_add_notifier(C->wm, win, 0, WM_NOTE_REDRAW, 0); + break; } case GHOST_kEventWindowSize: case GHOST_kEventWindowMove: { GHOST_RectangleHandle client_rect; int l, t, r, b, scr_w, scr_h; - GHOST_TWindowState state; client_rect= GHOST_GetClientBounds(win->ghostwin); GHOST_GetRectangle(client_rect, &l, &t, &r, &b); @@ -399,24 +412,34 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->posx= l; win->posy= scr_h - t - win->sizey; - if(type!=GHOST_kEventWindowSize) - printf("win move event pos %d %d size %d %d\n", win->posx, win->posy, win->sizex, win->sizey); - - state = GHOST_GetWindowState(win->ghostwin); - - if(state==GHOST_kWindowStateNormal) - printf("window state: normal\n"); - else if(state==GHOST_kWindowStateMinimized) - printf("window state: minimized\n"); - else if(state==GHOST_kWindowStateMaximized) - printf("window state: maximized\n"); - else if(state==GHOST_kWindowStateFullScreen) - printf("window state: fullscreen\n"); + /* debug prints */ + if(0) { + GHOST_TWindowState state; + state = GHOST_GetWindowState(win->ghostwin); + + if(state==GHOST_kWindowStateNormal) + printf("window state: normal\n"); + else if(state==GHOST_kWindowStateMinimized) + printf("window state: minimized\n"); + else if(state==GHOST_kWindowStateMaximized) + printf("window state: maximized\n"); + else if(state==GHOST_kWindowStateFullScreen) + printf("window state: fullscreen\n"); + + if(type!=GHOST_kEventWindowSize) + printf("win move event pos %d %d size %d %d\n", win->posx, win->posy, win->sizex, win->sizey); + + } + + wm_window_make_drawable(C, win); + WM_event_add_notifier(C->wm, win, 0, WM_NOTE_REFRESH, 0); + WM_event_add_notifier(C->wm, win, 0, WM_NOTE_REDRAW, 0); -// window_handle(win, RESHAPE, 1); break; } default: + if(type==GHOST_kEventKeyDown) + WM_event_add_notifier(C->wm, win, 0, WM_NOTE_REDRAW, 0); wm_event_add_ghostevent(win, type, data); break; } diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 0450adc1268..8269dd48533 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -33,6 +33,9 @@ extern void wm_close_and_free_all(bContext *C, ListBase *); extern void wm_add_default(bContext *C); extern void wm_check(bContext *C); + + /* register to windowmanager for redo or macro */ +void wm_operator_register(wmWindowManager *wm, wmOperator *ot); /* wm_operator.c, for init/exit */ void wm_operatortype_free(void); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 9b918ce3cf6..54cf45db61d 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -33,31 +33,6 @@ #define WM_HANDLER_BREAK 1 -/* each event should have full modifier state */ -/* event comes from eventmanager and from keymap */ -typedef struct wmEvent { - struct wmEvent *next, *prev; - - short type; /* event code itself (short, is also in keymap) */ - short val; /* press, release, scrollvalue */ - short x, y; /* mouse pointer position */ - short unicode; /* future, ghost? */ - char ascii; /* from ghost */ - char pad1; - - /* modifier states */ - short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ - short keymodifier; /* rawkey modifier */ - - /* keymap item, set by handler (weak?) */ - const char *keymap_idname; - - /* custom data */ - short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ - void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ - -} wmEvent; - /* wmKeyMap is in DNA_windowmanager.h, it's savable */ typedef struct wmEventHandler { @@ -73,10 +48,13 @@ typedef struct wmEventHandler { } wmEventHandler; + /* handler flag */ /* after this handler all others are ignored */ #define WM_HANDLER_BLOCKING 1 + + /* custom types for handlers, for signalling, freeing */ enum { WM_HANDLER_DEFAULT, @@ -84,14 +62,17 @@ enum { }; -void wm_event_free_all (wmWindow *win); -wmEvent *wm_event_next (wmWindow *win); -void wm_event_free_handlers (ListBase *lb); +void wm_event_free_all (wmWindow *win); +wmEvent *wm_event_next (wmWindow *win); +void wm_event_free_handlers (ListBase *lb); /* goes over entire hierarchy: events -> window -> screen -> area -> region */ -void wm_event_do_handlers(bContext *C); +void wm_event_do_handlers (bContext *C); + +void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata); -void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata); +void wm_event_do_notifiers (bContext *C); +void wm_draw_update (bContext *C); #endif /* WM_EVENT_SYSTEM_H */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index ccd1c645297..c6c9046d79e 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -20,8 +20,6 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * - * The Original Code is: all of this file. - * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** |