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
31 #ifndef __WM_TYPES_H__
32 #define __WM_TYPES_H__
35 * Overview of WM structs
36 * ======================
39 * > wmWindowManager (window manager stores a list of windows)
40 * > > wmWindow (window has an active screen)
41 * > > > bScreen (link to ScrAreas via 'areabase')
42 * > > > > ScrArea (stores multiple spaces via space links via 'spacedata')
43 * > > > > > SpaceLink (base struct for space data for all different space types)
44 * > > > > ScrArea (stores multiple regions via 'regionbase')
53 * +----------------------------------------------------------+
54 * |+-----------------------------------------+-------------+ |
55 * ||ScrArea (links to 3D view) |ScrArea | |
56 * ||+-------++----------+-------------------+|(links to | |
57 * |||ARegion|| |ARegion (quad view)|| properties) | |
58 * |||(tools)|| | || | |
62 * ||| |+----------+-------------------+| | |
68 * ||+-------++----------+-------------------+| | |
69 * |+-----------------------------------------+-------------+ |
70 * +----------------------------------------------------------+
77 * ScrArea's store a list of space data (SpaceLinks), each of unique type.
78 * The first one is the displayed in the UI, others are added as needed.
80 * +----------------------------+ <-- sa->spacedata.first;
82 * | |---+ <-- other inactive SpaceLink's stored.
89 * +----------------------------+ | |
91 * +-----------------------------+ |
93 * +------------------------------+
96 * A common way to get the space from the ScrArea:
98 * if (sa->spacetype == SPACE_VIEW3D) {
99 * View3D *v3d = sa->spacedata.first;
111 struct wmWindowManager;
116 #include "RNA_types.h"
117 #include "DNA_listBase.h"
119 /* exported types for WM */
120 #include "wm_cursors.h"
121 #include "wm_event_types.h"
123 /* ************** wmOperatorType ************************ */
126 #define OPTYPE_REGISTER 1 /* register operators in stack after finishing */
127 #define OPTYPE_UNDO 2 /* do undo push after after */
128 #define OPTYPE_BLOCKING 4 /* let blender grab all input from the WM (X11) */
129 #define OPTYPE_MACRO 8
130 #define OPTYPE_GRAB_POINTER 16 /* */
131 #define OPTYPE_PRESET 32 /* show preset menu */
132 #define OPTYPE_INTERNAL 64 /* some operators are mainly for internal use
133 * and don't make sense to be accessed from the
134 * search menu, even if poll() returns TRUE.
135 * currently only used for the search toolbox */
137 /* context to call operator in for WM_operator_name_call */
138 /* rna_ui.c contains EnumPropertyItem's of these, keep in sync */
140 /* if there's invoke, call it, otherwise exec */
141 WM_OP_INVOKE_DEFAULT,
142 WM_OP_INVOKE_REGION_WIN,
143 WM_OP_INVOKE_REGION_CHANNELS,
144 WM_OP_INVOKE_REGION_PREVIEW,
149 WM_OP_EXEC_REGION_WIN,
150 WM_OP_EXEC_REGION_CHANNELS,
151 WM_OP_EXEC_REGION_PREVIEW,
156 /* ************** wmKeyMap ************************ */
163 /* means modifier should be pressed 2nd */
167 #define KM_OSKEY2 128
169 /* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl */
170 /* note that KM_ANY and FALSE are used with these defines too */
171 #define KM_MOD_FIRST 1
172 #define KM_MOD_SECOND 2
174 /* type: defined in wm_event_types.c */
175 #define KM_TEXTINPUT -2
183 #define KM_DBL_CLICK 4
186 /* ************** UI Handler ***************** */
188 #define WM_UI_HANDLER_CONTINUE 0
189 #define WM_UI_HANDLER_BREAK 1
191 typedef int (*wmUIHandlerFunc)(struct bContext *C, const struct wmEvent *event, void *userdata);
192 typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
194 /* ************** Notifiers ****************** */
196 typedef struct wmNotifier {
197 struct wmNotifier *next, *prev;
199 struct wmWindowManager *wm;
200 struct wmWindow *window;
202 int swinid; /* can't rely on this, notifiers can be added without context, swinid of 0 */
203 unsigned int category, data, subtype, action;
212 * 0xFF000000; category
214 * 0x0000FF00; data subtype (unused?)
219 #define NOTE_CATEGORY 0xFF000000
220 #define NC_WM (1<<24)
221 #define NC_WINDOW (2<<24)
222 #define NC_SCREEN (3<<24)
223 #define NC_SCENE (4<<24)
224 #define NC_OBJECT (5<<24)
225 #define NC_MATERIAL (6<<24)
226 #define NC_TEXTURE (7<<24)
227 #define NC_LAMP (8<<24)
228 #define NC_GROUP (9<<24)
229 #define NC_IMAGE (10<<24)
230 #define NC_BRUSH (11<<24)
231 #define NC_TEXT (12<<24)
232 #define NC_WORLD (13<<24)
233 #define NC_ANIMATION (14<<24)
234 #define NC_SPACE (15<<24)
235 #define NC_GEOM (16<<24)
236 #define NC_NODE (17<<24)
237 #define NC_ID (18<<24)
238 #define NC_LOGIC (19<<24)
239 #define NC_MOVIECLIP (20<<24)
240 #define NC_MASK (21<<24)
241 #define NC_GPENCIL (22<<24)
243 /* data type, 256 entries is enough, it can overlap */
244 #define NOTE_DATA 0x00FF0000
246 /* NC_WM windowmanager */
247 #define ND_FILEREAD (1<<16)
248 #define ND_FILESAVE (2<<16)
249 #define ND_DATACHANGED (3<<16)
250 #define ND_HISTORY (4<<16)
251 #define ND_JOB (5<<16)
253 /* NC_SCREEN screen */
254 #define ND_SCREENBROWSE (1<<16)
255 #define ND_SCREENDELETE (2<<16)
256 #define ND_SCREENCAST (3<<16)
257 #define ND_ANIMPLAY (4<<16)
258 #define ND_GPENCIL (5<<16)
259 #define ND_EDITOR_CHANGED (6<<16) /*sent to new editors after switching to them*/
260 #define ND_SCREENSET (7<<16)
261 #define ND_SKETCH (8<<16)
262 #define ND_SUBWINACTIVE (9<<16)
265 #define ND_SCENEBROWSE (1<<16)
266 #define ND_MARKERS (2<<16)
267 #define ND_FRAME (3<<16)
268 #define ND_RENDER_OPTIONS (4<<16)
269 #define ND_NODES (5<<16)
270 #define ND_SEQUENCER (6<<16)
271 #define ND_OB_ACTIVE (7<<16)
272 #define ND_OB_SELECT (8<<16)
273 #define ND_OB_VISIBLE (9<<16)
274 #define ND_OB_RENDER (10<<16)
275 #define ND_MODE (11<<16)
276 #define ND_RENDER_RESULT (12<<16)
277 #define ND_COMPO_RESULT (13<<16)
278 #define ND_KEYINGSET (14<<16)
279 #define ND_TOOLSETTINGS (15<<16)
280 #define ND_LAYER (16<<16)
281 #define ND_FRAME_RANGE (17<<16)
282 #define ND_TRANSFORM_DONE (18<<16)
283 #define ND_WORLD (92<<16)
284 #define ND_LAYER_CONTENT (101<<16)
286 /* NC_OBJECT Object */
287 #define ND_TRANSFORM (18<<16)
288 #define ND_OB_SHADING (19<<16)
289 #define ND_POSE (20<<16)
290 #define ND_BONE_ACTIVE (21<<16)
291 #define ND_BONE_SELECT (22<<16)
292 #define ND_DRAW (23<<16)
293 #define ND_MODIFIER (24<<16)
294 #define ND_KEYS (25<<16)
295 #define ND_CONSTRAINT (26<<16)
296 #define ND_PARTICLE (27<<16)
297 #define ND_POINTCACHE (28<<16)
298 #define ND_PARENT (29<<16)
300 /* NC_MATERIAL Material */
301 #define ND_SHADING (30<<16)
302 #define ND_SHADING_DRAW (31<<16)
303 #define ND_SHADING_LINKS (32<<16)
306 #define ND_LIGHTING (40<<16)
307 #define ND_LIGHTING_DRAW (41<<16)
308 #define ND_SKY (42<<16)
311 #define ND_WORLD_DRAW (45<<16)
312 #define ND_WORLD_STARS (46<<16)
315 #define ND_CURSOR (50<<16)
316 #define ND_DISPLAY (51<<16)
318 /* NC_ANIMATION Animato */
319 #define ND_KEYFRAME (70<<16)
320 #define ND_KEYFRAME_PROP (71<<16)
321 #define ND_ANIMCHAN (72<<16)
322 #define ND_NLA (73<<16)
323 #define ND_NLA_ACTCHANGE (74<<16)
324 #define ND_FCURVES_ORDER (75<<16)
326 /* NC_GEOM Geometry */
327 /* Mesh, Curve, MetaBall, Armature, .. */
328 #define ND_SELECT (90<<16)
329 #define ND_DATA (91<<16)
330 #define ND_VERTEX_GROUP (92<<16)
335 #define ND_SPACE_CONSOLE (1<<16) /* general redraw */
336 #define ND_SPACE_INFO_REPORT (2<<16) /* update for reports, could specify type */
337 #define ND_SPACE_INFO (3<<16)
338 #define ND_SPACE_IMAGE (4<<16)
339 #define ND_SPACE_FILE_PARAMS (5<<16)
340 #define ND_SPACE_FILE_LIST (6<<16)
341 #define ND_SPACE_NODE (7<<16)
342 #define ND_SPACE_OUTLINER (8<<16)
343 #define ND_SPACE_VIEW3D (9<<16)
344 #define ND_SPACE_PROPERTIES (10<<16)
345 #define ND_SPACE_TEXT (11<<16)
346 #define ND_SPACE_TIME (12<<16)
347 #define ND_SPACE_GRAPH (13<<16)
348 #define ND_SPACE_DOPESHEET (14<<16)
349 #define ND_SPACE_NLA (15<<16)
350 #define ND_SPACE_SEQUENCER (16<<16)
351 #define ND_SPACE_NODE_VIEW (17<<16)
352 #define ND_SPACE_CHANGED (18<<16) /*sent to a new editor type after it's replaced an old one*/
353 #define ND_SPACE_CLIP (19<<16)
355 /* subtype, 256 entries too */
356 #define NOTE_SUBTYPE 0x0000FF00
358 /* subtype scene mode */
359 #define NS_MODE_OBJECT (1<<8)
361 #define NS_EDITMODE_MESH (2<<8)
362 #define NS_EDITMODE_CURVE (3<<8)
363 #define NS_EDITMODE_SURFACE (4<<8)
364 #define NS_EDITMODE_TEXT (5<<8)
365 #define NS_EDITMODE_MBALL (6<<8)
366 #define NS_EDITMODE_LATTICE (7<<8)
367 #define NS_EDITMODE_ARMATURE (8<<8)
368 #define NS_MODE_POSE (9<<8)
369 #define NS_MODE_PARTICLE (10<<8)
371 /* subtype 3d view editing */
372 #define NS_VIEW3D_GPU (16<<8)
374 /* action classification */
375 #define NOTE_ACTION (0x000000FF)
377 #define NA_EVALUATED 2
381 #define NA_SELECTED 6
383 /* ************** Gesture Manager data ************** */
385 /* wmGesture->type */
386 #define WM_GESTURE_TWEAK 0
387 #define WM_GESTURE_LINES 1
388 #define WM_GESTURE_RECT 2
389 #define WM_GESTURE_CROSS_RECT 3
390 #define WM_GESTURE_LASSO 4
391 #define WM_GESTURE_CIRCLE 5
392 #define WM_GESTURE_STRAIGHTLINE 6
394 /* wmGesture is registered to window listbase, handled by operator callbacks */
395 /* tweak gesture is builtin feature */
396 typedef struct wmGesture {
397 struct wmGesture *next, *prev;
398 int event_type; /* event->type */
399 int mode; /* for modal callback */
400 int type; /* gesture type define */
401 int swinid; /* initial subwindow id where it started */
402 int points; /* optional, amount of points stored */
403 int size; /* optional, maximum amount of points stored */
406 /* customdata for border is a recti */
407 /* customdata for circle is recti, (xmin, ymin) is center, xmax radius */
408 /* customdata for lasso is short array */
409 /* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */
411 /* free pointer to use for operator allocs (if set, its freed on exit)*/
415 /* ************** wmEvent ************************ */
417 /* each event should have full modifier state */
418 /* event comes from eventmanager and from keymap */
419 typedef struct wmEvent {
420 struct wmEvent *next, *prev;
422 short type; /* event code itself (short, is also in keymap) */
423 short val; /* press, release, scrollvalue */
424 int x, y; /* mouse pointer position, screen coord */
425 int mval[2]; /* region mouse position, name convention pre 2.5 :) */
426 char utf8_buf[6]; /* from, ghost if utf8 is enabled for the platform,
427 * BLI_str_utf8_size() must _always_ be valid, check
428 * when assigning s we don't need to check on every access after */
429 char ascii; /* from ghost, fallback if utf8 isn't set */
432 /* previous state, used for double click and the 'click' */
436 double prevclicktime;
437 int prevclickx, prevclicky;
439 /* modifier states */
440 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
441 short keymodifier; /* rawkey modifier */
443 /* set in case a KM_PRESS went by unhandled */
446 /* keymap item, set by handler (weak?) */
447 const char *keymap_idname;
449 /* tablet info, only use when the tablet is active */
450 struct wmTabletData *tablet_data;
453 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
454 short customdatafree;
456 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
460 /* ************** custom wmEvent data ************** */
461 typedef struct wmTabletData {
462 int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */
463 float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
464 float Xtilt; /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
465 float Ytilt; /* as above */
468 typedef enum { /* motion progress, for modal handlers */
470 P_STARTING, /* <-- */
471 P_IN_PROGRESS, /* <-- only these are sent for NDOF motion*/
472 P_FINISHING, /* <-- */
476 typedef struct wmNDOFMotionData {
477 /* awfully similar to GHOST_TEventNDOFMotionData... */
478 /* Each component normally ranges from -1 to +1, but can exceed that.
479 * These use blender standard view coordinates, with positive rotations being CCW about the axis. */
481 float tvec[3]; /* translation */
482 struct { float tx, ty, tz; };
485 float rvec[3]; /* rotation: */
486 struct { float rx, ry, rz; };
488 /* axis = (rx,ry,rz).normalized */
489 /* amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg] */
490 float dt; /* time since previous NDOF Motion event */
491 wmProgress progress; /* is this the first event, the last, or one of many in between? */
494 typedef struct wmTimer {
495 struct wmTimer *next, *prev;
497 struct wmWindow *win; /* window this timer is attached to (optional) */
499 double timestep; /* set by timer user */
500 int event_type; /* set by timer user, goes to event system */
501 void *customdata; /* set by timer user, to allow custom values */
503 double duration; /* total running time in seconds */
504 double delta; /* time since previous step in seconds */
506 double ltime; /* internal, last time timer was activated */
507 double ntime; /* internal, next time we want to activate the timer */
508 double stime; /* internal, when the timer started */
509 int sleep; /* internal, put timers to sleep when needed */
512 typedef struct wmOperatorType {
513 const char *name; /* text for ui, undo */
514 const char *idname; /* unique identifier */
515 const char *description; /* tooltips and python docs */
517 /* this callback executes the operator without any interactive input,
518 * parameters may be provided through operator properties. cannot use
519 * any interface code or input device state.
520 * - see defines below for return values */
521 int (*exec)(struct bContext *, struct wmOperator *)
523 __attribute__((warn_unused_result))
527 /* this callback executes on a running operator whenever as property
528 * is changed. It can correct its own properties or report errors for
529 * invalid settings in exceptional cases.
530 * Boolean return value, True denotes a change has been made and to redraw */
531 int (*check)(struct bContext *, struct wmOperator *);
533 /* for modal temporary operators, initially invoke is called. then
534 * any further events are handled in modal. if the operation is
535 * canceled due to some external reason, cancel is called
536 * - see defines below for return values */
537 int (*invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *)
539 __attribute__((warn_unused_result))
542 int (*cancel)(struct bContext *, struct wmOperator *);
543 int (*modal)(struct bContext *, struct wmOperator *, const struct wmEvent *)
545 __attribute__((warn_unused_result))
549 /* verify if the operator can be executed in the current context, note
550 * that the operator might still fail to execute even if this return true */
551 int (*poll)(struct bContext *)
553 __attribute__((warn_unused_result))
557 /* optional panel for redo and repeat, autogenerated if not set */
558 void (*ui)(struct bContext *, struct wmOperator *);
560 /* rna for properties */
561 struct StructRNA *srna;
563 /* previous settings - for initializing on re-use */
564 struct IDProperty *last_properties;
566 /* Default rna property to use for generic invoke functions.
567 * menus, enum search... etc. Example: Enum 'type' for a Delete menu */
570 /* struct wmOperatorTypeMacro */
573 /* pointer to modal keymap, do not free! */
574 struct wmKeyMap *modalkeymap;
576 /* only used for operators defined with python
577 * use to store pointers to python functions */
579 int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot)
581 __attribute__((warn_unused_result))
585 /* RNA integration */
588 /* Flag last for padding */
593 /* **************** Paint Cursor ******************* */
595 typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata);
598 /* ****************** Messages ********************* */
603 WM_LOG_WARNING = 2000,
604 WM_ERROR_UNDEFINED = 3000,
605 WM_ERROR_INVALID_INPUT = 3001,
606 WM_ERROR_INVALID_CONTEXT = 3002,
607 WM_ERROR_OUT_OF_MEMORY = 3003
610 typedef struct wmReport {
611 struct wmReport *next, *prev;
617 /* *************** Drag and drop *************** */
620 #define WM_DRAG_RNA 1
621 #define WM_DRAG_PATH 2
622 #define WM_DRAG_NAME 3
623 #define WM_DRAG_VALUE 4
625 /* note: structs need not exported? */
627 typedef struct wmDrag {
628 struct wmDrag *next, *prev;
630 int icon, type; /* type, see WM_DRAG defines above */
632 char path[1024]; /* FILE_MAX */
635 struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */
639 char opname[200]; /* if set, draws operator name*/
642 /* dropboxes are like keymaps, part of the screen/area/region definition */
643 /* allocation and free is on startup and exit */
644 typedef struct wmDropBox {
645 struct wmDropBox *next, *prev;
647 /* test if the dropbox is active, then can print optype name */
648 int (*poll)(struct bContext *, struct wmDrag *, const wmEvent *);
650 /* before exec, this copies drag info to wmDrop properties */
651 void (*copy)(struct wmDrag *, struct wmDropBox *);
653 /* if poll survives, operator is called */
654 wmOperatorType *ot; /* not saved in file, so can be pointer */
656 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */
657 struct PointerRNA *ptr; /* rna pointer to access properties */
659 short opcontext; /* default invoke */
663 /* *************** migrated stuff, clean later? ************** */
665 typedef struct RecentFile {
666 struct RecentFile *next, *prev;
675 #endif /* __WM_TYPES_H__ */