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 /* hardcoded constraints, smaller than these values region is not visible */
143 int minsizex, minsizey;
144 /* default keymaps to add */
150 typedef struct PanelType {
151 struct PanelType *next, *prev;
153 char idname[BKE_ST_MAXNAME]; /* unique name */
154 char label[BKE_ST_MAXNAME]; /* for panel header */
155 char context[BKE_ST_MAXNAME]; /* for buttons window */
161 /* verify if the panel should draw or not */
162 int (*poll)(const struct bContext *, struct PanelType *);
163 /* draw header (optional) */
164 void (*draw_header)(const struct bContext *, struct Panel *);
165 /* draw entirely, view changes should be handled here */
166 void (*draw)(const struct bContext *, struct Panel *);
168 /* RNA integration */
174 typedef struct HeaderType {
175 struct HeaderType *next, *prev;
177 char idname[BKE_ST_MAXNAME]; /* unique name */
180 /* draw entirely, view changes should be handled here */
181 void (*draw)(const struct bContext *, struct Header *);
183 /* RNA integration */
187 typedef struct Header {
188 struct HeaderType *type; /* runtime */
189 struct uiLayout *layout; /* runtime for drawing */
195 typedef struct MenuType {
196 struct MenuType *next, *prev;
198 char idname[BKE_ST_MAXNAME]; /* unique name */
199 char label[BKE_ST_MAXNAME]; /* for button text */
201 /* verify if the menu should draw or not */
202 int (*poll)(const struct bContext *, struct MenuType *);
203 /* draw entirely, view changes should be handled here */
204 void (*draw)(const struct bContext *, struct Menu *);
206 /* RNA integration */
210 typedef struct Menu {
211 struct MenuType *type; /* runtime */
212 struct uiLayout *layout; /* runtime for drawing */
216 struct SpaceType *BKE_spacetype_from_id(int spaceid);
217 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
218 const struct ListBase *BKE_spacetypes_list(void);
219 void BKE_spacetype_register(struct SpaceType *st);
220 void BKE_spacetypes_free(void); /* only for quitting blender */
222 // MenuType *BKE_spacemenu_find(const char *idname, int spacetype);
225 void BKE_spacedata_freelist(ListBase *lb);
226 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
227 void BKE_spacedata_copyfirst(ListBase *lb1, ListBase *lb2);
230 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
231 void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
232 void BKE_screen_area_free(struct ScrArea *sa);
235 void free_screen(struct bScreen *sc);
236 unsigned int BKE_screen_visible_layers(struct bScreen *screen);