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