aboutsummaryrefslogtreecommitdiffstats
path: root/include/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-22 16:02:04 -0400
committerDavid Robillard <d@drobilla.net>2023-11-11 10:20:03 -0500
commit91ba4a52701db0a43ffc7769d2fda510ca2ebfa3 (patch)
treebe2dca91d457f28e0c9c324736f24d85a5ed57c2 /include/pugl
parent91051e9059b67b8d633e385afb48a36d4f9467ba (diff)
downloadpugl-91ba4a52701db0a43ffc7769d2fda510ca2ebfa3.tar.gz
pugl-91ba4a52701db0a43ffc7769d2fda510ca2ebfa3.tar.bz2
pugl-91ba4a52701db0a43ffc7769d2fda510ca2ebfa3.zip
[WIP] Add support for drag and dropdragdrop
Diffstat (limited to 'include/pugl')
-rw-r--r--include/pugl/pugl.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index e57f6aa..89415f6 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -152,10 +152,12 @@ typedef enum {
A system clipboard.
A clipboard provides a mechanism for transferring data between views,
- including views in different processes.
+ including views in different processes. Clipboards are used for both "copy
+ and paste" and "drag and drop" interactions.
*/
typedef enum {
PUGL_CLIPBOARD_GENERAL, ///< General clipboard for copy/pasted data
+ PUGL_CLIPBOARD_DRAG, ///< Drag clipboard for drag and drop data
} PuglClipboard;
/**
@@ -977,10 +979,11 @@ typedef enum {
PUGL_REFRESH_RATE, ///< Refresh rate in Hz
PUGL_VIEW_TYPE, ///< View type (a #PuglViewType)
PUGL_DARK_FRAME, ///< True if window frame should be dark
+ PUGL_ACCEPT_DROP, ///< True if view accepts dropped data
} PuglViewHint;
/// The number of #PuglViewHint values
-#define PUGL_NUM_VIEW_HINTS ((unsigned)PUGL_DARK_FRAME + 1U)
+#define PUGL_NUM_VIEW_HINTS ((unsigned)PUGL_ACCEPT_DROP + 1U)
/// A special view hint value
typedef enum {
@@ -1195,6 +1198,16 @@ double
puglGetScaleFactor(const PuglView* view);
/**
+ Register a type as supported for drag and drop.
+
+ Before realizing the view, this function should be called for every type the
+ view may accept as a drop target.
+*/
+PUGL_API
+PuglStatus
+puglRegisterDragType(PuglView* view, const char* type);
+
+/**
@}
@defgroup pugl_frame Frame
Functions for working with the position and size of a view.
@@ -1569,6 +1582,29 @@ puglAcceptOffer(PuglView* view,
PuglRect region);
/**
+ Reject data offered from a clipboard.
+
+ This can be called instead of puglAcceptOffer() to explicitly reject the
+ offer. Note that drag-and-drop will still work if this isn't called, but
+ applications should always explicitly accept or reject each data offer for
+ optimal behaviour.
+
+ @param view The view.
+
+ @param offer The data offer event.
+
+ @param region The region of the view that will refuse this drop. This may
+ be used by the system to avoid sending redundant events when the item is
+ dragged within the region. This is only an optimization, an all-zero region
+ can safely be passed.
+*/
+PUGL_API
+PuglStatus
+puglRejectOffer(PuglView* view,
+ const PuglDataOfferEvent* offer,
+ PuglRect region);
+
+/**
Set the clipboard contents.
This sets the system clipboard contents, which can be retrieved with