|
Blender
V2.59
|
00001 /* 00002 * $Id: BKE_screen.h 36787 2011-05-20 04:14:29Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 #ifndef BKE_SCREEN_H 00030 #define BKE_SCREEN_H 00031 00038 struct ARegion; 00039 struct bContext; 00040 struct bContextDataResult; 00041 struct bScreen; 00042 struct ListBase; 00043 struct Panel; 00044 struct Header; 00045 struct Menu; 00046 struct ScrArea; 00047 struct SpaceType; 00048 struct Scene; 00049 struct wmNotifier; 00050 struct wmWindow; 00051 struct wmWindowManager; 00052 struct wmKeyConfig; 00053 struct uiLayout; 00054 struct uiMenuItem; 00055 00056 #include "RNA_types.h" 00057 00058 /* spacetype has everything stored to get an editor working, it gets initialized via 00059 ED_spacetypes_init() in editors/area/spacetypes.c */ 00060 /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ 00061 00062 #define BKE_ST_MAXNAME 64 00063 00064 typedef struct SpaceType { 00065 struct SpaceType *next, *prev; 00066 00067 char name[BKE_ST_MAXNAME]; /* for menus */ 00068 int spaceid; /* unique space identifier */ 00069 int iconid; /* icon lookup for menus */ 00070 00071 /* initial allocation, after this WM will call init() too */ 00072 struct SpaceLink *(*new)(const struct bContext *C); 00073 /* not free spacelink itself */ 00074 void (*free)(struct SpaceLink *); 00075 00076 /* init is to cope with file load, screen (size) changes, check handlers */ 00077 void (*init)(struct wmWindowManager *, struct ScrArea *); 00078 /* Listeners can react to bContext changes */ 00079 void (*listener)(struct ScrArea *, struct wmNotifier *); 00080 00081 /* refresh context, called after filereads, ED_area_tag_refresh() */ 00082 void (*refresh)(const struct bContext *, struct ScrArea *); 00083 00084 /* after a spacedata copy, an init should result in exact same situation */ 00085 struct SpaceLink *(*duplicate)(struct SpaceLink *); 00086 00087 /* register operator types on startup */ 00088 void (*operatortypes)(void); 00089 /* add default items to WM keymap */ 00090 void (*keymap)(struct wmKeyConfig *); 00091 /* on startup, define dropboxes for spacetype+regions */ 00092 void (*dropboxes)(void); 00093 00094 /* return context data */ 00095 int (*context)(const struct bContext *, const char*, struct bContextDataResult *); 00096 00097 /* region type definitions */ 00098 ListBase regiontypes; 00099 00100 /* tool shelf definitions */ 00101 ListBase toolshelf; 00102 00103 /* read and write... */ 00104 00105 /* default keymaps to add */ 00106 int keymapflag; 00107 00108 } SpaceType; 00109 00110 /* region types are also defined using spacetypes_init, via a callback */ 00111 00112 typedef struct ARegionType { 00113 struct ARegionType *next, *prev; 00114 00115 int regionid; /* unique identifier within this space, defines RGN_TYPE_xxxx */ 00116 00117 /* add handlers, stuff you only do once or on area/region type/size changes */ 00118 void (*init)(struct wmWindowManager *, struct ARegion *); 00119 /* draw entirely, view changes should be handled here */ 00120 void (*draw)(const struct bContext *, struct ARegion *); 00121 /* contextual changes should be handled here */ 00122 void (*listener)(struct ARegion *, struct wmNotifier *); 00123 00124 void (*free)(struct ARegion *); 00125 00126 /* split region, copy data optionally */ 00127 void *(*duplicate)(void *); 00128 00129 00130 /* register operator types on startup */ 00131 void (*operatortypes)(void); 00132 /* add own items to keymap */ 00133 void (*keymap)(struct wmKeyConfig *); 00134 /* allows default cursor per region */ 00135 void (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar); 00136 00137 /* return context data */ 00138 int (*context)(const struct bContext *, const char *, struct bContextDataResult *); 00139 00140 /* custom drawing callbacks */ 00141 ListBase drawcalls; 00142 00143 /* panels type definitions */ 00144 ListBase paneltypes; 00145 00146 /* header type definitions */ 00147 ListBase headertypes; 00148 00149 /* hardcoded constraints, smaller than these values region is not visible */ 00150 int minsizex, minsizey; 00151 /* when new region opens (region prefsizex/y are zero then */ 00152 int prefsizex, prefsizey; 00153 /* default keymaps to add */ 00154 int keymapflag; 00155 /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */ 00156 short do_lock, lock; 00157 } ARegionType; 00158 00159 /* panel types */ 00160 00161 typedef struct PanelType { 00162 struct PanelType *next, *prev; 00163 00164 char idname[BKE_ST_MAXNAME]; /* unique name */ 00165 char label[BKE_ST_MAXNAME]; /* for panel header */ 00166 char context[BKE_ST_MAXNAME]; /* for buttons window */ 00167 int space_type; 00168 int region_type; 00169 00170 int flag; 00171 00172 /* verify if the panel should draw or not */ 00173 int (*poll)(const struct bContext *, struct PanelType *); 00174 /* draw header (optional) */ 00175 void (*draw_header)(const struct bContext *, struct Panel *); 00176 /* draw entirely, view changes should be handled here */ 00177 void (*draw)(const struct bContext *, struct Panel *); 00178 00179 /* RNA integration */ 00180 ExtensionRNA ext; 00181 } PanelType; 00182 00183 /* header types */ 00184 00185 typedef struct HeaderType { 00186 struct HeaderType *next, *prev; 00187 00188 char idname[BKE_ST_MAXNAME]; /* unique name */ 00189 int space_type; 00190 00191 /* draw entirely, view changes should be handled here */ 00192 void (*draw)(const struct bContext *, struct Header *); 00193 00194 /* RNA integration */ 00195 ExtensionRNA ext; 00196 } HeaderType; 00197 00198 typedef struct Header { 00199 struct HeaderType *type; /* runtime */ 00200 struct uiLayout *layout; /* runtime for drawing */ 00201 } Header; 00202 00203 00204 /* menu types */ 00205 00206 typedef struct MenuType { 00207 struct MenuType *next, *prev; 00208 00209 char idname[BKE_ST_MAXNAME]; /* unique name */ 00210 char label[BKE_ST_MAXNAME]; /* for button text */ 00211 00212 /* verify if the menu should draw or not */ 00213 int (*poll)(const struct bContext *, struct MenuType *); 00214 /* draw entirely, view changes should be handled here */ 00215 void (*draw)(const struct bContext *, struct Menu *); 00216 00217 /* RNA integration */ 00218 ExtensionRNA ext; 00219 } MenuType; 00220 00221 typedef struct Menu { 00222 struct MenuType *type; /* runtime */ 00223 struct uiLayout *layout; /* runtime for drawing */ 00224 } Menu; 00225 00226 /* spacetypes */ 00227 struct SpaceType *BKE_spacetype_from_id(int spaceid); 00228 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid); 00229 const struct ListBase *BKE_spacetypes_list(void); 00230 void BKE_spacetype_register(struct SpaceType *st); 00231 void BKE_spacetypes_free(void); /* only for quitting blender */ 00232 00233 /* spacedata */ 00234 void BKE_spacedata_freelist(ListBase *lb); 00235 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); 00236 void BKE_spacedata_draw_locks(int set); 00237 00238 /* area/regions */ 00239 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); 00240 void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); 00241 void BKE_screen_area_free(struct ScrArea *sa); 00242 00243 struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); 00244 00245 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); 00246 void BKE_screen_view3d_scene_sync(struct bScreen *sc); 00247 void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene); 00248 00249 /* zoom factor conversion */ 00250 float BKE_screen_view3d_zoom_to_fac(float camzoom); 00251 float BKE_screen_view3d_zoom_from_fac(float zoomfac); 00252 00253 /* screen */ 00254 void free_screen(struct bScreen *sc); 00255 unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); 00256 00257 #endif 00258