|
Blender
V2.59
|
00001 /* 00002 * $Id: WM_types.h 39293 2011-08-11 06:06:17Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2007 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * 00024 * Contributor(s): Blender Foundation 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00033 #ifndef WM_TYPES_H 00034 #define WM_TYPES_H 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 struct bContext; 00041 struct wmEvent; 00042 struct wmWindowManager; 00043 struct uiLayout; 00044 struct wmOperator; 00045 struct ImBuf; 00046 00047 #include "RNA_types.h" 00048 #include "DNA_listBase.h" 00049 #include "BKE_utildefines.h" /* FILE_MAX */ 00050 00051 /* exported types for WM */ 00052 #include "wm_cursors.h" 00053 #include "wm_event_types.h" 00054 00055 /* ************** wmOperatorType ************************ */ 00056 00057 /* flag */ 00058 #define OPTYPE_REGISTER 1 /* register operators in stack after finishing */ 00059 #define OPTYPE_UNDO 2 /* do undo push after after */ 00060 #define OPTYPE_BLOCKING 4 /* let blender grab all input from the WM (X11) */ 00061 #define OPTYPE_MACRO 8 00062 #define OPTYPE_GRAB_POINTER 16 /* */ 00063 #define OPTYPE_PRESET 32 /* show preset menu */ 00064 #define OPTYPE_INTERNAL 64 /* some operators are mainly for internal use 00065 * and don't make sense to be accessed from the 00066 * search menu, even if poll() returns TRUE. 00067 * currently only used for the search toolbox */ 00068 00069 /* context to call operator in for WM_operator_name_call */ 00070 /* rna_ui.c contains EnumPropertyItem's of these, keep in sync */ 00071 enum { 00072 /* if there's invoke, call it, otherwise exec */ 00073 WM_OP_INVOKE_DEFAULT, 00074 WM_OP_INVOKE_REGION_WIN, 00075 WM_OP_INVOKE_REGION_CHANNELS, 00076 WM_OP_INVOKE_REGION_PREVIEW, 00077 WM_OP_INVOKE_AREA, 00078 WM_OP_INVOKE_SCREEN, 00079 /* only call exec */ 00080 WM_OP_EXEC_DEFAULT, 00081 WM_OP_EXEC_REGION_WIN, 00082 WM_OP_EXEC_REGION_CHANNELS, 00083 WM_OP_EXEC_REGION_PREVIEW, 00084 WM_OP_EXEC_AREA, 00085 WM_OP_EXEC_SCREEN 00086 }; 00087 00088 /* ************** wmKeyMap ************************ */ 00089 00090 /* modifier */ 00091 #define KM_SHIFT 1 00092 #define KM_CTRL 2 00093 #define KM_ALT 4 00094 #define KM_OSKEY 8 00095 /* means modifier should be pressed 2nd */ 00096 #define KM_SHIFT2 16 00097 #define KM_CTRL2 32 00098 #define KM_ALT2 64 00099 #define KM_OSKEY2 128 00100 00101 /* type: defined in wm_event_types.c */ 00102 #define KM_TEXTINPUT -2 00103 00104 /* val */ 00105 #define KM_ANY -1 00106 #define KM_NOTHING 0 00107 #define KM_PRESS 1 00108 #define KM_RELEASE 2 00109 #define KM_CLICK 3 00110 #define KM_DBL_CLICK 4 00111 00112 00113 /* ************** UI Handler ***************** */ 00114 00115 #define WM_UI_HANDLER_CONTINUE 0 00116 #define WM_UI_HANDLER_BREAK 1 00117 00118 typedef int (*wmUIHandlerFunc)(struct bContext *C, struct wmEvent *event, void *userdata); 00119 typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata); 00120 00121 /* ************** Notifiers ****************** */ 00122 00123 typedef struct wmNotifier { 00124 struct wmNotifier *next, *prev; 00125 00126 struct wmWindowManager *wm; 00127 struct wmWindow *window; 00128 00129 int swinid; /* can't rely on this, notifiers can be added without context, swinid of 0 */ 00130 unsigned int category, data, subtype, action; 00131 00132 void *reference; 00133 00134 } wmNotifier; 00135 00136 00137 /* 4 levels 00138 00139 0xFF000000; category 00140 0x00FF0000; data 00141 0x0000FF00; data subtype (unused?) 00142 0x000000FF; action 00143 */ 00144 00145 /* category */ 00146 #define NOTE_CATEGORY 0xFF000000 00147 #define NC_WM (1<<24) 00148 #define NC_WINDOW (2<<24) 00149 #define NC_SCREEN (3<<24) 00150 #define NC_SCENE (4<<24) 00151 #define NC_OBJECT (5<<24) 00152 #define NC_MATERIAL (6<<24) 00153 #define NC_TEXTURE (7<<24) 00154 #define NC_LAMP (8<<24) 00155 #define NC_GROUP (9<<24) 00156 #define NC_IMAGE (10<<24) 00157 #define NC_BRUSH (11<<24) 00158 #define NC_TEXT (12<<24) 00159 #define NC_WORLD (13<<24) 00160 #define NC_ANIMATION (14<<24) 00161 #define NC_SPACE (15<<24) 00162 #define NC_GEOM (16<<24) 00163 #define NC_NODE (17<<24) 00164 #define NC_ID (18<<24) 00165 #define NC_LOGIC (19<<24) 00166 00167 /* data type, 256 entries is enough, it can overlap */ 00168 #define NOTE_DATA 0x00FF0000 00169 00170 /* NC_WM windowmanager */ 00171 #define ND_FILEREAD (1<<16) 00172 #define ND_FILESAVE (2<<16) 00173 #define ND_DATACHANGED (3<<16) 00174 #define ND_HISTORY (4<<16) 00175 #define ND_JOB (5<<16) 00176 00177 /* NC_SCREEN screen */ 00178 #define ND_SCREENBROWSE (1<<16) 00179 #define ND_SCREENDELETE (2<<16) 00180 #define ND_SCREENCAST (3<<16) 00181 #define ND_ANIMPLAY (4<<16) 00182 #define ND_GPENCIL (5<<16) 00183 #define ND_EDITOR_CHANGED (6<<16) /*sent to new editors after switching to them*/ 00184 #define ND_SCREENSET (7<<16) 00185 #define ND_SKETCH (8<<16) 00186 #define ND_SUBWINACTIVE (9<<16) 00187 00188 /* NC_SCENE Scene */ 00189 #define ND_SCENEBROWSE (1<<16) 00190 #define ND_MARKERS (2<<16) 00191 #define ND_FRAME (3<<16) 00192 #define ND_RENDER_OPTIONS (4<<16) 00193 #define ND_NODES (5<<16) 00194 #define ND_SEQUENCER (6<<16) 00195 #define ND_OB_ACTIVE (7<<16) 00196 #define ND_OB_SELECT (8<<16) 00197 #define ND_OB_VISIBLE (9<<16) 00198 #define ND_OB_RENDER (10<<16) 00199 #define ND_MODE (11<<16) 00200 #define ND_RENDER_RESULT (12<<16) 00201 #define ND_COMPO_RESULT (13<<16) 00202 #define ND_KEYINGSET (14<<16) 00203 #define ND_TOOLSETTINGS (15<<16) 00204 #define ND_LAYER (16<<16) 00205 #define ND_FRAME_RANGE (17<<16) 00206 #define ND_TRANSFORM_DONE (18<<16) 00207 #define ND_WORLD (92<<16) 00208 #define ND_LAYER_CONTENT (101<<16) 00209 00210 /* NC_OBJECT Object */ 00211 #define ND_TRANSFORM (18<<16) 00212 #define ND_OB_SHADING (19<<16) 00213 #define ND_POSE (20<<16) 00214 #define ND_BONE_ACTIVE (21<<16) 00215 #define ND_BONE_SELECT (22<<16) 00216 #define ND_DRAW (23<<16) 00217 #define ND_MODIFIER (24<<16) 00218 #define ND_KEYS (25<<16) 00219 #define ND_CONSTRAINT (26<<16) 00220 #define ND_PARTICLE (27<<16) 00221 #define ND_POINTCACHE (28<<16) 00222 #define ND_PARENT (29<<16) 00223 00224 /* NC_MATERIAL Material */ 00225 #define ND_SHADING (30<<16) 00226 #define ND_SHADING_DRAW (31<<16) 00227 00228 /* NC_LAMP Lamp */ 00229 #define ND_LIGHTING (40<<16) 00230 #define ND_LIGHTING_DRAW (41<<16) 00231 #define ND_SKY (42<<16) 00232 00233 /* NC_WORLD World */ 00234 #define ND_WORLD_DRAW (45<<16) 00235 #define ND_WORLD_STARS (46<<16) 00236 00237 /* NC_TEXT Text */ 00238 #define ND_CURSOR (50<<16) 00239 #define ND_DISPLAY (51<<16) 00240 00241 /* NC_ANIMATION Animato */ 00242 #define ND_KEYFRAME (70<<16) 00243 #define ND_KEYFRAME_PROP (71<<16) 00244 #define ND_ANIMCHAN (72<<16) 00245 #define ND_NLA (73<<16) 00246 #define ND_NLA_ACTCHANGE (74<<16) 00247 #define ND_FCURVES_ORDER (75<<16) 00248 00249 /* NC_GEOM Geometry */ 00250 /* Mesh, Curve, MetaBall, Armature, .. */ 00251 #define ND_SELECT (90<<16) 00252 #define ND_DATA (91<<16) 00253 00254 /* NC_NODE Nodes */ 00255 00256 /* NC_SPACE */ 00257 #define ND_SPACE_CONSOLE (1<<16) /* general redraw */ 00258 #define ND_SPACE_INFO_REPORT (2<<16) /* update for reports, could specify type */ 00259 #define ND_SPACE_INFO (3<<16) 00260 #define ND_SPACE_IMAGE (4<<16) 00261 #define ND_SPACE_FILE_PARAMS (5<<16) 00262 #define ND_SPACE_FILE_LIST (6<<16) 00263 #define ND_SPACE_NODE (7<<16) 00264 #define ND_SPACE_OUTLINER (8<<16) 00265 #define ND_SPACE_VIEW3D (9<<16) 00266 #define ND_SPACE_PROPERTIES (10<<16) 00267 #define ND_SPACE_TEXT (11<<16) 00268 #define ND_SPACE_TIME (12<<16) 00269 #define ND_SPACE_GRAPH (13<<16) 00270 #define ND_SPACE_DOPESHEET (14<<16) 00271 #define ND_SPACE_NLA (15<<16) 00272 #define ND_SPACE_SEQUENCER (16<<16) 00273 #define ND_SPACE_NODE_VIEW (17<<16) 00274 #define ND_SPACE_CHANGED (18<<16) /*sent to a new editor type after it's replaced an old one*/ 00275 00276 /* subtype, 256 entries too */ 00277 #define NOTE_SUBTYPE 0x0000FF00 00278 00279 /* subtype scene mode */ 00280 #define NS_MODE_OBJECT (1<<8) 00281 00282 #define NS_EDITMODE_MESH (2<<8) 00283 #define NS_EDITMODE_CURVE (3<<8) 00284 #define NS_EDITMODE_SURFACE (4<<8) 00285 #define NS_EDITMODE_TEXT (5<<8) 00286 #define NS_EDITMODE_MBALL (6<<8) 00287 #define NS_EDITMODE_LATTICE (7<<8) 00288 #define NS_EDITMODE_ARMATURE (8<<8) 00289 #define NS_MODE_POSE (9<<8) 00290 #define NS_MODE_PARTICLE (10<<8) 00291 00292 /* subtype 3d view editing */ 00293 #define NS_VIEW3D_GPU (16<<8) 00294 00295 /* action classification */ 00296 #define NOTE_ACTION (0x000000FF) 00297 #define NA_EDITED 1 00298 #define NA_EVALUATED 2 00299 #define NA_ADDED 3 00300 #define NA_REMOVED 4 00301 #define NA_RENAME 5 00302 #define NA_SELECTED 6 00303 00304 /* ************** Gesture Manager data ************** */ 00305 00306 /* wmGesture->type */ 00307 #define WM_GESTURE_TWEAK 0 00308 #define WM_GESTURE_LINES 1 00309 #define WM_GESTURE_RECT 2 00310 #define WM_GESTURE_CROSS_RECT 3 00311 #define WM_GESTURE_LASSO 4 00312 #define WM_GESTURE_CIRCLE 5 00313 #define WM_GESTURE_STRAIGHTLINE 6 00314 00315 /* wmGesture is registered to window listbase, handled by operator callbacks */ 00316 /* tweak gesture is builtin feature */ 00317 typedef struct wmGesture { 00318 struct wmGesture *next, *prev; 00319 int event_type; /* event->type */ 00320 int mode; /* for modal callback */ 00321 int type; /* gesture type define */ 00322 int swinid; /* initial subwindow id where it started */ 00323 int points; /* optional, amount of points stored */ 00324 int size; /* optional, maximum amount of points stored */ 00325 00326 void *customdata; 00327 /* customdata for border is a recti */ 00328 /* customdata for circle is recti, (xmin, ymin) is center, xmax radius */ 00329 /* customdata for lasso is short array */ 00330 /* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */ 00331 } wmGesture; 00332 00333 /* ************** wmEvent ************************ */ 00334 00335 /* each event should have full modifier state */ 00336 /* event comes from eventmanager and from keymap */ 00337 typedef struct wmEvent { 00338 struct wmEvent *next, *prev; 00339 00340 short type; /* event code itself (short, is also in keymap) */ 00341 short val; /* press, release, scrollvalue */ 00342 int x, y; /* mouse pointer position, screen coord */ 00343 int mval[2]; /* region mouse position, name convention pre 2.5 :) */ 00344 short unicode; /* future, ghost? */ 00345 char ascii; /* from ghost */ 00346 char pad; 00347 00348 /* previous state */ 00349 short prevtype; 00350 short prevval; 00351 int prevx, prevy; 00352 double prevclicktime; 00353 int prevclickx, prevclicky; 00354 00355 /* modifier states */ 00356 short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ 00357 short keymodifier; /* rawkey modifier */ 00358 00359 short pad1; 00360 00361 /* keymap item, set by handler (weak?) */ 00362 const char *keymap_idname; 00363 00364 /* custom data */ 00365 short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ 00366 short customdatafree; 00367 int pad2; 00368 void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ 00369 00370 } wmEvent; 00371 00372 /* ************** custom wmEvent data ************** */ 00373 typedef struct wmTabletData { 00374 int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */ 00375 float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */ 00376 float Xtilt; /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */ 00377 float Ytilt; /* as above */ 00378 } wmTabletData; 00379 00380 typedef enum { // motion progress, for modal handlers 00381 P_NOT_STARTED, 00382 P_STARTING, // <-- 00383 P_IN_PROGRESS, // <-- only these are sent for NDOF motion 00384 P_FINISHING, // <-- 00385 P_FINISHED 00386 } wmProgress; 00387 00388 typedef struct wmNDOFMotionData { 00389 /* awfully similar to GHOST_TEventNDOFMotionData... */ 00390 // Each component normally ranges from -1 to +1, but can exceed that. 00391 // These use blender standard view coordinates, with positive rotations being CCW about the axis. 00392 union { 00393 float tvec[3]; // translation 00394 struct { float tx, ty, tz; }; 00395 }; 00396 union { 00397 float rvec[3]; // rotation: 00398 struct { float rx, ry, rz; }; 00399 }; 00400 // axis = (rx,ry,rz).normalized 00401 // amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg] 00402 float dt; // time since previous NDOF Motion event 00403 wmProgress progress; // is this the first event, the last, or one of many in between? 00404 } wmNDOFMotionData; 00405 00406 typedef struct wmTimer { 00407 struct wmTimer *next, *prev; 00408 00409 struct wmWindow *win; /* window this timer is attached to (optional) */ 00410 00411 double timestep; /* set by timer user */ 00412 int event_type; /* set by timer user, goes to event system */ 00413 void *customdata; /* set by timer user, to allow custom values */ 00414 00415 double duration; /* total running time in seconds */ 00416 double delta; /* time since previous step in seconds */ 00417 00418 double ltime; /* internal, last time timer was activated */ 00419 double ntime; /* internal, next time we want to activate the timer */ 00420 double stime; /* internal, when the timer started */ 00421 int sleep; /* internal, put timers to sleep when needed */ 00422 } wmTimer; 00423 00424 00425 typedef struct wmOperatorType { 00426 const char *name; /* text for ui, undo */ 00427 const char *idname; /* unique identifier */ 00428 const char *description; /* tooltips and python docs */ 00429 00430 /* this callback executes the operator without any interactive input, 00431 * parameters may be provided through operator properties. cannot use 00432 * any interface code or input device state. 00433 * - see defines below for return values */ 00434 int (*exec)(struct bContext *, struct wmOperator *); 00435 00436 /* this callback executes on a running operator whenever as property 00437 * is changed. It can correct its own properties or report errors for 00438 * invalid settings in exceptional cases. 00439 * Boolean return value, True denotes a change has been made and to redraw */ 00440 int (*check)(struct bContext *, struct wmOperator *); 00441 00442 /* for modal temporary operators, initially invoke is called. then 00443 * any further events are handled in modal. if the operation is 00444 * cancelled due to some external reason, cancel is called 00445 * - see defines below for return values */ 00446 int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *); 00447 int (*cancel)(struct bContext *, struct wmOperator *); 00448 int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *); 00449 00450 /* verify if the operator can be executed in the current context, note 00451 * that the operator might still fail to execute even if this return true */ 00452 int (*poll)(struct bContext *); 00453 00454 /* optional panel for redo and repeat, autogenerated if not set */ 00455 void (*ui)(struct bContext *, struct wmOperator *); 00456 00457 /* rna for properties */ 00458 struct StructRNA *srna; 00459 00460 /* rna property to use for generic invoke functions. 00461 * menus, enum search... etc */ 00462 PropertyRNA *prop; 00463 00464 /* struct wmOperatorTypeMacro */ 00465 ListBase macro; 00466 00467 short flag; 00468 00469 /* pointer to modal keymap, do not free! */ 00470 struct wmKeyMap *modalkeymap; 00471 00472 /* only used for operators defined with python 00473 * use to store pointers to python functions */ 00474 void *pyop_data; 00475 int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot); 00476 00477 /* RNA integration */ 00478 ExtensionRNA ext; 00479 } wmOperatorType; 00480 00481 /* **************** Paint Cursor ******************* */ 00482 00483 typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata); 00484 00485 00486 /* ****************** Messages ********************* */ 00487 00488 enum { 00489 WM_LOG_DEBUG = 0, 00490 WM_LOG_INFO = 1000, 00491 WM_LOG_WARNING = 2000, 00492 WM_ERROR_UNDEFINED = 3000, 00493 WM_ERROR_INVALID_INPUT = 3001, 00494 WM_ERROR_INVALID_CONTEXT = 3002, 00495 WM_ERROR_OUT_OF_MEMORY = 3003 00496 }; 00497 00498 typedef struct wmReport { 00499 struct wmReport *next, *prev; 00500 const char *typestr; 00501 char *message; 00502 int type; 00503 } wmReport; 00504 00505 /* *************** Drag and drop *************** */ 00506 00507 #define WM_DRAG_ID 0 00508 #define WM_DRAG_RNA 1 00509 #define WM_DRAG_PATH 2 00510 #define WM_DRAG_NAME 3 00511 #define WM_DRAG_VALUE 4 00512 00513 /* note: structs need not exported? */ 00514 00515 typedef struct wmDrag { 00516 struct wmDrag *next, *prev; 00517 00518 int icon, type; /* type, see WM_DRAG defines above */ 00519 void *poin; 00520 char path[240]; /* FILE_MAX */ 00521 double value; 00522 00523 struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */ 00524 float scale; 00525 int sx, sy; 00526 00527 char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/ 00528 } wmDrag; 00529 00530 /* dropboxes are like keymaps, part of the screen/area/region definition */ 00531 /* allocation and free is on startup and exit */ 00532 typedef struct wmDropBox { 00533 struct wmDropBox *next, *prev; 00534 00535 /* test if the dropbox is active, then can print optype name */ 00536 int (*poll)(struct bContext *, struct wmDrag *, wmEvent *); 00537 00538 /* before exec, this copies drag info to wmDrop properties */ 00539 void (*copy)(struct wmDrag *, struct wmDropBox *); 00540 00541 /* if poll survives, operator is called */ 00542 wmOperatorType *ot; /* not saved in file, so can be pointer */ 00543 short opcontext; /* default invoke */ 00544 00545 struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ 00546 struct PointerRNA *ptr; /* rna pointer to access properties */ 00547 00548 } wmDropBox; 00549 00550 /* *************** migrated stuff, clean later? ************** */ 00551 00552 typedef struct RecentFile { 00553 struct RecentFile *next, *prev; 00554 char *filepath; 00555 } RecentFile; 00556 00557 00558 #ifdef __cplusplus 00559 } 00560 #endif 00561 00562 #endif /* WM_TYPES_H */ 00563