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