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) 2007 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Blender Foundation
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file DNA_windowmanager_types.h
31 #ifndef __DNA_WINDOWMANAGER_TYPES_H__
32 #define __DNA_WINDOWMANAGER_TYPES_H__
34 #include "DNA_listBase.h"
35 #include "DNA_vec_types.h"
40 struct wmWindowManager;
45 struct wmOperatorType;
63 #define OP_MAX_TYPENAME 64
64 #define KMAP_MAX_NAME 64
66 /* keep in sync with 'wm_report_items' in wm_rna.c */
67 typedef enum ReportType {
70 RPT_OPERATOR = 1 << 2,
71 RPT_PROPERTY = 1 << 3,
74 RPT_ERROR_INVALID_INPUT = 1 << 6,
75 RPT_ERROR_INVALID_CONTEXT = 1 << 7,
76 RPT_ERROR_OUT_OF_MEMORY = 1 << 8
79 #define RPT_DEBUG_ALL (RPT_DEBUG)
80 #define RPT_INFO_ALL (RPT_INFO)
81 #define RPT_OPERATOR_ALL (RPT_OPERATOR)
82 #define RPT_PROPERTY_ALL (RPT_PROPERTY)
83 #define RPT_WARNING_ALL (RPT_WARNING)
84 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
86 enum ReportListFlags {
90 RPT_OP_HOLD = 8 /* don't move them into the operator global list (caller will use) */
94 typedef struct Report {
95 struct Report *next, *prev;
96 short type; /* ReportType */
98 int len; /* strlen(message), saves some time calculating the word wrap */
103 /* saved in the wm, don't remove */
104 typedef struct ReportList {
106 int printlevel; /* ReportType */
107 int storelevel; /* ReportType */
109 struct wmTimer *reporttimer;
112 /* timer customdata to control reports display */
115 typedef struct ReportTimerInfo {
121 /* reports need to be before wmWindowManager */
124 /* windowmanager is saved, tag WMAN */
125 typedef struct wmWindowManager {
128 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
131 int initialized; /* set on file read */
132 short file_saved; /* indicator whether data was saved */
133 short op_undo_depth; /* operator stack depth to avoid nested undo pushes */
135 ListBase operators; /* operator registry */
137 ListBase queue; /* refresh/redraw wmNotifier structs */
139 struct ReportList reports; /* information and error reports */
141 ListBase jobs; /* threaded jobs manager */
143 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
145 ListBase drags; /* active dragged items */
147 ListBase keyconfigs; /* known key configurations */
148 struct wmKeyConfig *defaultconf; /* default configuration */
149 struct wmKeyConfig *addonconf; /* addon configuration */
150 struct wmKeyConfig *userconf; /* user configuration */
152 ListBase timers; /* active timers */
153 struct wmTimer *autosavetimer; /* timer for auto save */
156 /* wmWindowManager.initialized */
157 #define WM_INIT_WINDOW (1<<0)
158 #define WM_INIT_KEYMAP (1<<1)
160 /* the savable part, rest of data is local in ghostwinlay */
161 typedef struct wmWindow {
162 struct wmWindow *next, *prev;
164 void *ghostwin; /* don't want to include ghost.h stuff */
166 int winid; /* winid also in screens, is for retrieving this window after read */
168 short grabcursor; /* cursor grab mode */
171 struct bScreen *screen; /* active screen */
172 struct bScreen *newscreen; /* temporary when switching */
173 char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
175 short posx, posy, sizex, sizey; /* window coords */
176 short windowstate; /* borderless, full */
177 short monitor; /* multiscreen... no idea how to store yet */
178 short active; /* set to 1 if an active window, for quick rejects */
179 short cursor; /* current mouse cursor type */
180 short lastcursor; /* previous cursor when setting modal one */
181 short modalcursor; /* the current modal cursor */
182 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
185 struct wmEvent *eventstate; /* storage for event system */
187 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
189 struct wmGesture *tweak; /* internal for wm_operators.c */
191 int drawmethod, drawfail; /* internal for wm_draw.c only */
192 void *drawdata; /* internal for wm_draw.c only */
194 ListBase queue; /* all events (ghost level events were handled) */
195 ListBase handlers; /* window+screen handlers, handled last */
196 ListBase modalhandlers; /* priority handlers, handled first */
198 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
199 ListBase gesture; /* gesture stuff */
202 /* should be something like DNA_EXCLUDE
203 * but the preprocessor first removes all comments, spaces etc */
207 typedef struct wmOperatorTypeMacro {
208 struct wmOperatorTypeMacro *next, *prev;
212 /* rna pointer to access properties, like keymap */
213 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
214 struct PointerRNA *ptr;
216 } wmOperatorTypeMacro;
218 /* partial copy of the event, for matching by eventhandler */
219 typedef struct wmKeyMapItem {
220 struct wmKeyMapItem *next, *prev;
223 char idname[64]; /* used to retrieve operator type pointer */
224 IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
227 char propvalue_str[64]; /* runtime temporary storage for loading */
228 short propvalue; /* if used, the item is from modal map */
231 short type; /* event code itself */
232 short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */
233 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
234 short keymodifier; /* rawkey modifier */
236 /* flag: inactive, expanded */
240 short maptype; /* keymap editor */
241 short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */
243 struct PointerRNA *ptr; /* rna pointer to access properties */
246 /* used instead of wmKeyMapItem for diff keymaps */
247 typedef struct wmKeyMapDiffItem {
248 struct wmKeyMapDiffItem *next, *prev;
250 wmKeyMapItem *remove_item;
251 wmKeyMapItem *add_item;
254 /* wmKeyMapItem.flag */
255 #define KMI_INACTIVE 1
256 #define KMI_EXPANDED 2
257 #define KMI_USER_MODIFIED 4
260 /* stored in WM, the actively used keymaps */
261 typedef struct wmKeyMap {
262 struct wmKeyMap *next, *prev;
267 char idname[64]; /* global editor keymaps, or for more per space/region */
268 short spaceid; /* same IDs as in DNA_space_types.h */
269 short regionid; /* see above */
271 short flag; /* general flags */
272 short kmi_id; /* last kmi id */
275 int (*poll)(struct bContext *); /* verify if enabled in the current context */
276 void *modal_items; /* for modal, EnumPropertyItem for now */
280 #define KEYMAP_MODAL 1 /* modal map, not using operatornames */
281 #define KEYMAP_USER 2 /* user keymap */
282 #define KEYMAP_EXPANDED 4
283 #define KEYMAP_CHILDREN_EXPANDED 8
284 #define KEYMAP_DIFF 16 /* diff keymap for user preferences */
285 #define KEYMAP_USER_MODIFIED 32 /* keymap has user modifications */
286 #define KEYMAP_UPDATE 64
288 typedef struct wmKeyConfig {
289 struct wmKeyConfig *next, *prev;
291 char idname[64]; /* unique name */
292 char basename[64]; /* idname of configuration this is derives from, "" if none */
298 /* wmKeyConfig.flag */
299 #define KEYCONF_USER (1 << 1)
300 #define KEYCONF_INIT_DEFAULT (1 << 2)
302 /* this one is the operator itself, stored in files for macros etc */
303 /* operator + operatortype should be able to redo entirely, but for different contextes */
304 typedef struct wmOperator {
305 struct wmOperator *next, *prev;
308 char idname[64];/* used to retrieve type pointer */
309 IDProperty *properties; /* saved, user-settable properties */
312 struct wmOperatorType *type;/* operator type definition from idname */
313 void *customdata; /* custom storage, only while operator runs */
314 void *py_instance; /* python stores the class instance here */
316 struct PointerRNA *ptr; /* rna pointer to access properties */
317 struct ReportList *reports; /* errors and warnings storage */
319 ListBase macro; /* list of operators, can be a tree */
320 struct wmOperator *opm; /* current running macro, not saved */
321 struct uiLayout *layout; /* runtime for drawing */
327 /* operator type return flags: exec(), invoke() modal(), return values */
328 #define OPERATOR_RUNNING_MODAL (1<<0)
329 #define OPERATOR_CANCELLED (1<<1)
330 #define OPERATOR_FINISHED (1<<2)
331 /* add this flag if the event should pass through */
332 #define OPERATOR_PASS_THROUGH (1<<3)
333 /* in case operator got executed outside WM code... like via fileselect */
334 #define OPERATOR_HANDLED (1<<4)
336 #define OPERATOR_FLAGS_ALL ((1<<5)-1)
338 /* sanity checks for debug mode only */
339 #define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
341 /* wmOperator flag */
342 #define OP_GRAB_POINTER 1
344 #endif /* __DNA_WINDOWMANAGER_TYPES_H__ */