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;
57 typedef enum ReportType {
63 RPT_ERROR_INVALID_INPUT = 1<<5,
64 RPT_ERROR_INVALID_CONTEXT = 1<<6,
65 RPT_ERROR_OUT_OF_MEMORY = 1<<7
68 #define RPT_DEBUG_ALL (RPT_DEBUG)
69 #define RPT_INFO_ALL (RPT_INFO)
70 #define RPT_OPERATOR_ALL (RPT_OPERATOR)
71 #define RPT_WARNING_ALL (RPT_WARNING)
72 #define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
74 enum ReportListFlags {
78 typedef struct Report {
79 struct Report *next, *prev;
80 short type; /* ReportType */
82 int len; /* strlen(message), saves some time calculating the word wrap */
86 typedef struct ReportList {
88 int printlevel; /* ReportType */
89 int storelevel; /* ReportType */
92 /* reports need to be before wmWindowManager */
95 /* windowmanager is saved, tag WMAN */
96 typedef struct wmWindowManager {
99 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
102 int initialized; /* set on file read */
103 short file_saved; /* indicator whether data was saved */
106 ListBase operators; /* operator registry */
108 ListBase queue; /* refresh/redraw wmNotifier structs */
110 struct ReportList reports; /* information and error reports */
112 ListBase jobs; /* threaded jobs manager */
114 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
116 /* used keymaps, optionally/partially saved */
121 /* wmWindowManager.initialized */
122 #define WM_INIT_WINDOW 1<<0
123 #define WM_INIT_KEYMAP 1<<1
125 /* the savable part, rest of data is local in ghostwinlay */
126 typedef struct wmWindow {
127 struct wmWindow *next, *prev;
129 void *ghostwin; /* dont want to include ghost.h stuff */
131 int winid, pad; /* winid also in screens, is for retrieving this window after read */
133 struct bScreen *screen; /* active screen */
134 struct bScreen *newscreen; /* temporary when switching */
135 char screenname[32]; /* MAX_ID_NAME for matching window with active screen after file read */
137 short posx, posy, sizex, sizey; /* window coords */
138 short windowstate; /* borderless, full */
139 short monitor; /* multiscreen... no idea how to store yet */
140 short active; /* set to 1 if an active window, for quick rejects */
141 short cursor; /* current mouse cursor type */
142 short lastcursor; /* for temp waitcursor */
143 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
146 struct wmEvent *eventstate; /* storage for event system */
148 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
150 struct wmGesture *tweak; /* internal for wm_operators.c */
152 int drawmethod, drawfail; /* internal for wm_draw.c only */
153 void *drawdata; /* internal for wm_draw.c only */
157 ListBase queue; /* all events (ghost level events were handled) */
158 ListBase handlers; /* window+screen handlers, overriding all queues */
160 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
161 ListBase gesture; /* gesture stuff */
164 /* should be somthing like DNA_EXCLUDE
165 * but the preprocessor first removes all comments, spaces etc */
169 typedef struct wmOperatorType {
170 struct wmOperatorType *next, *prev;
172 char *name; /* text for ui, undo */
173 char *idname; /* unique identifier */
174 char *description; /* tooltips and python docs */
176 /* this callback executes the operator without any interactive input,
177 * parameters may be provided through operator properties. cannot use
178 * any interface code or input device state.
179 * - see defines below for return values */
180 int (*exec)(struct bContext *, struct wmOperator *);
182 /* for modal temporary operators, initially invoke is called. then
183 * any further events are handled in modal. if the operation is
184 * cancelled due to some external reason, cancel is called
185 * - see defines below for return values */
186 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *);
187 int (*cancel)(struct bContext *, struct wmOperator *);
188 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *);
190 /* verify if the operator can be executed in the current context, note
191 * that the operator might still fail to execute even if this return true */
192 int (*poll)(struct bContext *);
194 /* panel for redo and repeat */
195 void *(*uiBlock)(struct wmOperator *);
197 /* rna for properties */
198 struct StructRNA *srna;
202 /* only used for operators defined with python
203 * use to store pointers to python functions */
208 #define OP_MAX_TYPENAME 64
210 /* partial copy of the event, for matching by eventhandler */
211 typedef struct wmKeymapItem {
212 struct wmKeymapItem *next, *prev;
214 char idname[64]; /* used to retrieve operator type pointer */
215 struct PointerRNA *ptr; /* rna pointer to access properties */
217 short type; /* event code itself */
218 short val; /* 0=any, 1=click, 2=release, or wheelvalue, or... */
219 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
220 short keymodifier; /* rawkey modifier */
225 #define KMAP_MAX_NAME 64
227 /* stored in WM, the actively used keymaps */
228 typedef struct wmKeyMap {
229 struct wmKeyMap *next, *prev;
233 char nameid[64]; /* global editor keymaps, or for more per space/region */
234 int spaceid; /* same IDs as in DNA_space_types.h */
235 int regionid; /* see above */
239 /* this one is the operator itself, stored in files for macros etc */
240 /* operator + operatortype should be able to redo entirely, but for different contextes */
241 typedef struct wmOperator {
242 struct wmOperator *next, *prev;
245 char idname[64]; /* used to retrieve type pointer */
246 IDProperty *properties; /* saved, user-settable properties */
249 wmOperatorType *type; /* operator type definition from idname */
250 void *customdata; /* custom storage, only while operator runs */
251 struct PointerRNA *ptr; /* rna pointer to access properties */
252 struct ReportList *reports; /* errors and warnings storage */
255 /* operator type exec(), invoke() modal(), return values */
256 #define OPERATOR_RUNNING_MODAL 1
257 #define OPERATOR_CANCELLED 2
258 #define OPERATOR_FINISHED 4
259 /* add this flag if the event should pass through */
260 #define OPERATOR_PASS_THROUGH 8
263 /* ************** wmEvent ************************ */
264 /* for read-only rna access, dont save this */
266 /* each event should have full modifier state */
267 /* event comes from eventmanager and from keymap */
268 typedef struct wmEvent {
269 struct wmEvent *next, *prev;
271 short type; /* event code itself (short, is also in keymap) */
272 short val; /* press, release, scrollvalue */
273 short x, y; /* mouse pointer position, screen coord */
274 short mval[2]; /* region mouse position, name convention pre 2.5 :) */
275 short prevx, prevy; /* previous mouse pointer position */
276 short unicode; /* future, ghost? */
277 char ascii; /* from ghost */
280 /* modifier states */
281 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
282 short keymodifier; /* rawkey modifier */
286 /* keymap item, set by handler (weak?) */
287 const char *keymap_idname;
290 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
291 short customdatafree;
293 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
297 typedef enum wmRadialControlMode {
298 WM_RADIALCONTROL_SIZE,
299 WM_RADIALCONTROL_STRENGTH,
300 WM_RADIALCONTROL_ANGLE
301 } wmRadialControlMode;
303 #endif /* DNA_WINDOWMANAGER_TYPES_H */