BKE_screen.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  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.
  8. *
  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.
  13. *
  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.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. #ifndef __BKE_SCREEN_H__
  28. #define __BKE_SCREEN_H__
  29. /** \file BKE_screen.h
  30. * \ingroup bke
  31. * \since March 2001
  32. * \author nzc
  33. */
  34. struct ARegion;
  35. struct Header;
  36. struct ID;
  37. struct ListBase;
  38. struct Menu;
  39. struct Panel;
  40. struct Scene;
  41. struct ScrArea;
  42. struct SpaceType;
  43. struct View3D;
  44. struct bContext;
  45. struct bContextDataResult;
  46. struct bScreen;
  47. struct uiLayout;
  48. struct uiList;
  49. struct wmKeyConfig;
  50. struct wmNotifier;
  51. struct wmWindow;
  52. struct wmWindowManager;
  53. struct GPUFXSettings;
  54. #include "BLI_compiler_attrs.h"
  55. #include "RNA_types.h"
  56. /* spacetype has everything stored to get an editor working, it gets initialized via
  57. * ED_spacetypes_init() in editors/space_api/spacetypes.c */
  58. /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
  59. #define BKE_ST_MAXNAME 64
  60. typedef struct SpaceType {
  61. 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 */
  65. /* initial allocation, after this WM will call init() too */
  66. struct SpaceLink *(*new)(const struct bContext *C);
  67. /* not free spacelink itself */
  68. void (*free)(struct SpaceLink *);
  69. /* init is to cope with file load, screen (size) changes, check handlers */
  70. void (*init)(struct wmWindowManager *, struct ScrArea *);
  71. /* exit is called when the area is hidden or removed */
  72. void (*exit)(struct wmWindowManager *, struct ScrArea *);
  73. /* Listeners can react to bContext changes */
  74. void (*listener)(struct bScreen *sc, struct ScrArea *, struct wmNotifier *);
  75. /* refresh context, called after filereads, ED_area_tag_refresh() */
  76. void (*refresh)(const struct bContext *, struct ScrArea *);
  77. /* after a spacedata copy, an init should result in exact same situation */
  78. struct SpaceLink *(*duplicate)(struct SpaceLink *);
  79. /* register operator types on startup */
  80. void (*operatortypes)(void);
  81. /* add default items to WM keymap */
  82. void (*keymap)(struct wmKeyConfig *);
  83. /* on startup, define dropboxes for spacetype+regions */
  84. void (*dropboxes)(void);
  85. /* return context data */
  86. int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
  87. /* Used when we want to replace an ID by another (or NULL). */
  88. void (*id_remap)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *);
  89. /* region type definitions */
  90. ListBase regiontypes;
  91. /* tool shelf definitions */
  92. ListBase toolshelf;
  93. /* read and write... */
  94. /* default keymaps to add */
  95. int keymapflag;
  96. } SpaceType;
  97. /* region types are also defined using spacetypes_init, via a callback */
  98. typedef struct ARegionType {
  99. struct ARegionType *next, *prev;
  100. int regionid; /* unique identifier within this space, defines RGN_TYPE_xxxx */
  101. /* add handlers, stuff you only do once or on area/region type/size changes */
  102. void (*init)(struct wmWindowManager *, struct ARegion *);
  103. /* exit is called when the region is hidden or removed */
  104. void (*exit)(struct wmWindowManager *, struct ARegion *);
  105. /* draw entirely, view changes should be handled here */
  106. void (*draw)(const struct bContext *, struct ARegion *);
  107. /* contextual changes should be handled here */
  108. void (*listener)(struct bScreen *sc, struct ScrArea *, struct ARegion *, struct wmNotifier *);
  109. void (*free)(struct ARegion *);
  110. /* split region, copy data optionally */
  111. void *(*duplicate)(void *);
  112. /* register operator types on startup */
  113. void (*operatortypes)(void);
  114. /* add own items to keymap */
  115. void (*keymap)(struct wmKeyConfig *);
  116. /* allows default cursor per region */
  117. void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar);
  118. /* return context data */
  119. int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
  120. /* custom drawing callbacks */
  121. ListBase drawcalls;
  122. /* panels type definitions */
  123. ListBase paneltypes;
  124. /* header type definitions */
  125. ListBase headertypes;
  126. /* hardcoded constraints, smaller than these values region is not visible */
  127. int minsizex, minsizey;
  128. /* when new region opens (region prefsizex/y are zero then */
  129. int prefsizex, prefsizey;
  130. /* default keymaps to add */
  131. int keymapflag;
  132. /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */
  133. short do_lock, lock;
  134. /* call cursor function on each move event */
  135. short event_cursor;
  136. } ARegionType;
  137. /* panel types */
  138. typedef struct PanelType {
  139. struct PanelType *next, *prev;
  140. char idname[BKE_ST_MAXNAME]; /* unique name */
  141. char label[BKE_ST_MAXNAME]; /* for panel header */
  142. char translation_context[BKE_ST_MAXNAME];
  143. char context[BKE_ST_MAXNAME]; /* for buttons window */
  144. char category[BKE_ST_MAXNAME]; /* for category tabs */
  145. int space_type;
  146. int region_type;
  147. int flag;
  148. /* verify if the panel should draw or not */
  149. int (*poll)(const struct bContext *, struct PanelType *);
  150. /* draw header (optional) */
  151. void (*draw_header)(const struct bContext *, struct Panel *);
  152. /* draw entirely, view changes should be handled here */
  153. void (*draw)(const struct bContext *, struct Panel *);
  154. /* RNA integration */
  155. ExtensionRNA ext;
  156. } PanelType;
  157. /* uilist types */
  158. /* Draw an item in the uiList */
  159. typedef void (*uiListDrawItemFunc)(struct uiList *, struct bContext *, struct uiLayout *, struct PointerRNA *,
  160. struct PointerRNA *, int, struct PointerRNA *, const char *, int, int);
  161. /* Draw the filtering part of an uiList */
  162. typedef void (*uiListDrawFilterFunc)(struct uiList *, struct bContext *, struct uiLayout *);
  163. /* Filter items of an uiList */
  164. typedef void (*uiListFilterItemsFunc)(struct uiList *, struct bContext *, struct PointerRNA *, const char *);
  165. typedef struct uiListType {
  166. struct uiListType *next, *prev;
  167. char idname[BKE_ST_MAXNAME]; /* unique name */
  168. uiListDrawItemFunc draw_item;
  169. uiListDrawFilterFunc draw_filter;
  170. uiListFilterItemsFunc filter_items;
  171. /* RNA integration */
  172. ExtensionRNA ext;
  173. } uiListType;
  174. /* header types */
  175. typedef struct HeaderType {
  176. struct HeaderType *next, *prev;
  177. char idname[BKE_ST_MAXNAME]; /* unique name */
  178. int space_type;
  179. /* draw entirely, view changes should be handled here */
  180. void (*draw)(const struct bContext *, struct Header *);
  181. /* RNA integration */
  182. ExtensionRNA ext;
  183. } HeaderType;
  184. typedef struct Header {
  185. struct HeaderType *type; /* runtime */
  186. struct uiLayout *layout; /* runtime for drawing */
  187. } Header;
  188. /* menu types */
  189. typedef struct MenuType {
  190. struct MenuType *next, *prev;
  191. char idname[BKE_ST_MAXNAME]; /* unique name */
  192. char label[BKE_ST_MAXNAME]; /* for button text */
  193. char translation_context[BKE_ST_MAXNAME];
  194. const char *description;
  195. /* verify if the menu should draw or not */
  196. int (*poll)(const struct bContext *, struct MenuType *);
  197. /* draw entirely, view changes should be handled here */
  198. void (*draw)(const struct bContext *, struct Menu *);
  199. /* RNA integration */
  200. ExtensionRNA ext;
  201. } MenuType;
  202. typedef struct Menu {
  203. struct MenuType *type; /* runtime */
  204. struct uiLayout *layout; /* runtime for drawing */
  205. } Menu;
  206. /* spacetypes */
  207. struct SpaceType *BKE_spacetype_from_id(int spaceid);
  208. struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
  209. const struct ListBase *BKE_spacetypes_list(void);
  210. void BKE_spacetype_register(struct SpaceType *st);
  211. bool BKE_spacetype_exists(int spaceid);
  212. void BKE_spacetypes_free(void); /* only for quitting blender */
  213. /* spacedata */
  214. void BKE_spacedata_freelist(ListBase *lb);
  215. void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
  216. void BKE_spacedata_draw_locks(int set);
  217. void BKE_spacedata_callback_id_remap_set(void (*func)(struct ScrArea *, struct SpaceLink *, struct ID *, struct ID *));
  218. void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID *id);
  219. /* area/regions */
  220. struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
  221. void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
  222. void BKE_screen_area_free(struct ScrArea *sa);
  223. struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
  224. struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
  225. struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y);
  226. struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2);
  227. struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
  228. struct ScrArea *BKE_screen_find_area_xy(struct bScreen *sc, const int spacetype, int x, int y);
  229. unsigned int BKE_screen_view3d_layer_active_ex(
  230. const struct View3D *v3d, const struct Scene *scene, bool use_localvd) ATTR_NONNULL(2);
  231. unsigned int BKE_screen_view3d_layer_active(
  232. const struct View3D *v3d, const struct Scene *scene) ATTR_NONNULL(2);
  233. unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
  234. void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
  235. void BKE_screen_view3d_scene_sync(struct bScreen *sc);
  236. void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
  237. void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i);
  238. void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
  239. void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings);
  240. /* zoom factor conversion */
  241. float BKE_screen_view3d_zoom_to_fac(float camzoom);
  242. float BKE_screen_view3d_zoom_from_fac(float zoomfac);
  243. /* screen */
  244. void BKE_screen_free(struct bScreen *sc);
  245. unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
  246. #endif