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;
58 #define OP_MAX_TYPENAME 64
59 #define KMAP_MAX_NAME 64
62 typedef enum ReportType {
68 RPT_ERROR_INVALID_INPUT = 1<<5,
69 RPT_ERROR_INVALID_CONTEXT = 1<<6,
70 RPT_ERROR_OUT_OF_MEMORY = 1<<7
73 #define RPT_DEBUG_ALL (RPT_DEBUG)
74 #define RPT_INFO_ALL (RPT_INFO)
75 #define RPT_OPERATOR_ALL (RPT_OPERATOR)
76 #define RPT_WARNING_ALL (RPT_WARNING)
77 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
79 enum ReportListFlags {
83 typedef struct Report {
84 struct Report *next, *prev;
85 short type; /* ReportType */
87 int len; /* strlen(message), saves some time calculating the word wrap */
91 typedef struct ReportList {
93 int printlevel; /* ReportType */
94 int storelevel; /* ReportType */
97 /* reports need to be before wmWindowManager */
100 /* windowmanager is saved, tag WMAN */
101 typedef struct wmWindowManager {
104 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
107 int initialized; /* set on file read */
108 short file_saved; /* indicator whether data was saved */
111 ListBase operators; /* operator registry */
113 ListBase queue; /* refresh/redraw wmNotifier structs */
115 struct ReportList reports; /* information and error reports */
117 ListBase jobs; /* threaded jobs manager */
119 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
121 /* used keymaps, optionally/partially saved */
126 /* wmWindowManager.initialized */
127 #define WM_INIT_WINDOW 1<<0
128 #define WM_INIT_KEYMAP 1<<1
130 /* the savable part, rest of data is local in ghostwinlay */
131 typedef struct wmWindow {
132 struct wmWindow *next, *prev;
134 void *ghostwin; /* dont want to include ghost.h stuff */
136 int winid, pad; /* winid also in screens, is for retrieving this window after read */
138 struct bScreen *screen; /* active screen */
139 struct bScreen *newscreen; /* temporary when switching */
140 char screenname[32]; /* MAX_ID_NAME for matching window with active screen after file read */
142 short posx, posy, sizex, sizey; /* window coords */
143 short windowstate; /* borderless, full */
144 short monitor; /* multiscreen... no idea how to store yet */
145 short active; /* set to 1 if an active window, for quick rejects */
146 short cursor; /* current mouse cursor type */
147 short lastcursor; /* for temp waitcursor */
148 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
149 short downstate; /* used for drag & drop: remembers mouse button down state */
150 short downx, downy; /* mouse coords for button down event */
151 short pad3, pad4, pad5;
153 struct wmEvent *eventstate; /* storage for event system */
155 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
157 struct wmGesture *tweak; /* internal for wm_operators.c */
159 int drawmethod, drawfail; /* internal for wm_draw.c only */
160 void *drawdata; /* internal for wm_draw.c only */
164 ListBase queue; /* all events (ghost level events were handled) */
165 ListBase handlers; /* window+screen handlers, overriding all queues */
167 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
168 ListBase gesture; /* gesture stuff */
171 /* should be somthing like DNA_EXCLUDE
172 * but the preprocessor first removes all comments, spaces etc */
176 typedef struct wmOperatorType {
177 struct wmOperatorType *next, *prev;
179 char *name; /* text for ui, undo */
180 char *idname; /* unique identifier */
181 char *description; /* tooltips and python docs */
183 /* this callback executes the operator without any interactive input,
184 * parameters may be provided through operator properties. cannot use
185 * any interface code or input device state.
186 * - see defines below for return values */
187 int (*exec)(struct bContext *, struct wmOperator *);
189 /* for modal temporary operators, initially invoke is called. then
190 * any further events are handled in modal. if the operation is
191 * cancelled due to some external reason, cancel is called
192 * - see defines below for return values */
193 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *);
194 int (*cancel)(struct bContext *, struct wmOperator *);
195 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *);
197 /* verify if the operator can be executed in the current context, note
198 * that the operator might still fail to execute even if this return true */
199 int (*poll)(struct bContext *);
201 /* panel for redo and repeat */
202 void *(*uiBlock)(struct wmOperator *);
204 /* rna for properties */
205 struct StructRNA *srna;
209 /* pointer to modal keymap, do not free! */
210 struct wmKeyMap *modalkeymap;
212 /* only used for operators defined with python
213 * use to store pointers to python functions */
219 /* partial copy of the event, for matching by eventhandler */
220 typedef struct wmKeymapItem {
221 struct wmKeymapItem *next, *prev;
223 char idname[64]; /* used to retrieve operator type pointer */
224 struct PointerRNA *ptr; /* rna pointer to access properties */
226 short type; /* event code itself */
227 short val; /* 0=any, 1=click, 2=release, or wheelvalue, or... */
228 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
229 short keymodifier; /* rawkey modifier */
231 short propvalue; /* if used, the item is from modal map */
233 short inactive; /* if set, deactivated item */
234 short maptype; /* keymap editor */
239 /* stored in WM, the actively used keymaps */
240 typedef struct wmKeyMap {
241 struct wmKeyMap *next, *prev;
245 char nameid[64]; /* global editor keymaps, or for more per space/region */
246 short spaceid; /* same IDs as in DNA_space_types.h */
247 short regionid; /* see above */
249 short is_modal; /* modal map, not using operatornames */
252 void *items; /* struct EnumPropertyItem for now */
256 /* this one is the operator itself, stored in files for macros etc */
257 /* operator + operatortype should be able to redo entirely, but for different contextes */
258 typedef struct wmOperator {
259 struct wmOperator *next, *prev;
262 char idname[64]; /* used to retrieve type pointer */
263 IDProperty *properties; /* saved, user-settable properties */
266 wmOperatorType *type; /* operator type definition from idname */
267 void *customdata; /* custom storage, only while operator runs */
268 struct PointerRNA *ptr; /* rna pointer to access properties */
269 struct ReportList *reports; /* errors and warnings storage */
273 /* operator type exec(), invoke() modal(), return values */
274 #define OPERATOR_RUNNING_MODAL 1
275 #define OPERATOR_CANCELLED 2
276 #define OPERATOR_FINISHED 4
277 /* add this flag if the event should pass through */
278 #define OPERATOR_PASS_THROUGH 8
281 /* ************** wmEvent ************************ */
282 /* for read-only rna access, dont save this */
284 /* each event should have full modifier state */
285 /* event comes from eventmanager and from keymap */
286 typedef struct wmEvent {
287 struct wmEvent *next, *prev;
289 short type; /* event code itself (short, is also in keymap) */
290 short val; /* press, release, scrollvalue */
291 short x, y; /* mouse pointer position, screen coord */
292 short mval[2]; /* region mouse position, name convention pre 2.5 :) */
293 short prevx, prevy; /* previous mouse pointer position */
294 short unicode; /* future, ghost? */
295 char ascii; /* from ghost */
298 /* modifier states */
299 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
300 short keymodifier; /* rawkey modifier */
304 /* keymap item, set by handler (weak?) */
305 const char *keymap_idname;
308 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
309 short customdatafree;
311 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
315 typedef enum wmRadialControlMode {
316 WM_RADIALCONTROL_SIZE,
317 WM_RADIALCONTROL_STRENGTH,
318 WM_RADIALCONTROL_ANGLE
319 } wmRadialControlMode;
321 #endif /* DNA_WINDOWMANAGER_TYPES_H */