Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2007 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00031 #ifndef DNA_WINDOWMANAGER_TYPES_H 00032 #define DNA_WINDOWMANAGER_TYPES_H 00033 00034 #include "DNA_listBase.h" 00035 #include "DNA_vec_types.h" 00036 00037 #include "DNA_ID.h" 00038 00039 /* defined here: */ 00040 struct wmWindowManager; 00041 struct wmWindow; 00042 00043 struct wmEvent; 00044 struct wmGesture; 00045 struct wmOperatorType; 00046 struct wmOperator; 00047 struct wmKeyMap; 00048 struct wmKeyConfig; 00049 00050 /* forwards */ 00051 struct bContext; 00052 struct wmLocal; 00053 struct bScreen; 00054 struct uiBlock; 00055 struct wmSubWindow; 00056 struct wmTimer; 00057 struct StructRNA; 00058 struct PointerRNA; 00059 struct ReportList; 00060 struct Report; 00061 struct uiLayout; 00062 00063 #define OP_MAX_TYPENAME 64 00064 #define KMAP_MAX_NAME 64 00065 00066 /* keep in sync with 'wm_report_items' in wm_rna.c */ 00067 typedef enum ReportType { 00068 RPT_DEBUG = 1<<0, 00069 RPT_INFO = 1<<1, 00070 RPT_OPERATOR = 1<<2, 00071 RPT_WARNING = 1<<3, 00072 RPT_ERROR = 1<<4, 00073 RPT_ERROR_INVALID_INPUT = 1<<5, 00074 RPT_ERROR_INVALID_CONTEXT = 1<<6, 00075 RPT_ERROR_OUT_OF_MEMORY = 1<<7 00076 } ReportType; 00077 00078 #define RPT_DEBUG_ALL (RPT_DEBUG) 00079 #define RPT_INFO_ALL (RPT_INFO) 00080 #define RPT_OPERATOR_ALL (RPT_OPERATOR) 00081 #define RPT_WARNING_ALL (RPT_WARNING) 00082 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY) 00083 00084 enum ReportListFlags { 00085 RPT_PRINT = 1, 00086 RPT_STORE = 2, 00087 RPT_FREE = 4, 00088 RPT_OP_HOLD = 8 /* dont move them into the operator global list (caller will use) */ 00089 }; 00090 # 00091 # 00092 typedef struct Report { 00093 struct Report *next, *prev; 00094 short type; /* ReportType */ 00095 short flag; 00096 int len; /* strlen(message), saves some time calculating the word wrap */ 00097 const char *typestr; 00098 const char *message; 00099 } Report; 00100 00101 /* saved in the wm, dont remove */ 00102 typedef struct ReportList { 00103 ListBase list; 00104 int printlevel; /* ReportType */ 00105 int storelevel; /* ReportType */ 00106 int flag, pad; 00107 struct wmTimer *reporttimer; 00108 } ReportList; 00109 00110 /* timer customdata to control reports display */ 00111 # 00112 # 00113 typedef struct ReportTimerInfo { 00114 float col[3]; 00115 float greyscale; 00116 float widthfac; 00117 } ReportTimerInfo; 00118 00119 /* reports need to be before wmWindowManager */ 00120 00121 00122 /* windowmanager is saved, tag WMAN */ 00123 typedef struct wmWindowManager { 00124 ID id; 00125 00126 struct wmWindow *windrawable, *winactive; /* separate active from drawable */ 00127 ListBase windows; 00128 00129 int initialized; /* set on file read */ 00130 short file_saved; /* indicator whether data was saved */ 00131 short op_undo_depth; /* operator stack depth to avoid nested undo pushes */ 00132 00133 ListBase operators; /* operator registry */ 00134 00135 ListBase queue; /* refresh/redraw wmNotifier structs */ 00136 00137 struct ReportList reports; /* information and error reports */ 00138 00139 ListBase jobs; /* threaded jobs manager */ 00140 00141 ListBase paintcursors; /* extra overlay cursors to draw, like circles */ 00142 00143 ListBase drags; /* active dragged items */ 00144 00145 ListBase keyconfigs; /* known key configurations */ 00146 struct wmKeyConfig *defaultconf; /* default configuration */ 00147 struct wmKeyConfig *addonconf; /* addon configuration */ 00148 struct wmKeyConfig *userconf; /* user configuration */ 00149 00150 ListBase timers; /* active timers */ 00151 struct wmTimer *autosavetimer; /* timer for auto save */ 00152 } wmWindowManager; 00153 00154 /* wmWindowManager.initialized */ 00155 #define WM_INIT_WINDOW (1<<0) 00156 #define WM_INIT_KEYMAP (1<<1) 00157 00158 /* the savable part, rest of data is local in ghostwinlay */ 00159 typedef struct wmWindow { 00160 struct wmWindow *next, *prev; 00161 00162 void *ghostwin; /* dont want to include ghost.h stuff */ 00163 00164 int winid; /* winid also in screens, is for retrieving this window after read */ 00165 00166 short grabcursor; /* cursor grab mode */ 00167 short pad; 00168 00169 struct bScreen *screen; /* active screen */ 00170 struct bScreen *newscreen; /* temporary when switching */ 00171 char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */ 00172 00173 short posx, posy, sizex, sizey; /* window coords */ 00174 short windowstate; /* borderless, full */ 00175 short monitor; /* multiscreen... no idea how to store yet */ 00176 short active; /* set to 1 if an active window, for quick rejects */ 00177 short cursor; /* current mouse cursor type */ 00178 short lastcursor; /* previous cursor when setting modal one */ 00179 short modalcursor; /* the current modal cursor */ 00180 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */ 00181 short pad2; 00182 00183 struct wmEvent *eventstate; /* storage for event system */ 00184 00185 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */ 00186 00187 struct wmGesture *tweak; /* internal for wm_operators.c */ 00188 00189 int drawmethod, drawfail; /* internal for wm_draw.c only */ 00190 void *drawdata; /* internal for wm_draw.c only */ 00191 00192 ListBase queue; /* all events (ghost level events were handled) */ 00193 ListBase handlers; /* window+screen handlers, handled last */ 00194 ListBase modalhandlers; /* priority handlers, handled first */ 00195 00196 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */ 00197 ListBase gesture; /* gesture stuff */ 00198 } wmWindow; 00199 00200 /* should be somthing like DNA_EXCLUDE 00201 * but the preprocessor first removes all comments, spaces etc */ 00202 00203 # 00204 # 00205 typedef struct wmOperatorTypeMacro { 00206 struct wmOperatorTypeMacro *next, *prev; 00207 00208 /* operator id */ 00209 char idname[64]; 00210 /* rna pointer to access properties, like keymap */ 00211 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ 00212 struct PointerRNA *ptr; 00213 00214 } wmOperatorTypeMacro; 00215 00216 /* partial copy of the event, for matching by eventhandler */ 00217 typedef struct wmKeyMapItem { 00218 struct wmKeyMapItem *next, *prev; 00219 00220 /* operator */ 00221 char idname[64]; /* used to retrieve operator type pointer */ 00222 IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ 00223 00224 /* modal */ 00225 short propvalue; /* if used, the item is from modal map */ 00226 00227 /* event */ 00228 short type; /* event code itself */ 00229 short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */ 00230 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ 00231 short keymodifier; /* rawkey modifier */ 00232 00233 /* flag: inactive, expanded */ 00234 short flag; 00235 00236 /* runtime */ 00237 short maptype; /* keymap editor */ 00238 short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */ 00239 short pad; 00240 struct PointerRNA *ptr; /* rna pointer to access properties */ 00241 } wmKeyMapItem; 00242 00243 /* used instead of wmKeyMapItem for diff keymaps */ 00244 typedef struct wmKeyMapDiffItem { 00245 struct wmKeyMapDiffItem *next, *prev; 00246 00247 wmKeyMapItem *remove_item; 00248 wmKeyMapItem *add_item; 00249 } wmKeyMapDiffItem; 00250 00251 /* wmKeyMapItem.flag */ 00252 #define KMI_INACTIVE 1 00253 #define KMI_EXPANDED 2 00254 #define KMI_USER_MODIFIED 4 00255 #define KMI_UPDATE 8 00256 00257 /* stored in WM, the actively used keymaps */ 00258 typedef struct wmKeyMap { 00259 struct wmKeyMap *next, *prev; 00260 00261 ListBase items; 00262 ListBase diff_items; 00263 00264 char idname[64]; /* global editor keymaps, or for more per space/region */ 00265 short spaceid; /* same IDs as in DNA_space_types.h */ 00266 short regionid; /* see above */ 00267 00268 short flag; /* general flags */ 00269 short kmi_id; /* last kmi id */ 00270 00271 /* runtime */ 00272 int (*poll)(struct bContext *); /* verify if enabled in the current context */ 00273 void *modal_items; /* for modal, EnumPropertyItem for now */ 00274 } wmKeyMap; 00275 00276 /* wmKeyMap.flag */ 00277 #define KEYMAP_MODAL 1 /* modal map, not using operatornames */ 00278 #define KEYMAP_USER 2 /* user keymap */ 00279 #define KEYMAP_EXPANDED 4 00280 #define KEYMAP_CHILDREN_EXPANDED 8 00281 #define KEYMAP_DIFF 16 /* diff keymap for user preferences */ 00282 #define KEYMAP_USER_MODIFIED 32 /* keymap has user modifications */ 00283 #define KEYMAP_UPDATE 64 00284 00285 typedef struct wmKeyConfig { 00286 struct wmKeyConfig *next, *prev; 00287 00288 char idname[64]; /* unique name */ 00289 char basename[64]; /* idname of configuration this is derives from, "" if none */ 00290 00291 ListBase keymaps; 00292 int actkeymap, flag; 00293 } wmKeyConfig; 00294 00295 /* wmKeyConfig.flag */ 00296 #define KEYCONF_USER (1 << 1) 00297 #define KEYCONF_INIT_DEFAULT (1 << 2) 00298 00299 /* this one is the operator itself, stored in files for macros etc */ 00300 /* operator + operatortype should be able to redo entirely, but for different contextes */ 00301 typedef struct wmOperator { 00302 struct wmOperator *next, *prev; 00303 00304 /* saved */ 00305 char idname[64];/* used to retrieve type pointer */ 00306 IDProperty *properties; /* saved, user-settable properties */ 00307 00308 /* runtime */ 00309 struct wmOperatorType *type;/* operator type definition from idname */ 00310 void *customdata; /* custom storage, only while operator runs */ 00311 void *py_instance; /* python stores the class instance here */ 00312 00313 struct PointerRNA *ptr; /* rna pointer to access properties */ 00314 struct ReportList *reports; /* errors and warnings storage */ 00315 00316 ListBase macro; /* list of operators, can be a tree */ 00317 struct wmOperator *opm; /* current running macro, not saved */ 00318 struct uiLayout *layout; /* runtime for drawing */ 00319 short flag, pad[3]; 00320 00321 } wmOperator; 00322 00323 00324 /* operator type return flags: exec(), invoke() modal(), return values */ 00325 #define OPERATOR_RUNNING_MODAL (1<<0) 00326 #define OPERATOR_CANCELLED (1<<1) 00327 #define OPERATOR_FINISHED (1<<2) 00328 /* add this flag if the event should pass through */ 00329 #define OPERATOR_PASS_THROUGH (1<<3) 00330 /* in case operator got executed outside WM code... like via fileselect */ 00331 #define OPERATOR_HANDLED (1<<4) 00332 00333 #define OPERATOR_FLAGS_ALL ((1<<5)-1) 00334 00335 /* sanity checks for debug mode only */ 00336 #define OPERATOR_RETVAL_CHECK(ret) BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret) 00337 00338 /* wmOperator flag */ 00339 #define OP_GRAB_POINTER 1 00340 00341 #endif /* DNA_WINDOWMANAGER_TYPES_H */