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 blender/windowmanager/WM_types.h
40 struct wmWindowManager;
45 #include "RNA_types.h"
46 #include "DNA_listBase.h"
47 #include "BKE_utildefines.h" /* FILE_MAX */
49 /* exported types for WM */
50 #include "wm_cursors.h"
51 #include "wm_event_types.h"
53 /* ************** wmOperatorType ************************ */
56 #define OPTYPE_REGISTER 1 /* register operators in stack after finishing */
57 #define OPTYPE_UNDO 2 /* do undo push after after */
58 #define OPTYPE_BLOCKING 4 /* let blender grab all input from the WM (X11) */
59 #define OPTYPE_MACRO 8
60 #define OPTYPE_GRAB_POINTER 16 /* */
61 #define OPTYPE_PRESET 32 /* show preset menu */
62 #define OPTYPE_INTERNAL 64 /* some operators are mainly for internal use
63 * and don't make sense to be accessed from the
64 * search menu, even if poll() returns TRUE.
65 * currently only used for the search toolbox */
67 /* context to call operator in for WM_operator_name_call */
68 /* rna_ui.c contains EnumPropertyItem's of these, keep in sync */
70 /* if there's invoke, call it, otherwise exec */
72 WM_OP_INVOKE_REGION_WIN,
73 WM_OP_INVOKE_REGION_CHANNELS,
74 WM_OP_INVOKE_REGION_PREVIEW,
79 WM_OP_EXEC_REGION_WIN,
80 WM_OP_EXEC_REGION_CHANNELS,
81 WM_OP_EXEC_REGION_PREVIEW,
86 /* ************** wmKeyMap ************************ */
93 /* means modifier should be pressed 2nd */
99 /* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl */
100 /* note that KM_ANY and FALSE are used with these defines too */
101 #define KM_MOD_FIRST 1
102 #define KM_MOD_SECOND 2
104 /* type: defined in wm_event_types.c */
105 #define KM_TEXTINPUT -2
113 #define KM_DBL_CLICK 4
116 /* ************** UI Handler ***************** */
118 #define WM_UI_HANDLER_CONTINUE 0
119 #define WM_UI_HANDLER_BREAK 1
121 typedef int (*wmUIHandlerFunc)(struct bContext *C, struct wmEvent *event, void *userdata);
122 typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
124 /* ************** Notifiers ****************** */
126 typedef struct wmNotifier {
127 struct wmNotifier *next, *prev;
129 struct wmWindowManager *wm;
130 struct wmWindow *window;
132 int swinid; /* can't rely on this, notifiers can be added without context, swinid of 0 */
133 unsigned int category, data, subtype, action;
144 0x0000FF00; data subtype (unused?)
149 #define NOTE_CATEGORY 0xFF000000
150 #define NC_WM (1<<24)
151 #define NC_WINDOW (2<<24)
152 #define NC_SCREEN (3<<24)
153 #define NC_SCENE (4<<24)
154 #define NC_OBJECT (5<<24)
155 #define NC_MATERIAL (6<<24)
156 #define NC_TEXTURE (7<<24)
157 #define NC_LAMP (8<<24)
158 #define NC_GROUP (9<<24)
159 #define NC_IMAGE (10<<24)
160 #define NC_BRUSH (11<<24)
161 #define NC_TEXT (12<<24)
162 #define NC_WORLD (13<<24)
163 #define NC_ANIMATION (14<<24)
164 #define NC_SPACE (15<<24)
165 #define NC_GEOM (16<<24)
166 #define NC_NODE (17<<24)
167 #define NC_ID (18<<24)
168 #define NC_LOGIC (19<<24)
169 #define NC_MOVIECLIP (20<<24)
171 /* data type, 256 entries is enough, it can overlap */
172 #define NOTE_DATA 0x00FF0000
174 /* NC_WM windowmanager */
175 #define ND_FILEREAD (1<<16)
176 #define ND_FILESAVE (2<<16)
177 #define ND_DATACHANGED (3<<16)
178 #define ND_HISTORY (4<<16)
179 #define ND_JOB (5<<16)
181 /* NC_SCREEN screen */
182 #define ND_SCREENBROWSE (1<<16)
183 #define ND_SCREENDELETE (2<<16)
184 #define ND_SCREENCAST (3<<16)
185 #define ND_ANIMPLAY (4<<16)
186 #define ND_GPENCIL (5<<16)
187 #define ND_EDITOR_CHANGED (6<<16) /*sent to new editors after switching to them*/
188 #define ND_SCREENSET (7<<16)
189 #define ND_SKETCH (8<<16)
190 #define ND_SUBWINACTIVE (9<<16)
193 #define ND_SCENEBROWSE (1<<16)
194 #define ND_MARKERS (2<<16)
195 #define ND_FRAME (3<<16)
196 #define ND_RENDER_OPTIONS (4<<16)
197 #define ND_NODES (5<<16)
198 #define ND_SEQUENCER (6<<16)
199 #define ND_OB_ACTIVE (7<<16)
200 #define ND_OB_SELECT (8<<16)
201 #define ND_OB_VISIBLE (9<<16)
202 #define ND_OB_RENDER (10<<16)
203 #define ND_MODE (11<<16)
204 #define ND_RENDER_RESULT (12<<16)
205 #define ND_COMPO_RESULT (13<<16)
206 #define ND_KEYINGSET (14<<16)
207 #define ND_TOOLSETTINGS (15<<16)
208 #define ND_LAYER (16<<16)
209 #define ND_FRAME_RANGE (17<<16)
210 #define ND_TRANSFORM_DONE (18<<16)
211 #define ND_WORLD (92<<16)
212 #define ND_LAYER_CONTENT (101<<16)
214 /* NC_OBJECT Object */
215 #define ND_TRANSFORM (18<<16)
216 #define ND_OB_SHADING (19<<16)
217 #define ND_POSE (20<<16)
218 #define ND_BONE_ACTIVE (21<<16)
219 #define ND_BONE_SELECT (22<<16)
220 #define ND_DRAW (23<<16)
221 #define ND_MODIFIER (24<<16)
222 #define ND_KEYS (25<<16)
223 #define ND_CONSTRAINT (26<<16)
224 #define ND_PARTICLE (27<<16)
225 #define ND_POINTCACHE (28<<16)
226 #define ND_PARENT (29<<16)
228 /* NC_MATERIAL Material */
229 #define ND_SHADING (30<<16)
230 #define ND_SHADING_DRAW (31<<16)
233 #define ND_LIGHTING (40<<16)
234 #define ND_LIGHTING_DRAW (41<<16)
235 #define ND_SKY (42<<16)
238 #define ND_WORLD_DRAW (45<<16)
239 #define ND_WORLD_STARS (46<<16)
242 #define ND_CURSOR (50<<16)
243 #define ND_DISPLAY (51<<16)
245 /* NC_ANIMATION Animato */
246 #define ND_KEYFRAME (70<<16)
247 #define ND_KEYFRAME_PROP (71<<16)
248 #define ND_ANIMCHAN (72<<16)
249 #define ND_NLA (73<<16)
250 #define ND_NLA_ACTCHANGE (74<<16)
251 #define ND_FCURVES_ORDER (75<<16)
253 /* NC_GEOM Geometry */
254 /* Mesh, Curve, MetaBall, Armature, .. */
255 #define ND_SELECT (90<<16)
256 #define ND_DATA (91<<16)
261 #define ND_SPACE_CONSOLE (1<<16) /* general redraw */
262 #define ND_SPACE_INFO_REPORT (2<<16) /* update for reports, could specify type */
263 #define ND_SPACE_INFO (3<<16)
264 #define ND_SPACE_IMAGE (4<<16)
265 #define ND_SPACE_FILE_PARAMS (5<<16)
266 #define ND_SPACE_FILE_LIST (6<<16)
267 #define ND_SPACE_NODE (7<<16)
268 #define ND_SPACE_OUTLINER (8<<16)
269 #define ND_SPACE_VIEW3D (9<<16)
270 #define ND_SPACE_PROPERTIES (10<<16)
271 #define ND_SPACE_TEXT (11<<16)
272 #define ND_SPACE_TIME (12<<16)
273 #define ND_SPACE_GRAPH (13<<16)
274 #define ND_SPACE_DOPESHEET (14<<16)
275 #define ND_SPACE_NLA (15<<16)
276 #define ND_SPACE_SEQUENCER (16<<16)
277 #define ND_SPACE_NODE_VIEW (17<<16)
278 #define ND_SPACE_CHANGED (18<<16) /*sent to a new editor type after it's replaced an old one*/
279 #define ND_SPACE_CLIP (19<<16)
281 /* subtype, 256 entries too */
282 #define NOTE_SUBTYPE 0x0000FF00
284 /* subtype scene mode */
285 #define NS_MODE_OBJECT (1<<8)
287 #define NS_EDITMODE_MESH (2<<8)
288 #define NS_EDITMODE_CURVE (3<<8)
289 #define NS_EDITMODE_SURFACE (4<<8)
290 #define NS_EDITMODE_TEXT (5<<8)
291 #define NS_EDITMODE_MBALL (6<<8)
292 #define NS_EDITMODE_LATTICE (7<<8)
293 #define NS_EDITMODE_ARMATURE (8<<8)
294 #define NS_MODE_POSE (9<<8)
295 #define NS_MODE_PARTICLE (10<<8)
297 /* subtype 3d view editing */
298 #define NS_VIEW3D_GPU (16<<8)
300 /* action classification */
301 #define NOTE_ACTION (0x000000FF)
303 #define NA_EVALUATED 2
307 #define NA_SELECTED 6
309 /* ************** Gesture Manager data ************** */
311 /* wmGesture->type */
312 #define WM_GESTURE_TWEAK 0
313 #define WM_GESTURE_LINES 1
314 #define WM_GESTURE_RECT 2
315 #define WM_GESTURE_CROSS_RECT 3
316 #define WM_GESTURE_LASSO 4
317 #define WM_GESTURE_CIRCLE 5
318 #define WM_GESTURE_STRAIGHTLINE 6
320 /* wmGesture is registered to window listbase, handled by operator callbacks */
321 /* tweak gesture is builtin feature */
322 typedef struct wmGesture {
323 struct wmGesture *next, *prev;
324 int event_type; /* event->type */
325 int mode; /* for modal callback */
326 int type; /* gesture type define */
327 int swinid; /* initial subwindow id where it started */
328 int points; /* optional, amount of points stored */
329 int size; /* optional, maximum amount of points stored */
332 /* customdata for border is a recti */
333 /* customdata for circle is recti, (xmin, ymin) is center, xmax radius */
334 /* customdata for lasso is short array */
335 /* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */
338 /* ************** wmEvent ************************ */
340 /* each event should have full modifier state */
341 /* event comes from eventmanager and from keymap */
342 typedef struct wmEvent {
343 struct wmEvent *next, *prev;
345 short type; /* event code itself (short, is also in keymap) */
346 short val; /* press, release, scrollvalue */
347 int x, y; /* mouse pointer position, screen coord */
348 int mval[2]; /* region mouse position, name convention pre 2.5 :) */
349 char utf8_buf[6]; /* from, ghost if utf8 is enabled for the platform,
350 * BLI_str_utf8_size() must _always_ be valid, check
351 * when assigning s we dont need to check on every access after */
352 char ascii; /* from ghost, fallback if utf8 isnt set */
359 double prevclicktime;
360 int prevclickx, prevclicky;
362 /* modifier states */
363 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
364 short keymodifier; /* rawkey modifier */
368 /* keymap item, set by handler (weak?) */
369 const char *keymap_idname;
372 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
373 short customdatafree;
375 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
379 /* ************** custom wmEvent data ************** */
380 typedef struct wmTabletData {
381 int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */
382 float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
383 float Xtilt; /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
384 float Ytilt; /* as above */
387 typedef enum { // motion progress, for modal handlers
390 P_IN_PROGRESS, // <-- only these are sent for NDOF motion
395 typedef struct wmNDOFMotionData {
396 /* awfully similar to GHOST_TEventNDOFMotionData... */
397 // Each component normally ranges from -1 to +1, but can exceed that.
398 // These use blender standard view coordinates, with positive rotations being CCW about the axis.
400 float tvec[3]; // translation
401 struct { float tx, ty, tz; };
404 float rvec[3]; // rotation:
405 struct { float rx, ry, rz; };
407 // axis = (rx,ry,rz).normalized
408 // amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg]
409 float dt; // time since previous NDOF Motion event
410 wmProgress progress; // is this the first event, the last, or one of many in between?
413 typedef struct wmTimer {
414 struct wmTimer *next, *prev;
416 struct wmWindow *win; /* window this timer is attached to (optional) */
418 double timestep; /* set by timer user */
419 int event_type; /* set by timer user, goes to event system */
420 void *customdata; /* set by timer user, to allow custom values */
422 double duration; /* total running time in seconds */
423 double delta; /* time since previous step in seconds */
425 double ltime; /* internal, last time timer was activated */
426 double ntime; /* internal, next time we want to activate the timer */
427 double stime; /* internal, when the timer started */
428 int sleep; /* internal, put timers to sleep when needed */
432 typedef struct wmOperatorType {
433 const char *name; /* text for ui, undo */
434 const char *idname; /* unique identifier */
435 const char *description; /* tooltips and python docs */
437 /* this callback executes the operator without any interactive input,
438 * parameters may be provided through operator properties. cannot use
439 * any interface code or input device state.
440 * - see defines below for return values */
441 int (*exec)(struct bContext *, struct wmOperator *);
443 /* this callback executes on a running operator whenever as property
444 * is changed. It can correct its own properties or report errors for
445 * invalid settings in exceptional cases.
446 * Boolean return value, True denotes a change has been made and to redraw */
447 int (*check)(struct bContext *, struct wmOperator *);
449 /* for modal temporary operators, initially invoke is called. then
450 * any further events are handled in modal. if the operation is
451 * cancelled due to some external reason, cancel is called
452 * - see defines below for return values */
453 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *);
454 int (*cancel)(struct bContext *, struct wmOperator *);
455 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *);
457 /* verify if the operator can be executed in the current context, note
458 * that the operator might still fail to execute even if this return true */
459 int (*poll)(struct bContext *);
461 /* optional panel for redo and repeat, autogenerated if not set */
462 void (*ui)(struct bContext *, struct wmOperator *);
464 /* rna for properties */
465 struct StructRNA *srna;
467 /* rna property to use for generic invoke functions.
468 * menus, enum search... etc */
471 /* struct wmOperatorTypeMacro */
474 /* pointer to modal keymap, do not free! */
475 struct wmKeyMap *modalkeymap;
477 /* only used for operators defined with python
478 * use to store pointers to python functions */
480 int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot);
482 /* RNA integration */
485 /* Flag last for padding */
490 /* **************** Paint Cursor ******************* */
492 typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata);
495 /* ****************** Messages ********************* */
500 WM_LOG_WARNING = 2000,
501 WM_ERROR_UNDEFINED = 3000,
502 WM_ERROR_INVALID_INPUT = 3001,
503 WM_ERROR_INVALID_CONTEXT = 3002,
504 WM_ERROR_OUT_OF_MEMORY = 3003
507 typedef struct wmReport {
508 struct wmReport *next, *prev;
514 /* *************** Drag and drop *************** */
517 #define WM_DRAG_RNA 1
518 #define WM_DRAG_PATH 2
519 #define WM_DRAG_NAME 3
520 #define WM_DRAG_VALUE 4
522 /* note: structs need not exported? */
524 typedef struct wmDrag {
525 struct wmDrag *next, *prev;
527 int icon, type; /* type, see WM_DRAG defines above */
529 char path[240]; /* FILE_MAX */
532 struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */
536 char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/
539 /* dropboxes are like keymaps, part of the screen/area/region definition */
540 /* allocation and free is on startup and exit */
541 typedef struct wmDropBox {
542 struct wmDropBox *next, *prev;
544 /* test if the dropbox is active, then can print optype name */
545 int (*poll)(struct bContext *, struct wmDrag *, wmEvent *);
547 /* before exec, this copies drag info to wmDrop properties */
548 void (*copy)(struct wmDrag *, struct wmDropBox *);
550 /* if poll survives, operator is called */
551 wmOperatorType *ot; /* not saved in file, so can be pointer */
553 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
554 struct PointerRNA *ptr; /* rna pointer to access properties */
556 short opcontext; /* default invoke */
560 /* *************** migrated stuff, clean later? ************** */
562 typedef struct RecentFile {
563 struct RecentFile *next, *prev;
572 #endif /* WM_TYPES_H */