diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-08 18:02:57 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-08 18:02:57 +0300 |
commit | 02e23c16dd9e403deb1694829c11d16dc47392ee (patch) | |
tree | f5ec9e3f68bad13137bdeafa326281c74387327e /source/blender/blenkernel | |
parent | 11e15bf68979670b2257814aa296886222b3ee40 (diff) |
2.5
Part one of wrapping up area/region management.
Read design doc here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/AreaManager
This commit:
- brings keymap storage to WM, based on names/types. This structure
allows rna-ifying it too, so you can browse keymaps etc.
- creating areas and regions works slightly different now, wich
regiontypes stored in areatype.
Todo:
- better callbacks and structure for defining which handlers need to
be added.
- using region types to validate regions
- proper implementation of local region data
- code method for customizing keymaps. Current idea is that you have
to indicate an entire keymap to be custom, to prevent too complicated
merging problems of default and custom maps (like order, multiple keys
for same operator, disabling options, etc).
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 32 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 33 |
3 files changed, 62 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 129093f6078..49e6b20725d 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -40,13 +40,15 @@ struct wmWindowManager; struct ListBase; /* spacetype has everything stored to get an editor working, it gets initialized via -spacetypes_init() in editors/area/spacetypes.c */ + ED_spacetypes_init() in editors/area/spacetypes.c */ /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ +#define BKE_ST_MAXNAME 32 + typedef struct SpaceType { struct SpaceType *next, *prev; - char name[32]; /* for menus */ + char name[BKE_ST_MAXNAME]; /* for menus */ int spaceid; /* unique space identifier */ int iconid; /* icon lookup for menus */ @@ -56,7 +58,7 @@ typedef struct SpaceType { void (*free)(struct SpaceLink *); /* init is to cope with internal contextual changes, adds handlers, - * sets screarea regions */ + * creates/sets screarea regions */ void (*init)(struct wmWindowManager *, struct ScrArea *); /* refresh is for external bContext changes */ void (*refresh)(struct bContext *, struct ScrArea *); @@ -66,23 +68,35 @@ typedef struct SpaceType { /* register operator types on startup */ void (*operatortypes)(void); - /* add default items to keymap */ + /* add default items to WM keymap */ void (*keymap)(struct wmWindowManager *); + /* region type definitions */ + ListBase regiontypes; + /* 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!) */ +/* region types are also defined using spacetypes_init, via a callback */ + typedef struct ARegionType { + struct ARegionType *next, *prev; + + int regionid; /* unique identifier within this space */ 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 (*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 *); void (*free)(struct ARegion *); + + /* register operator types on startup */ + void (*operatortypes)(void); + /* add default items to keymap */ + void (*keymap)(struct wmWindowManager *); + } ARegionType; @@ -90,9 +104,13 @@ void BKE_screen_area_free(struct ScrArea *sa); void BKE_area_region_free(struct ARegion *ar); void free_screen(struct bScreen *sc); +/* spacetypes */ struct SpaceType *BKE_spacetype_from_id(int spaceid); const struct ListBase *BKE_spacetypes_list(void); void BKE_spacetype_register(struct SpaceType *st); +void BKE_spacetypes_free(void); /* only for quitting blender */ + +/* spacedata */ void BKE_spacedata_freelist(ListBase *lb); void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b63d63c925c..e5625fa03e0 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -77,6 +77,7 @@ #include "BKE_node.h" #include "BKE_object.h" #include "BKE_scene.h" +#include "BKE_screen.h" #include "BKE_sound.h" #include "BLI_editVert.h" @@ -166,6 +167,7 @@ void pushpop_test() /* ********** free ********** */ +/* only to be called on exit blender */ void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ @@ -174,6 +176,8 @@ void free_blender(void) free_main(G.main); G.main= NULL; + BKE_spacetypes_free(); /* after free main, it uses space callbacks */ + IMB_freeImBufdata(); /* imbuf lib */ free_nodesystem(); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 266a387732e..8332e7baea1 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -31,8 +31,11 @@ #include <stdio.h> #include <math.h> +#include "MEM_guardedalloc.h" + #include "DNA_screen_types.h" #include "DNA_space_types.h" + #include "BLI_blenlib.h" #include "BKE_screen.h" @@ -41,9 +44,27 @@ #include "BPY_extern.h" #endif +/* ************ Spacetype/regiontype handling ************** */ + /* keep global; this has to be accessible outside of windowmanager */ static ListBase spacetypes= {NULL, NULL}; +/* not SpaceType itself */ +static void spacetype_free(SpaceType *st) +{ + BLI_freelistN(&st->regiontypes); +} + +void BKE_spacetypes_free(void) +{ + SpaceType *st; + + for(st= spacetypes.first; st; st= st->next) + spacetype_free(st); + + BLI_freelistN(&spacetypes); +} + SpaceType *BKE_spacetype_from_id(int spaceid) { SpaceType *st; @@ -62,9 +83,21 @@ const ListBase *BKE_spacetypes_list() void BKE_spacetype_register(SpaceType *st) { + SpaceType *stype; + + /* sanity check */ + stype= BKE_spacetype_from_id(st->spaceid); + if(stype) { + printf("error: redefinition of spacetype %s\n", stype->name); + spacetype_free(stype); + MEM_freeN(stype); + } + BLI_addtail(&spacetypes, st); } +/* ***************** Space handling ********************** */ + void BKE_spacedata_freelist(ListBase *lb) { SpaceLink *sl; |