diff options
author | Damien Plisson <damien.plisson@yahoo.fr> | 2009-11-10 15:56:46 +0300 |
---|---|---|
committer | Damien Plisson <damien.plisson@yahoo.fr> | 2009-11-10 15:56:46 +0300 |
commit | af2e6c38e99024d5055e66e2aea75de61c3280e9 (patch) | |
tree | f7c58a77af74ccdab2cb13bd48a2e587c6ad32a6 /intern/ghost/GHOST_Types.h | |
parent | 14f9e686fa7b729a36549778fcf8e2cfd31bf424 (diff) |
Drag & drop implementation at GHOST level (only OSX for now)
The dragging sequence is performed in four phases:
- Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started. Already gives the object data type, and the entering mouse location
- Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the drag'n'drop operation stops, to give the updated mouse position.
Useful to highlight a potential destination, and update the status (through GHOST_setAcceptDragOperation) telling if the object can be dropped at the current cursor position.
- Abort drag'n'drop sequence (GHOST_kEventDraggingExited) sent when the user moved the mouse outside the window.
- Send the dropped data (GHOST_kEventDraggingDropDone)
- Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon). This can happen when the user drops an object on the application icon. (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)
Note that the event handler is responsible for freeing the received data.
And the mouse position is sent directly in blender client coordinates (y=0 at bottom)
The GHOST_setAcceptDragOperation(TRUE) call must be placed before the user drops the object for it to be accepted.
Current handled data types :
- Text string
- Array of filenames (full paths)
- Bitmap image (not implemented yet)
Diffstat (limited to 'intern/ghost/GHOST_Types.h')
-rw-r--r-- | intern/ghost/GHOST_Types.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index e98e58740ad..5c888e218d8 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -167,6 +167,12 @@ typedef enum { GHOST_kEventWindowUpdate, GHOST_kEventWindowSize, GHOST_kEventWindowMove, + + GHOST_kEventDraggingEntered, + GHOST_kEventDraggingUpdated, + GHOST_kEventDraggingExited, + GHOST_kEventDraggingDropDone, + GHOST_kEventDraggingDropOnIcon, GHOST_kEventTimer, @@ -368,6 +374,30 @@ typedef struct { } GHOST_TEventWheelData; +typedef enum { + GHOST_kDragnDropTypeUnknown =0, + GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */ + GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */ + GHOST_kDragnDropTypeBitmap /*Bitmap image data */ +} GHOST_TDragnDropTypes; + +typedef struct { + /** The x-coordinate of the cursor position. */ + GHOST_TInt32 x; + /** The y-coordinate of the cursor position. */ + GHOST_TInt32 y; + /** The dropped item type */ + GHOST_TDragnDropTypes dataType; + /** The "dropped content" */ + GHOST_TEventDataPtr data; +} GHOST_TEventDragnDropData; + +typedef struct { + int count; + GHOST_TUns8 **strings; +} GHOST_TStringArray; + + /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */ /* as all USB device controls are likely to use ints, this is also more future proof */ //typedef struct { |