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