Fix for [#27142] manipulator in particle mode does not work
[blender-staging.git] / intern / ghost / GHOST_Types.h
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file ghost/GHOST_Types.h
30  *  \ingroup GHOST
31  */
32
33
34 #ifndef _GHOST_TYPES_H_
35 #define _GHOST_TYPES_H_
36
37 #ifdef WITH_CXX_GUARDEDALLOC
38 #include "MEM_guardedalloc.h"
39 #endif
40
41 #define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
42
43 typedef char                            GHOST_TInt8;
44 typedef unsigned char           GHOST_TUns8;
45 typedef short                           GHOST_TInt16;
46 typedef unsigned short          GHOST_TUns16;
47 typedef int                                     GHOST_TInt32;
48 typedef unsigned int            GHOST_TUns32;
49
50 #ifdef WIN32
51 #define WM_BLND_NDOF_AXIS       WM_USER + 1
52 #define WM_BLND_NDOF_BTN        WM_USER + 2
53 #endif
54
55 #if defined(WIN32) && !defined(FREE_WINDOWS)
56 typedef __int64                         GHOST_TInt64;
57 typedef unsigned __int64        GHOST_TUns64;
58 #else
59 typedef long long                       GHOST_TInt64;
60 typedef unsigned long long      GHOST_TUns64;
61 #endif
62
63 typedef void*                           GHOST_TUserDataPtr;
64
65 typedef enum
66 {
67         GHOST_kFailure = 0,
68         GHOST_kSuccess
69 } GHOST_TSuccess;
70
71 /* Xtilt and Ytilt represent how much the pen is tilted away from 
72  * vertically upright in either the X or Y direction, with X and Y the
73  * axes of the tablet surface.
74  * In other words, Xtilt and Ytilt are components of a vector created by projecting
75  * the pen's angle in 3D space vertically downwards on to the XY plane
76  * --Matt
77  */
78 typedef enum {
79         GHOST_kTabletModeNone = 0,
80         GHOST_kTabletModeStylus,
81         GHOST_kTabletModeEraser
82 } GHOST_TTabletMode;
83
84 typedef struct GHOST_TabletData {
85         GHOST_TTabletMode Active; /* 0=None, 1=Stylus, 2=Eraser */
86         float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
87         float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
88         float Ytilt;    /* as above */
89 } GHOST_TabletData;
90
91
92 typedef enum {
93         GHOST_kNotVisible = 0,
94         GHOST_kPartiallyVisible,
95         GHOST_kFullyVisible
96 } GHOST_TVisibility;
97
98
99 typedef enum {
100         GHOST_kFireTimeNever = 0xFFFFFFFF
101 } GHOST_TFireTimeConstant;
102
103 typedef enum {
104     GHOST_kModifierKeyLeftShift = 0,
105     GHOST_kModifierKeyRightShift,
106     GHOST_kModifierKeyLeftAlt,
107     GHOST_kModifierKeyRightAlt,
108     GHOST_kModifierKeyLeftControl,
109     GHOST_kModifierKeyRightControl,
110     GHOST_kModifierKeyOS,
111     GHOST_kModifierKeyNumMasks
112 } GHOST_TModifierKeyMask;
113
114
115 typedef enum {
116         GHOST_kWindowStateNormal = 0,
117         GHOST_kWindowStateMaximized,
118         GHOST_kWindowStateMinimized,
119         GHOST_kWindowStateFullScreen,
120         GHOST_kWindowStateEmbedded,
121         GHOST_kWindowState8Normal = 8,
122         GHOST_kWindowState8Maximized,
123         GHOST_kWindowState8Minimized,
124         GHOST_kWindowState8FullScreen,
125         GHOST_kWindowStateModified,
126         GHOST_kWindowStateUnModified
127 } GHOST_TWindowState;
128
129
130 /** Constants for the answer to the blender exit request */
131 typedef enum {
132         GHOST_kExitCancel = 0,
133         GHOST_kExitNow
134 } GHOST_TExitRequestResponse;
135
136 typedef enum {
137         GHOST_kWindowOrderTop = 0,
138         GHOST_kWindowOrderBottom
139 } GHOST_TWindowOrder;
140
141
142 typedef enum {
143         GHOST_kDrawingContextTypeNone = 0,
144         GHOST_kDrawingContextTypeOpenGL
145 } GHOST_TDrawingContextType;
146
147
148 typedef enum {
149         GHOST_kButtonMaskLeft = 0,
150         GHOST_kButtonMaskMiddle,
151         GHOST_kButtonMaskRight,
152         GHOST_kButtonMaskButton4,
153         GHOST_kButtonMaskButton5,
154         GHOST_kButtonNumMasks
155 } GHOST_TButtonMask;
156
157
158 typedef enum {
159         GHOST_kEventUnknown = 0,
160
161         GHOST_kEventCursorMove,         /// Mouse move event
162         GHOST_kEventButtonDown,         /// Mouse button event
163         GHOST_kEventButtonUp,           /// Mouse button event
164         GHOST_kEventWheel,                      /// Mouse wheel event
165         GHOST_kEventTrackpad,           /// Trackpad event
166
167         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
168         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
169
170         GHOST_kEventKeyDown,
171         GHOST_kEventKeyUp,
172 //      GHOST_kEventKeyAuto,
173
174         GHOST_kEventQuit,
175
176         GHOST_kEventWindowClose,
177         GHOST_kEventWindowActivate,
178         GHOST_kEventWindowDeactivate,
179         GHOST_kEventWindowUpdate,
180         GHOST_kEventWindowSize,
181         GHOST_kEventWindowMove,
182         
183         GHOST_kEventDraggingEntered,
184         GHOST_kEventDraggingUpdated,
185         GHOST_kEventDraggingExited,
186         GHOST_kEventDraggingDropDone,
187         
188         GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
189
190         GHOST_kEventTimer,
191
192         GHOST_kNumEventTypes
193 } GHOST_TEventType;
194
195
196 typedef enum {
197         GHOST_kStandardCursorFirstCursor = 0,
198         GHOST_kStandardCursorDefault = 0,
199         GHOST_kStandardCursorRightArrow,
200         GHOST_kStandardCursorLeftArrow,
201         GHOST_kStandardCursorInfo, 
202         GHOST_kStandardCursorDestroy,
203         GHOST_kStandardCursorHelp,    
204         GHOST_kStandardCursorCycle,
205         GHOST_kStandardCursorSpray,
206         GHOST_kStandardCursorWait,
207         GHOST_kStandardCursorText,
208         GHOST_kStandardCursorCrosshair,
209         GHOST_kStandardCursorUpDown,
210         GHOST_kStandardCursorLeftRight,
211         GHOST_kStandardCursorTopSide,
212         GHOST_kStandardCursorBottomSide,
213         GHOST_kStandardCursorLeftSide,
214         GHOST_kStandardCursorRightSide,
215         GHOST_kStandardCursorTopLeftCorner,
216         GHOST_kStandardCursorTopRightCorner,
217         GHOST_kStandardCursorBottomRightCorner,
218         GHOST_kStandardCursorBottomLeftCorner,
219         GHOST_kStandardCursorCopy,
220         GHOST_kStandardCursorCustom, 
221         GHOST_kStandardCursorNumCursors, 
222         GHOST_kStandardCursorPencil
223 } GHOST_TStandardCursor;
224
225
226 typedef enum {
227         GHOST_kKeyUnknown = -1,
228         GHOST_kKeyBackSpace,
229         GHOST_kKeyTab,
230         GHOST_kKeyLinefeed,
231         GHOST_kKeyClear,
232         GHOST_kKeyEnter  = 0x0D,
233         
234         GHOST_kKeyEsc    = 0x1B,
235         GHOST_kKeySpace  = ' ',
236         GHOST_kKeyQuote  = 0x27,
237         GHOST_kKeyComma  = ',',
238         GHOST_kKeyMinus  = '-',
239         GHOST_kKeyPeriod = '.',
240         GHOST_kKeySlash  = '/',
241
242         // Number keys
243         GHOST_kKey0 = '0',
244         GHOST_kKey1,
245         GHOST_kKey2,
246         GHOST_kKey3,
247         GHOST_kKey4,
248         GHOST_kKey5,
249         GHOST_kKey6,
250         GHOST_kKey7,
251         GHOST_kKey8,
252         GHOST_kKey9,
253
254         GHOST_kKeySemicolon = ';',
255         GHOST_kKeyEqual     = '=',
256
257         // Character keys
258         GHOST_kKeyA = 'A',
259         GHOST_kKeyB,
260         GHOST_kKeyC,
261         GHOST_kKeyD,
262         GHOST_kKeyE,
263         GHOST_kKeyF,
264         GHOST_kKeyG,
265         GHOST_kKeyH,
266         GHOST_kKeyI,
267         GHOST_kKeyJ,
268         GHOST_kKeyK,
269         GHOST_kKeyL,
270         GHOST_kKeyM,
271         GHOST_kKeyN,
272         GHOST_kKeyO,
273         GHOST_kKeyP,
274         GHOST_kKeyQ,
275         GHOST_kKeyR,
276         GHOST_kKeyS,
277         GHOST_kKeyT,
278         GHOST_kKeyU,
279         GHOST_kKeyV,
280         GHOST_kKeyW,
281         GHOST_kKeyX,
282         GHOST_kKeyY,
283         GHOST_kKeyZ,
284
285         GHOST_kKeyLeftBracket  = '[',
286         GHOST_kKeyRightBracket = ']',
287         GHOST_kKeyBackslash    = 0x5C,
288         GHOST_kKeyAccentGrave  = '`',
289
290         
291         GHOST_kKeyLeftShift = 0x100,
292         GHOST_kKeyRightShift,
293         GHOST_kKeyLeftControl,
294         GHOST_kKeyRightControl,
295         GHOST_kKeyLeftAlt,
296         GHOST_kKeyRightAlt,
297         GHOST_kKeyOS,           // Command key on Apple, Windows key(s) on Windows
298         GHOST_kKeyGrLess ,              // German PC only!
299
300         GHOST_kKeyCapsLock,
301         GHOST_kKeyNumLock,
302         GHOST_kKeyScrollLock,
303
304         GHOST_kKeyLeftArrow,
305         GHOST_kKeyRightArrow,
306         GHOST_kKeyUpArrow,
307         GHOST_kKeyDownArrow,
308
309         GHOST_kKeyPrintScreen,
310         GHOST_kKeyPause,
311
312         GHOST_kKeyInsert,
313         GHOST_kKeyDelete,
314         GHOST_kKeyHome,
315         GHOST_kKeyEnd,
316         GHOST_kKeyUpPage,
317         GHOST_kKeyDownPage,
318
319         // Numpad keys
320         GHOST_kKeyNumpad0,
321         GHOST_kKeyNumpad1,
322         GHOST_kKeyNumpad2,
323         GHOST_kKeyNumpad3,
324         GHOST_kKeyNumpad4,
325         GHOST_kKeyNumpad5,
326         GHOST_kKeyNumpad6,
327         GHOST_kKeyNumpad7,
328         GHOST_kKeyNumpad8,
329         GHOST_kKeyNumpad9,
330         GHOST_kKeyNumpadPeriod,
331         GHOST_kKeyNumpadEnter,
332         GHOST_kKeyNumpadPlus,
333         GHOST_kKeyNumpadMinus,
334         GHOST_kKeyNumpadAsterisk,
335         GHOST_kKeyNumpadSlash,
336
337         // Function keys
338         GHOST_kKeyF1,
339         GHOST_kKeyF2,
340         GHOST_kKeyF3,
341         GHOST_kKeyF4,
342         GHOST_kKeyF5,
343         GHOST_kKeyF6,
344         GHOST_kKeyF7,
345         GHOST_kKeyF8,
346         GHOST_kKeyF9,
347         GHOST_kKeyF10,
348         GHOST_kKeyF11,
349         GHOST_kKeyF12,
350         GHOST_kKeyF13,
351         GHOST_kKeyF14,
352         GHOST_kKeyF15,
353         GHOST_kKeyF16,
354         GHOST_kKeyF17,
355         GHOST_kKeyF18,
356         GHOST_kKeyF19,
357         GHOST_kKeyF20,
358         GHOST_kKeyF21,
359         GHOST_kKeyF22,
360         GHOST_kKeyF23,
361         GHOST_kKeyF24,
362         
363         // Multimedia keypad buttons
364         GHOST_kKeyMediaPlay,
365         GHOST_kKeyMediaStop,
366         GHOST_kKeyMediaFirst,
367         GHOST_kKeyMediaLast
368 } GHOST_TKey;
369
370 typedef enum {
371         GHOST_kGrabDisable = 0, /* grab not set */
372         GHOST_kGrabNormal,      /* no cursor adjustments */
373         GHOST_kGrabWrap,                /* wrap the mouse location to prevent limiting screen bounds */
374         GHOST_kGrabHide,                /* hide the mouse while grabbing and restore the original location on release (numbuts) */
375 } GHOST_TGrabCursorMode;
376
377 typedef void* GHOST_TEventDataPtr;
378
379 typedef struct {
380         /** The x-coordinate of the cursor position. */
381         GHOST_TInt32 x;
382         /** The y-coordinate of the cursor position. */
383         GHOST_TInt32 y;
384 } GHOST_TEventCursorData;
385
386 typedef struct {
387         /** The mask of the mouse button. */
388         GHOST_TButtonMask button;
389 } GHOST_TEventButtonData;
390
391 typedef struct {
392         /** Displacement of a mouse wheel. */
393         GHOST_TInt32 z; 
394 } GHOST_TEventWheelData;
395
396 typedef enum {
397         GHOST_kTrackpadEventUnknown =0,
398         GHOST_kTrackpadEventScroll,
399         GHOST_kTrackpadEventRotate,
400         GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
401         GHOST_kTrackpadEventMagnify
402 } GHOST_TTrackpadEventSubTypes;
403         
404
405 typedef struct {
406         /** The event subtype */
407         GHOST_TTrackpadEventSubTypes subtype;
408         /** The x-location of the trackpad event */
409         GHOST_TInt32 x;
410         /** The y-location of the trackpad event */
411         GHOST_TInt32 y;
412         /** The x-delta or value of the trackpad event */
413         GHOST_TInt32 deltaX;
414         /** The y-delta (currently only for scroll subtype) of the trackpad event */
415         GHOST_TInt32 deltaY;
416 } GHOST_TEventTrackpadData;
417
418
419 typedef enum {
420         GHOST_kDragnDropTypeUnknown =0,
421         GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
422         GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
423         GHOST_kDragnDropTypeBitmap /*Bitmap image data */
424 } GHOST_TDragnDropTypes;
425
426 typedef struct {
427         /** The x-coordinate of the cursor position. */
428         GHOST_TInt32 x;
429         /** The y-coordinate of the cursor position. */
430         GHOST_TInt32 y;
431         /** The dropped item type */
432         GHOST_TDragnDropTypes dataType;
433         /** The "dropped content" */
434         GHOST_TEventDataPtr data;
435 } GHOST_TEventDragnDropData;
436
437 typedef struct {
438         int count;
439         GHOST_TUns8 **strings;
440 } GHOST_TStringArray;
441
442
443 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
444 /* as all USB device controls are likely to use ints, this is also more future proof */
445 //typedef struct {
446 //   /** N-degree of freedom device data */
447 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
448 //   float rx, ry, rz;
449 //   float dt;
450 //} GHOST_TEventNDOFData;
451
452 typedef struct {
453    /** N-degree of freedom device data v2*/
454    int changed;
455    GHOST_TUns64 client;
456    GHOST_TUns64 address;
457    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
458    GHOST_TInt16 rx, ry, rz;
459    GHOST_TInt16 buttons;
460    GHOST_TUns64 time;
461    GHOST_TUns64 delta;
462 } GHOST_TEventNDOFData;
463
464 typedef int     (*GHOST_NDOFLibraryInit_fp)(void);
465 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
466 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
467
468 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
469 // not necessary faster, but better integration with other events. 
470
471 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
472 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
473
474 typedef struct {
475         /** The key code. */
476         GHOST_TKey              key;
477         /** The ascii code for the key event ('\0' if none). */
478         char                    ascii;
479 } GHOST_TEventKeyData;
480
481 typedef struct {
482         /** Number of pixels on a line. */
483         GHOST_TUns32    xPixels;
484         /** Number of lines. */
485         GHOST_TUns32    yPixels;
486         /** Numberof bits per pixel. */
487         GHOST_TUns32    bpp;
488         /** Refresh rate (in Hertz). */
489         GHOST_TUns32    frequency;
490 } GHOST_DisplaySetting;
491
492
493 #ifdef _WIN32
494 typedef long GHOST_TEmbedderWindowID;
495 #endif // _WIN32
496
497 #ifndef _WIN32
498 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
499 typedef int GHOST_TEmbedderWindowID;
500 #endif // _WIN32
501
502 /**
503  * A timer task callback routine.
504  * @param task The timer task object.
505  * @param time The current time.
506  */
507 #ifdef __cplusplus
508 class GHOST_ITimerTask;
509 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
510 #else
511 struct GHOST_TimerTaskHandle__;
512 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
513 #endif
514
515 #endif // _GHOST_TYPES_H_
516