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