1use crate::Length;
2use std::sync::Arc;
3
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5pub enum DragAction {
6 #[default]
7 None,
8 Copy,
9 Move,
10 Link,
11}
12
13#[derive(Clone, Debug, PartialEq)]
14pub enum DragEvent {
15 Started,
16 Finished(DragAction),
17 Entered { data: String, action: DragAction },
18 FilesEntered(Arc<[String]>),
19 Moved { x: Length, y: Length },
20 Exited,
21 Dropped { data: String, action: DragAction },
22 FilesDropped(Arc<[String]>),
23}
24
25impl DragEvent {
26 #[doc(hidden)]
27 pub fn target_kind(&self) -> &'static str {
28 match self {
29 Self::Started | Self::Finished(_) => "DragArea",
30 _ => "DropArea",
31 }
32 }
33
34 #[doc(hidden)]
35 pub fn is_terminal(&self) -> bool {
36 matches!(self, Self::Exited | Self::Finished(_))
37 }
38}
39
40pub fn is_drag_area(kind: &str) -> bool {
41 matches!(kind, "DragArea" | "DropArea")
42}