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 {
73 RPT_ERROR_INVALID_INPUT = 1<<5,
74 RPT_ERROR_INVALID_CONTEXT = 1<<6,
75 RPT_ERROR_OUT_OF_MEMORY = 1<<7
78 #define RPT_DEBUG_ALL (RPT_DEBUG)
79 #define RPT_INFO_ALL (RPT_INFO)
80 #define RPT_OPERATOR_ALL (RPT_OPERATOR)
81 #define RPT_WARNING_ALL (RPT_WARNING)
82 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
84 enum ReportListFlags {
88 RPT_OP_HOLD = 8 /* don't move them into the operator global list (caller will use) */
92 typedef struct Report {
93 struct Report *next, *prev;
94 short type; /* ReportType */
96 int len; /* strlen(message), saves some time calculating the word wrap */
101 /* saved in the wm, don't remove */
102 typedef struct ReportList {
104 int printlevel; /* ReportType */
105 int storelevel; /* ReportType */
107 struct wmTimer *reporttimer;
110 /* timer customdata to control reports display */
113 typedef struct ReportTimerInfo {
119 /* reports need to be before wmWindowManager */
122 /* windowmanager is saved, tag WMAN */
123 typedef struct wmWindowManager {
126 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
129 int initialized; /* set on file read */
130 short file_saved; /* indicator whether data was saved */
131 short op_undo_depth; /* operator stack depth to avoid nested undo pushes */
133 ListBase operators; /* operator registry */
135 ListBase queue; /* refresh/redraw wmNotifier structs */
137 struct ReportList reports; /* information and error reports */
139 ListBase jobs; /* threaded jobs manager */
141 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
143 ListBase drags; /* active dragged items */
145 ListBase keyconfigs; /* known key configurations */
146 struct wmKeyConfig *defaultconf; /* default configuration */
147 struct wmKeyConfig *addonconf; /* addon configuration */
148 struct wmKeyConfig *userconf; /* user configuration */
150 ListBase timers; /* active timers */
151 struct wmTimer *autosavetimer; /* timer for auto save */
154 /* wmWindowManager.initialized */
155 #define WM_INIT_WINDOW (1<<0)
156 #define WM_INIT_KEYMAP (1<<1)
158 /* the savable part, rest of data is local in ghostwinlay */
159 typedef struct wmWindow {
160 struct wmWindow *next, *prev;
162 void *ghostwin; /* don't want to include ghost.h stuff */
164 int winid; /* winid also in screens, is for retrieving this window after read */
166 short grabcursor; /* cursor grab mode */
169 struct bScreen *screen; /* active screen */
170 struct bScreen *newscreen; /* temporary when switching */
171 char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */
173 short posx, posy, sizex, sizey; /* window coords */
174 short windowstate; /* borderless, full */
175 short monitor; /* multiscreen... no idea how to store yet */
176 short active; /* set to 1 if an active window, for quick rejects */
177 short cursor; /* current mouse cursor type */
178 short lastcursor; /* previous cursor when setting modal one */
179 short modalcursor; /* the current modal cursor */
180 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
183 struct wmEvent *eventstate; /* storage for event system */
185 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
187 struct wmGesture *tweak; /* internal for wm_operators.c */
189 int drawmethod, drawfail; /* internal for wm_draw.c only */
190 void *drawdata; /* internal for wm_draw.c only */
192 ListBase queue; /* all events (ghost level events were handled) */
193 ListBase handlers; /* window+screen handlers, handled last */
194 ListBase modalhandlers; /* priority handlers, handled first */
196 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
197 ListBase gesture; /* gesture stuff */
200 /* should be something like DNA_EXCLUDE
201 * but the preprocessor first removes all comments, spaces etc */
205 typedef struct wmOperatorTypeMacro {
206 struct wmOperatorTypeMacro *next, *prev;
210 /* rna pointer to access properties, like keymap */
211 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
212 struct PointerRNA *ptr;
214 } wmOperatorTypeMacro;
216 /* partial copy of the event, for matching by eventhandler */
217 typedef struct wmKeyMapItem {
218 struct wmKeyMapItem *next, *prev;
221 char idname[64]; /* used to retrieve operator type pointer */
222 IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
225 char propvalue_str[64]; /* runtime temporary storage for loading */
226 short propvalue; /* if used, the item is from modal map */
229 short type; /* event code itself */
230 short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */
231 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
232 short keymodifier; /* rawkey modifier */
234 /* flag: inactive, expanded */
238 short maptype; /* keymap editor */
239 short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */
241 struct PointerRNA *ptr; /* rna pointer to access properties */
244 /* used instead of wmKeyMapItem for diff keymaps */
245 typedef struct wmKeyMapDiffItem {
246 struct wmKeyMapDiffItem *next, *prev;
248 wmKeyMapItem *remove_item;
249 wmKeyMapItem *add_item;
252 /* wmKeyMapItem.flag */
253 #define KMI_INACTIVE 1
254 #define KMI_EXPANDED 2
255 #define KMI_USER_MODIFIED 4
258 /* stored in WM, the actively used keymaps */
259 typedef struct wmKeyMap {
260 struct wmKeyMap *next, *prev;
265 char idname[64]; /* global editor keymaps, or for more per space/region */
266 short spaceid; /* same IDs as in DNA_space_types.h */
267 short regionid; /* see above */
269 short flag; /* general flags */
270 short kmi_id; /* last kmi id */
273 int (*poll)(struct bContext *); /* verify if enabled in the current context */
274 void *modal_items; /* for modal, EnumPropertyItem for now */
278 #define KEYMAP_MODAL 1 /* modal map, not using operatornames */
279 #define KEYMAP_USER 2 /* user keymap */
280 #define KEYMAP_EXPANDED 4
281 #define KEYMAP_CHILDREN_EXPANDED 8
282 #define KEYMAP_DIFF 16 /* diff keymap for user preferences */
283 #define KEYMAP_USER_MODIFIED 32 /* keymap has user modifications */
284 #define KEYMAP_UPDATE 64
286 typedef struct wmKeyConfig {
287 struct wmKeyConfig *next, *prev;
289 char idname[64]; /* unique name */
290 char basename[64]; /* idname of configuration this is derives from, "" if none */
296 /* wmKeyConfig.flag */
297 #define KEYCONF_USER (1 << 1)
298 #define KEYCONF_INIT_DEFAULT (1 << 2)
300 /* this one is the operator itself, stored in files for macros etc */
301 /* operator + operatortype should be able to redo entirely, but for different contextes */
302 typedef struct wmOperator {
303 struct wmOperator *next, *prev;
306 char idname[64];/* used to retrieve type pointer */
307 IDProperty *properties; /* saved, user-settable properties */
310 struct wmOperatorType *type;/* operator type definition from idname */
311 void *customdata; /* custom storage, only while operator runs */
312 void *py_instance; /* python stores the class instance here */
314 struct PointerRNA *ptr; /* rna pointer to access properties */
315 struct ReportList *reports; /* errors and warnings storage */
317 ListBase macro; /* list of operators, can be a tree */
318 struct wmOperator *opm; /* current running macro, not saved */
319 struct uiLayout *layout; /* runtime for drawing */
325 /* operator type return flags: exec(), invoke() modal(), return values */
326 #define OPERATOR_RUNNING_MODAL (1<<0)
327 #define OPERATOR_CANCELLED (1<<1)
328 #define OPERATOR_FINISHED (1<<2)
329 /* add this flag if the event should pass through */
330 #define OPERATOR_PASS_THROUGH (1<<3)
331 /* in case operator got executed outside WM code... like via fileselect */
332 #define OPERATOR_HANDLED (1<<4)
334 #define OPERATOR_FLAGS_ALL ((1<<5)-1)
336 /* sanity checks for debug mode only */
337 #define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
339 /* wmOperator flag */
340 #define OP_GRAB_POINTER 1
342 #endif /* __DNA_WINDOWMANAGER_TYPES_H__ */