repose_core/
dnd.rs

1use std::{any::Any, path::PathBuf, rc::Rc};
2
3/// Opaque payload moved during internal drag & drop.
4/// Use `payload.as_ref().downcast_ref::<T>()` on the receiver side.
5pub type DragPayload = Rc<dyn Any>;
6
7#[derive(Clone, Debug)]
8pub struct DragStart {
9    pub source_id: u64,
10    pub position: crate::Vec2,
11    pub modifiers: crate::Modifiers,
12}
13
14#[derive(Clone, Debug)]
15pub struct DragOver {
16    pub source_id: u64,
17    pub target_id: u64,
18    pub position: crate::Vec2,
19    pub modifiers: crate::Modifiers,
20    pub payload: DragPayload,
21}
22
23#[derive(Clone, Debug)]
24pub struct DropEvent {
25    pub source_id: u64,
26    pub target_id: u64,
27    pub position: crate::Vec2,
28    pub modifiers: crate::Modifiers,
29    pub payload: DragPayload,
30}
31
32/// Sent to the drag source when the drag ends (drop or cancel).
33#[derive(Clone, Copy, Debug)]
34pub struct DragEnd {
35    pub accepted: bool,
36}
37
38/// A single dropped file descriptor.
39/// - On desktop: `path` is `Some(PathBuf)`.
40/// - On web: `path` is usually `None` (browser doesn't expose local paths).
41#[derive(Clone, Debug)]
42pub struct DroppedFile {
43    pub name: String,
44    pub path: Option<PathBuf>,
45}
46
47/// Payload type for file drag/drop coming from the OS/browser.
48#[derive(Clone, Debug)]
49pub struct DroppedFiles {
50    pub files: Vec<DroppedFile>,
51}