4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2007 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
28 #ifndef DNA_WINDOWMANAGER_TYPES_H
29 #define DNA_WINDOWMANAGER_TYPES_H
31 #include "DNA_listBase.h"
32 #include "DNA_vec_types.h"
37 struct wmWindowManager;
42 struct wmOperatorType;
60 #define OP_MAX_TYPENAME 64
61 #define KMAP_MAX_NAME 64
64 typedef enum ReportType {
70 RPT_ERROR_INVALID_INPUT = 1<<5,
71 RPT_ERROR_INVALID_CONTEXT = 1<<6,
72 RPT_ERROR_OUT_OF_MEMORY = 1<<7
75 #define RPT_DEBUG_ALL (RPT_DEBUG)
76 #define RPT_INFO_ALL (RPT_INFO)
77 #define RPT_OPERATOR_ALL (RPT_OPERATOR)
78 #define RPT_WARNING_ALL (RPT_WARNING)
79 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
81 enum ReportListFlags {
86 typedef struct Report {
87 struct Report *next, *prev;
88 short type; /* ReportType */
90 int len; /* strlen(message), saves some time calculating the word wrap */
94 typedef struct ReportList {
96 int printlevel; /* ReportType */
97 int storelevel; /* ReportType */
100 /* reports need to be before wmWindowManager */
103 /* windowmanager is saved, tag WMAN */
104 typedef struct wmWindowManager {
107 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
110 int initialized; /* set on file read */
111 short file_saved; /* indicator whether data was saved */
114 ListBase operators; /* operator registry */
116 ListBase queue; /* refresh/redraw wmNotifier structs */
118 struct ReportList reports; /* information and error reports */
120 ListBase jobs; /* threaded jobs manager */
122 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
124 ListBase keyconfigs; /* known key configurations */
125 struct wmKeyConfig *defaultconf; /* default configuration, not saved */
126 int defaultactmap, pad2; /* active keymap from default for editing */
129 /* wmWindowManager.initialized */
130 #define WM_INIT_WINDOW 1<<0
131 #define WM_INIT_KEYMAP 1<<1
133 /* the savable part, rest of data is local in ghostwinlay */
134 typedef struct wmWindow {
135 struct wmWindow *next, *prev;
137 void *ghostwin; /* dont want to include ghost.h stuff */
139 int winid, pad; /* winid also in screens, is for retrieving this window after read */
141 struct bScreen *screen; /* active screen */
142 struct bScreen *newscreen; /* temporary when switching */
143 char screenname[32]; /* MAX_ID_NAME for matching window with active screen after file read */
145 short posx, posy, sizex, sizey; /* window coords */
146 short windowstate; /* borderless, full */
147 short monitor; /* multiscreen... no idea how to store yet */
148 short active; /* set to 1 if an active window, for quick rejects */
149 short cursor; /* current mouse cursor type */
150 short lastcursor; /* for temp waitcursor */
151 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
154 struct wmEvent *eventstate; /* storage for event system */
156 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
158 struct wmGesture *tweak; /* internal for wm_operators.c */
160 int drawmethod, drawfail; /* internal for wm_draw.c only */
161 void *drawdata; /* internal for wm_draw.c only */
165 ListBase queue; /* all events (ghost level events were handled) */
166 ListBase handlers; /* window+screen handlers, handled last */
167 ListBase modalhandlers; /* priority handlers, handled first */
169 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
170 ListBase gesture; /* gesture stuff */
173 /* should be somthing like DNA_EXCLUDE
174 * but the preprocessor first removes all comments, spaces etc */
178 typedef struct wmOperatorTypeMacro {
179 struct wmOperatorTypeMacro *next, *prev;
182 char idname[MAX_ID_NAME];
183 /* rna pointer to access properties, like keymap */
184 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
185 struct PointerRNA *ptr;
187 } wmOperatorTypeMacro;
191 typedef struct wmOperatorType {
192 struct wmOperatorType *next, *prev;
194 char *name; /* text for ui, undo */
195 char *idname; /* unique identifier */
196 char *description; /* tooltips and python docs */
198 /* this callback executes the operator without any interactive input,
199 * parameters may be provided through operator properties. cannot use
200 * any interface code or input device state.
201 * - see defines below for return values */
202 int (*exec)(struct bContext *, struct wmOperator *);
204 /* for modal temporary operators, initially invoke is called. then
205 * any further events are handled in modal. if the operation is
206 * cancelled due to some external reason, cancel is called
207 * - see defines below for return values */
208 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *);
209 int (*cancel)(struct bContext *, struct wmOperator *);
210 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *);
212 /* verify if the operator can be executed in the current context, note
213 * that the operator might still fail to execute even if this return true */
214 int (*poll)(struct bContext *);
216 /* optional panel for redo and repeat, autogenerated if not set */
217 void (*ui)(struct bContext *, struct PointerRNA *, struct uiLayout *);
219 /* rna for properties */
220 struct StructRNA *srna;
222 /* struct wmOperatorTypeMacro */
227 /* pointer to modal keymap, do not free! */
228 struct wmKeyMap *modalkeymap;
230 /* only used for operators defined with python
231 * use to store pointers to python functions */
233 int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot);
238 /* partial copy of the event, for matching by eventhandler */
239 typedef struct wmKeyMapItem {
240 struct wmKeyMapItem *next, *prev;
243 char idname[64]; /* used to retrieve operator type pointer */
244 IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
247 short propvalue; /* if used, the item is from modal map */
250 short type; /* event code itself */
251 short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */
252 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
253 short keymodifier; /* rawkey modifier */
255 /* flag: inactive, expanded */
259 short maptype, pad[2]; /* keymap editor */
260 struct PointerRNA *ptr; /* rna pointer to access properties */
263 /* wmKeyMapItem.flag */
264 #define KMI_INACTIVE 1
265 #define KMI_EXPANDED 2
267 /* stored in WM, the actively used keymaps */
268 typedef struct wmKeyMap {
269 struct wmKeyMap *next, *prev;
273 char idname[64]; /* global editor keymaps, or for more per space/region */
274 short spaceid; /* same IDs as in DNA_space_types.h */
275 short regionid; /* see above */
277 short flag; /* general flags */
281 int (*poll)(struct bContext *); /* verify if enabled in the current context */
282 void *modal_items; /* for modal, EnumPropertyItem for now */
286 #define KEYMAP_MODAL 1 /* modal map, not using operatornames */
287 #define KEYMAP_USER 2 /* user created keymap */
289 typedef struct wmKeyConfig {
290 struct wmKeyConfig *next, *prev;
292 char idname[64]; /* unique name */
293 char basename[64]; /* idname of configuration this is derives from, "" if none */
299 /* wmKeyConfig.flag */
300 #define KEYCONF_TWOBUTTONMOUSE (1 << 1)
301 #define KEYCONF_LMOUSESELECT (1 << 2)
302 #define KEYCONF_NONUMPAD (1 << 3)
304 /* this one is the operator itself, stored in files for macros etc */
305 /* operator + operatortype should be able to redo entirely, but for different contextes */
306 typedef struct wmOperator {
307 struct wmOperator *next, *prev;
310 char idname[64]; /* used to retrieve type pointer */
311 IDProperty *properties; /* saved, user-settable properties */
314 wmOperatorType *type; /* operator type definition from idname */
315 void *customdata; /* custom storage, only while operator runs */
317 struct PointerRNA *ptr; /* rna pointer to access properties */
318 struct ReportList *reports; /* errors and warnings storage */
320 ListBase macro; /* list of operators, can be a tree */
321 struct wmOperator *opm; /* current running macro, not saved */
326 /* operator type exec(), invoke() modal(), return values */
327 #define OPERATOR_RUNNING_MODAL 1
328 #define OPERATOR_CANCELLED 2
329 #define OPERATOR_FINISHED 4
330 /* add this flag if the event should pass through */
331 #define OPERATOR_PASS_THROUGH 8
333 /* wmOperator flag */
334 #define OP_GRAB_POINTER 1
336 /* ************** wmEvent ************************ */
337 /* for read-only rna access, dont save this */
339 /* each event should have full modifier state */
340 /* event comes from eventmanager and from keymap */
341 typedef struct wmEvent {
342 struct wmEvent *next, *prev;
344 short type; /* event code itself (short, is also in keymap) */
345 short val; /* press, release, scrollvalue */
346 short x, y; /* mouse pointer position, screen coord */
347 short mval[2]; /* region mouse position, name convention pre 2.5 :) */
348 short prevx, prevy; /* previous mouse pointer position */
349 short unicode; /* future, ghost? */
350 char ascii; /* from ghost */
353 /* modifier states */
354 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
355 short keymodifier; /* rawkey modifier */
359 /* keymap item, set by handler (weak?) */
360 const char *keymap_idname;
363 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
364 short customdatafree;
366 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
370 typedef enum wmRadialControlMode {
371 WM_RADIALCONTROL_SIZE,
372 WM_RADIALCONTROL_STRENGTH,
373 WM_RADIALCONTROL_ANGLE
374 } wmRadialControlMode;
376 #endif /* DNA_WINDOWMANAGER_TYPES_H */