2 * blenlib/BKE_screen.h (mar-2001 nzc)
6 * ***** BEGIN GPL LICENSE BLOCK *****
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL LICENSE BLOCK *****
36 struct bContextDataResult;
46 struct wmWindowManager;
51 #include "RNA_types.h"
53 /* spacetype has everything stored to get an editor working, it gets initialized via
54 ED_spacetypes_init() in editors/area/spacetypes.c */
55 /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
57 #define BKE_ST_MAXNAME 32
59 typedef struct SpaceType {
60 struct SpaceType *next, *prev;
62 char name[BKE_ST_MAXNAME]; /* for menus */
63 int spaceid; /* unique space identifier */
64 int iconid; /* icon lookup for menus */
66 /* initial allocation, after this WM will call init() too */
67 struct SpaceLink *(*new)(const struct bContext *C);
68 /* not free spacelink itself */
69 void (*free)(struct SpaceLink *);
71 /* init is to cope with file load, screen (size) changes, check handlers */
72 void (*init)(struct wmWindowManager *, struct ScrArea *);
73 /* Listeners can react to bContext changes */
74 void (*listener)(struct ScrArea *, struct wmNotifier *);
76 /* refresh context, called after filereads, ED_area_tag_refresh() */
77 void (*refresh)(const struct bContext *, struct ScrArea *);
79 /* after a spacedata copy, an init should result in exact same situation */
80 struct SpaceLink *(*duplicate)(struct SpaceLink *);
82 /* register operator types on startup */
83 void (*operatortypes)(void);
84 /* add default items to WM keymap */
85 void (*keymap)(struct wmKeyConfig *);
87 /* return context data */
88 int (*context)(const struct bContext *, const char*, struct bContextDataResult *);
90 /* region type definitions */
93 /* tool shelf definitions */
96 /* read and write... */
98 /* default keymaps to add */
103 /* region types are also defined using spacetypes_init, via a callback */
105 typedef struct ARegionType {
106 struct ARegionType *next, *prev;
108 int regionid; /* unique identifier within this space */
110 /* add handlers, stuff you only do once or on area/region type/size changes */
111 void (*init)(struct wmWindowManager *, struct ARegion *);
112 /* draw entirely, view changes should be handled here */
113 void (*draw)(const struct bContext *, struct ARegion *);
114 /* contextual changes should be handled here */
115 void (*listener)(struct ARegion *, struct wmNotifier *);
117 void (*free)(struct ARegion *);
119 /* split region, copy data optionally */
120 void *(*duplicate)(void *);
123 /* register operator types on startup */
124 void (*operatortypes)(void);
125 /* add own items to keymap */
126 void (*keymap)(struct wmKeyConfig *);
127 /* allows default cursor per region */
128 void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar);
130 /* return context data */
131 int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
133 /* custom drawing callbacks */
136 /* panels type definitions */
139 /* header type definitions */
140 ListBase headertypes;
142 /* menu type definitions */
145 /* hardcoded constraints, smaller than these values region is not visible */
146 int minsizex, minsizey;
147 /* default keymaps to add */
153 typedef struct PanelType {
154 struct PanelType *next, *prev;
156 char idname[BKE_ST_MAXNAME]; /* unique name */
157 char label[BKE_ST_MAXNAME]; /* for panel header */
158 char context[BKE_ST_MAXNAME]; /* for buttons window */
164 /* verify if the panel should draw or not */
165 int (*poll)(const struct bContext *, struct PanelType *);
166 /* draw header (optional) */
167 void (*draw_header)(const struct bContext *, struct Panel *);
168 /* draw entirely, view changes should be handled here */
169 void (*draw)(const struct bContext *, struct Panel *);
171 /* RNA integration */
177 typedef struct HeaderType {
178 struct HeaderType *next, *prev;
180 char idname[BKE_ST_MAXNAME]; /* unique name */
183 /* draw entirely, view changes should be handled here */
184 void (*draw)(const struct bContext *, struct Header *);
186 /* RNA integration */
190 typedef struct Header {
191 struct HeaderType *type; /* runtime */
192 struct uiLayout *layout; /* runtime for drawing */
198 typedef struct MenuType {
199 struct MenuType *next, *prev;
201 char idname[BKE_ST_MAXNAME]; /* unique name */
202 char label[BKE_ST_MAXNAME]; /* for button text */
205 /* verify if the menu should draw or not */
206 int (*poll)(const struct bContext *, struct MenuType *);
207 /* draw entirely, view changes should be handled here */
208 void (*draw)(const struct bContext *, struct Menu *);
210 /* RNA integration */
214 typedef struct Menu {
215 struct MenuType *type; /* runtime */
216 struct uiLayout *layout; /* runtime for drawing */
220 struct SpaceType *BKE_spacetype_from_id(int spaceid);
221 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
222 const struct ListBase *BKE_spacetypes_list(void);
223 void BKE_spacetype_register(struct SpaceType *st);
224 void BKE_spacetypes_free(void); /* only for quitting blender */
226 MenuType *BKE_spacemenu_find(const char *idname, int spacetype);
229 void BKE_spacedata_freelist(ListBase *lb);
230 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
231 void BKE_spacedata_copyfirst(ListBase *lb1, ListBase *lb2);
234 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
235 void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
236 void BKE_screen_area_free(struct ScrArea *sa);
239 void free_screen(struct bScreen *sc);
240 unsigned int BKE_screen_visible_layers(struct bScreen *screen);