2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
27 #ifndef __BKE_SCREEN_H__
28 #define __BKE_SCREEN_H__
30 /** \file BKE_screen.h
47 struct bContextDataResult;
54 struct wmWindowManager;
57 #include "BLI_compiler_attrs.h"
59 #include "RNA_types.h"
61 /* spacetype has everything stored to get an editor working, it gets initialized via
62 * ED_spacetypes_init() in editors/space_api/spacetypes.c */
63 /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
65 #define BKE_ST_MAXNAME 64
67 typedef struct SpaceType {
68 struct SpaceType *next, *prev;
70 char name[BKE_ST_MAXNAME]; /* for menus */
71 int spaceid; /* unique space identifier */
72 int iconid; /* icon lookup for menus */
74 /* initial allocation, after this WM will call init() too */
75 struct SpaceLink *(*new)(const struct bContext *C);
76 /* not free spacelink itself */
77 void (*free)(struct SpaceLink *sl);
79 /* init is to cope with file load, screen (size) changes, check handlers */
80 void (*init)(struct wmWindowManager *wm, struct ScrArea *sa);
81 /* exit is called when the area is hidden or removed */
82 void (*exit)(struct wmWindowManager *wm, struct ScrArea *sa);
83 /* Listeners can react to bContext changes */
84 void (*listener)(struct bScreen *sc, struct ScrArea *sa, struct wmNotifier *wmn);
86 /* refresh context, called after filereads, ED_area_tag_refresh() */
87 void (*refresh)(const struct bContext *C, struct ScrArea *sa);
89 /* after a spacedata copy, an init should result in exact same situation */
90 struct SpaceLink *(*duplicate)(struct SpaceLink *sl);
92 /* register operator types on startup */
93 void (*operatortypes)(void);
94 /* add default items to WM keymap */
95 void (*keymap)(struct wmKeyConfig *keyconf);
96 /* on startup, define dropboxes for spacetype+regions */
97 void (*dropboxes)(void);
99 /* return context data */
100 int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
102 /* Used when we want to replace an ID by another (or NULL). */
103 void (*id_remap)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id);
105 /* region type definitions */
106 ListBase regiontypes;
108 /* tool shelf definitions */
111 /* read and write... */
113 /* default keymaps to add */
118 /* region types are also defined using spacetypes_init, via a callback */
120 typedef struct ARegionType {
121 struct ARegionType *next, *prev;
123 /* unique identifier within this space, defines RGN_TYPE_xxxx */
126 /* add handlers, stuff you only do once or on area/region type/size changes */
127 void (*init)(struct wmWindowManager *wm, struct ARegion *ar);
128 /* exit is called when the region is hidden or removed */
129 void (*exit)(struct wmWindowManager *wm, struct ARegion *ar);
130 /* draw entirely, view changes should be handled here */
131 void (*draw)(const struct bContext *C, struct ARegion *ar);
132 /* contextual changes should be handled here */
133 void (*listener)(struct bScreen *sc, struct ScrArea *sa, struct ARegion *ar, struct wmNotifier *wmn);
135 void (*free)(struct ARegion *ar);
137 /* split region, copy data optionally */
138 void *(*duplicate)(void *poin);
141 /* register operator types on startup */
142 void (*operatortypes)(void);
143 /* add own items to keymap */
144 void (*keymap)(struct wmKeyConfig *keyconf);
145 /* allows default cursor per region */
146 void (*cursor)(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
148 /* return context data */
149 int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
151 /* custom drawing callbacks */
154 /* panels type definitions */
157 /* header type definitions */
158 ListBase headertypes;
160 /* hardcoded constraints, smaller than these values region is not visible */
161 int minsizex, minsizey;
162 /* when new region opens (region prefsizex/y are zero then */
163 int prefsizex, prefsizey;
164 /* default keymaps to add */
166 /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */
168 /* call cursor function on each move event */
174 typedef struct PanelType {
175 struct PanelType *next, *prev;
177 char idname[BKE_ST_MAXNAME]; /* unique name */
178 char label[BKE_ST_MAXNAME]; /* for panel header */
179 char translation_context[BKE_ST_MAXNAME];
180 char context[BKE_ST_MAXNAME]; /* for buttons window */
181 char category[BKE_ST_MAXNAME]; /* for category tabs */
187 /* verify if the panel should draw or not */
188 int (*poll)(const struct bContext *C, struct PanelType *pt);
189 /* draw header (optional) */
190 void (*draw_header)(const struct bContext *C, struct Panel *pa);
191 /* draw entirely, view changes should be handled here */
192 void (*draw)(const struct bContext *C, struct Panel *pa);
194 /* RNA integration */
200 /* Draw an item in the uiList */
201 typedef void (*uiListDrawItemFunc)(
202 struct uiList *ui_list, struct bContext *C, struct uiLayout *layout, struct PointerRNA *dataptr,
203 struct PointerRNA *itemptr, int icon, struct PointerRNA *active_dataptr, const char *active_propname,
204 int index, int flt_flag);
206 /* Draw the filtering part of an uiList */
207 typedef void (*uiListDrawFilterFunc)(
208 struct uiList *ui_list, struct bContext *C, struct uiLayout *layout);
210 /* Filter items of an uiList */
211 typedef void (*uiListFilterItemsFunc)(
212 struct uiList *ui_list, struct bContext *C, struct PointerRNA *, const char *propname);
214 typedef struct uiListType {
215 struct uiListType *next, *prev;
217 char idname[BKE_ST_MAXNAME]; /* unique name */
219 uiListDrawItemFunc draw_item;
220 uiListDrawFilterFunc draw_filter;
221 uiListFilterItemsFunc filter_items;
223 /* RNA integration */
229 typedef struct HeaderType {
230 struct HeaderType *next, *prev;
232 char idname[BKE_ST_MAXNAME]; /* unique name */
235 /* draw entirely, view changes should be handled here */
236 void (*draw)(const struct bContext *C, struct Header *header);
238 /* RNA integration */
242 typedef struct Header {
243 struct HeaderType *type; /* runtime */
244 struct uiLayout *layout; /* runtime for drawing */
250 typedef struct MenuType {
251 struct MenuType *next, *prev;
253 char idname[BKE_ST_MAXNAME]; /* unique name */
254 char label[BKE_ST_MAXNAME]; /* for button text */
255 char translation_context[BKE_ST_MAXNAME];
256 const char *description;
258 /* verify if the menu should draw or not */
259 int (*poll)(const struct bContext *C, struct MenuType *mt);
260 /* draw entirely, view changes should be handled here */
261 void (*draw)(const struct bContext *C, struct Menu *menu);
263 /* RNA integration */
267 typedef struct Menu {
268 struct MenuType *type; /* runtime */
269 struct uiLayout *layout; /* runtime for drawing */
273 struct SpaceType *BKE_spacetype_from_id(int spaceid);
274 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
275 const struct ListBase *BKE_spacetypes_list(void);
276 void BKE_spacetype_register(struct SpaceType *st);
277 bool BKE_spacetype_exists(int spaceid);
278 void BKE_spacetypes_free(void); /* only for quitting blender */
281 void BKE_spacedata_freelist(ListBase *lb);
282 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
283 void BKE_spacedata_draw_locks(int set);
285 void BKE_spacedata_callback_id_remap_set(
286 void (*func)(struct ScrArea *sa, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id));
287 void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id);
290 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
291 void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
292 void BKE_screen_area_free(struct ScrArea *sa);
294 struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
295 struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
296 struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y);
297 struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
298 struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
299 struct ScrArea *BKE_screen_find_area_xy(struct bScreen *sc, const int spacetype, int x, int y);
301 unsigned int BKE_screen_view3d_layer_active_ex(
302 const struct View3D *v3d, const struct Scene *scene, bool use_localvd) ATTR_NONNULL(2);
303 unsigned int BKE_screen_view3d_layer_active(
304 const struct View3D *v3d, const struct Scene *scene) ATTR_NONNULL(2);
306 unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
308 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
309 void BKE_screen_view3d_scene_sync(struct bScreen *sc);
310 void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
311 void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i);
312 void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
313 void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings);
315 /* zoom factor conversion */
316 float BKE_screen_view3d_zoom_to_fac(float camzoom);
317 float BKE_screen_view3d_zoom_from_fac(float zoomfac);
320 void BKE_screen_free(struct bScreen *sc);
321 unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
323 #endif /* __BKE_SCREEN_H__ */