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 int type; /* ReportType */
81 int len; /* strlen(message), saves some time calculating the word wrap */
85 typedef struct ReportList {
87 int printlevel; /* ReportType */
88 int storelevel; /* ReportType */
91 /* reports need to be before wmWindowManager */
94 /* windowmanager is saved, tag WMAN */
95 typedef struct wmWindowManager {
98 struct wmWindow *windrawable, *winactive; /* separate active from drawable */
101 int initialized; /* set on file read */
102 short file_saved; /* indicator whether data was saved */
105 ListBase operators; /* operator registry */
107 ListBase queue; /* refresh/redraw wmNotifier structs */
109 struct ReportList reports; /* information and error reports */
111 ListBase jobs; /* threaded jobs manager */
113 ListBase paintcursors; /* extra overlay cursors to draw, like circles */
115 /* used keymaps, optionally/partially saved */
121 /* the savable part, rest of data is local in ghostwinlay */
122 typedef struct wmWindow {
123 struct wmWindow *next, *prev;
125 void *ghostwin; /* dont want to include ghost.h stuff */
127 int winid, pad; /* winid also in screens, is for retrieving this window after read */
129 struct bScreen *screen; /* active screen */
130 struct bScreen *newscreen; /* temporary when switching */
131 char screenname[32]; /* MAX_ID_NAME for matching window with active screen after file read */
133 short posx, posy, sizex, sizey; /* window coords */
134 short windowstate; /* borderless, full */
135 short monitor; /* multiscreen... no idea how to store yet */
136 short active; /* set to 1 if an active window, for quick rejects */
137 short cursor; /* current mouse cursor type */
138 short lastcursor; /* for temp waitcursor */
139 short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
142 struct wmEvent *eventstate; /* storage for event system */
144 struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
146 struct wmGesture *tweak; /* internal for wm_operators.c */
148 int drawmethod, drawfail; /* internal for wm_draw.c only */
149 void *drawdata; /* internal for wm_draw.c only */
153 ListBase queue; /* all events (ghost level events were handled) */
154 ListBase handlers; /* window+screen handlers, overriding all queues */
156 ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */
157 ListBase gesture; /* gesture stuff */
160 /* should be somthing like DNA_EXCLUDE
161 * but the preprocessor first removes all comments, spaces etc */
165 typedef struct wmOperatorType {
166 struct wmOperatorType *next, *prev;
168 char *name; /* text for ui, undo */
169 char *idname; /* unique identifier */
170 char *description; /* tooltips and python docs */
172 /* this callback executes the operator without any interactive input,
173 * parameters may be provided through operator properties. cannot use
174 * any interface code or input device state.
175 * - see defines below for return values */
176 int (*exec)(struct bContext *, struct wmOperator *);
178 /* for modal temporary operators, initially invoke is called. then
179 * any further events are handled in modal. if the operation is
180 * cancelled due to some external reason, cancel is called
181 * - see defines below for return values */
182 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *);
183 int (*cancel)(struct bContext *, struct wmOperator *);
184 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *);
186 /* verify if the operator can be executed in the current context, note
187 * that the operator might still fail to execute even if this return true */
188 int (*poll)(struct bContext *);
190 /* panel for redo and repeat */
191 void *(*uiBlock)(struct wmOperator *);
193 /* rna for properties */
194 struct StructRNA *srna;
198 /* only used for operators defined with python
199 * use to store pointers to python functions */
204 #define OP_MAX_TYPENAME 64
206 /* partial copy of the event, for matching by eventhandler */
207 typedef struct wmKeymapItem {
208 struct wmKeymapItem *next, *prev;
210 char idname[64]; /* used to retrieve operator type pointer */
211 struct PointerRNA *ptr; /* rna pointer to access properties */
213 short type; /* event code itself */
214 short val; /* 0=any, 1=click, 2=release, or wheelvalue, or... */
215 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
216 short keymodifier; /* rawkey modifier */
221 #define KMAP_MAX_NAME 64
223 /* stored in WM, the actively used keymaps */
224 typedef struct wmKeyMap {
225 struct wmKeyMap *next, *prev;
229 char nameid[64]; /* global editor keymaps, or for more per space/region */
230 int spaceid; /* same IDs as in DNA_space_types.h */
231 int regionid; /* see above */
235 /* this one is the operator itself, stored in files for macros etc */
236 /* operator + operatortype should be able to redo entirely, but for different contextes */
237 typedef struct wmOperator {
238 struct wmOperator *next, *prev;
241 char idname[64]; /* used to retrieve type pointer */
242 IDProperty *properties; /* saved, user-settable properties */
245 wmOperatorType *type; /* operator type definition from idname */
246 void *customdata; /* custom storage, only while operator runs */
247 struct PointerRNA *ptr; /* rna pointer to access properties */
248 struct ReportList *reports; /* errors and warnings storage */
251 /* operator type exec(), invoke() modal(), return values */
252 #define OPERATOR_RUNNING_MODAL 1
253 #define OPERATOR_CANCELLED 2
254 #define OPERATOR_FINISHED 4
255 /* add this flag if the event should pass through */
256 #define OPERATOR_PASS_THROUGH 8
259 /* ************** wmEvent ************************ */
260 /* for read-only rna access, dont save this */
262 /* each event should have full modifier state */
263 /* event comes from eventmanager and from keymap */
264 typedef struct wmEvent {
265 struct wmEvent *next, *prev;
267 short type; /* event code itself (short, is also in keymap) */
268 short val; /* press, release, scrollvalue */
269 short x, y; /* mouse pointer position, screen coord */
270 short mval[2]; /* region mouse position, name convention pre 2.5 :) */
271 short prevx, prevy; /* previous mouse pointer position */
272 short unicode; /* future, ghost? */
273 char ascii; /* from ghost */
276 /* modifier states */
277 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
278 short keymodifier; /* rawkey modifier */
282 /* keymap item, set by handler (weak?) */
283 const char *keymap_idname;
286 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
287 short customdatafree;
289 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
293 typedef enum wmRadialControlMode {
294 WM_RADIALCONTROL_SIZE,
295 WM_RADIALCONTROL_STRENGTH,
296 WM_RADIALCONTROL_ANGLE
297 } wmRadialControlMode;
299 #endif /* DNA_WINDOWMANAGER_TYPES_H */